|
--- |
|
license: apache-2.0 |
|
tags: |
|
- goemotions |
|
- emotion-detection |
|
- text-classification |
|
- bert |
|
--- |
|
|
|
# Fine-tuned GoEmotions Model |
|
|
|
This repository contains a BERT-based model fine-tuned on the **GoEmotions** dataset to classify text into one of 28 emotions. |
|
|
|
## Model Details |
|
- **Base Model**: BERT |
|
- **Dataset**: GoEmotions (Google's dataset with 28 emotions + neutral) |
|
- **Task**: Multi-class emotion detection |
|
- **Fine-tuned by**: nayeemsam |
|
|
|
## Supported Emotions |
|
The model predicts the following emotions: |
|
- 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 |
|
|
|
## How to Use |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
# Load model and tokenizer |
|
model = AutoModelForSequenceClassification.from_pretrained("nayeems94/text-emotion-classifier") |
|
tokenizer = AutoTokenizer.from_pretrained("nayeems94/text-emotion-classifier") |
|
|
|
# Example text |
|
text = "I am feeling so frustrated and angry!" |
|
|
|
# Tokenize |
|
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=128) |
|
|
|
# Predict |
|
outputs = model(**inputs) |
|
logits = outputs.logits |
|
predicted_class_id = logits.argmax(dim=-1).item() |
|
|
|
# Emotion labels |
|
id2label = { |
|
0: 'admiration', 1: 'amusement', 2: 'anger', 3: 'annoyance', 4: 'approval', 5: 'caring', |
|
6: 'confusion', 7: 'curiosity', 8: 'desire', 9: 'disappointment', 10: 'disapproval', |
|
11: 'disgust', 12: 'embarrassment', 13: 'excitement', 14: 'fear', 15: 'gratitude', |
|
16: 'grief', 17: 'joy', 18: 'love', 19: 'nervousness', 20: 'optimism', 21: 'pride', |
|
22: 'realization', 23: 'relief', 24: 'remorse', 25: 'sadness', 26: 'surprise', 27: 'neutral' |
|
} |
|
|
|
print(f"Predicted emotion: {id2label[predicted_class_id]}") |
|
|
|
|