Views
No views yet
| Label | Category |
|---|---|
| 0 | World |
| 1 | Sports |
| 2 | Business |
| 3 | Science/Technology |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3model_name = "rkmakd2258-wq/agnews-bert-4class"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSequenceClassification.from_pretrained(model_name)
6
7text = "Apple announced its latest earnings report."
8inputs = tokenizer(text, return_tensors="pt")
9outputs = model(**inputs)
10pred = outputs.logits.argmax(dim=1).item()
11
12labels = ["World", "Sports", "Business", "Science/Technology"]
13print("Prediction:", labels[pred])| Metric | Value |
|---|---|
| Accuracy | - |
| F1 Score | - |