Team Ai
Modelpublic

cirimus/modernbert-base-emotions

sourceHugging Facecc-by-4.0updated 1y agoView on Hugging Face
3likes544downloads
Model Card

banner

Overview

This model was fine-tuned from ModernBERT-base on the Super Emotion dataset for multi-class emotion classification. It predicts emotional states in text across seven labels: joy, sadness, anger, fear, love, neutral, surprise.


Model Details

  • —Base Model: ModernBERT-base
  • —Fine-Tuning Dataset: Super Emotion
  • —Number of Labels: 7
  • —Problem Type: Single-label classification
  • —Language: English
  • —License: CC-BY-4.0
  • —Fine-Tuning Framework: Hugging Face Transformers

Example Usage

Here’s how to use the model with Hugging Face Transformers:

python
from transformers import pipeline

# Load the model
classifier = pipeline(
    "text-classification", 
    model="cirimus/modernbert-base-emotions",
    top_k=5
)

text = "I can't believe this just happened!"
predictions = classifier(text)

# Print top 3 detected emotions
sorted_preds = sorted(predictions[0], key=lambda x: x['score'], reverse=True)
top_3 = sorted_preds[:3]

print("\nTop 3 emotions detected:")
for pred in top_3:
    print(f"\t{pred['label']:10s} : {pred['score']:.3f}")

# Example output:
# Top 3 emotions detected:
#        SURPRISE   : 0.913
#        SADNESS    : 0.033
#        NEUTRAL    : 0.021

How the Model Was Created

The model was fine-tuned for 2 epochs using the following hyperparameters:

  • —Learning Rate: 2e-5
  • —Batch Size: 16
  • —Weight Decay: 0.01
  • —Warmup Steps: Cosine decay scheduling
  • —Optimizer: AdamW
  • —Evaluation Metrics: Precision, Recall, F1 Score (macro), Accuracy

Evaluation Results

As evaluated on the joint test-set:

AccuracyPrecisionRecallF1MCCSupport
macro avg0.8720.8270.8500.8360.84056310
NEUTRAL0.9650.7110.8420.7710.7553907
SURPRISE0.9760.6930.7720.7300.7192374
FEAR0.9750.8970.8410.8680.8555608
SADNESS0.9600.9100.9370.9230.89614547
JOY0.9410.9330.8720.9020.86117328
ANGER0.9640.9120.8180.8620.8437793
LOVE0.9620.7340.8670.7950.7784753

[image]


Intended Use

The model is designed for emotion classification in English-language text, particularly useful for:

  • —Social media sentiment analysis
  • —Customer feedback evaluation
  • —Large scale behavioral or psychological research

The model is designed for fast and accurate emotion detection but struggles with subtle expressions or indirect references to emotions (e.g., "I find myself remembering the little things you say, long after you've said them.")


Limitations and Biases

  • —Data Bias: The dataset is aggregated from multiple sources and may contain biases in annotation and class distribution.
  • —Underrepresented Classes: Some emotions have fewer samples, affecting their classification performance.
  • —Context Dependence: The model classifies individual sentences and may not perform well on multi-sentence contexts.

Environmental Impact

  • —Hardware Used: NVIDIA RTX 4090
  • —Training Time: < 1 hour
  • —Carbon Emissions: ~0.04 kg CO2 (estimated via ML CO2 Impact Calculator)

Citation

If you use this model, please cite:

bibtex
@inproceedings{JdFE2025b,
  title = {Emotion Detection with ModernBERT},
  author = {Enric Junqu\'e de Fortuny},
  year = {2025},
  howpublished = {\url{https://huggingface.co/your_model_name_here}},
}