Text Classification
Transformers
English
emotion
distilbert

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
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support