Views
No views yet
ag_news)distilbert-base-uncasedag_news (quick test run for pipeline validation)mlops-assignment2)| Metric | Score |
|---|---|
| Accuracy | 0.87145 |
| F1 (weighted) | 0.86951 |
| Eval Loss | 0.46378 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "YOUR_USERNAME/distilbert-agnews-smoke"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8text = "Stock markets rose today after strong earnings reports."
9inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
10with torch.no_grad():
11 logits = model(**inputs).logits
12pred_id = int(torch.argmax(logits, dim=-1))
13print("Predicted class id:", pred_id)