cardiffnlp/tweet_sentiment_multilingual
Viewer • Updated • 48.5k • 1.58k • 24
How to use ZyroGod/distilbert-sentiment-classifier with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="ZyroGod/distilbert-sentiment-classifier") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("ZyroGod/distilbert-sentiment-classifier")
model = AutoModelForSequenceClassification.from_pretrained("ZyroGod/distilbert-sentiment-classifier", device_map="auto")Fine-tuned distilbert-base-uncased for 3-class sentiment classification (negative, neutral, positive) on the English subset of the cardiffnlp/tweet_sentiment_multilingual dataset.
Trained with hardware optimizations designed for a 4GB VRAM NVIDIA GeForce RTX 3050 Laptop GPU, including FP16 Tensor Core mixed precision and CUDA-fused AdamW (adamw_torch_fused).
| Metric | Score | Notes |
|---|---|---|
| Accuracy | 66.90% | +1.04% over 3-epoch baseline |
| Macro F1 | 66.51% | Balanced across all 3 classes |
| Weighted F1 | 66.51% | Metric used for checkpoint selection |
| Negative F1 / Recall | 72.98% / 82.41% | Robust detection of complaints & negative sentiment |
| Positive F1 / Precision | 73.70% / 79.60% | High precision when flagging positive sentiment |
| Neutral F1 / Recall | 52.84% / 49.66% | Weakest class; neutral is often confused with its neighbors |
| Severe Polarity Inversion | 3.56% | Low confusion between opposing sentiments (31/870 samples) |
distilbert-base-uncased (66.95M parameters)adamw_torch_fused (Weight Decay = 0.01)from transformers import pipeline
# Load pipeline directly from Hugging Face Hub
classifier = pipeline("sentiment-analysis", model="ZyroGod/distilbert-sentiment-classifier")
# Run inference
sample_text = "I absolutely love this product! Best purchase ever!"
prediction = classifier(sample_text)
print(prediction)
# Output: [{'label': 'positive', 'score': 0.7588}]
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = "ZyroGod/distilbert-sentiment-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
text = "Amazing customer service and quick resolution!"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)[0]
id2label = model.config.id2label
for idx, prob in enumerate(probs):
print(f"{id2label[idx]:<10s}: {prob.item():.2%}")
| Label ID | Sentiment Class |
|---|---|
0 |
negative |
1 |
neutral |
2 |
positive |
This model is open-sourced under the Apache 2.0 License.