google-research-datasets/go_emotions
Viewer • Updated • 265k • 20.1k • 285
Detects which of 27 emotions + neutral a short English text expresses. A text can have several emotions at once, so each label has its own sigmoid output and its own decision threshold.
FacebookAI/roberta-basesimplified, 43.4k Reddit comments)thresholds.json.| Metric | Value |
|---|---|
| Micro-F1 (per-emotion thresholds) | 0.603 |
| Macro-F1 (per-emotion thresholds) | 0.523 |
| Macro-F1 (single threshold 0.35) | 0.509 |
| Baseline TF-IDF + logistic regression (macro-F1) | 0.420 |
| Baseline always 'neutral' (macro-F1) | 0.018 |
import json, torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "jeffespejo/roberta-base-goemotions-udea"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo)
thresholds = json.load(open(hf_hub_download(repo, "thresholds.json")))
text = "Thank you so much for helping me with my thesis, you are amazing!"
with torch.no_grad():
probs = torch.sigmoid(model(**tok(text, return_tensors="pt")).logits)[0]
print({model.config.id2label[i]: round(p.item(), 2) for i, p in enumerate(probs)
if p >= thresholds[model.config.id2label[i]]})
Trained on Reddit comments in English; very rare emotions (grief, relief) are still hard to detect. Built as a university course project (Fundamentos de Procesamiento de Lenguaje Natural · Universidad de Antioquia) by Jefferson Espejo. Code: https://github.com/AndiEspejo/emotions-skills-detox-nlp
Base model
FacebookAI/roberta-base