💡 It is part of the collection Frontier BERT Workhorses.
Overview
This model was fine-tuned from ModernBERT-large on the GoEmotions dataset for multi-label classification. It predicts emotional states in text, with a total of 28 possible labels. Each input text can have one or more associated labels, reflecting the multi-label nature of the task.
Model Details
- Base Model: ModernBERT-large
- Fine-Tuning Dataset: GoEmotions
- Number of Labels: 28
- Problem Type: Multi-label classification
- Language: English
- License: MIT
- Fine-Tuning Framework: Hugging Face Transformers
Example Usage
Here’s how to use the model with Hugging Face Transformers:
from transformers import pipeline
import torch
# Load the model
classifier = pipeline(
"text-classification",
model="cirimus/modernbert-large-go-emotions",
top_k=5
)
text = "I am so happy and excited about this opportunity!"
predictions = classifier(text)
# Print top 5 detected emotions
sorted_preds = sorted(predictions[0], key=lambda x: x['score'], reverse=True)
top_5 = sorted_preds[:5]
print("\nTop 5 emotions detected:")
for pred in top_5:
print(f"\t{pred['label']:10s} : {pred['score']:.3f}")
# Example output:
# Top 5 emotions detected:
# excitement : 0.915
# joy : 0.771
# admiration : 0.021
# gratitude : 0.015
# surprise : 0.006
How the Model Was Created
The model was fine-tuned for 3 epochs using the following hyperparameters:
- Learning Rate:
2e-5 - Batch Size: 16
- Weight Decay:
0.01 - Optimizer: AdamW
- Evaluation Metrics: Precision, Recall, F1 Score (weighted), Accuracy
Dataset
The GoEmotions dataset is a multi-label emotion classification dataset derived from Reddit comments. It contains 58,000 examples with 28 emotion labels (e.g., admiration, amusement, anger, etc.), and it is annotated for multi-label classification.
Evaluation Results
The model was evaluated on the test split of the GoEmotions dataset, using a threshold of 0.5 for binarizing predictions. The overall metrics were:
Standard Results:
Using the default threshold of 0.5.
| Label | Accuracy | Precision | Recall | F1 | MCC | Support | Threshold |
|---|---|---|---|---|---|---|---|
| macro avg | 0.971 | 0.648 | 0.420 | 0.490 | 0.495 | 5427 | 0.5 |
| admiration | 0.946 | 0.713 | 0.708 | 0.710 | 0.681 | 504 | 0.5 |
| amusement | 0.982 | 0.813 | 0.822 | 0.817 | 0.808 | 264 | 0.5 |
| anger | 0.968 | 0.598 | 0.399 | 0.479 | 0.473 | 198 | 0.5 |
| annoyance | 0.939 | 0.461 | 0.203 | 0.282 | 0.279 | 320 | 0.5 |
| approval | 0.940 | 0.572 | 0.259 | 0.357 | 0.359 | 351 | 0.5 |
| caring | 0.977 | 0.583 | 0.311 | 0.406 | 0.416 | 135 | 0.5 |
| confusion | 0.974 | 0.583 | 0.320 | 0.414 | 0.421 | 153 | 0.5 |
| curiosity | 0.956 | 0.606 | 0.454 | 0.519 | 0.502 | 284 | 0.5 |
| desire | 0.988 | 0.674 | 0.373 | 0.481 | 0.496 | 83 | 0.5 |
| disappointment | 0.973 | 0.579 | 0.146 | 0.233 | 0.281 | 151 | 0.5 |
| disapproval | 0.953 | 0.543 | 0.258 | 0.350 | 0.354 | 267 | 0.5 |
| disgust | 0.982 | 0.694 | 0.350 | 0.465 | 0.485 | 123 | 0.5 |
| embarrassment | 0.994 | 0.706 | 0.324 | 0.444 | 0.476 | 37 | 0.5 |
| excitement | 0.982 | 0.525 | 0.301 | 0.383 | 0.389 | 103 | 0.5 |
| fear | 0.992 | 0.790 | 0.628 | 0.700 | 0.701 | 78 | 0.5 |
| gratitude | 0.990 | 0.952 | 0.898 | 0.924 | 0.919 | 352 | 0.5 |
| grief | 0.999 | 1.000 | 0.167 | 0.286 | 0.408 | 6 | 0.5 |
| joy | 0.981 | 0.740 | 0.565 | 0.641 | 0.637 | 161 | 0.5 |
| love | 0.983 | 0.809 | 0.803 | 0.806 | 0.797 | 238 | 0.5 |
| nervousness | 0.996 | 0.500 | 0.261 | 0.343 | 0.359 | 23 | 0.5 |
| optimism | 0.974 | 0.662 | 0.473 | 0.552 | 0.547 | 186 | 0.5 |
| pride | 0.998 | 0.750 | 0.375 | 0.500 | 0.529 | 16 | 0.5 |
| realization | 0.974 | 0.528 | 0.131 | 0.210 | 0.254 | 145 | 0.5 |
| relief | 0.998 | 0.000 | 0.000 | 0.000 | -0.001 | 11 | 0.5 |
| remorse | 0.992 | 0.591 | 0.696 | 0.639 | 0.637 | 56 | 0.5 |
| sadness | 0.981 | 0.752 | 0.487 | 0.591 | 0.596 | 156 | 0.5 |
| surprise | 0.980 | 0.706 | 0.426 | 0.531 | 0.539 | 141 | 0.5 |
| neutral | 0.795 | 0.712 | 0.635 | 0.671 | 0.525 | 1787 | 0.5 |
Optimal Results:
Using the best threshold for each label based on the training set (tuned on F1), tested on the test set:
| Label | Accuracy | Precision | Recall | F1 | MCC | Support | Threshold |
|---|---|---|---|---|---|---|---|
| macro avg | 0.968 | 0.567 | 0.533 | 0.543 | 0.528 | 5427 | various |
| admiration | 0.947 | 0.708 | 0.722 | 0.715 | 0.686 | 504 | 0.47 |
| amusement | 0.982 | 0.796 | 0.845 | 0.820 | 0.811 | 264 | 0.46 |
| anger | 0.967 | 0.547 | 0.495 | 0.520 | 0.503 | 198 | 0.38 |
| annoyance | 0.925 | 0.383 | 0.434 | 0.407 | 0.368 | 320 | 0.30 |
| approval | 0.927 | 0.433 | 0.436 | 0.435 | 0.395 | 351 | 0.27 |
| caring | 0.975 | 0.486 | 0.393 | 0.434 | 0.424 | 135 | 0.33 |
| confusion | 0.966 | 0.418 | 0.536 | 0.470 | 0.456 | 153 | 0.26 |
| curiosity | 0.947 | 0.499 | 0.606 | 0.547 | 0.522 | 284 | 0.37 |
| desire | 0.988 | 0.673 | 0.446 | 0.536 | 0.542 | 83 | 0.36 |
| disappointment | 0.967 | 0.386 | 0.338 | 0.360 | 0.344 | 151 | 0.27 |
| disapproval | 0.944 | 0.436 | 0.446 | 0.441 | 0.411 | 267 | 0.28 |
| disgust | 0.978 | 0.517 | 0.504 | 0.510 | 0.499 | 123 | 0.24 |
| embarrassment | 0.994 | 0.650 | 0.351 | 0.456 | 0.475 | 37 | 0.46 |
| excitement | 0.981 | 0.494 | 0.388 | 0.435 | 0.428 | 103 | 0.36 |
| fear | 0.992 | 0.736 | 0.679 | 0.707 | 0.703 | 78 | 0.39 |
| gratitude | 0.990 | 0.946 | 0.903 | 0.924 | 0.920 | 352 | 0.43 |
| grief | 0.999 | 0.333 | 0.333 | 0.333 | 0.333 | 6 | 0.16 |
| joy | 0.980 | 0.676 | 0.621 | 0.647 | 0.638 | 161 | 0.39 |
| love | 0.983 | 0.787 | 0.836 | 0.811 | 0.802 | 238 | 0.42 |
| nervousness | 0.996 | 0.500 | 0.348 | 0.410 | 0.415 | 23 | 0.35 |
| optimism | 0.972 | 0.591 | 0.559 | 0.575 | 0.560 | 186 | 0.29 |
| pride | 0.998 | 0.667 | 0.375 | 0.480 | 0.499 | 16 | 0.11 |
| realization | 0.962 | 0.283 | 0.269 | 0.276 | 0.256 | 145 | 0.17 |
| relief | 0.998 | 0.417 | 0.455 | 0.435 | 0.434 | 11 | 0.12 |
| remorse | 0.992 | 0.582 | 0.821 | 0.681 | 0.688 | 56 | 0.36 |
| sadness | 0.977 | 0.608 | 0.577 | 0.592 | 0.581 | 156 | 0.33 |
| surprise | 0.980 | 0.640 | 0.504 | 0.563 | 0.557 | 141 | 0.39 |
| neutral | 0.790 | 0.678 | 0.691 | 0.684 | 0.527 | 1787 | 0.44 |
Intended Use
The model is designed for emotion classification in English-language text, particularly in domains such as:
- Social media sentiment analysis
- Customer feedback evaluation
- Behavioral or psychological research
Limitations and Biases
- Data Bias: The dataset is based on Reddit comments, which may not generalize well to other domains or cultural contexts.
- Underrepresented Classes: Certain labels like "grief" and "relief" have very few examples, leading to lower performance for those classes.
- Ambiguity: Some training data contain annotation inconsistencies or ambiguities that may impact predictions.
Environmental Impact
- Hardware Used: NVIDIA RTX4090
- Training Time: <1 hour
- Carbon Emissions: ~0.06 kg CO2 (calculated via ML CO2 Impact Calculator).
Citation
If you use this model, please cite it as follows:
@misc{junque2025emotion,
title = {Emotion and Bias Classification with Modern Encoders},
author = {Junqu\'e de Fortuny, Enric},
year = {2025},
howpublished = {\url{https://huggingface.co/spaces/cirimus/emotion-detection}}
}