dair-ai/emotion
Viewer • Updated • 437k • 33.7k • 443
How to use gabe-zhang/twitter-emotion-bert with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="gabe-zhang/twitter-emotion-bert") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("gabe-zhang/twitter-emotion-bert")
model = AutoModelForSequenceClassification.from_pretrained("gabe-zhang/twitter-emotion-bert")A fine-tuned bert-base-cased model for classifying emotions in text
into six categories: sadness, joy, love, anger, fear, and surprise.
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="gabe-zhang/twitter-emotion-bert",
)
classifier("I am so happy today!")
# [{'label': 'joy', 'score': 0.95}]
classifier("This makes me really angry")
# [{'label': 'anger', 'score': 0.89}]
| ID | Emotion |
|---|---|
| 0 | sadness |
| 1 | joy |
| 2 | love |
| 3 | anger |
| 4 | fear |
| 5 | surprise |
Overall: Accuracy 0.9385 | Weighted F1 0.9399
| Emotion | Precision | Recall | F1-Score |
|---|---|---|---|
| Sadness | 0.94 | 0.93 | 0.93 |
| Joy | 0.95 | 0.96 | 0.95 |
| Love | 0.86 | 0.89 | 0.87 |
| Anger | 0.93 | 0.90 | 0.91 |
| Fear | 0.91 | 0.89 | 0.90 |
| Surprise | 0.85 | 0.82 | 0.83 |
bert-base-casedFull training code, notebooks, and baseline comparisons: github.com/gabe-zhang/twitter-emotion-classification