File size: 1,925 Bytes
65c0bdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3d4702
 
65c0bdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3d4702
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
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]}")