Downloads · 30 days
3
7% of all-time downloads
fakhrulfaiz201/emotion-distilbert-7class
emotion-distilbert-7class is a text classification model from fakhrulfaiz201. Use it when you need a label for a piece of text. It is set up for transformers.
This is a fine-tuned Hugging Face transformers model for emotion classification. The model is based on DistilBERT and trained on a synthetic dataset containing 7 emotions.
Downloads · 30 days
3
7% of all-time downloads
All-time downloads
45
Public
Parameters
67M
268 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
This is a fine-tuned Hugging Face transformers model for emotion classification. The model is based on DistilBERT and trained on a synthetic dataset containing 7 emotions.
This model can be used for classifying text into one of seven emotions: Love, Sad, Anger, Fun, Hate, Surprise, Happiness.
The model was trained on a synthetic dataset. Its performance on real-world, nuanced, or informal text might vary. It should not be used for critical applications without further validation.
The model's performance is limited by the synthetic nature of its training data. It might not generalize well to diverse linguistic styles, cultural contexts, or sarcasm/irony.
Users should test the model thoroughly on their specific use cases and consider fine-tuning on more diverse and real-world datasets if necessary.
Use the code below to get started with the model.
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model_name = "fakhrulfaiz201/emotion-distilbert-7class"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
id2label = {
0: 'Love', 1: 'Sad', 2: 'Anger', 3: 'Fun',
4: 'Hate', 5: 'Surprise', 6: 'Happiness'
}
def predict(text):
device = next(model.parameters()).device
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predicted_class_id = logits.argmax().item()
return id2label[predicted_class_id]
print(predict("I feel amazing today!"))
The model was trained on the "synthetic_emotions.csv" dataset (available on Kaggle as prashanthan24/synthetic-emotions-dataset-14k-texts-7-emotions). This dataset contains 13,970 text samples labeled with one of seven emotions: Love, Sad, Anger, Fun, Hate, Surprise, Happiness. The dataset was split into training (60%), validation (20%), and test (20%) sets.
The text data was tokenized using DistilBertTokenizer. Input sequences were truncated and padded to a maximum length of 128 tokens.
The model was evaluated on a held-out test set (20% of the original dataset) from the "synthetic_emotions.csv" dataset.
The evaluation metrics used were accuracy and macro F1-score.
The model achieved the following performance on the test set: