Downloads · 30 days
16
23% of all-time downloads
ArmanXAI/bert-base-agnews-news-classifier
bert-base-agnews-news-classifier is a text classification model from ArmanXAI. Use it when you need a label for a piece of text. The card lists the license as mit.
Fine-tuned bert-base-uncased on AG News for 4-class news topic classification. 94.74% accuracy · 94.75 macro F1 — trained on RTX 4060 with fp16 in under an hour.
Downloads · 30 days
16
23% of all-time downloads
All-time downloads
71
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
Fine-tuned
bert-base-uncasedon AG News for 4-class news topic classification. 94.74% accuracy · 94.75 macro F1 — trained on RTX 4060 with fp16 in under an hour.
This model is a fine-tuned version of bert-base-uncased
on the AG News dataset, a benchmark corpus of
120,000 news headlines across four topic categories.
It classifies a short news headline or sentence into one of four classes:
| ID | Label |
|---|---|
| 0 | World |
| 1 | Sports |
| 2 | Business |
| 3 | Sci/Tech |
Built as part of the DevelopersHub AI/ML Engineering Internship (Advanced Track, 2026).
| Split | Size |
|---|---|
| Train | 120,000 |
| Test | 7,600 |
Classes are perfectly balanced (30,000 / 1,900 per class).
| Parameter | Value |
|---|---|
| Base model | bert-base-uncased |
| Learning rate | 2e-5 |
| Batch size | 16 |
| Epochs | 3 |
| Mixed precision | fp16 |
| Optimizer | AdamW |
| Warmup ratio | 0.1 |
| Max sequence len | 128 |
Trained on NVIDIA RTX 4060 Laptop GPU (8 GB VRAM) using HuggingFace Trainer.
| Metric | Value |
|---|---|
| Accuracy | 94.74% |
| Macro F1 | 0.9475 |
| Weighted F1 | 0.9474 |
| Class | F1 |
|---|---|
| World | 0.95 |
| Sports | 0.99 |
| Business | 0.92 |
| Sci/Tech | 0.93 |
| Model | Accuracy |
|---|---|
| TF-IDF + Logistic Reg. | ~91% |
| This model (BERT) | 94.74% |
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="ArmanXAI/bert-base-agnews-news-classifier"
)
result = classifier("NASA launches new telescope to study deep space phenomena.")
print(result)
# [{'label': 'Sci/Tech', 'score': 0.984}]
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "ArmanXAI/bert-base-agnews-news-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
labels = ["World", "Sports", "Business", "Sci/Tech"]
def classify(text: str) -> dict:
inputs = tokenizer(text, return_tensors="pt",
truncation=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
pred = torch.argmax(logits, dim=-1).item()
score = torch.softmax(logits, dim=-1)[0][pred].item()
return {"label": labels[pred], "score": round(score, 4)}
print(classify("Apple unveils M4 chip with major AI performance gains."))
# {'label': 'Sci/Tech', 'score': 0.9821}
See the training notebook in the notebooks/ folder of this repository,
or on GitHub:
DevelopersHub-AI-Internship-Advance-Tasks
Arman Adil Mangat — AI/ML Engineer, BS AI '26, UMT Lahore 🇵🇰
Specializing in Embedded AI + NLP. Building GENIE — a fully offline voice assistant on ESP32-S3 (Whisper + Mistral 7B, no cloud, $22 hardware).
@misc{mangat2026bertagNews,
author = {Arman Adil Mangat},
title = {BERT-base Fine-tuned on AG News for News Topic Classification},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/ArmanXAI/bert-base-agnews-news-classifier}
}
MIT — free to use, modify, and distribute with attribution.