File size: 3,273 Bytes
83d7821 |
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
---
language: en
tags:
- goemotions
- multi-label
- distilbert
- emotion-detection
- transformers
- text-classification
license: apache-2.0
datasets: go_emotions
library_name: transformers
pipeline_tag: text-classification
---
# π§ DistilBERT Emotion Classifier (GoEmotions, Multi-Label)
This model is a fine-tuned version of **[`distilbert-base-uncased`](https://huggingface.co/distilbert-base-uncased)** on the **[GoEmotions (Simplified)](https://huggingface.co/datasets/go_emotions)** dataset β a **multi-label emotion classification** task with 28 emotion categories.
It uses `sigmoid` + `BCEWithLogitsLoss` and supports **multiple simultaneous emotion predictions** per sentence.
---
## π·οΈ Labels
There are **28 possible emotions**, including:
> admiration, amusement, anger, annoyance, approval, caring, confusion, curiosity, desire, disappointment, disapproval, embarrassment, excitement, fear, gratitude, grief, joy, love, nervousness, optimism, pride, realization, relief, remorse, sadness, surprise, neutral
---
## π¦ Training Setup
- Base model: `distilbert-base-uncased`
- Dataset: `go_emotions` (simplified version with 28 labels)
- Task type: Multi-label classification
- Loss: `BCEWithLogitsLoss` (enabled via `problem_type="multi_label_classification"`)
- Epochs: 3
- Batch size: 16
- Learning rate: 2e-5
- Framework: `transformers` Trainer
---
## π Usage Example
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained("TuhinG/distilbert-goemotions")
tokenizer = AutoTokenizer.from_pretrained("TuhinG/distilbert-goemotions")
text = "I'm feeling excited and a little nervous about tomorrow."
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.sigmoid(logits)[0]
# Threshold and map to labels
emotions = [
"admiration", "amusement", "anger", "annoyance", "approval", "caring", "confusion", "curiosity",
"desire", "disappointment", "disapproval", "embarrassment", "excitement", "fear", "gratitude", "grief",
"joy", "love", "nervousness", "optimism", "pride", "realization", "relief", "remorse", "sadness",
"surprise", "neutral"
]
for i, prob in enumerate(probs):
if prob > 0.5:
print(f"{emotions[i]}: {prob:.2f}")
```
---
## π Evaluation Metric
During training, micro and macro **F1 scores** were used:
- `f1_micro`: high recall on rare labels
- `f1_macro`: balanced performance across labels
---
## β¨ Author
Fine-tuned and maintained by [TuhinG](https://huggingface.co/TuhinG)
---
## π‘οΈ License
Apache 2.0 β free to use, share, and modify.
```
---
## β
Next Steps
You can now:
1. Copy this to a file: `README.md`
2. Place it inside your model folder (`./distilbert_emotion_model`)
3. Push it to Hugging Face again:
```python
from huggingface_hub import upload_folder
upload_folder(
folder_path="./distilbert_emotion_model",
repo_id="TuhinG/distilbert-goemotions",
repo_type="model",
commit_message="Add model card README"
)
```
Let me know if you'd like me to generate the Python code for pushing this, or if you'd like to preview the model page before making it public. |