Instructions to use arslanahmed3/emotion-roberta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use arslanahmed3/emotion-roberta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="arslanahmed3/emotion-roberta")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("arslanahmed3/emotion-roberta") model = AutoModelForSequenceClassification.from_pretrained("arslanahmed3/emotion-roberta", device_map="auto") - Notebooks
- Google Colab
- Kaggle
RoBERTa fine-tuned for emotion detection
This is roberta-base fine-tuned to classify English text into six emotions: anger, fear, joy, love, sadness and surprise.
It is one of four models compared in the paper:
Comparative Analysis of DistilBERT, XLNet, RoBERTa & BigBird for Emotion Detection in Conversational Text Arslan Ahmed, Barkha, Tushar Kanjwani, Shahzad Nasim. ILMA Journal of Technology & Software Management (IJTSM), Vol. 6, Issue 1, pp. 1–12, 2025. 📄 Paper · 💻 Code, notebooks & web demo
Results (test set, 2,000 samples)
| Accuracy | Macro F1 | Weighted F1 |
|---|---|---|
| 93.15 % | 0.89 | 0.93 |
Strengths: most balanced precision/recall across all six classes; highest validation accuracy (94.20 %). Like every model in the study, it is weakest on surprise, the rarest class.
Other models from the paper: DistilBERT · XLNet · RoBERTa · BigBird
Labels
| id | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| label | anger | fear | joy | love | sadness | surprise |
Usage
# pip install "transformers>=4.50,<5" tensorflow tf-keras sentencepiece
import tensorflow as tf
from transformers import RobertaTokenizer, TFRobertaForSequenceClassification
repo = "arslanahmed3/emotion-roberta"
tokenizer = RobertaTokenizer.from_pretrained(repo)
model = TFRobertaForSequenceClassification.from_pretrained(repo)
inputs = tokenizer("i feel so lucky to have friends like you", return_tensors="tf", truncation=True, max_length=128)
probs = tf.nn.softmax(model(**inputs).logits, axis=-1)[0].numpy()
print(model.config.id2label[int(probs.argmax())], float(probs.max()))
Transformers 5.x removed the TensorFlow model classes, so use
transformers<5.
Training
| Dataset | Emotions Dataset for NLP (16,000 train / 2,000 val / 2,000 test) |
| Framework | TensorFlow |
| Optimizer / LR | 5e-5 (Adam) |
| Batch size | 32 |
| Max sequence length | 128 |
| Epochs | 20 |
| Hardware | Google Colab GPU |
The training notebook is in the GitHub repo.
Citation
@article{ahmed2025emotion,
title = {Comparative Analysis of DistilBERT, XLNet, RoBERTa \& BigBird for Emotion Detection in Conversational Text},
author = {Ahmed, Arslan and Barkha and Kanjwani, Tushar and Nasim, Shahzad},
journal = {ILMA Journal of Technology \& Software Management (IJTSM)},
volume = {6},
number = {1},
pages = {1--12},
year = {2025},
url = {https://ijtsm.ilmauniversity.edu.pk/arc/Vol6/i1p1}
}
- Downloads last month
- 6
Model tree for arslanahmed3/emotion-roberta
Base model
FacebookAI/roberta-base