A fine-tuned DistilBERT model for
emotion classification of English text. The model classifies text into
6 emotion categories: sadness, joy, love, anger, fear, and surprise. It was fine-tuned on the
dair-ai/emotion dataset with random oversampling to handle class imbalance.
This model can be used directly for classifying the emotion expressed in a piece of English text. Suitable use cases include:
Users should be aware that the model's predictions are probabilistic and may not always be accurate, especially on edge cases or ambiguous text. Always validate model outputs before using them in production or sensitive contexts.
1from transformers import pipeline
2
3classifier = pipeline("text-classification", model="OmarMaqousi/distilbert-emotion-model")
4
5result = classifier("I am so happy today!")
6print(result)
7# [{'label': 'joy', 'score': 0.98}]
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4model = AutoModelForSequenceClassification.from_pretrained("OmarMaqousi/distilbert-emotion-model")
5tokenizer = AutoTokenizer.from_pretrained("OmarMaqousi/distilbert-emotion-model")
6
7text = "I feel really scared about the exam"
8inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
9
10with torch.no_grad():
11 outputs = model(**inputs)
12 predicted_class = torch.argmax(outputs.logits, dim=-1).item()
13
14labels = ["sadness", "joy", "love", "anger", "fear", "surprise"]
15print(f"Predicted emotion: {labels[predicted_class]}")
The model was fine-tuned on the
dair-ai/emotion dataset, which contains ~20,000 English text samples labeled with 6 emotions:
1@misc{maqousi2026distilbert-emotion,
2 author = {Omar Al Maqousi},
3 title = {DistilBERT Emotion Classification Model},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/OmarMaqousi/distilbert-emotion-model}
7}