A sentiment classifier for 12 Indian languages and English: Hindi, Bengali, Marathi, Tamil, Telugu, Kannada,
Malayalam, Gujarati, Punjabi, Odia, Assamese, Urdu and English, in native script, romanized or code-mixed. Give it a
comment, review, post or sentence and it returns positive, negative or neutral: the writer's own sentiment. It
is InDIM-small (32M) fine-tuned for sentiment, and runs in a few
milliseconds on a CPU.
from cbx_sentiment import SentimentClassifier # cbx_sentiment.py is in this repository
clf = SentimentClassifier(".") # folder with the model files; CPU or GPU
clf.classify("Bahut badhiya phone hai, battery poora din chalti hai.")
# {"label": "positive", "scores": {"positive": 0.97, "negative": 0.02, "neutral": 0.01}, "truncated": False}
python example.py runs six examples; python onnx_example.py runs the same model with ONNX Runtime
(onnx/model.onnx, fp32, same decisions as PyTorch on 1,000 of 1,000 test texts).
positive 0.97 Bahut badhiya phone hai, battery poora din chalti hai.
negative 1.00 ডেলিভারি তিন দিন দেরিতে এসেছে, খুবই হতাশ।
neutral 1.00 நாளை காலை பத்து மணிக்கு கூட்டம் தொடங்கும்.
positive 1.00 ಈ ಸಿನಿಮಾ ತುಂಬಾ ಚೆನ್ನಾಗಿದೆ, ಎಲ್ಲರೂ ನೋಡಿ!
negative 1.00 yaar kya bakwaas movie thi, paisa barbaad
negative 0.98 Service was okay but the food was cold and overpriced.
| Label | Meaning |
|---|---|
positive |
the writer expresses a favourable opinion or feeling: praise, liking, satisfaction, thanks, good wishes, excitement |
negative |
the writer expresses an unfavourable opinion or feeling: complaint, dislike, anger, sadness, disappointment, criticism, mockery |
neutral |
no opinion or feeling from the writer: facts, news reporting, announcements, questions, requests, instructions, ads without evaluation |
Sentiment is the writer's own stance, not the event: news that only reports a crime or good news is neutral.
Sarcasm takes its intended meaning, and a text with both polarities gets the one that dominates or is the writer's
conclusion, otherwise neutral.
Two test sets labelled by people (not used in training). Every model was fine-tuned with the same recipe and data (plain fine-tuning, learning rate picked on validation); mean of 3 training runs ± SD unless marked.
positive and negative scores only
(two-way accuracy).| Model | Parameters | IndicSentiment accuracy | Source-labelled macro F1 | English tweets | Romanized Hindi | Telugu |
|---|---|---|---|---|---|---|
| InDIM-small (this model's base) | 32M | 0.822 ± 0.016 | 0.512 ± 0.005 | 0.640 | 0.560 | 0.443 |
| mmBERT-small | 140M | 0.839 ± 0.004 | 0.508 ± 0.015 | 0.706 | 0.565 | 0.415 |
| mmBERT-base (1 run) | 307M | 0.901 | 0.524 | 0.716 | 0.601 | 0.421 |
| IndicBERT v2 | 278M | 0.944 ± 0.003 | 0.547 ± 0.002 | 0.713 | 0.577 | 0.475 |
(The last three columns are macro F1 within each source.)
CPU latency (Intel i7-10700, 8 threads, one text at a time, PyTorch fp32): 5.7 ms for a 15-token sentence, 22.8 ms for a long (about 200-word) input.
Precision: fp16 gives the same labels as fp32 on both test sets. PyTorch dynamic int8 (per-channel) keeps 95–97% of labels unchanged; ONNX int8 changed 4% of decisions in our test, so only the fp32 ONNX file is provided.
"truncated": True).positive and negative scores, as in the IndicSentiment accuracy above.neutral. Compare positive and negative only if your texts always carry an
opinion.Intended use: measuring and routing sentiment in text at scale, for example customer feedback, reviews, support messages and social-media posts, where results are read in aggregate or checked by people. Not intended for decisions about individual people (hiring, credit, moderation penalties, surveillance) without a person reviewing each case. The model makes mistakes, more in some languages than others. It is provided "as is", without warranties of any kind; Cobuild Tech Private Limited is not liable for its use. You are responsible for checking that it suits your data and for complying with the laws that apply to your use.
InDIM-small (32M) fine-tuned on about 63,000 texts in 13 languages (social-media comments, tweets, reviews and web text, about 15% written by LLMs to fill gaps), labelled to the guide above by LLMs (plain fine-tuning, learning rate 4e-4). The source datasets are credited in NOTICE.
If you use this model, please cite InDIM-small (32M).
Apache-2.0 (see LICENSE). Dataset credits and licences: see NOTICE.
Questions: hello@cobuildx.ai.
onnx/model.onnx 126 MBmodel.safetensors 126 MBCobuildX-AI/InDIM-small