Text Classification
Transformers
Safetensors
modernbert
fill-mask
sentiment-analysis
indic
multilingual
code-mixed
romanized
text-embeddings-inference
Instructions to use CobuildX-AI/cbx-indic-sentiment-classifier-58M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CobuildX-AI/cbx-indic-sentiment-classifier-58M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="CobuildX-AI/cbx-indic-sentiment-classifier-58M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("CobuildX-AI/cbx-indic-sentiment-classifier-58M") model = AutoModelForMaskedLM.from_pretrained("CobuildX-AI/cbx-indic-sentiment-classifier-58M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from CobuildX-AI/cbx-indic-sentiment-classifier-58M: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/CobuildX-AI/cbx-indic-sentiment-classifier-58M/resolve/main/README.md
- Command line
-
hf download hf://CobuildX-AI/cbx-indic-sentiment-classifier-58M/README.md
-
curl -L -o README.md https://huggingface.co/CobuildX-AI/cbx-indic-sentiment-classifier-58M/resolve/main/README.md
11.1 kB
| license: apache-2.0 | |
| language: | |
| - hi | |
| - bn | |
| - mr | |
| - ta | |
| - te | |
| - kn | |
| - ml | |
| - gu | |
| - pa | |
| - or | |
| - as | |
| - ur | |
| - en | |
| library_name: transformers | |
| pipeline_tag: text-classification | |
| base_model: jhu-clsp/mmBERT-small | |
| tags: | |
| - sentiment-analysis | |
| - indic | |
| - multilingual | |
| - code-mixed | |
| - romanized | |
| - text-classification | |
| # cbx-indic-sentiment-classifier-58M | |
| 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 57.6M parameters: mmBERT-small with its vocabulary pruned to the 40,000 tokens these languages use, distilled from a fine-tuned mmBERT-base. Other sizes: 36M. | |
| On a CPU (8 threads, fp32) one short text (17 tokens) takes about 13 ms and a full 256-token text about 52 ms. | |
| **Licence: Apache License, Version 2.0.** Read [Intended use and disclaimer](#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.74 | | |
| | `negative` | the writer expresses an unfavourable opinion or feeling: complaint, dislike, anger, sadness, disappointment, criticism, mockery | 0.61 | | |
| | `neutral` | no opinion or feeling from the writer: facts, news reporting, announcements, questions, requests, instructions, ads without evaluation | 0.82 | | |
| 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 | |
| ```bash | |
| pip install -r requirements.txt | |
| python example.py | |
| ``` | |
| ```python | |
| 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 1.00 Bahut badhiya phone hai, battery poora din chalti hai. | |
| negative 1.00 ডেলিভারি তিন দিন দেরিতে এসেছে, খুবই হতাশ। | |
| neutral 1.00 நாளை காலை பத்து மணிக்கு கூட்டம் தொடங்கும். | |
| 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) | | |
| |---|---:|---:|---:| | |
| | **this model (58M)** | 0.721 | 0.680 | 0.849 | | |
| | 36M (same family) | 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 (this model) | 36M | 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.86 (28 texts), native script 0.78 (1700 texts), romanized 0.73 (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](https://huggingface.co/datasets/mounikaiiith/Telugu_Sentiment) | te | CC BY 4.0 | training and testing | | |
| | [XLM-T tweet_sentiment_multilingual, Barbieri et al. 2022](https://huggingface.co/datasets/cardiffnlp/tweet_sentiment_multilingual) | en, hi | CC BY 3.0 (tweets: X / Twitter terms) | training and testing | | |
| | [Hinglish YouTube sentiments dataset (shae2977)](https://huggingface.co/datasets/shae2977/hinglish-youtube-sentiments-dataset) | hi | CC BY 4.0 | training and testing | | |
| | [Roman Urdu Data Set, Sharf 2018, UCI Machine Learning Repository](https://archive.ics.uci.edu/dataset/458/roman+urdu+data+set) | ur | CC BY 4.0 | training and testing | | |
| | [Assamese movie reviews sentiment, A. Dutta and S. Dutta](https://huggingface.co/datasets/AvinabhDutta-Dev/assamese-movie-reviews-sentiment) | as | CC BY 4.0 | training and testing | | |
| | [Bangla sentiment benchmark corpus, Sazzed 2021](https://huggingface.co/datasets/Akash190104/bengali_sentiment_analysis) | bn | CC BY 4.0 | training and testing | | |
| | [Motamot (Bengali political sentiment), arXiv:2407.19528](https://huggingface.co/datasets/Mukaffi28/Motamot_Bengali_Political_Sentiment_Analysis) | bn | MIT | training | | |
| | [Sangraha, AI4Bharat](https://huggingface.co/datasets/ai4bharat/sangraha) | as, bn, en, gu, hi, kn, ml, mr, or, pa, ta, te, ur | CC BY 4.0 | training and testing | | |
| | [FineWeb-2, Hugging Face](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2) | 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.](https://huggingface.co/datasets/community-datasets/offenseval_dravidian) | kn, ml, ta | CC BY 4.0 | training and testing | | |
| | [Gujarati-English code-mixed comments (ShrutiPatel3011)](https://huggingface.co/datasets/ShrutiPatel3011/gujarati-english-codemixed-sentiment) | gu | CC BY 4.0 | training and testing | | |
| | [IndicSentiment, Doddapaneni et al. 2023 (IndicXTREME), AI4Bharat](https://huggingface.co/datasets/ai4bharat/IndicSentiment) | 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 47% of reviews `neutral`. Negative opinions are missed most (`negative` F1 0.61 on the real text test). If your texts always carry an opinion, compare `positive` and `negative` scores only. | |
| - **Weaker languages:** Odia (0.46), Punjabi (0.57), Telugu (0.57) 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. | |