Downloads · 30 days
12
27% of all-time downloads
Lucky0626/bert-base-uncased-agnews4-v01
bert-base-uncased-agnews4-v01 is a text classification model from Lucky0626. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
AG News dataset and classifies texts into 4 categories: - 0: [World News] - 1: [Sports] - 2: [Business] - 3: [Sci/Tech]
Downloads · 30 days
12
27% of all-time downloads
All-time downloads
45
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
AG News dataset and classifies texts into 4 categories:
The maximum token length used during training is set to 128.
from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch
model_name = "Lucky0626/bert-based-uncased-agnews4-v01" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "NASA launches a new satellite into space" inputs = tokenizer(text, return_tensors="pt", max_length=128, truncation=True)
with torch.no_grad(): outputs = model(**inputs) predictions = torch.argmax(outputs.logits, dim=-1)
print("Predicted label:", predictions.item())
text