stanfordnlp/imdb
Viewer • Updated • 100k • 171k • 1.28k
How to use Gillone06/distilbert-sentiment-its with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Gillone06/distilbert-sentiment-its") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Gillone06/distilbert-sentiment-its")
model = AutoModelForSequenceClassification.from_pretrained("Gillone06/distilbert-sentiment-its", device_map="auto")Classificatore di sentimento binario su recensioni di film (dataset IMDB), basato su distilbert-base-uncased.
NEGATIVE (id 0), POSITIVE (id 1)| Tag | Descrizione | Test accuracy |
|---|---|---|
v1 |
Fine-tuning iniziale: 1 epoca, 2000 train / 500 test (seed 42), lr 2e-5. Pubblicato in forma incompleta (config senza label mapping). | 82,8 % |
v2 |
Continuazione del training da v1 su dataset allargato: 8000 train / 2000 test (stesso seed 42), 3 epoche, lr 2e-5 con warmup 10 %, fp16 (GPU). Config completata (num_labels=2, id2label/label2id). |
86,45 % (test da 2000) / 85,4 % sul test v1 originale |
[[869, 131], [140, 860]] → errori totali 271/2000Il modello v2 riprende i pesi del checkpoint v1 e continua l'addestramento
(train_v2.py, tracking con MLflow nell'esperimento sentiment-analysis-lab):
data/v2 (seed 42, 8000 train / 2000 test)max_length=128, padding a lunghezza massimafrom transformers import pipeline
clf = pipeline("sentiment-analysis", model="Gillone06/distilbert-sentiment-its")
print(clf("This was an incredible movie! The acting was superb."))
# [{'label': 'POSITIVE', 'score': 0.98...}]
oppure direttamente con transformers:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tok = AutoTokenizer.from_pretrained("Gillone06/distilbert-sentiment-its")
model = AutoModelForSequenceClassification.from_pretrained("Gillone06/distilbert-sentiment-its")
inp = tok("A waste of time, flat characters.", return_tensors="pt", truncation=True)
probs = torch.softmax(model(**inp).logits, dim=-1)
print(probs.argmax(), probs.max()) # → NEGATIVE con score ~0.99
Nell'API FastAPI di accompagnamento (serve.py) il modello viene caricato dalla revisione
indicata dalla variabile d'ambiente MODEL_REVISION (es. v2, v1).