This model is a fine-tuned version of distilbert-base-uncased on the English split of the cardiffnlp/tweet_sentiment_multilingual benchmark.
It classifies text into three sentiment classes:
negative (Label 0)neutral (Label 1)positive (Label 2)pipeline (Recommended)from transformers import pipeline
# Load pipeline directly from Hugging Face Hub
classifier = pipeline(
"text-classification",
model="satishmachine/distillbert-sentiment-model"
)
# Single text inference
result = classifier("I absolutely love this product! Best purchase ever!")
print(result)
# Output: [{'label': 'positive', 'score': 0.98}]
# Batch prediction
texts = [
"The delivery arrived on time.",
"This was a complete waste of money.",
"Customer service resolved my issue within minutes!"
]
results = classifier(texts)
for text, res in zip(texts, results):
print(f"{text} -> {res['label']} ({res['score']:.2%})")
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_id = "satishmachine/distillbert-sentiment-model"
device = "cuda" if torch.cuda.is_available() else "cpu"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id).to(device)
text = "Not impressed. Expected much better quality."
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding=True,
max_length=128
).to(device)
model.eval()
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.softmax(outputs.logits, dim=-1)[0]
predicted_class_id = torch.argmax(probabilities).item()
id2label = model.config.id2label
print(f"Prediction: {id2label[predicted_class_id]} ({probabilities[predicted_class_id]:.2%})")
cardiffnlp/tweet_sentiment_multilingual (subset: english)| ID | Label | Description |
|---|---|---|
0 |
negative |
Unfavorable sentiment, dissatisfaction, complaints |
1 |
neutral |
Factual statements, objective announcements, neutral tone |
2 |
positive |
Favorable sentiment, praise, appreciation |
The model was fine-tuned using Hugging Face Trainer:
distilbert-base-uncased2e-5adamw_torch_fused / adamw_torch)321280.013epochf1_weightedEvaluated on the test split of tweet_sentiment_multilingual (English):
| Metric | Score |
|---|---|
| Accuracy | ~0.72 |
| F1 (Weighted) | ~0.72 |
| F1 (Macro) | ~0.70 |
| Precision | ~0.72 |
| Recall | ~0.72 |
(Note: Replace the approximate scores above with the exact values from your training output).
If you use this model or dataset, please cite the original benchmark:
@inproceedings{barbieri-etal-2022-xlm,
title = "{XLM}-{T}: Multilingual Language Models in {T}witter for Sentiment Analysis and Beyond",
author = "Barbieri, Francesco and Camacho-Collados, Jose and Espinosa Anke, Luis and Neves, Leonardo",
booktitle = "Proceedings of the Language Resources and Evaluation Conference",
year = "2022"
}
model.safetensors 268 MBtraining_args.bin 5.2 kBdistilbert/distilbert-base-uncased