π Fast Emotion Classifier
High-performance emotion classification model achieving 87.1% accuracy on 7 Ekman emotions.
Built with DistilBERT and optimized for speed and accuracy, trained on 43K+ GoEmotions samples.
Model Details
- Base Model: DistilBERT (distilbert-base-uncased)
- Architecture: 6 transformer layers, 768 hidden dimensions
- Parameters: 66M (40% smaller than BERT)
- Training Data: 43,410 samples from GoEmotions β Ekman mapping
- Accuracy: 87.1% on balanced test set
- Speed: 60% faster than BERT
Emotion Categories
The model predicts 7 Ekman emotions:
| Label | Emotion | Accuracy | Examples |
|---|---|---|---|
| LABEL_0 | anger | 80% | "I am so furious about this situation" |
| LABEL_1 | disgust | 50% | "This is absolutely disgusting" |
| LABEL_2 | fear | 100% | "I'm terrified of what might happen" |
| LABEL_3 | joy | 100% | "I feel so happy and joyful today" |
| LABEL_4 | sadness | 100% | "This makes me feel so sad" |
| LABEL_5 | surprise | 80% | "What an unexpected turn of events" |
| LABEL_6 | neutral | 100% | "The meeting is scheduled for Tuesday" |
Quick Start
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
# Load model
model_name = "bijdolphin/fast-emotion-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Create pipeline
classifier = pipeline(
"text-classification",
model=model,
tokenizer=tokenizer,
return_all_scores=True
)
# Classify emotions
text = "I am so excited about this amazing news!"
result = classifier(text)
print(result)
Label Mapping
EMOTIONS = {
'LABEL_0': 'anger',
'LABEL_1': 'disgust',
'LABEL_2': 'fear',
'LABEL_3': 'joy',
'LABEL_4': 'sadness',
'LABEL_5': 'surprise',
'LABEL_6': 'neutral'
}
Training Details
Dataset
- Source: GoEmotions β Ekman emotion mapping
- Training samples: 43,410
- Text source: Reddit comments (real-world data)
- Preprocessing: Clean, curated emotional text
Training Configuration
- Epochs: 3
- Batch size: 64
- Learning rate: 3e-5 (with warmup)
- Hardware: H100 GPU
- Precision: BF16
- Training time: ~1-2 hours
Performance Metrics
Overall Accuracy: 87.14%
Weighted F1-Score: 86.55%
Macro F1-Score: 86.55%
Per-class Performance:
- Joy: 100% (Perfect)
- Fear: 100% (Perfect)
- Sadness: 100% (Perfect)
- Neutral: 100% (Perfect)
- Anger: 80% (Strong)
- Surprise: 80% (Strong)
- Disgust: 50% (Needs improvement)
Limitations
- Disgust Detection: Lower accuracy due to limited training data
- Context Dependency: Optimized for single sentences
- Domain: Best performance on social media text
- Mixed Emotions: May struggle with ambiguous emotional states
Usage Examples
Basic Classification
texts = [
"I love this so much!",
"This makes me really angry",
"I'm worried about tomorrow"
]
results = classifier(texts)
for text, result in zip(texts, results):
best = max(result, key=lambda x: x['score'])
emotion = best['label'].replace('LABEL_', '')
emotions = ['anger', 'disgust', 'fear', 'joy', 'sadness', 'surprise', 'neutral']
print(f"{text} β {emotions[int(emotion)]} ({best['score']:.2%})")
Batch Processing
import torch
def predict_emotions(texts, model, tokenizer):
inputs = tokenizer(texts, return_tensors='pt', truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
return probabilities.numpy()
Model Architecture
- Base: DistilBERT (distilbert-base-uncased)
- Layers: 6 (vs 12 in BERT)
- Hidden Size: 768
- Attention Heads: 12
- Parameters: ~66M
- Classification Head: Linear(768 β 7)
Training Curves
The model shows excellent training dynamics:
- Smooth loss convergence
- No overfitting
- Stable accuracy growth to 87.1%
- Optimal stopping at epoch 3
Citation
@misc{fast-emotion-classifier-2025,
title={Fast Emotion Classifier: High-Performance DistilBERT for Emotion Classification},
author={bijdolphin},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/bijdolphin/fast-emotion-classifier}
}
License
This model is licensed under the MIT License.
- Downloads last month
- 6
Dataset used to train Frankhihi/fast-emotion-classifier
Evaluation results
- Accuracy on GoEmotions (Ekman mapping)self-reported0.871
- F1 Score (weighted) on GoEmotions (Ekman mapping)self-reported0.865