Downloads · 30 days
6
23% of all-time downloads
AventIQ-AI/topic-classification-for-news-title
topic-classification-for-news-title is a machine learning model from AventIQ-AI. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository hosts a quantized version of the RoBERTa model, fine-tuned for topic classification using the AG News dataset. The model has been optimized using FP16 quantization for efficient deployment without sign…
Downloads · 30 days
6
23% of all-time downloads
All-time downloads
26
Public
Parameters
125M
249 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors249 MB · 99%
From the Hugging Face model README
This repository hosts a quantized version of the RoBERTa model, fine-tuned for topic classification using the AG News dataset. The model has been optimized using FP16 quantization for efficient deployment without significant accuracy loss.
pip install transformers torch datasets
from transformers import RobertaTokenizer
from transformers import RobertaForSequenceClassification
import torch
# Load tokenizer and model
tokenizer = RobertaTokenizer.from_pretrained("roberta-base")
model = RobertaForSequenceClassification.from_pretrained("roberta-base", num_labels=4).to(device)
# Define test sentences
samples = [
"Tensions rise in the Middle East as diplomats gather for emergency talks to prevent further escalation.",
"Tesla reports a 25% increase in quarterly revenue, driven by strong demand for its Model Y vehicles in Asia.",
"Researchers develop a new quantum computing chip that significantly reduces energy consumption.",
"Argentina defeats Brazil 2-1 in the Copa América final, securing their 16th continental title.",
"Meta unveils its latest AI model capable of generating 3D virtual environments from text prompts."
]
from transformers import pipeline
# Load pipeline for inference
classifier = pipeline("text-classification", model=trainer.model, tokenizer=tokenizer, device=0) # device=-1 if using CPU
predictions = classifier(samples)
# Print results
for text, pred in zip(samples, predictions):
print(f"\nText: {text}\nPredicted Topic: {pred['label']} (Score: {pred['score']:.4f})")
The dataset is sourced from Hugging Face’s ag_news dataset. It contains 120,000 training samples and 7,600 test samples, with each news article labeled into one of four categories: World, Sports, Business, or Sci/Tech. The original dataset was used as provided, and input texts were tokenized using the RoBERTa tokenizer and truncated/padded to a maximum length of 128 tokens.
epochPost-training quantization was applied using PyTorch’s half() precision (FP16) to reduce model size and inference time.
.
├── config.json # Model configuration
├── merges.txt # Byte Pair Encoding (BPE) merge rules for tokenizer
├── model.safetensors # Quantized model weights
├── README.md # Model documentation
├── special_tokens_map.json # Tokenizer special tokens
├── tokenizer_config.json # Tokenizer configuration
├── vocab.json # Tokenizer vocabulary
├── README.md # Model documentation
Feel free to open issues or submit pull requests to improve the model or documentation.