Downloads · 30 days
47
16% of all-time downloads
Mango-Juice/trpg_emotion_classification
trpg_emotion_classification is a text classification model from Mango-Juice. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
This is a multi-label emotion classification model trained on the GoEmotions dataset and TRPG sentences.
Downloads · 30 days
47
16% of all-time downloads
All-time downloads
298
Public
Parameters
435M
1.7 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.7 GB · 100%
From the Hugging Face model README
This is a multi-label emotion classification model trained on the GoEmotions dataset and TRPG sentences.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Mango-Juice/trpg_emotion_classification")
model = AutoModelForSequenceClassification.from_pretrained("Mango-Juice/trpg_emotion_classification")
# Inference
def predict_emotions(text):
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.sigmoid(logits).cpu().numpy()[0]
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']
return {emotion: float(prob) for emotion, prob in zip(emotion_labels, probs)}
# Example
text = "I am so happy today!"
emotions = predict_emotions(text)
print(emotions)