Instructions to use MahnoorIqbal/emotion-classification-distilbert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MahnoorIqbal/emotion-classification-distilbert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="MahnoorIqbal/emotion-classification-distilbert")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MahnoorIqbal/emotion-classification-distilbert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Emotion Classification with DistilBERT
Fine-tuned DistilBERT model for classifying text into 6 emotions: sadness, joy, love, anger, fear, and surprise.
Model Details
- Developed by: Mahnoor Iqbal
- Model type: Text Classification
- Language: English
- License: MIT
- Finetuned from: distilbert/distilbert-base-uncased
Uses
Direct Use
Classifying short English text into one of 6 emotion categories. Suitable for social media analysis, sentiment pipelines, or mental health monitoring tools.
Out-of-Scope Use
- Non-English text
- Long documents (truncated at 128 tokens)
- Detecting mixed or blended emotions (returns single label only)
How to Get Started
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="MahnoorIqbal/emotion-classification-distilbert"
)
classifier("I can't believe this actually worked!")
# [{'label': 'surprise', 'score': 0.91}]
Training Details
Training Data
praveengovi/emotions-dataset-for-nlp — 16,000 training samples across 6 emotion classes.
Class distribution is imbalanced (joy: 5,362 vs surprise: 572), handled via inverse-frequency class weights in the loss function.
Training Hyperparameters
- Base model: distilbert-base-uncased
- Epochs: 2
- Batch size: 32
- Learning rate: 2e-5
- Weight decay: 0.01
- Max token length: 128
- Precision: fp16
- Class weighting: Yes (inverse-frequency)
Evaluation
Results on Test Set (2000 samples)
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| sadness | 0.96 | 0.96 | 0.96 | 581 |
| joy | 0.95 | 0.94 | 0.94 | 695 |
| love | 0.80 | 0.86 | 0.83 | 159 |
| anger | 0.92 | 0.92 | 0.92 | 275 |
| fear | 0.87 | 0.90 | 0.89 | 224 |
| surprise | 0.78 | 0.68 | 0.73 | 66 |
- Accuracy: 0.92
- Macro F1: 0.88
- Weighted F1: 0.92
Limitations
- Surprise performs weakest (F1: 0.73) due to limited training samples (66 in test set)
- Joy and love are occasionally confused due to semantic overlap
- Fear and surprise are occasionally confused due to semantic overlap