HelaBERT: Enhancing Sinhala Language Understanding with Dual Pooling Classification Head
Organizations: Department of Computer Science & Engineering University of Moratuwa
Abstract
We present HelaBERT, a family of two BERT-based masked language models pre-trained from scratch on approximately 1 billion tokens of Sinhala text sourced from MADLAD-400, CulturaX, and a custom corpus comprising news articles, Sinhala Wikipedia, and web crawl data. HelaBERT-Small (~23.3M parameters, 6 layers) and HelaBERT-Large (~110M parameters, 12 layers) both use a SentencePiece Unigram tokenizer (vocabulary size 32,000) tailored to Sinhala's agglutinative morphology and complex script. We evaluate both models on four downstream Sinhala text classification tasks: news category classification, news source classification, sentiment analysis, and writing style classification, using 5 independent seed runs with stratified 80/20 train/test splits. We additionally propose a dual pooling classification head and evaluate it systematically across all four tasks, finding consistent improvements on sentiment analysis and a moderate gain on news category classification for HelaBERT-Small, while the standard [CLS]-linear head remains competitive on news source classification, a headline-level task with short average input length. We release both models to support further research in Sinhala NLP.
Figures & tables
| Parameter | Small | Large |
|---|---|---|
| Parameters | 23.3M | 110M |
| Hidden size | 384 | 768 |
| Transformer layers | 6 | 12 |
| Attention heads | 6 | 12 |
| Intermediate size | 1,536 | 3,072 |
| Max sequence length | 512 | 512 |
| Metric | Small | Large |
|---|---|---|
| Final train loss | 3.69 | 2.26 |
| Final eval loss | 3.49 | 2.17 |
| Total training steps | 52,000 | 90,700 |
| Dataset | Classes | Train | Test | Avg. W |
|---|---|---|---|---|
| News Category | 5 | 2,596 | 640 | 23.8 |
| News Source | 9 | 18,280 | 4,571 | 8.3 |
| Sentiment | 3 | 2,049 | 513 | 16.8 |
| Writing Style | 4 | 10,008 | 2,462 | 182.6 |
| News Cat. | News Src. | Senti. | Style | |
| LR (Small) | 1e-5 | 5e-5 | 3e-5 | 1e-5 |
| LR (Large) | 3e-5 | 5e-5 | 5e-6 | 1e-5 |
| Epochs (Small) | 10 | 3 | 6 | 3 |
| Epochs (Large) | 3 | 3 | 10 | 3 |
| Max seq. len. | 512 | 512 | 512 | 512 |
| Batch size | 16 | |||
| Model | Sentiment † | News Source | News Category | Writing Style |
|---|---|---|---|---|
| Baseline (majority class) | 59.42 (w-F 1 ) | — | — | — |
| LaBSE | 20.63 | 11.85 | 24.09 | — |
| LASER | 54.07 | 28.84 | 48.54 | 87.06 |
| XLM-R | 58.08 | 58.29 | 85.12 | 96.89 |
| XLM-R | 60.45 | 61.84 | 89.54 | 98.41 |
| SinBERT O | 50.83 | 57.22 | 78.07 | 93.84 |
| Model | Head | News Cat. | News Src. | Sentiment | Writing |
|---|---|---|---|---|---|
| Small | Standard | 85.97 | 60.16 | 65.34 | 95.92 |
| Co-attn | 89.02 | 59.90 | 69.27 | 96.42 | |
| +3.05 | 0.26 | +3.93 | +0.50 | ||
| Large | Standard | 90.38 | 63.65 | 64.60 | 97.73 |
| Co-attn | 90.50 | 63.31 | 70.22 | 97.75 | |
| +0.12 | 0.34 | +5.62 | +0.02 |
| Model / Head | Acc. | Macro-F 1 | W-F 1 |
|---|---|---|---|
| HelaBERT-Small, standard | 0.6589 | 0.6534 | 0.6581 |
| HelaBERT-Small, dual pooling | 0.6881 | 0.6927 | 0.6904 |
| (dual pooling std.) | +0.029 | +0.039 | +0.032 |
| HelaBERT-Large, standard | 0.6530 | 0.6460 | 0.6539 |
| HelaBERT-Large, dual pooling | 0.7135 | 0.7022 | 0.7096 |
| (dual pooling std.) | +0.061 | +0.056 | +0.056 |
| Standard | Dual pooling | |||||
|---|---|---|---|---|---|---|
| Model | NEG | NEU | POS | NEG | NEU | POS |
| Small | 0.54 | 0.67 | 0.75 | 0.64 | 0.67 | 0.77 |
| Large | 0.55 | 0.68 | 0.70 | 0.59 | 0.73 | 0.78 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Hyperparameter | Small | Large |
|---|---|---|
| Sequence length | 256 (stride 128) | 512 |
| Total training samples | 7.4M | 4.3M |
| Train / validation split | 90% / 10% | 90% / 10% |
| MLM probability | 15% | 15% |
| Per-device batch size | 32 | 256 |
| Gradient accumulation steps | 8 | 1 |
| Label | Train | Test |
|---|---|---|
| 0 | 418 | 102 |
| 1 | 365 | 91 |
| 2 | 675 | 166 |
| 3 | 797 | 199 |
| 4 | 341 | 82 |
| Total | 2,596 | 640 |
| Label | Train | Test |
|---|---|---|
| 0 | 2,233 | 558 |
| 1 | 1,303 | 326 |
| 2 | 2,334 | 584 |
| 3 | 1,143 | 286 |
| 4 | 2,366 | 592 |
| 5 | 2,282 | 571 |
| Label | Train | Test |
|---|---|---|
| Neutral | 899 | 225 |
| Positive | 599 | 150 |
| Negative | 551 | 138 |
| Total | 2,049 | 513 |
| Label | Train | Test |
|---|---|---|
| News | 3,568 | 885 |
| Academic | 2,834 | 701 |
| Creative | 1,919 | 458 |
| Blog | 1,687 | 418 |
| Total | 10,008 | 2,462 |
Language Model Pretraining
Language model pretraining teaches models language patterns and knowledge from large text corpora before they are adapted to specific tasks.
See all 434 papers