Text Classification
Transformers
Safetensors
PyTorch
English
roberta
emotion-classification
natural-language-processing
goemotions
ekman-emotions
sentiment-analysis
Eval Results (legacy)
text-embeddings-inference
Instructions to use SobanHM/EmotionSense with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SobanHM/EmotionSense with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="SobanHM/EmotionSense")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("SobanHM/EmotionSense") model = AutoModelForSequenceClassification.from_pretrained("SobanHM/EmotionSense", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,249 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
- natural-language-processing
|
| 10 |
+
- roberta
|
| 11 |
+
- transformers
|
| 12 |
+
- pytorch
|
| 13 |
+
- goemotions
|
| 14 |
+
- ekman-emotions
|
| 15 |
+
- sentiment-analysis
|
| 16 |
+
- text-classification
|
| 17 |
+
datasets:
|
| 18 |
+
- go_emotions
|
| 19 |
+
metrics:
|
| 20 |
+
- accuracy
|
| 21 |
+
- precision
|
| 22 |
+
- recall
|
| 23 |
+
- f1
|
| 24 |
+
model-index:
|
| 25 |
+
- name: EmotionSense
|
| 26 |
+
results:
|
| 27 |
+
- task:
|
| 28 |
+
type: text-classification
|
| 29 |
+
name: Emotion Classification
|
| 30 |
+
dataset:
|
| 31 |
+
name: Customized GoEmotions (Ekman Mapping)
|
| 32 |
+
type: go_emotions
|
| 33 |
+
metrics:
|
| 34 |
+
- type: Accuracy
|
| 35 |
+
value: 0.903
|
| 36 |
+
- type: Precision
|
| 37 |
+
value: 0.901
|
| 38 |
+
- type: Recall
|
| 39 |
+
value: 0.894
|
| 40 |
+
- type: Weighted F1
|
| 41 |
+
value: 0.891
|
| 42 |
---
|
| 43 |
+
|
| 44 |
+
# π§ EmotionSense
|
| 45 |
+
### Fine-Grained Emotion Classification using RoBERTa
|
| 46 |
+
|
| 47 |
+
<p align="center">
|
| 48 |
+
|
| 49 |
+
π€ <b>Hugging Face</b> β’ π₯ <b>RoBERTa</b> β’ π¬ <b>Emotion AI</b> β’ π <b>Production Ready</b>
|
| 50 |
+
|
| 51 |
+
</p>
|
| 52 |
+
|
| 53 |
+
EmotionSense is a **RoBERTa-base** model fine-tuned for **emotion classification**. The model predicts **seven human emotions** from English text using a cleaned and simplified version of the GoEmotions dataset.
|
| 54 |
+
|
| 55 |
+
Unlike the original GoEmotions dataset containing 28 fine-grained emotion labels, this work reorganizes emotions according to the **Ekman Emotion Framework**, improving interpretability while maintaining strong predictive performance.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
# β¨ Highlights
|
| 60 |
+
|
| 61 |
+
- π₯ Fine-tuned **RoBERTa-base**
|
| 62 |
+
- π§ Context-aware emotion recognition
|
| 63 |
+
- π Class-balanced training using Weighted Cross Entropy Loss
|
| 64 |
+
- β‘ Early stopping for improved generalization
|
| 65 |
+
- π― Optimized using Weighted F1 Score
|
| 66 |
+
- π€ Compatible with Hugging Face Transformers Pipeline
|
| 67 |
+
|
| 68 |
+
---
|
| 69 |
+
|
| 70 |
+
# π― Supported Emotion Classes
|
| 71 |
+
|
| 72 |
+
| Label | Description |
|
| 73 |
+
|--------|------------|
|
| 74 |
+
| π Joy | Positive emotions, happiness, gratitude, love |
|
| 75 |
+
| π’ Sadness | Grief, disappointment, remorse |
|
| 76 |
+
| π‘ Anger | Anger, annoyance, disapproval |
|
| 77 |
+
| π¨ Fear | Fear and nervousness |
|
| 78 |
+
| π€’ Disgust | Disgust |
|
| 79 |
+
| π² Surprise | Surprise, curiosity, realization |
|
| 80 |
+
| π Neutral | Emotionally neutral statements |
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
# π Dataset
|
| 85 |
+
|
| 86 |
+
The model was trained using a **customized version of the GoEmotions dataset**.
|
| 87 |
+
|
| 88 |
+
The original dataset contains approximately **58,000 Reddit comments** annotated with **28 fine-grained emotion labels**.
|
| 89 |
+
|
| 90 |
+
To improve annotation quality:
|
| 91 |
+
|
| 92 |
+
- β Majority Voting was applied.
|
| 93 |
+
- β Samples without annotator agreement were removed.
|
| 94 |
+
- β Multi-label ambiguity was eliminated.
|
| 95 |
+
- β Fine-grained emotions were mapped into **Ekman's seven universal emotion categories**.
|
| 96 |
+
|
| 97 |
+
### Emotion Mapping
|
| 98 |
+
|
| 99 |
+
| Ekman Category | Original GoEmotions Labels |
|
| 100 |
+
|---------------|----------------------------|
|
| 101 |
+
| Anger | anger, annoyance, disapproval |
|
| 102 |
+
| Disgust | disgust |
|
| 103 |
+
| Fear | fear, nervousness |
|
| 104 |
+
| Joy | joy, amusement, admiration, approval, caring, desire, excitement, gratitude, love, optimism, pride, relief |
|
| 105 |
+
| Sadness | sadness, disappointment, embarrassment, grief, remorse |
|
| 106 |
+
| Surprise | surprise, realization, curiosity, confusion |
|
| 107 |
+
| Neutral | neutral |
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
# π Model Architecture
|
| 112 |
+
|
| 113 |
+
| Property | Value |
|
| 114 |
+
|----------|------|
|
| 115 |
+
| Base Model | RoBERTa-base |
|
| 116 |
+
| Framework | Hugging Face Transformers |
|
| 117 |
+
| Language | English |
|
| 118 |
+
| Task | Emotion Classification |
|
| 119 |
+
| Max Sequence Length | 128 |
|
| 120 |
+
| Batch Size | 16 |
|
| 121 |
+
| Learning Rate | 2e-5 |
|
| 122 |
+
| Epochs | 5 |
|
| 123 |
+
| Optimizer | AdamW |
|
| 124 |
+
| Loss Function | Weighted Cross Entropy |
|
| 125 |
+
| Early Stopping | Enabled |
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
# π Performance
|
| 130 |
+
|
| 131 |
+
EmotionSense achieved the best performance among all evaluated models.
|
| 132 |
+
|
| 133 |
+
| Model | Accuracy | Weighted F1 |
|
| 134 |
+
|-------|---------:|------------:|
|
| 135 |
+
| Logistic Regression | 0.59 | 0.57 |
|
| 136 |
+
| Random Forest | 0.61 | 0.59 |
|
| 137 |
+
| Linear SVM | 0.63 | 0.61 |
|
| 138 |
+
| DistilBERT | 0.68 | 0.67 |
|
| 139 |
+
| **EmotionSense (RoBERTa)** | **0.903** | **0.891** |
|
| 140 |
+
|
| 141 |
+
### Final Evaluation
|
| 142 |
+
|
| 143 |
+
| Metric | Score |
|
| 144 |
+
|---------|------:|
|
| 145 |
+
| Accuracy | **90.3%** |
|
| 146 |
+
| Precision | **90.1%** |
|
| 147 |
+
| Recall | **89.4%** |
|
| 148 |
+
| Weighted F1 | **89.1%** |
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
# π Quick Start
|
| 153 |
+
|
| 154 |
+
Install Transformers
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
pip install transformers torch
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
Load the model
|
| 161 |
+
|
| 162 |
+
```python
|
| 163 |
+
from transformers import pipeline
|
| 164 |
+
|
| 165 |
+
classifier = pipeline(
|
| 166 |
+
"text-classification",
|
| 167 |
+
model="SobanHM/EmotionSense"
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
classifier("I finally got my dream job today!")
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
Example Output
|
| 174 |
+
|
| 175 |
+
```python
|
| 176 |
+
[
|
| 177 |
+
{
|
| 178 |
+
"label": "joy",
|
| 179 |
+
"score": 0.997
|
| 180 |
+
}
|
| 181 |
+
]
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
---
|
| 185 |
+
|
| 186 |
+
# π‘ Applications
|
| 187 |
+
|
| 188 |
+
- Conversational AI
|
| 189 |
+
- Emotion-aware Chatbots
|
| 190 |
+
- Mental Health Support Systems
|
| 191 |
+
- Customer Feedback Analysis
|
| 192 |
+
- Social Media Analytics
|
| 193 |
+
- Human-Computer Interaction
|
| 194 |
+
- Intelligent Virtual Assistants
|
| 195 |
+
|
| 196 |
+
---
|
| 197 |
+
|
| 198 |
+
# β Limitations
|
| 199 |
+
|
| 200 |
+
- Supports English language only.
|
| 201 |
+
- Performance may decrease on domain-specific text.
|
| 202 |
+
- Sarcasm and irony remain challenging.
|
| 203 |
+
- Emotion recognition is probabilistic and should not be used for clinical diagnosis or psychological assessment.
|
| 204 |
+
|
| 205 |
+
---
|
| 206 |
+
|
| 207 |
+
# π¨βπ» About the Author
|
| 208 |
+
|
| 209 |
+
**Soban Hussain**
|
| 210 |
+
|
| 211 |
+
AI Engineer β’ Machine Learning Researcher β’ Computer Vision & NLP
|
| 212 |
+
|
| 213 |
+
π€ **Hugging Face:** https://huggingface.co/SobanHM
|
| 214 |
+
|
| 215 |
+
πΌ **LinkedIn:** https://www.linkedin.com/in/sobanhussain
|
| 216 |
+
|
| 217 |
+
π» **GitHub:** https://github.com/SobanHM
|
| 218 |
+
|
| 219 |
+
---
|
| 220 |
+
|
| 221 |
+
# π Acknowledgements
|
| 222 |
+
|
| 223 |
+
This project was built using:
|
| 224 |
+
|
| 225 |
+
- Hugging Face Transformers
|
| 226 |
+
- PyTorch
|
| 227 |
+
- GoEmotions Dataset
|
| 228 |
+
- RoBERTa
|
| 229 |
+
|
| 230 |
+
Special thanks to the open-source AI community for providing exceptional tools and resources.
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
# π Citation
|
| 235 |
+
|
| 236 |
+
If you use this model in your research, please cite both this repository and the GoEmotions dataset.
|
| 237 |
+
|
| 238 |
+
```bibtex
|
| 239 |
+
@inproceedings{demszky2020goemotions,
|
| 240 |
+
title={GoEmotions: A Dataset of Fine-Grained Emotions},
|
| 241 |
+
author={Demszky, Dorottya and others},
|
| 242 |
+
booktitle={Proceedings of ACL},
|
| 243 |
+
year={2020}
|
| 244 |
+
}
|
| 245 |
+
```
|
| 246 |
+
|
| 247 |
+
---
|
| 248 |
+
|
| 249 |
+
## β If you find this model useful, consider giving it a Like on Hugging Face and sharing your feedback!
|