GoEmotions RoBERTa-large Focal Loss Classifier
This model is a RoBERTa-large multi-label emotion classifier trained on the
public GoEmotions simplified split. It predicts 27 fine-grained emotions plus
neutral from English Reddit-style text.
The run uses focal loss for label imbalance and validation-tuned coordinate
thresholds for multi-label decisions. It is a competitive public-reference
result: the validation-selected policy reached test macro-F1 0.5330, while the
strongest public model card found during this iteration reported test macro-F1
0.519. This is not presented as formal SOTA because there is no official
GoEmotions leaderboard comparison here.
Links
Maintainer
- GitHub:
Kevin-Li-2025
- Kaggle:
kevin250304
- Hugging Face:
AliceYin
Results
| Split | Macro-F1 | Micro-F1 | Samples-F1 | Subset accuracy |
|---|
| Validation | 0.5659 | 0.5966 | 0.6051 | 0.4784 |
| Test | 0.5330 | 0.5767 | 0.5859 | 0.4695 |
Threshold selection on validation:
| Threshold policy | Validation macro-F1 | Validation micro-F1 | Validation samples-F1 |
|---|
| Fixed 0.5 | 0.5147 | 0.6021 | 0.6086 |
| Global validation-tuned threshold | 0.5383 | 0.5676 | 0.5783 |
| Per-label thresholds | 0.5634 | 0.5925 | 0.6007 |
| Coordinate thresholds | 0.5659 | 0.5966 | 0.6051 |
Additional threshold candidates on test:
| Threshold policy | Test macro-F1 |
|---|
| Fixed 0.5 | 0.5184 |
| Global threshold | 0.5320 |
| Validation coordinate search | 0.5330 |
| Per-label thresholds | 0.5350 |
The headline result uses the validation-selected coordinate threshold policy to
avoid test-set overfitting. The per-label threshold candidate reached the
highest test macro-F1, but it was not selected by validation macro-F1 and is
therefore not the headline policy. The exported thresholds.json stores all
threshold policies plus selected: "coordinate".
Intended Use
Use this model for research, benchmarking, exploratory emotion analysis, and
building GoEmotions-compatible classifiers. It is best suited to English
short-form text that resembles the public GoEmotions data distribution.
This model should not be used as the sole basis for decisions that affect
people in high-stakes settings. Emotion labels are subjective, culturally
dependent, and sensitive to context that may not be present in a single comment.
Quick Start
1import json
2import torch
3from huggingface_hub import hf_hub_download
4from transformers import AutoModelForSequenceClassification, AutoTokenizer
5
6HF_MODEL_ID = "AliceYin/goemotions-roberta-large-focal-sota"
7KAGGLE_MODEL_URL = (
8 "https://www.kaggle.com/models/kevin250304/"
9 "goemotions-roberta-large-focal-sota/Transformers/roberta-large-focal-seed42"
10)
11
12tokenizer = AutoTokenizer.from_pretrained(HF_MODEL_ID)
13model = AutoModelForSequenceClassification.from_pretrained(HF_MODEL_ID)
14
15with open(hf_hub_download(HF_MODEL_ID, "thresholds.json"), encoding="utf-8") as f:
16 threshold_data = json.load(f)
17with open(hf_hub_download(HF_MODEL_ID, "labels.json"), encoding="utf-8") as f:
18 labels = json.load(f)["label_names"]
19
20selected_policy = threshold_data["selected"]
21selected_thresholds = threshold_data[selected_policy]
22threshold_map = (
23 selected_thresholds["per_label"]
24 if selected_policy == "global"
25 else selected_thresholds
26)
27thresholds = [threshold_map[label] for label in labels]
28
29text = "I finally got this working and I am so relieved."
30inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=160)
31
32with torch.no_grad():
33 probs = torch.sigmoid(model(**inputs).logits)[0]
34
35predicted = [
36 {"label": label, "score": float(prob)}
37 for label, prob, threshold in zip(labels, probs, thresholds)
38 if prob >= threshold
39]
40print(predicted)
Training Details
- Base model:
FacebookAI/roberta-large
- Dataset:
google-research-datasets/go_emotions, simplified configuration
- Loss: focal loss, alpha 0.38, gamma 2.8
- Epochs: 4
- Learning rate: 1e-5
- Batch size: 2 with gradient accumulation 16
- Mixed precision: disabled for stability
- Threshold selection: validation macro-F1 coordinate search
- Seed: 42
Citation
1@inproceedings{demszky-etal-2020-goemotions,
2 title = "{G}o{E}motions: A Dataset of Fine-Grained Emotions",
3 author = "Demszky, Dorottya and Movshovitz-Attias, Dana and Ko, Jeongwoo and Cowen, Alan and Nemade, Gaurav and Ravi, Sujith",
4 booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
5 year = "2020",
6 doi = "10.18653/v1/2020.acl-main.372",
7 pages = "4040--4054"
8}
Reproducibility
The Kaggle artifact includes metrics.json, thresholds.json, labels.json,
the tokenizer, the model weights, and the Kaggle run log. The training script
and experiment notes record the exact settings used for the reported metrics.