Fill-Mask
Transformers
Safetensors
pakmosaic
pakistan
multilingual
encoder
research-preview
sota-target
custom_code
Instructions to use ProximaAI/PakMosaic-Small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProximaAI/PakMosaic-Small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="ProximaAI/PakMosaic-Small", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("ProximaAI/PakMosaic-Small", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add Transformers AutoModelForMaskedLM remote code
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
library_name:
|
| 3 |
license: apache-2.0
|
| 4 |
pipeline_tag: fill-mask
|
| 5 |
language:
|
|
@@ -72,38 +72,24 @@ Encoder-only MLM: pre-norm, RoPE, GeGLU, full attention, tied embeddings.
|
|
| 72 |
| intermediate | 2048 |
|
| 73 |
| vocab | 32,000 |
|
| 74 |
|
| 75 |
-
This is a custom
|
| 76 |
|
| 77 |
## How to load
|
| 78 |
|
| 79 |
```python
|
| 80 |
-
import
|
| 81 |
-
from pathlib import Path
|
| 82 |
-
import torch
|
| 83 |
-
from huggingface_hub import hf_hub_download
|
| 84 |
-
from safetensors.torch import load_file
|
| 85 |
-
|
| 86 |
-
# Install the Pakistan NLP Suite package, then:
|
| 87 |
-
from paknlp_registry.encoder.config import EncoderConfig, SamplingConfig, MaskingConfig, TrainConfig
|
| 88 |
-
from paknlp_registry.encoder.model import PakEncoderForMLM
|
| 89 |
|
| 90 |
repo = "ProximaAI/PakMosaic-Small"
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
if isinstance(raw.get("masking"), dict):
|
| 97 |
-
raw["masking"] = MaskingConfig(**raw["masking"])
|
| 98 |
-
if isinstance(raw.get("train"), dict):
|
| 99 |
-
raw["train"] = TrainConfig(**raw["train"])
|
| 100 |
-
model = PakEncoderForMLM(EncoderConfig(**raw))
|
| 101 |
-
weights = load_file(hf_hub_download(repo, "model.safetensors"))
|
| 102 |
-
model.load_state_dict(weights)
|
| 103 |
-
model.eval()
|
| 104 |
```
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
## Data
|
| 109 |
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: transformers
|
| 3 |
license: apache-2.0
|
| 4 |
pipeline_tag: fill-mask
|
| 5 |
language:
|
|
|
|
| 72 |
| intermediate | 2048 |
|
| 73 |
| vocab | 32,000 |
|
| 74 |
|
| 75 |
+
This is a **custom PakMosaic encoder**, not BERT. Hugging Face Transformers loads it with `trust_remote_code=True` (RoPE + GeGLU + pre-norm live in this repo).
|
| 76 |
|
| 77 |
## How to load
|
| 78 |
|
| 79 |
```python
|
| 80 |
+
from transformers import AutoModelForMaskedLM, AutoTokenizer, pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
repo = "ProximaAI/PakMosaic-Small"
|
| 83 |
+
tok = AutoTokenizer.from_pretrained(repo)
|
| 84 |
+
model = AutoModelForMaskedLM.from_pretrained(repo, trust_remote_code=True)
|
| 85 |
+
|
| 86 |
+
fill = pipeline("fill-mask", model=model, tokenizer=tok)
|
| 87 |
+
print(fill("یہ ایک <mask> ہے۔"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
```
|
| 89 |
|
| 90 |
+
`AutoModel` also works (`trust_remote_code=True`) and returns encoder hidden states.
|
| 91 |
+
|
| 92 |
+
Tokenizer: PakMosaic-Tokenizer-32k / `hf_byte_bpe_32k_identity` (hash `0f55e47920211588e6985172cd71338c8aff6226fe912c9668055b44bacc7ce7`). Frozen Urdu fertility 1.250 vs XLM-R 1.382 is a **tokenizer** metric, not model SOTA.
|
| 93 |
|
| 94 |
## Data
|
| 95 |
|