File size: 1,107 Bytes
b491a03 c7568c3 b491a03 c7568c3 b491a03 c7568c3 b491a03 cf7a8c3 c7568c3 b491a03 c7568c3 | 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 56 57 58 | ---
library_name: transformers
license: apache-2.0
datasets:
- dair-ai/emotion
language:
- en
metrics:
- accuracy
base_model:
- google-bert/bert-base-uncased
pipeline_tag: text-classification
---
### Direct Use
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "SkyAsl/Bert-Emotion_classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "I am so happy to see you!"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits, dim=1).item()
id2label = {
0: "sadness", 1: "joy", 2: "love",
3: "anger", 4: "fear", 5: "surprise"
}
print("Predicted emotion:", id2label[predicted_class])
```
## Training Details
### Training Data
https://huggingface.co/datasets/dair-ai/emotion
#### Training Hyperparameters
lr = 2e-4
batch_size = 128
epochs = 5
weight_decay = 0.01
#### Metrics
training_loss: 0.106100
validation_loss: 0.143851
accuracy: 0.940000
|