🧠 EmotionSense

Fine-Grained Emotion Classification using RoBERTa

πŸ€— Hugging Face β€’ πŸ”₯ RoBERTa β€’ πŸ’¬ Emotion AI β€’ πŸš€ Production Ready

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.

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.


✨ Highlights

  • πŸ”₯ Fine-tuned RoBERTa-base
  • 🧠 Context-aware emotion recognition
  • πŸ“Š Class-balanced training using Weighted Cross Entropy Loss
  • ⚑ Early stopping for improved generalization
  • 🎯 Optimized using Weighted F1 Score
  • πŸ€— Compatible with Hugging Face Transformers Pipeline

🎯 Supported Emotion Classes

Label Description
πŸ˜€ Joy Positive emotions, happiness, gratitude, love
😒 Sadness Grief, disappointment, remorse
😑 Anger Anger, annoyance, disapproval
😨 Fear Fear and nervousness
🀒 Disgust Disgust
😲 Surprise Surprise, curiosity, realization
😐 Neutral Emotionally neutral statements

πŸ“š Dataset

The model was trained using a customized version of the GoEmotions dataset.

The original dataset contains approximately 58,000 Reddit comments annotated with 28 fine-grained emotion labels.

To improve annotation quality:

  • βœ” Majority Voting was applied.
  • βœ” Samples without annotator agreement were removed.
  • βœ” Multi-label ambiguity was eliminated.
  • βœ” Fine-grained emotions were mapped into Ekman's seven universal emotion categories.

Emotion Mapping

Ekman Category Original GoEmotions Labels
Anger anger, annoyance, disapproval
Disgust disgust
Fear fear, nervousness
Joy joy, amusement, admiration, approval, caring, desire, excitement, gratitude, love, optimism, pride, relief
Sadness sadness, disappointment, embarrassment, grief, remorse
Surprise surprise, realization, curiosity, confusion
Neutral neutral

πŸ— Model Architecture

Property Value
Base Model RoBERTa-base
Framework Hugging Face Transformers
Language English
Task Emotion Classification
Max Sequence Length 128
Batch Size 16
Learning Rate 2e-5
Epochs 5
Optimizer AdamW
Loss Function Weighted Cross Entropy
Early Stopping Enabled

πŸ“ˆ Performance

EmotionSense achieved the best performance among all evaluated models.

Model Accuracy Weighted F1
Logistic Regression 0.59 0.57
Random Forest 0.61 0.59
Linear SVM 0.63 0.61
DistilBERT 0.68 0.67
EmotionSense (RoBERTa) 0.903 0.891

Final Evaluation

Metric Score
Accuracy 90.3%
Precision 90.1%
Recall 89.4%
Weighted F1 89.1%

πŸš€ Quick Start

Install Transformers

pip install transformers torch

Load the model

from transformers import pipeline

classifier = pipeline(
    "text-classification",
    model="SobanHM/EmotionSense"
)

classifier("I finally got my dream job today!")

Example Output

[
    {
        "label": "joy",
        "score": 0.997
    }
]

πŸ’‘ Applications

  • Conversational AI
  • Emotion-aware Chatbots
  • Mental Health Support Systems
  • Customer Feedback Analysis
  • Social Media Analytics
  • Human-Computer Interaction
  • Intelligent Virtual Assistants

⚠ Limitations

  • Supports English language only.
  • Performance may decrease on domain-specific text.
  • Sarcasm and irony remain challenging.
  • Emotion recognition is probabilistic and should not be used for clinical diagnosis or psychological assessment.

πŸ‘¨β€πŸ’» About the Author

Soban Hussain

AI Engineer β€’ Machine Learning Researcher β€’ Computer Vision & NLP

πŸ€— Hugging Face: https://huggingface.co/SobanHM

πŸ’Ό LinkedIn: https://www.linkedin.com/in/sobanhussain

πŸ’» GitHub: https://github.com/SobanHM


πŸ™Œ Acknowledgements

This project was built using:

  • Hugging Face Transformers
  • PyTorch
  • GoEmotions Dataset
  • RoBERTa

Special thanks to the open-source AI community for providing exceptional tools and resources.


πŸ“– Citation

If you use this model in your research, please cite both this repository and the GoEmotions dataset.

@inproceedings{demszky2020goemotions,
  title={GoEmotions: A Dataset of Fine-Grained Emotions},
  author={Demszky, Dorottya and others},
  booktitle={Proceedings of ACL},
  year={2020}
}

⭐ If you find this model useful, consider giving it a Like on Hugging Face and sharing your feedback!

Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Dataset used to train SobanHM/EmotionSense

Evaluation results

  • Accuracy on Customized GoEmotions (Ekman Mapping)
    self-reported
    0.903
  • Precision on Customized GoEmotions (Ekman Mapping)
    self-reported
    0.901
  • Recall on Customized GoEmotions (Ekman Mapping)
    self-reported
    0.894
  • Weighted F1 on Customized GoEmotions (Ekman Mapping)
    self-reported
    0.891