đ Fine-Tuned BERT on GoEmotions Dataset
This model is a fine - tuned version of BERT (bert - base - uncased
) on the GoEmotions dataset for multi - label emotion classification, capable of predicting multiple emotions per input text.
đ Quick Start
You can quickly start using this model through the following code example:
from transformers import pipeline
classifier = pipeline("text-classification", model="codewithdark/bert-Gomotions", top_k=None)
classifier("I'm so excited about the trip!")
⨠Features
- Multi - label Classification: This model can predict multiple emotions for each input text.
- Fine - tuned on GoEmotions: It is fine - tuned on the GoEmotions dataset, which is suitable for emotion classification tasks.
đĻ Installation
To use this model, you need to install the transformers
library:
pip install transformers torch
đģ Usage Examples
Basic Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "codewithdark/bert-Gomotions"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
emotion_labels = [
"Admiration", "Amusement", "Anger", "Annoyance", "Approval", "Caring", "Confusion",
"Curiosity", "Desire", "Disappointment", "Disapproval", "Disgust", "Embarrassment",
"Excitement", "Fear", "Gratitude", "Grief", "Joy", "Love", "Nervousness", "Optimism",
"Pride", "Realization", "Relief", "Remorse", "Sadness", "Surprise", "Neutral"
]
text = "I'm so happy today!"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.sigmoid(outputs.logits).squeeze(0)
top5_indices = torch.argsort(probs, descending=True)[:5]
top5_labels = [emotion_labels[i] for i in top5_indices]
top5_probs = [probs[i].item() for i in top5_indices]
print("Top 5 Predicted Emotions:")
for label, prob in zip(top5_labels, top5_probs):
print(f"{label}: {prob:.4f}")
'''
output:
Top 5 Predicted Emotions:
Joy: 0.9478
Love: 0.7854
Optimism: 0.6342
Admiration: 0.5678
Excitement: 0.5231
'''
đ Documentation
Model Overview
This model is a fine - tuned version of BERT (bert - base - uncased
) on the GoEmotions dataset for multi - label emotion classification. It can predict multiple emotions per input text.
Performance
Property |
Details |
Accuracy |
46.57% |
F1 Score |
56.41% |
Hamming Loss |
3.39% |
Training Details
- Model:
bert - base - uncased
- Dataset: GoEmotions
- Optimizer: AdamW
- Loss Function: BCEWithLogitsLoss (Binary Cross - Entropy for multi - label classification)
- Batch Size: 16
- Epochs: 3
- Evaluation Metrics: Accuracy, F1 Score, Hamming Loss
đ License
This model is licensed under the Apache 2.0 license.
đ ī¸ Citation
If you use this model, please cite:
@misc{your_model,
author = {codewithdark},
title = {Fine - tuned BERT on GoEmotions},
year = {2025},
url = {https://huggingface.co/codewithdark/bert-Gomotions}
}