Downloads · 30 days
7
4% of all-time downloads
Sukuna404/distilbert-emotion-fp32
distilbert-emotion-fp32 is a text classification model from Sukuna404. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
Fine-tuned version of DistilBERT for 6-class emotion classification using the dair-ai/emotion dataset.
Downloads · 30 days
7
4% of all-time downloads
All-time downloads
159
Public
Parameters
118M
1.8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors471 MB · 97%
From the Hugging Face model README
Fine-tuned version of DistilBERT for 6-class emotion classification using the dair-ai/emotion dataset.
| Format | Accuracy | F1 Macro |
|---|---|---|
| FP32 | 92.50% | 0.8799 |
| INT8* | 91.95% | 0.8659 |
*INT8 is applied at runtime via quantize_dynamic — see usage below.
| ID | Emotion |
|---|---|
| 0 | sadness |
| 1 | joy |
| 2 | love |
| 3 | anger |
| 4 | fear |
| 5 | surprise |
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo_id = "Sukuna404/distilbert-emotion-fp32"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
# Optional: apply INT8 quantization at runtime for faster CPU inference
model = torch.quantization.quantize_dynamic(
model,
{torch.nn.Linear},
dtype=torch.qint8
)
model.eval()
model.cpu()
def predict(text: str) -> str:
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="longest")
with torch.no_grad():
outputs = model(**inputs)
pred_id = outputs.logits.argmax().item()
return model.config.id2label[pred_id]
print(predict("I am so happy today!")) # joy
print(predict("I am really angry!")) # anger