Downloads · 30 days
3
9% of all-time downloads
JUSTIAM/distilbert-base-uncased-sst2-sentiment-kd
distilbert-base-uncased-sst2-sentiment-kd is a machine learning model from JUSTIAM. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This model is a DistilBERT-base-uncased model fine-tuned on the SST-2 (Stanford Sentiment Treebank) dataset using knowledge distillation from a BERT-base teacher (textattack/bert-base-uncased-SST-2).
Downloads · 30 days
3
9% of all-time downloads
All-time downloads
33
Public
Parameters
67M
268 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
This model is a DistilBERT-base-uncased model fine-tuned on the SST-2 (Stanford Sentiment Treebank) dataset using knowledge distillation from a BERT-base teacher (textattack/bert-base-uncased-SST-2).
It achieves 90.83% validation accuracy — just 1.61% below the teacher — while being 1.6× smaller and nearly 2× faster at inference time.
distilbert-base-uncasedtextattack/bert-base-uncased-SST-242)This model is intended for binary sentiment classification of English sentences (e.g., movie reviews). It outputs two classes:
0: Negative sentiment1: Positive sentiment| Model | SST-2 Val Accuracy | Parameters | Speed (samples/sec) |
|---|---|---|---|
| Teacher (BERT-base) | 92.43% | 109.5M | ~1,980 |
| This model (DistilBERT) | 90.83% | 67.0M | ~3,915 |
| Fresh (untrained) DistilBERT | 54.47% | 67.0M | 3,915 |
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="JUSTIAM/distilbert-base-uncased-sst2-sentiment-kd",
tokenizer="JUSTIAM/distilbert-base-uncased-sst2-sentiment-kd"
)
result = classifier("This movie is absolutely fantastic!")
print(result)
# Output: [{'label': 'POSITIVE', 'score': 0.998}]
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "JUSTIAM/distilbert-base-uncased-sst2-sentiment-kd"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "I really hate this boring film."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
probabilities = torch.softmax(logits, dim=-1)
predicted_class = torch.argmax(probabilities, dim=-1).item()
sentiment = "POSITIVE" if predicted_class == 1 else "NEGATIVE"
confidence = probabilities[0][predicted_class].item()
print(f"Sentiment: {sentiment}, Confidence: {confidence:.3f}")
Evaluated on the official SST-2 validation set. No test set used.