Fill-Mask
Transformers
Safetensors
Bengali
distilbert
bengali
bangla
BnLM-F
bnlm
bangla-model
small-bangla-model
bengali-nlp
bnlp
low-resource
masked-language-modeling
pretrained
language-model
Instructions to use nahid-hub/BnLM-F-135m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nahid-hub/BnLM-F-135m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="nahid-hub/BnLM-F-135m")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("nahid-hub/BnLM-F-135m") model = AutoModelForMaskedLM.from_pretrained("nahid-hub/BnLM-F-135m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: cc-by-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- bn
|
| 4 |
license: cc-by-4.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: fill-mask
|
| 7 |
+
tags:
|
| 8 |
+
- bengali
|
| 9 |
+
- bangla
|
| 10 |
+
- BnLM-F
|
| 11 |
+
- bnlm
|
| 12 |
+
- bangla-model
|
| 13 |
+
- small-bangla-model
|
| 14 |
+
- bengali-nlp
|
| 15 |
+
- bnlp
|
| 16 |
+
- low-resource
|
| 17 |
+
- masked-language-modeling
|
| 18 |
+
- pretrained
|
| 19 |
+
- language-model
|
| 20 |
+
- distilbert
|
| 21 |
+
datasets:
|
| 22 |
+
- nahid-hub/B-CORE-bengali-corpus
|
| 23 |
+
model-index:
|
| 24 |
+
- name: BnLM-F
|
| 25 |
+
results: []
|
| 26 |
---
|
| 27 |
+
|
| 28 |
+
# BnLM-F: Bangla Language Model (135M)
|
| 29 |
+
|
| 30 |
+
**BnLM-F** is a 135M-parameter Bangla-specific pretrained language model, one of three models in the **BnLM** suite (**B**e**n**gali **L**anguage **M**odel) introduced alongside the **BLUGE** benchmark and **B-CORE** pretraining corpus. BnLM models are pretrained from scratch on Bangla text using the Masked Language Modeling (MLM) objective, and are designed for efficient, low-resource NLP without relying on large multilingual models.
|
| 31 |
+
|
| 32 |
+
See the [BLUGE collection](https://huggingface.co/collections/nahid-hub/bluge) for the full release — evaluation tasks, pretraining corpus, tokenizers, and all three BnLM variants (BnLM-F, BnLM-M, BnLM-C).
|
| 33 |
+
|
| 34 |
+
## Model Details
|
| 35 |
+
|
| 36 |
+
| | |
|
| 37 |
+
|---|---|
|
| 38 |
+
| Base architecture | DistilBERT-multilingual |
|
| 39 |
+
| Parameters | 135M |
|
| 40 |
+
| Tokenizer | Custom Bangla WordPiece, 120K vocabulary |
|
| 41 |
+
| Objective | Masked Language Modeling (MLM) |
|
| 42 |
+
| Max sequence length | 512 tokens |
|
| 43 |
+
| Pretraining data | [B-CORE](https://huggingface.co/datasets/nahid-hub/B-CORE-bengali-corpus) — 4.32B tokens, 52GB |
|
| 44 |
+
|
| 45 |
+
Despite its compact size, BnLM-F achieves state-of-the-art results across BLUGE and four cross-lingual/Indic benchmarks, while requiring 44–91% fewer FLOPs and ~2x faster inference than competitive multilingual baselines. Full training configuration and hyperparameters are available in the paper.
|
| 46 |
+
|
| 47 |
+
## Usage
|
| 48 |
+
|
| 49 |
+
### Fine-tuning for sentiment classification
|
| 50 |
+
|
| 51 |
+
Example using [BLUGE-TSC](https://huggingface.co/datasets/nahid-hub/BLUGE-bengali-sentiment-classification):
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 55 |
+
import torch
|
| 56 |
+
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained("nahid-hub/BnLM-F-135m")
|
| 58 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 59 |
+
"nahid-hub/BnLM-F-135m",
|
| 60 |
+
num_labels=3 # 0: neutral, 1: positive, 2: negative
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
text = "খাবারটা অসাধারণ ছিল, আমি খুব খুশি!"
|
| 64 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
| 65 |
+
|
| 66 |
+
with torch.no_grad():
|
| 67 |
+
logits = model(**inputs).logits
|
| 68 |
+
|
| 69 |
+
predicted_class = logits.argmax(dim=-1).item()
|
| 70 |
+
labels = {0: "neutral", 1: "positive", 2: "negative"}
|
| 71 |
+
print(labels[predicted_class])
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
> Note: `AutoModelForSequenceClassification` attaches a randomly initialized classification head on top of the pretrained BnLM-F encoder — you'll need to fine-tune on labeled data (e.g. BLUGE-TSC) before this produces meaningful predictions. Skip straight to inference only if loading your own fine-tuned checkpoint.
|
| 75 |
+
|
| 76 |
+
### Loading the base model (for masked-language-modeling or custom heads)
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
| 80 |
+
|
| 81 |
+
tokenizer = AutoTokenizer.from_pretrained("nahid-hub/BnLM-F-135m")
|
| 82 |
+
model = AutoModelForMaskedLM.from_pretrained("nahid-hub/BnLM-F-135m")
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Training Data
|
| 86 |
+
|
| 87 |
+
Pretrained exclusively on **B-CORE**, a 16.5M-document, 4.32-billion-token Bangla corpus built via a reproducible multi-stage pipeline achieving a 22.4% reduction in corpus volume through quality filtering and cross-corpus deduplication.
|
| 88 |
+
|
| 89 |
+
## Evaluation
|
| 90 |
+
|
| 91 |
+
Evaluated on **BLUGE** (7-task Bangla NLU benchmark) and 4 cross-lingual/Indic benchmarks. See the paper for full results tables.
|
| 92 |
+
|
| 93 |
+
| Task | Metric | Score |
|
| 94 |
+
|---|---|---|
|
| 95 |
+
| [fill in from your paper's results tables] | | |
|
| 96 |
+
|
| 97 |
+
## Related Models
|
| 98 |
+
|
| 99 |
+
- [BnLM-M](https://huggingface.co/nahid-hub/BnLM-M-135m) — 135M parameters, larger-vocabulary variant tuned for different training regime
|
| 100 |
+
- [BnLM-C](https://huggingface.co/nahid-hub/BnLM-C-66m) — 66M parameters, compact variant with 30.5K-vocabulary tokenizer
|
| 101 |
+
|
| 102 |
+
## Limitations
|
| 103 |
+
|
| 104 |
+
[e.g. domain coverage of B-CORE, max sequence length, any known biases — fill in from your paper's limitations section]
|
| 105 |
+
|
| 106 |
+
## License
|
| 107 |
+
|
| 108 |
+
Released under **CC BY 4.0**.
|
| 109 |
+
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
If you use this model, please cite:
|
| 113 |
+
|
| 114 |
+
```bibtex
|
| 115 |
+
@ARTICLE{BnLM-BLUGE-B-CORE,
|
| 116 |
+
author={Hossain, Nahid and Faisal Kabir, Md.},
|
| 117 |
+
journal={IEEE Access},
|
| 118 |
+
title={Efficient Monolingual Pretraining in Low-Resource Settings Through Morphology-Aware Tokenization, Principled Corpus Denoising, and Benchmark-Driven Evaluation},
|
| 119 |
+
year={2026},
|
| 120 |
+
volume={14},
|
| 121 |
+
number={},
|
| 122 |
+
pages={91979-92003},
|
| 123 |
+
keywords={Modeling;Multilingual;Training;Cleaning;Vocabulary;Labeling;Tokenization;Computational linguistics;Pipelines;Conferences;B-CORE;BLUGE;BnLM;corpus;evaluation benchmark;pretrained models},
|
| 124 |
+
doi={10.1109/ACCESS.2026.3701520}
|
| 125 |
+
}
|
| 126 |
+
```
|