google-research-datasets/go_emotions
Viewer • Updated • 265k • 10.5k • 267
How to use duelker/samo-goemotions-deberta-v3-large with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="duelker/samo-goemotions-deberta-v3-large") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("duelker/samo-goemotions-deberta-v3-large")
model = AutoModelForSequenceClassification.from_pretrained("duelker/samo-goemotions-deberta-v3-large", device_map="auto")A multi-label emotion classification model fine-tuned on the GoEmotions dataset using Microsoft's DeBERTa v3 Large architecture.
This model is based on microsoft/deberta-v3-large and fine-tuned for multi-label emotion classification on the GoEmotions dataset. It achieves 51.8% F1 Macro and 59.8% F1 Micro performance, significantly outperforming baseline models.
from transformers import pipeline
# Load the model
clf = pipeline(
"text-classification",
model="duelker/samo-goemotions-deberta-v3-large",
tokenizer="duelker/samo-goemotions-deberta-v3-large",
top_k=None, # Return all emotions with scores
truncation=True
)
# Example predictions
texts = [
"I am feeling really happy today!",
"I'm frustrated but hopeful about the future.",
"Thank you so much for your help!"
]
results = clf(texts)
print(results)
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("duelker/samo-goemotions-deberta-v3-large")
model = AutoModelForSequenceClassification.from_pretrained("duelker/samo-goemotions-deberta-v3-large")
# Emotion labels
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'
]
def predict_emotions(text, threshold=0.4):
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
probabilities = torch.sigmoid(logits).squeeze(0)
predictions = {}
for i, emotion in enumerate(emotion_labels):
predictions[emotion] = {
'probability': float(probabilities[i]),
'predicted': probabilities[i] > threshold
}
return predictions
# Example usage
text = "I'm so grateful for this opportunity!"
results = predict_emotions(text)
print(results)
If you use this model, please cite.
## License
This model is licensed under the Apache 2.0 License.
Base model
microsoft/deberta-v3-large