IndicBERTv2 low-resource Indic classifiers (sentiment · news topic)
Two classifiers fine-tuned from ai4bharat/IndicBERTv2-MLM-only in the project
"Low-resource Indic text classifier: IndicBERT transfer learning with Hugging Face deployment".
Every number below is generated from the project's results/ files by python -m src.analysis.report.
| model | task | training data | labels |
|---|---|---|---|
indicbertv2-indicsentiment-13lang |
product-review sentiment | 13 languages × ≈690 reviews (8 968 total) | Negative, Positive |
indicbertv2-indicglue-topic-6lang |
news topic / genre | 6 languages × ≤1 000 articles | 17-label union (business, entertainment, sports, …) |
Intended use
- Research and teaching on low-resource Indic NLP; coarse sentiment of short product-review-style text, and coarse genre of news text, in the listed languages and scripts.
- A baseline / starting checkpoint for further fine-tuning on in-domain data.
Out of scope: decisions about individuals (moderation, hiring, credit), clinical or legal text, social-media text with heavy slang or natural English code-switching, languages not listed, long documents (inputs are truncated to 128 subword tokens).
Languages
Assamese, Bengali, Bodo, Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, Telugu, Urdu (sentiment); Bengali, Gujarati, Hindi, Malayalam, Marathi, Tamil (topic). Input script is detected automatically; romanized (Latin-script) input is accepted but degrades accuracy (see Limitations).
Training data
- IndicSentiment (
ai4bharat/IndicSentiment): the released validation + test files (1 156 reviews per language, translated from English product reviews) were pooled and re-split 60/10/30 stratified, seed 42. - IndicGLUE news genre (
inltkh.{ta,ml,mr,gu},sna.bn,bbca.hi): capped at 1 000 train / 300 val / 1 000 test per language to stay low-resource. - Cleaning: Unicode NFC, IndicNLP script normalisation (nuktas kept), zero-width removal, danda normalisation.
| task | lang | train | val | test | imbalance |
|---|---|---|---|---|---|
| sentiment | Assamese (as) | 689 | 116 | 346 | 1.01 |
| sentiment | Bodo (bd) | 690 | 116 | 346 | 1.02 |
| sentiment | Bengali (bn) | 690 | 116 | 346 | 1.02 |
| sentiment | Gujarati (gu) | 689 | 116 | 346 | 1.01 |
| sentiment | Hindi (hi) | 690 | 116 | 346 | 1.02 |
| sentiment | Kannada (kn) | 690 | 116 | 346 | 1.02 |
| sentiment | Malayalam (ml) | 690 | 116 | 346 | 1.02 |
| sentiment | Marathi (mr) | 690 | 116 | 346 | 1.02 |
| sentiment | Odia (or) | 690 | 116 | 346 | 1.02 |
| sentiment | Punjabi (pa) | 690 | 116 | 346 | 1.02 |
| sentiment | Tamil (ta) | 690 | 116 | 346 | 1.02 |
| sentiment | Telugu (te) | 690 | 116 | 346 | 1.02 |
| sentiment | Urdu (ur) | 690 | 116 | 346 | 1.02 |
| topic | Bengali (bn) | 1000 | 300 | 1000 | 9.04 |
| topic | Gujarati (gu) | 1000 | 300 | 659 | 2.17 |
| topic | Hindi (hi) | 1000 | 300 | 856 | 80.8 |
| topic | Malayalam (ml) | 1000 | 300 | 619 | 1.16 |
| topic | Marathi (mr) | 1000 | 300 | 1000 | 6.18 |
| topic | Tamil (ta) | 1000 | 300 | 669 | 1.51 |
Training procedure
HF Trainer, lr 3e-5, batch 16, fp16, max 128 tokens, ≤5 epochs, early stopping on validation macro-F1
(patience 3). Word-embedding matrix frozen (4 GB GPU budget; all 12 transformer layers and the
classifier trained: 86 M of 278 M parameters). Class-weighted loss for imbalanced topic data. Seed 42.
The sentiment model is trained with transliteration augmentation: every training review is added twice more,
once fully romanized and once 50 % script-mixed, with the same rule-based romanizer used for the robustness
test sets (26 904 training examples). It was chosen over the plain joint model by a rule fixed before training
(mean native-script test macro-F1 within 0.01; DECISIONS.md D20).
Metrics (test macro-F1)
Deployed sentiment model, per language (mean over 13 languages: 0.960):
| test language | IndicBERTv2 joint (13 langs) | IndicBERTv2 monolingual | XLM-R joint (13 langs) |
|---|---|---|---|
| as | 0.964 ± 0.003 | 0.960 ± 0.002 | 0.924 ± 0.007 |
| bd | 0.911 ± 0.007 | 0.902 ± 0.008 | 0.760 ± 0.040 |
| bn | 0.950 ± 0.007 | 0.959 ± 0.002 | 0.939 ± 0.006 |
| gu | 0.962 ± 0.003 | 0.969 ± 0.009 | 0.952 ± 0.010 |
| hi | 0.976 ± 0.003 | 0.968 ± 0.003 | 0.961 ± 0.003 |
| kn | 0.954 ± 0.006 | 0.943 ± 0.012 | 0.950 ± 0.007 |
| ml | 0.973 ± 0.009 | 0.950 ± 0.017 | 0.958 ± 0.009 |
| mr | 0.959 ± 0.002 | 0.970 ± 0.002 | 0.957 ± 0.003 |
| or | 0.964 ± 0.002 | 0.944 ± 0.012 | 0.925 ± 0.008 |
| pa | 0.963 ± 0.009 | 0.966 ± 0.007 | 0.939 ± 0.003 |
| ta | 0.959 ± 0.007 | 0.942 ± 0.008 | 0.949 ± 0.007 |
| te | 0.975 ± 0.003 | 0.975 ± 0.002 | 0.951 ± 0.010 |
| ur | 0.960 ± 0.010 | 0.956 ± 0.002 | 0.946 ± 0.003 |
| mean | 0.959 | 0.954 | 0.932 |
Learning curves (monolingual models, mean ± std over 3 seeds):
| Bodo (bd) | 50 | 100 | 250 | 500 | full |
|---|---|---|---|---|---|
| IndicBERTv2 | 0.724 ± 0.085 | 0.833 ± 0.040 | 0.868 ± 0.002 | 0.898 ± 0.012 | 0.902 ± 0.008 |
| IndicBERT-v1 | 0.534 ± 0.033 | 0.590 ± 0.024 | 0.543 ± 0.047 | 0.676 ± 0.021 | 0.678 ± 0.059 |
| XLM-R | 0.573 ± 0.045 | 0.630 ± 0.028 | 0.596 ± 0.075 | 0.578 ± 0.065 | 0.528 ± 0.175 |
| mBERT | 0.607 ± 0.050 | 0.703 ± 0.032 | 0.724 ± 0.017 | 0.758 ± 0.050 | 0.760 ± 0.048 |
| TF-IDF+LR | 0.683 ± 0.034 | 0.756 ± 0.023 | 0.796 ± 0.020 | 0.846 ± 0.017 | 0.853 ± 0.000 |
| Bengali (bn) | 50 | 100 | 250 | 500 | full |
|---|---|---|---|---|---|
| IndicBERTv2 | 0.788 ± 0.061 | 0.898 ± 0.040 | 0.942 ± 0.015 | 0.958 ± 0.007 | 0.959 ± 0.002 |
| IndicBERT-v1 | 0.654 ± 0.058 | 0.740 ± 0.030 | 0.697 ± 0.015 | 0.809 ± 0.012 | 0.807 ± 0.028 |
| XLM-R | 0.752 ± 0.039 | 0.872 ± 0.005 | 0.875 ± 0.067 | 0.922 ± 0.010 | 0.940 ± 0.010 |
| mBERT | 0.758 ± 0.011 | 0.794 ± 0.042 | 0.846 ± 0.017 | 0.843 ± 0.034 | 0.870 ± 0.025 |
| TF-IDF+LR | 0.715 ± 0.007 | 0.767 ± 0.016 | 0.806 ± 0.019 | 0.852 ± 0.016 | 0.853 ± 0.000 |
| Hindi (hi) | 50 | 100 | 250 | 500 | full |
|---|---|---|---|---|---|
| IndicBERTv2 | 0.784 ± 0.079 | 0.888 ± 0.063 | 0.951 ± 0.015 | 0.965 ± 0.013 | 0.968 ± 0.003 |
| IndicBERT-v1 | 0.675 ± 0.060 | 0.749 ± 0.060 | 0.759 ± 0.063 | 0.785 ± 0.023 | 0.838 ± 0.013 |
| XLM-R | 0.811 ± 0.053 | 0.902 ± 0.022 | 0.934 ± 0.010 | 0.950 ± 0.010 | 0.952 ± 0.004 |
| mBERT | 0.740 ± 0.056 | 0.806 ± 0.028 | 0.863 ± 0.016 | 0.883 ± 0.011 | 0.901 ± 0.007 |
| TF-IDF+LR | 0.715 ± 0.029 | 0.765 ± 0.021 | 0.817 ± 0.009 | 0.842 ± 0.003 | 0.861 ± 0.000 |
| Tamil (ta) | 50 | 100 | 250 | 500 | full |
|---|---|---|---|---|---|
| IndicBERTv2 | 0.805 ± 0.050 | 0.916 ± 0.013 | 0.937 ± 0.009 | 0.943 ± 0.002 | 0.942 ± 0.008 |
| IndicBERT-v1 | 0.606 ± 0.056 | 0.691 ± 0.022 | 0.707 ± 0.059 | 0.779 ± 0.004 | 0.794 ± 0.011 |
| XLM-R | 0.850 ± 0.042 | 0.890 ± 0.014 | 0.908 ± 0.019 | 0.919 ± 0.033 | 0.939 ± 0.006 |
| mBERT | 0.736 ± 0.032 | 0.777 ± 0.029 | 0.841 ± 0.029 | 0.852 ± 0.019 | 0.871 ± 0.006 |
| TF-IDF+LR | 0.701 ± 0.028 | 0.763 ± 0.017 | 0.817 ± 0.008 | 0.835 ± 0.008 | 0.835 ± 0.000 |
News topic (mean ± std over 3 seeds):
| system | bn | gu | hi | ml | mr | ta | mean |
|---|---|---|---|---|---|---|---|
| IndicBERTv2 joint | 0.891 ± 0.005 | 0.927 ± 0.003 | 0.425 ± 0.019 | 0.977 ± 0.001 | 0.930 ± 0.004 | 0.969 ± 0.001 | 0.853 |
| IndicBERTv2 mono | 0.889 ± 0.011 | 0.921 ± 0.004 | 0.446 ± 0.030 | 0.971 ± 0.005 | 0.926 ± 0.000 | 0.960 ± 0.004 | 0.852 |
| TF-IDF+LR joint | 0.692 ± 0.000 | 0.861 ± 0.000 | 0.447 ± 0.000 | 0.872 ± 0.000 | 0.779 ± 0.000 | 0.876 ± 0.000 | 0.755 |
| TF-IDF+LR mono | 0.791 ± 0.000 | 0.865 ± 0.000 | 0.497 ± 0.000 | 0.914 ± 0.000 | 0.820 ± 0.000 | 0.906 ± 0.000 | 0.799 |
| XLM-R joint | 0.740 ± 0.012 | 0.896 ± 0.008 | 0.400 ± 0.013 | 0.925 ± 0.007 | 0.866 ± 0.014 | 0.935 ± 0.002 | 0.794 |
| XLM-R mono | 0.691 ± 0.078 | 0.877 ± 0.010 | 0.381 ± 0.011 | 0.919 ± 0.004 | 0.853 ± 0.008 | 0.932 ± 0.007 | 0.776 |
Robustness to romanized / script-mixed input:
| system | ta native | ta mixed | ta romanized | hi native | hi mixed | hi romanized |
|---|---|---|---|---|---|---|
| IndicBERT-v1 | 0.794 ± 0.011 | 0.591 ± 0.047 | 0.377 ± 0.030 | 0.838 ± 0.013 | 0.645 ± 0.055 | 0.398 ± 0.103 |
| IndicBERTv2 | 0.942 ± 0.008 | 0.838 ± 0.015 | 0.436 ± 0.087 | 0.968 ± 0.003 | 0.883 ± 0.011 | 0.422 ± 0.125 |
| IndicBERTv2 +translit-aug | 0.941 ± 0.004 | 0.850 ± 0.050 | 0.590 ± 0.125 | 0.977 ± 0.003 | 0.923 ± 0.006 | 0.847 ± 0.007 |
| IndicBERTv2 joint | 0.959 ± 0.007 | 0.858 ± 0.015 | 0.422 ± 0.003 | 0.976 ± 0.003 | 0.848 ± 0.014 | 0.346 ± 0.004 |
| IndicBERTv2 joint +translit-aug | 0.951 ± 0.006 | 0.866 ± 0.009 | 0.705 ± 0.016 | 0.973 ± 0.004 | 0.930 ± 0.003 | 0.834 ± 0.014 |
| TF-IDF+LR | 0.835 ± 0.000 | 0.803 ± 0.000 | 0.332 ± 0.000 | 0.861 ± 0.000 | 0.812 ± 0.000 | 0.480 ± 0.000 |
| TF-IDF+LR +translit-aug | 0.844 ± 0.008 | 0.843 ± 0.007 | 0.838 ± 0.010 | 0.846 ± 0.022 | 0.848 ± 0.004 | 0.855 ± 0.007 |
| XLM-R | 0.939 ± 0.006 | 0.831 ± 0.015 | 0.575 ± 0.065 | 0.952 ± 0.004 | 0.883 ± 0.016 | 0.662 ± 0.104 |
| XLM-R +translit-aug | 0.928 ± 0.005 | 0.869 ± 0.007 | 0.757 ± 0.027 | 0.938 ± 0.002 | 0.893 ± 0.019 | 0.828 ± 0.044 |
| XLM-R joint | 0.949 ± 0.007 | 0.821 ± 0.016 | 0.475 ± 0.021 | 0.961 ± 0.003 | 0.899 ± 0.013 | 0.722 ± 0.031 |
| mBERT | 0.871 ± 0.006 | 0.802 ± 0.009 | 0.520 ± 0.030 | 0.901 ± 0.007 | 0.751 ± 0.046 | 0.463 ± 0.080 |
| mBERT +translit-aug | 0.867 ± 0.017 | 0.830 ± 0.006 | 0.807 ± 0.010 | 0.909 ± 0.003 | 0.868 ± 0.020 | 0.824 ± 0.032 |
Calibration (15-bin ECE; temperature fitted on validation):
| model | mean ECE before | mean ECE after | mean T | # test langs |
|---|---|---|---|---|
| IndicBERT-v1 | 0.0902 | 0.0852 | 1.79 | 4 |
| IndicBERTv2 | 0.0366 | 0.0263 | 1.63 | 13 |
| IndicBERTv2 joint | 0.0401 | 0.0236 | 2.32 | 13 |
| XLM-R | 0.0547 | 0.031 | 2.16 | 4 |
| XLM-R joint | 0.0661 | 0.0371 | 2.75 | 13 |
| mBERT | 0.1007 | 0.064 | 2.39 | 4 |
Per language (ECE before → after temperature scaling):
| model | bd | bn | hi | ta |
|---|---|---|---|---|
| IndicBERT-v1 | 0.0805 → 0.0868 | 0.1062 → 0.1201 | 0.0709 → 0.0409 | 0.1033 → 0.0931 |
| IndicBERTv2 | 0.0793 → 0.0336 | 0.0373 → 0.0183 | 0.0277 → 0.0180 | 0.0390 → 0.0256 |
| IndicBERTv2 joint | 0.0868 → 0.0591 | 0.0490 → 0.0311 | 0.0238 → 0.0093 | 0.0425 → 0.0254 |
| XLM-R | 0.0773 → 0.0322 | 0.0420 → 0.0353 | 0.0428 → 0.0183 | 0.0564 → 0.0382 |
| XLM-R joint | 0.2223 → 0.1232 | 0.0583 → 0.0292 | 0.0380 → 0.0241 | 0.0505 → 0.0268 |
| mBERT | 0.0997 → 0.0728 | 0.1032 → 0.0688 | 0.0893 → 0.0595 | 0.1106 → 0.0551 |
Deployment variants (CPU, batch 1; macro-F1 over all 13 test sets):
| variant | size (MB) | size reduction | latency mean (ms) | p95 (ms) | speed-up | macro-F1 | F1 drop | accuracy |
|---|---|---|---|---|---|---|---|---|
| pytorch_fp32 | 1112.2 | 1.00x | 62.2 | 85.6 | 1.00x | 0.9602 | 0 | 0.9602 |
| onnx_fp32 | 1112.4 | 1.00x | 30.1 | 45.6 | 2.06x | 0.9602 | 0 | 0.9602 |
| onnx_int8 | 278.8 | 3.99x | 15 | 24.2 | 4.13x | 0.9401 | 0.0201 | 0.9402 |
Limitations
- IndicSentiment is translated from English reviews: sentence structure and vocabulary are cleaner than native user text, so these scores over-estimate real-world performance.
- Romanized and script-mixed input loses a lot of accuracy unless the model was trained with transliteration augmentation (table above); the romanization used in evaluation is rule-based and synthetic.
- Inputs longer than 128 subword tokens are truncated (most topic articles; few reviews).
- Devanagari input defaults to Hindi for normalisation unless the language is given (Marathi, Bodo share the script).
- Hindi news-topic quality is low (0.424 macro-F1): BBC Hindi articles are long (truncated at
128 tokens), five of its 11 classes have ≤ 10 test examples, and the
newslabel overlapsindia/international. TF-IDF is similarly low (0.497); seereports/hindi_topic_diagnosis.md. - Only binary sentiment; neutral or mixed reviews are forced into one class.
Biases
- Product-review domain (electronics, appliances, fashion …) with an urban, online-shopping register.
- Translation artefacts may carry English-source framing and translator style; all languages share the same underlying English reviews, so cross-language comparisons partly measure translation quality.
- News-topic labels reflect the editorial categories of a few publishers (e.g.
kolkata,tamil-cinema). - No evaluation of performance across dialects, gender, caste or religion-related content was possible.
Carbon / compute note
All 501 training runs were done on one laptop NVIDIA RTX 3050 (4 GB, ≈30 W board power cap) with
fp16; per-run times are recorded in each result JSON (train_time_s). No energy meter was used, so no CO₂
figure is claimed; the power cap bounds GPU energy at roughly 30 W × total GPU hours.
Citation
IndicBERTv2 / IndicXTREME: Doddapaneni et al., ACL 2023. IndicNLPSuite / IndicGLUE: Kakwani et al., Findings of EMNLP 2020.