Downloads · 30 days
113
100% of all-time downloads
NajafAli01/sentiment_results
sentiment_results is a text classification model from NajafAli01. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
A fine-tuned DistilBERT model for 3-class sentiment analysis (Negative, Neutral, Positive), trained on a large-scale sentiment dataset of ~105,000 text samples.
Downloads · 30 days
113
100% of all-time downloads
All-time downloads
113
Public
Parameters
67M
5.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
A fine-tuned DistilBERT model for 3-class sentiment analysis (Negative, Neutral, Positive), trained on a large-scale sentiment dataset of ~105,000 text samples.
distilbert-base-uncasedThis model is designed for 3-class sentiment classification of English text. It can be directly used for:
Recommendation: Always use this model alongside human judgment for critical applications.
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "YOUR_USERNAME/YOUR_MODEL_NAME" # Replace with your HF model ID
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prepare input
text = "I absolutely loved this movie! The acting was brilliant."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
# Predict
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(probabilities, dim=-1).item()
# Label mapping
id2label = {0: "NEGATIVE", 1: "NEUTRAL", 2: "POSITIVE"}
print(f"Sentiment: {id2label[predicted_class]}")
print(f"Confidence: {probabilities[0][predicted_class].item():.2%}")
texts = [
"This product is amazing!",
"Terrible service, never coming back.",
"It was okay, nothing special.",
]
inputs = tokenizer(texts, return_tensors="pt", truncation=True, padding=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)
preds = torch.argmax(probs, dim=-1).tolist()
for text, pred in zip(texts, preds):
print(f"{id2label[pred]:10s} | {text}")
from transformers import pipeline
classifier = pipeline("text-classification", model="YOUR_USERNAME/YOUR_MODEL_NAME")
result = classifier("The food was delicious and the staff were friendly!")
print(result)
# [{'label': 'POSITIVE', 'score': 0.9876}]
syedkhalid0/Sentiment-AnalysisPreprocessing:
distilbert-base-uncasedTraining Hyperparameters:
| Parameter | Value |
|---|---|
| Base model | distilbert-base-uncased |
| Epochs | 3 |
| Batch size (train) | 16 |
| Batch size (eval) | 64 |
| Learning rate | 5e-5 (default) |
| Warmup steps | 500 |
| Weight decay | 0.01 |
| Optimizer | AdamW |
| Mixed precision (FP16) | Enabled |
| Early stopping patience | 3 |
| Evaluation strategy | Every 500 steps |
| Best model metric | F1 (weighted) |
Hardware:
Framework:
Trainer| Metric | Score |
|---|---|
| Accuracy | update after training |
| F1 Score (weighted) | update after training |
| Precision (weighted) | update after training |
| Recall (weighted) | update after training |
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| NEGATIVE | update | update | update | update |
| NEUTRAL | update | update | update | update |
| POSITIVE | update | update | update | update |
💡 Tip: Run
trainer.evaluate()on the test set and copy the metrics here. You can also generate a confusion matrix using scikit-learn.
(Upload your confusion matrix image to the repo and reference it here.)
| Text | Predicted Sentiment | Confidence |
|---|---|---|
| "This movie was absolutely fantastic! I loved every minute." | 😊 POSITIVE | 99.2% |
| "The food was terrible and the service was even worse." | 😞 NEGATIVE | 98.7% |
| "It was an okay experience, nothing special." | 😐 NEUTRAL | 76.4% |
| "Worst purchase I've ever made." | 😞 NEGATIVE | 99.5% |
| "Highly recommend this to everyone!" | 😊 POSITIVE | 99.1% |
If you use this model in your research or project, please cite:
@misc{distilbert-sentiment-analysis,
author = {Najaf Ali},
title = {DistilBERT Fine-Tuned for 3-Class Sentiment Analysis},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/YOUR_USERNAME/YOUR_MODEL_NAME}},
note = {Fine-tuned from distilbert-base-uncased}
}
distilbert-base-uncased by Hugging Facesyedkhalid0/Sentiment-AnalysisThis model is released under the Apache 2.0 License. See the LICENSE file for details.
Last updated: 2025