The model was trained on the
dair-ai/emotion dataset with a
stratified 80/10/10 split to ensure balanced class representation across train, validation, and test sets.
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="OmarMaqousi/distilbert-emotion-model-v2",
6 return_all_scores=True,
7)
8
9result = classifier("I am so happy today!")
10print(result)
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "OmarMaqousi/distilbert-emotion-model-v2"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8text = "I am so happy today!"
9inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
10
11with torch.no_grad():
12 outputs = model(**inputs)
13 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
14
15labels = ["sadness", "joy", "love", "anger", "fear", "surprise"]
16for label, score in zip(labels, predictions[0]):
17 print(f"{label}: {score:.4f}")