Overview
This model was fine-tuned from UltraBERT-380M 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: UltraBERT-380M
- Fine-Tuning Dataset: GoEmotions
- Number of Labels: 28
- Problem Type: Multi-label classification
- Language: English
- License: Apache 2.0
- Fine-Tuning Framework: Hugging Face Transformers
Example Usage
Here’s how to use the model with Hugging Face Transformers:
# requires transformers>=5.2: pip install -U "transformers>=5.2"
from transformers import pipeline
import torch
# Load the model
classifier = pipeline(
"text-classification",
model="cirimus/ultrabert-380M-go-emotions",
top_k=5,
trust_remote_code=True
)
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.885
# joy : 0.753
# admiration : 0.015
# love : 0.015
# gratitude : 0.009
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 - 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.657 | 0.452 | 0.521 | 0.521 | 5427 | 0.5 |
| admiration | 0.946 | 0.718 | 0.696 | 0.707 | 0.678 | 504 | 0.5 |
| amusement | 0.983 | 0.812 | 0.852 | 0.832 | 0.823 | 264 | 0.5 |
| anger | 0.971 | 0.644 | 0.429 | 0.515 | 0.512 | 198 | 0.5 |
| annoyance | 0.941 | 0.494 | 0.269 | 0.348 | 0.336 | 320 | 0.5 |
| approval | 0.940 | 0.572 | 0.293 | 0.388 | 0.382 | 351 | 0.5 |
| caring | 0.978 | 0.581 | 0.370 | 0.452 | 0.453 | 135 | 0.5 |
| confusion | 0.973 | 0.545 | 0.353 | 0.429 | 0.426 | 153 | 0.5 |
| curiosity | 0.952 | 0.550 | 0.426 | 0.480 | 0.459 | 284 | 0.5 |
| desire | 0.989 | 0.735 | 0.434 | 0.545 | 0.560 | 83 | 0.5 |
| disappointment | 0.973 | 0.538 | 0.185 | 0.276 | 0.305 | 151 | 0.5 |
| disapproval | 0.953 | 0.540 | 0.303 | 0.388 | 0.383 | 267 | 0.5 |
| disgust | 0.982 | 0.653 | 0.398 | 0.495 | 0.502 | 123 | 0.5 |
| embarrassment | 0.995 | 0.737 | 0.378 | 0.500 | 0.526 | 37 | 0.5 |
| excitement | 0.982 | 0.552 | 0.359 | 0.435 | 0.437 | 103 | 0.5 |
| fear | 0.992 | 0.758 | 0.603 | 0.671 | 0.672 | 78 | 0.5 |
| gratitude | 0.990 | 0.952 | 0.898 | 0.924 | 0.919 | 352 | 0.5 |
| grief | 0.999 | 1.000 | 0.333 | 0.500 | 0.577 | 6 | 0.5 |
| joy | 0.980 | 0.706 | 0.553 | 0.620 | 0.615 | 161 | 0.5 |
| love | 0.983 | 0.795 | 0.815 | 0.805 | 0.796 | 238 | 0.5 |
| nervousness | 0.996 | 0.538 | 0.304 | 0.389 | 0.403 | 23 | 0.5 |
| optimism | 0.974 | 0.677 | 0.484 | 0.564 | 0.560 | 186 | 0.5 |
| pride | 0.998 | 0.875 | 0.438 | 0.583 | 0.618 | 16 | 0.5 |
| realization | 0.974 | 0.559 | 0.131 | 0.212 | 0.262 | 145 | 0.5 |
| relief | 0.998 | 0.250 | 0.091 | 0.133 | 0.150 | 11 | 0.5 |
| remorse | 0.992 | 0.585 | 0.679 | 0.628 | 0.626 | 56 | 0.5 |
| sadness | 0.978 | 0.664 | 0.494 | 0.566 | 0.562 | 156 | 0.5 |
| surprise | 0.980 | 0.670 | 0.447 | 0.536 | 0.538 | 141 | 0.5 |
| neutral | 0.788 | 0.696 | 0.632 | 0.662 | 0.509 | 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.596 | 0.554 | 0.568 | 0.553 | 5427 | various |
| admiration | 0.945 | 0.694 | 0.720 | 0.707 | 0.676 | 504 | 0.44 |
| amusement | 0.983 | 0.810 | 0.856 | 0.832 | 0.824 | 264 | 0.47 |
| anger | 0.969 | 0.592 | 0.520 | 0.554 | 0.539 | 198 | 0.36 |
| annoyance | 0.923 | 0.361 | 0.400 | 0.379 | 0.339 | 320 | 0.30 |
| approval | 0.926 | 0.430 | 0.422 | 0.426 | 0.387 | 351 | 0.31 |
| caring | 0.975 | 0.491 | 0.422 | 0.454 | 0.443 | 135 | 0.37 |
| confusion | 0.968 | 0.441 | 0.536 | 0.484 | 0.470 | 153 | 0.32 |
| curiosity | 0.950 | 0.524 | 0.574 | 0.548 | 0.522 | 284 | 0.41 |
| desire | 0.989 | 0.702 | 0.482 | 0.571 | 0.576 | 83 | 0.40 |
| disappointment | 0.967 | 0.387 | 0.305 | 0.341 | 0.327 | 151 | 0.29 |
| disapproval | 0.946 | 0.444 | 0.404 | 0.424 | 0.396 | 267 | 0.33 |
| disgust | 0.979 | 0.528 | 0.528 | 0.528 | 0.518 | 123 | 0.28 |
| embarrassment | 0.994 | 0.652 | 0.405 | 0.500 | 0.512 | 37 | 0.43 |
| excitement | 0.978 | 0.421 | 0.388 | 0.404 | 0.393 | 103 | 0.36 |
| fear | 0.992 | 0.705 | 0.705 | 0.705 | 0.701 | 78 | 0.33 |
| gratitude | 0.990 | 0.960 | 0.884 | 0.920 | 0.916 | 352 | 0.58 |
| grief | 1.000 | 1.000 | 0.833 | 0.909 | 0.913 | 6 | 0.23 |
| joy | 0.979 | 0.632 | 0.671 | 0.651 | 0.640 | 161 | 0.34 |
| love | 0.984 | 0.792 | 0.849 | 0.819 | 0.811 | 238 | 0.45 |
| nervousness | 0.996 | 0.471 | 0.348 | 0.400 | 0.402 | 23 | 0.31 |
| optimism | 0.973 | 0.613 | 0.570 | 0.591 | 0.577 | 186 | 0.32 |
| pride | 0.998 | 0.875 | 0.438 | 0.583 | 0.618 | 16 | 0.27 |
| realization | 0.966 | 0.315 | 0.234 | 0.269 | 0.255 | 145 | 0.21 |
| relief | 0.998 | 0.400 | 0.364 | 0.381 | 0.380 | 11 | 0.22 |
| remorse | 0.992 | 0.584 | 0.804 | 0.677 | 0.682 | 56 | 0.42 |
| sadness | 0.977 | 0.597 | 0.590 | 0.594 | 0.582 | 156 | 0.34 |
| surprise | 0.979 | 0.612 | 0.560 | 0.585 | 0.575 | 141 | 0.38 |
| neutral | 0.785 | 0.668 | 0.688 | 0.678 | 0.516 | 1787 | 0.43 |
Confusion matrix:
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 DGX Spark (GB10)
- Training Time: <1 hour
- Carbon Emissions: ~0.03 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}}
}