cbx-indic-sentiment-classifier-36M

A sentiment classifier for 12 Indian languages and English: Hindi, Bengali, Marathi, Tamil, Telugu, Kannada, Malayalam, Gujarati, Punjabi, Odia, Assamese, Urdu and English, written in native script, in Latin letters (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 has 36.5M parameters: the 58M with every second layer removed (11 of 22 layers), distilled again from the fine-tuned mmBERT-base, also on about 160,000 unlabelled real texts scored by that model. Other sizes: 58M. On a CPU (8 threads, fp32) one short text (17 tokens) takes about 7 ms and a full 256-token text about 27 ms.

Licence: Apache License, Version 2.0. Read Intended use and disclaimer before using it.

Labels

One label per text. F1 per label on Real text test (below).

Label Meaning F1
positive the writer expresses a favourable opinion or feeling: praise, liking, satisfaction, thanks, good wishes, excitement 0.73
negative the writer expresses an unfavourable opinion or feeling: complaint, dislike, anger, sadness, disappointment, criticism, mockery 0.58
neutral no opinion or feeling from the writer: facts, news reporting, announcements, questions, requests, instructions, ads without evaluation 0.83

The labels follow a written guide. Sentiment is the writer's own stance, not the event: news that only reports a crime, a disaster or good news is neutral, however bad or good the event. Sarcasm takes its intended meaning, mild opinions count ("decent phone for the price" is positive), and a text with both polarities gets the one that dominates or is the writer's conclusion, otherwise neutral.

Quick start

pip install -r requirements.txt
python example.py
from cbx_sentiment import SentimentClassifier

clf = SentimentClassifier(".")                  # folder with the model files; CPU or GPU
r = clf.classify("Bahut badhiya phone hai, battery poora din chalti hai.")
r["label"], r["scores"]                # top label and the probability of each label
clf.classify(["first text", "second text"])   # a list gives a list

python example.py prints (texts invented; any errors are the model's own):

positive  0.98  Bahut badhiya phone hai, battery poora din chalti hai.
negative  1.00  เฆกเง‡เฆฒเฆฟเฆญเฆพเฆฐเฆฟ เฆคเฆฟเฆจ เฆฆเฆฟเฆจ เฆฆเง‡เฆฐเฆฟเฆคเง‡ เฆเฆธเง‡เฆ›เง‡, เฆ–เงเฆฌเฆ‡ เฆนเฆคเฆพเฆถเฅค
neutral   0.93  เฎจเฎพเฎณเฏˆ เฎ•เฎพเฎฒเฏˆ เฎชเฎคเฏเฎคเฏ เฎฎเฎฃเฎฟเฎ•เฏเฎ•เฏ เฎ•เฏ‚เฎŸเฏเฎŸเฎฎเฏ เฎคเฏŠเฎŸเฎ™เฏเฎ•เฏเฎฎเฏ.
positive  1.00  เฒˆ เฒธเฒฟเฒจเฒฟเฒฎเฒพ เฒคเณเฒ‚เฒฌเฒพ เฒšเณ†เฒจเณเฒจเฒพเฒ—เฒฟเฒฆเณ†, เฒŽเฒฒเณเฒฒเฒฐเณ‚ เฒจเณ‹เฒกเฒฟ!
neutral   1.00  เคธเคฐเค•เคพเคฐ เคจเฅ‡ เคจเคˆ เคฏเฅ‹เคœเคจเคพ เค•เฅ€ เค˜เฅ‹เคทเคฃเคพ เค•เฅ€ เคนเฅˆเฅค
negative  1.00  yaar kya bakwaas movie thi, paisa barbaad
negative  1.00  Service was okay but the food was cold and overpriced.

Input

  • One comment, review, post or sentence. The model reads at most 256 tokens; longer text is cut ("truncated": True).
  • Native script, romanized and code-mixed text are all supported. The model judges the text alone: it does not see the conversation, the product or the post a comment replies to.
  • If every text you score carries an opinion (for example product reviews with a star rating), compare only the positive and negative scores: that is how the IndicSentiment accuracy below is computed.

Evaluation

Real text test: 2,575 real texts, about 200 per language, never used in training: web text (Sangraha, FineWeb-2), social-media comments, tweets and reviews from the datasets credited below, with at least 50 opinionated texts per language (53% neutral, 27% positive, 20% negative). Each text was labelled independently by two LLMs (Gemma 4 31B and Claude Sonnet 5.5) following the written guide; gpt-5.4-mini decided their disagreements. No person reviewed the labels, so they contain errors.

Web text test: 1,252 real texts (80โ€“150 per language; web text and Dravidian comments, 72% neutral), labelled the same way. Smaller and mostly neutral; reported for comparison with the real text test.

IndicSentiment: 12,946 product reviews (AI4Bharat IndicSentiment, test and validation splits, 13 languages), each positive or negative as labelled by the dataset's authors. The model's positive and negative scores are compared (neutral is ignored), so this is a two-way accuracy. Not used in training.

Model Real text test (macro F1) Web text test (macro F1) IndicSentiment (accuracy)
58M (same family) 0.721 0.680 0.849
this model (36M) 0.713 0.650 0.818
TF-IDF + logistic regression 0.685 0.623 0.726
cardiffnlp/twitter-xlm-roberta-base-sentiment 0.601 โ€“ 0.847
cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual 0.606 โ€“ 0.758
tabularisai/multilingual-sentiment-analysis 0.524 โ€“ 0.779

TF-IDF: character n-grams with logistic regression, trained on the same data. The three public models were used as published, with their labels mapped to ours; they were not trained on our data or guide, so part of their gap on the real text tests is a difference in what counts as neutral. tabularisai/multilingual-sentiment-analysis is licensed for non-commercial use only.

By language (Real text test, macro F1):

Language 58M 36M (this model) Texts
Hindi (hi) 0.67 0.68 199
Bengali (bn) 0.87 0.86 200
Marathi (mr) 0.73 0.70 199
Tamil (ta) 0.78 0.75 197
Telugu (te) 0.57 0.59 199
Kannada (kn) 0.80 0.77 195
Malayalam (ml) 0.73 0.72 196
Gujarati (gu) 0.71 0.70 196
Punjabi (pa) 0.57 0.56 200
Odia (or) 0.46 0.53 199
Assamese (as) 0.82 0.81 200
Urdu (ur) 0.61 0.61 197
English (en) 0.74 0.68 198

By script (this model, accuracy): code-mixed 0.71 (28 texts), native script 0.77 (1700 texts), romanized 0.74 (847 texts)

Training data

About 63,000 labelled texts from the eleven training datasets credited below: social-media comments, tweets and reviews, plus web text from Sangraha and FineWeb-2. All of them were labelled to the written guide by two LLMs, with a third deciding disagreements; the datasets' own labels were not used. About 15% of the training texts (9,500) were written by LLMs to fill language and label combinations with little real text; no generated text is in any test set. The models were distilled from mmBERT-base fine-tuned on the same data.

Dataset Languages Licence Used for
Telugu_Sentiment, Marreddy et al. 2022 te CC BY 4.0 training and testing
XLM-T tweet_sentiment_multilingual, Barbieri et al. 2022 en, hi CC BY 3.0 (tweets: X / Twitter terms) training and testing
Hinglish YouTube sentiments dataset (shae2977) hi CC BY 4.0 training and testing
Roman Urdu Data Set, Sharf 2018, UCI Machine Learning Repository ur CC BY 4.0 training and testing
Assamese movie reviews sentiment, A. Dutta and S. Dutta as CC BY 4.0 training and testing
Bangla sentiment benchmark corpus, Sazzed 2021 bn CC BY 4.0 training and testing
Motamot (Bengali political sentiment), arXiv:2407.19528 bn MIT training
Sangraha, AI4Bharat as, bn, en, gu, hi, kn, ml, mr, or, pa, ta, te, ur CC BY 4.0 training and testing
FineWeb-2, Hugging Face as, bn, gu, hi, kn, ml, mr, or, pa, ta, te, ur ODC-By 1.0 training and testing
DravidianCodeMix comments (OffensEval Dravidian), Chakravarthi et al. kn, ml, ta CC BY 4.0 training and testing
Gujarati-English code-mixed comments (ShrutiPatel3011) gu CC BY 4.0 training and testing
IndicSentiment, Doddapaneni et al. 2023 (IndicXTREME), AI4Bharat as, bn, en, gu, hi, kn, ml, mr, or, pa, ta, te, ur CC0 1.0 testing

Limitations

  • Too many opinions are called neutral. On IndicSentiment, where every review is positive or negative, the model labels 52% of reviews neutral. Negative opinions are missed most (negative F1 0.58 on the real text test). If your texts always carry an opinion, compare positive and negative scores only.
  • Weaker languages: Odia (0.53), Punjabi (0.56), Telugu (0.59) and Urdu (0.61) score well below the other languages on the real text test. Expect more errors there.
  • Code-mixed text is in training, but the real text test has only 28 code-mixed texts, so its accuracy there is not well measured.
  • Labels are from LLMs, not people, for training and for the tests. The guide's choices (for example, that reported news is neutral) are one reasonable reading, not the only one; data labelled another way will score lower.
  • Context. The model sees one text. Sarcasm, irony, quotes and replies to content it cannot see are often misread.
  • Bias. Errors are not spread evenly across languages, scripts, dialects or topics; political, religious and community-related text may be judged less accurately.

Intended use and disclaimer

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 (see Limitations). 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.

Downloads last month
19
Safetensors
Model size
36.5M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for CobuildX-AI/cbx-indic-sentiment-classifier-36M

Finetuned
(86)
this model

Collection including CobuildX-AI/cbx-indic-sentiment-classifier-36M

Paper for CobuildX-AI/cbx-indic-sentiment-classifier-36M