mrm8488/goemotions
Viewer • Updated • 211k • 188 • 13
Run Mango-Juice/trpg_emotion_classification on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/Mango-Juice/trpg_emotion_classification. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/Mango-Juice/trpg_emotion_classification on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use Mango-Juice/trpg_emotion_classification with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Mango-Juice/trpg_emotion_classification") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Mango-Juice/trpg_emotion_classification")
model = AutoModelForSequenceClassification.from_pretrained("Mango-Juice/trpg_emotion_classification", device_map="auto")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)