Downloads · 30 days
9
19% of all-time downloads
chiunhau/news-classifier-2
news-classifier-2 is a text classification model from chiunhau. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
Fine-tuned bert-base-uncased for multi-label news topic classification using Asymmetric Loss (ASL, ICCV 2021). ASL suppresses easy-negative gradients (γ⁻=4, γ⁺=1, margin=0.15), which helps on the long tail of rare top…
Downloads · 30 days
9
19% of all-time downloads
All-time downloads
48
Public
Parameters
110M
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-uncased for
multi-label news topic classification using Asymmetric Loss (ASL, ICCV 2021).
ASL suppresses easy-negative gradients (γ⁻=4, γ⁺=1, margin=0.15), which helps
on the long tail of rare topic codes.
| Base model | bert-base-uncased |
| Task | Multi-label classification |
| Loss | Asymmetric Loss (γ⁺=1, γ⁻=4, margin=0.15) |
| Number of labels | 126 topic codes |
| Max input length | 256 tokens (title + body) |
| Best val micro-F1 | ~0.844 |
from transformers import BertForSequenceClassification, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("chiunhau/news-classifier-2")
model = BertForSequenceClassification.from_pretrained("chiunhau/news-classifier-2")
model.eval()
title = "Finland wins gold in ice hockey."
text = "The Finnish national team claimed victory in the final."
inputs = tokenizer(title, text, return_tensors="pt",
truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
threshold = 0.5
probs = logits.sigmoid().squeeze()
predicted = [model.config.id2label[i]
for i, p in enumerate(probs) if p > threshold]
print("Topics:", predicted)
title + text fields, separated by the tokenizer's [SEP] token.sigmoid() and threshold at 0.5 for binary predictions.chiunhau/news-classifier-1) uses standard Binary Cross-Entropy and
achieves slightly higher overall micro-F1.