Downloads · 30 days
124
9% of all-time downloads
shah-bakhsh/BalBERT
BalBERT is a fill-mask model from shah-bakhsh. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
124
9% of all-time downloads
All-time downloads
1.4K
Public
Parameters
278M
1.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
shahbakhsh/BalBERT)BalBERT is the first research-grade Transformer encoder domain-adapted specifically for the Balochi language (bal). Built via continuous Domain-Adaptive Pretraining (DAPT) of xlm-roberta-base on a normalized monolingual corpus of 97,624 Balochi sentences, BalBERT provides a domain-adapted foundation model for all downstream Balochi natural language processing tasks.
bal)xlm-roberta-base| Metric | xlm-roberta-base (Baseline) | BalBERT (Ours) | Improvement |
|---|---|---|---|
| MLM Loss | 5.8100 | 1.7681 | -69.6% Reduction |
| Perplexity | 333.63 | 7.40 (Val: 5.86) | +97.8% Drop |
| Masked Prediction Quality | Generic Punctuation (،) | Contextual Balochi Words (اے, آئی) | Linguistically Coherent |
| Embedding Affinity | Collapsed uniform score | High dynamic margin | Enhanced Representations |
You can run token completion directly using the Hugging Face pipeline:
from transformers import pipeline
# Load pipeline directly from Hugging Face Hub
unmasker = pipeline("fill-mask", model="shahbakhsh/BalBERT")
# Predict masked word in Balochi
text = "اے دوئیں دبستانانی <mask> دیگءَ پرکے ھست۔"
results = unmasker(text)
print("Top Predictions:")
for res in results[:5]:
print(f"Token: {res['token_str']:<15} | Score: {res['score']:.4f}")
import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM
MODEL_ID = "shahbakhsh/BalBERT"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForMaskedLM.from_pretrained(MODEL_ID)
text = "پاکستان ءِ ردءَ اے <mask> باز ارزښت دار اِنت۔"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
mask_token_index = torch.where(inputs["input_ids"] == tokenizer.mask_token_id)[1]
mask_logits = logits[0, mask_token_index, :]
top_5_tokens = torch.topk(mask_logits, 5, dim=1).indices[0].tolist()
print("Top Mask Completions:")
for token_id in top_5_tokens:
print(f" • {tokenizer.decode([token_id])}")
import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("shahbakhsh/BalBERT")
model = AutoModel.from_pretrained("shahbakhsh/BalBERT")
sentence = "بلۆچی زبان ءِ شَرّێن زانتکار"
inputs = tokenizer(sentence, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
# Tensor Shape: [batch_size, sequence_length, 768]
last_hidden_state = outputs.last_hidden_state
print("Embedding Shape:", last_hidden_state.shape)
Given the Balochi sentence:
اے جستءِ پسو گپءُ درجنی دگہ جنگے رودین ایت کہ ادا <mask> ءِ سرجمیں پہناتانی گیشواری المی نہ اِنت۔
xlm-roberta-base Top Predictions:
1. ، (4.5%)
2. ِ (3.0%)
3. کی (2.9%)
4. (2.3%)
5. ، (2.0%)
BalBERT Top Predictions (Ours):
1. اے (28.4%) [Demonstrative: "this"]
2. آئی (28.3%) [Pronoun: "its/his/her"]
3. انسانی (13.1%) [Adjective: "human"]
4. پہ (2.5%) [Preposition: "for"]
5. کہ (1.6%) [Conjunction: "that"]
xlm-roberta-base)5e-5 (Linear decay)0.060.05bf16 Mixed Precisionsentences_clean.txt42BalBERT acts as the pre-trained feature extractor for the entire Balochi NLP stack:
$$\text{BalCorpus} \longrightarrow \text{BalTokenizer} \longrightarrow \mathbf{BalBERT} \longrightarrow \text{BalPOS v2} \longrightarrow \text{BalNER} \longrightarrow \text{BalMorph} \longrightarrow \text{BalParser}$$
shahbakhsh/BalBERT.@misc{shahbakhsh2026balbert,
author = {Shah Bakhsh},
title = {BalBERT: Domain-Adaptive Pretraining of XLM-RoBERTa for Balochi Natural Language Processing},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/shahbakhsh/BalBERT}},
note = {GitHub Repository: shah-bakhsh/BalBERT}
}