fancyzhx/ag_news
Viewer • Updated • 128k • 123k • 190
How to use svenk029/mb-agn with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="svenk029/mb-agn") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("svenk029/mb-agn")
model = AutoModelForSequenceClassification.from_pretrained("svenk029/mb-agn")ModernBERT-base fine-tuned on AG News
A 4-way news-headline classifier (World, Sports, Business, Sci/Tech) built by extending theanswerdotai/ModernBERT-base encoder.
This model uses the ModernBERT-base transformer as its encoder and a fresh 4-class classification head.
Inputs are English news headlines (merged title + description) tokenized to a maximum of 128 tokens.
Outputs are class indices {0,1,2,3} with corresponding confidence scores.
Intended use:
Limitations:
label,title,description. title + description into a single text field. train_test_split. AutoTokenizer.from_pretrained("svenk029/mb-agn"), truncation/padding to 128 tokens.| Parameter | Value |
|---|---|
| Epochs | 3 |
| Train batch size | 16 |
| Eval batch size | 16 |
| Learning rate | 2 × 10⁻⁵ |
| Weight decay | 0.01 |
| Optimizer | AdamW (betas=(0.9,0.999), eps=1e-8) |
| LR scheduler | Linear |
| Seed | 42 |
| Evaluation strategy | Epoch |
| Save strategy | Epoch |
| Load best model at end | True (metric: accuracy) |
| Split | Accuracy | Precision | Recall | F1-Score |
|---|---|---|---|---|
| Validation | 0.9421 | 0.9430 | 0.9421 | 0.9421 |
| Test | 0.9432 | 0.9436 | 0.9432 | 0.9432 |
Per-class F1 on test: World 0.95, Sports 0.99, Business 0.91, Sci/Tech 0.92
Base model
answerdotai/ModernBERT-base