Downloads · 30 days
76
19% of all-time downloads
muhammadsuleman1533/xlm-roberta-multilingual-emotion-classifier
xlm-roberta-multilingual-emotion-classifier is a text classification model from muhammadsuleman1533. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
This model is a fine‑tuned version of XLM‑RoBERTa‑base for 7‑class emotion detection in code‑mixed Pakistani text, including English, Roman Urdu, and Urdu script. It is designed for social media analysis, customer fee…
Downloads · 30 days
76
19% of all-time downloads
All-time downloads
403
Public
Parameters
278M
1.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 99%
From the Hugging Face model README
This model is a fine‑tuned version of XLM‑RoBERTa‑base for 7‑class emotion detection in code‑mixed Pakistani text, including English, Roman Urdu, and Urdu script. It is designed for social media analysis, customer feedback, and multilingual NLP applications in the Pakistani context.
The training dataset was compiled from multiple sources:
| Source | Description |
|---|---|
| GoEmotions | Subset of the Google emotion dataset |
| Parul Pandey’s Emotion Dataset | Primary source (most samples) |
| Roman Urdu‑English Code‑Switched Dataset | Specialised code‑mixed data |
| LLM‑generated samples (GPT, Grok, Gemini) | Used for English‑Urdu translation and augmentation |
Initial raw data showed significant imbalance:
We augmented Sad, Disgust, Surprise (and Fear/Joy where needed per language) using:
Approximate additional samples added:
We randomly under‑sampled the majority English classes (Anger, Fear, Sad) to prevent bias:
Total rows: 20,235
Languages: English (7,734), Roman Urdu (5,572), Urdu (6,929)
Per‑language emotion counts (exact numbers used in training):
| Language | anger | disgust | fear | joy | neutral | sad | surprise | Total |
|---|---|---|---|---|---|---|---|---|
| English | 1128 | 1106 | 1207 | 1200 | 1004 | 1207 | 882 | 7734 |
| Roman Urdu | 839 | 791 | 839 | 839 | 839 | 691 | 734 | 5572 |
| Urdu | 1009 | 935 | 1059 | 980 | 948 | 1059 | 939 | 6929 |
| Total | 2976 | 2832 | 3105 | 3019 | 2791 | 2957 | 2555 | 20235 |
Global percentages:
The final dataset is much more balanced than raw sources, with all classes represented across all three languages.
The model was evaluated on a held‑out test set of 4,047 samples (20% of total data, stratified).
| Emotion | Precision | Recall | F1‑score | Support |
|---|---|---|---|---|
| anger | 0.83 | 0.87 | 0.85 | 595 |
| disgust | 0.90 | 0.93 | 0.91 | 567 |
| fear | 0.93 | 0.90 | 0.92 | 621 |
| joy | 0.82 | 0.79 | 0.81 | 604 |
| neutral | 0.77 | 0.75 | 0.76 | 558 |
| sad | 0.75 | 0.75 | 0.75 | 591 |
| surprise | 0.80 | 0.81 | 0.81 | 511 |
| Actual ↓ / Predicted → | anger | disgust | fear | joy | neutral | sad | surprise |
|---|---|---|---|---|---|---|---|
| anger | 518 | 10 | 13 | 10 | 12 | 26 | 6 |
| disgust | 9 | 526 | 2 | 0 | 13 | 8 | 9 |
| fear | 7 | 3 | 560 | 0 | 0 | 2 | 49 |
| joy | 6 | 3 | 0 | 480 | 54 | 38 | 23 |
| neutral | 9 | 19 | 2 | 39 | 418 | 64 | 7 |
| sad | 52 | 23 | 2 | 29 | 34 | 443 | 8 |
| surprise | 21 | 2 | 23 | 30 | 13 | 8 | 414 |
| Language | Accuracy | Samples |
|---|---|---|
| English | 84.5% | 851 |
| Roman Urdu | 80.8% | 506 |
| Urdu | 84.0% | 681 |