Downloads · 30 days
34
16% of all-time downloads
Thi144/sentiment-distilbert-7class
sentiment-distilbert-7class is a text classification model from Thi144. 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 nuanced sentiment analysis with 7 sentiment classes on a scale from -3 (Very Negative) to +3 (Very Positive).
Downloads · 30 days
34
16% of all-time downloads
All-time downloads
215
Public
Parameters
67M
536 MB on disk
Likes
0
Public
Click a slice to open those files.
.pkl268 MB · 50%
From the Hugging Face model README
A fine-tuned DistilBERT model for nuanced sentiment analysis with 7 sentiment classes on a scale from -3 (Very Negative) to +3 (Very Positive).
This model performs fine-grained sentiment classification, providing more nuanced predictions than traditional binary positive/negative models. It's particularly useful for business applications where understanding the intensity of sentiment matters (e.g., identifying "at-risk" customers vs. extremely dissatisfied ones).
Architecture: DistilBERT (distilbert-base-uncased)
Parameters: 66 million
Training Data: 6,000 IMDB movie reviews
Accuracy: 73.7%
| Class | Scale | Label | Description |
|---|---|---|---|
| 0 | -3 | Very Negative | Extremely dissatisfied, angry |
| 1 | -2 | Negative | Clearly unhappy, disappointed |
| 2 | -1 | Slightly Negative | Somewhat disappointed |
| 3 | 0 | Neutral | Balanced, neither positive nor negative |
| 4 | +1 | Slightly Positive | Somewhat satisfied |
| 5 | +2 | Positive | Clearly satisfied, happy |
| 6 | +3 | Very Positive | Extremely satisfied, delighted |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_id = "Thi144/sentiment-distilbert-7class"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
# Class mapping
CLASS_LABELS = {
0: {"scale": -3, "label": "negative", "name": "Very Negative"},
1: {"scale": -2, "label": "negative", "name": "Negative"},
2: {"scale": -1, "label": "negative", "name": "Slightly Negative"},
3: {"scale": 0, "label": "neutral", "name": "Neutral"},
4: {"scale": 1, "label": "positive", "name": "Slightly Positive"},
5: {"scale": 2, "label": "positive", "name": "Positive"},
6: {"scale": 3, "label": "positive", "name": "Very Positive"}
}
# Predict sentiment
def predict_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
class_id = predictions.argmax().item()
confidence = predictions[0][class_id].item()
result = CLASS_LABELS[class_id]
return {
"class": class_id,
"scale": result["scale"],
"label": result["label"],
"name": result["name"],
"confidence": confidence
}
# Example
result = predict_sentiment("This movie was absolutely amazing!")
print(f"Sentiment: {result['name']} (Scale: {result['scale']}, Confidence: {result['confidence']:.2%})")
Overall Accuracy: 73.7%
Class-Specific Performance:
The model performs best at identifying strong sentiments (Very Negative/Positive) and struggles most with subtle distinctions (Slightly Negative/Positive).
Primary Use Cases:
Not Recommended For:
Apache 2.0
If you use this model, please cite:
@model{thi144-sentiment-distilbert-7class,
author = {Thi144},
title = {DistilBERT 7-Class Sentiment Analysis},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/Thi144/sentiment-distilbert-7class}
}