fancyzhx/ag_news
Viewer β’ Updated β’ 128k β’ 124k β’ 190
How to use Koushim/distilbert-agnews with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Koushim/distilbert-agnews") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Koushim/distilbert-agnews", dtype="auto")This repository provides two fine-tuned DistilBERT models for topic classification on the AG News dataset:
model_no_smoothing: Fine-tuned without label smoothingmodel_label_smoothing: Fine-tuned with label smoothing (smoothing=0.1)Both models use the same tokenizer (distilbert-base-uncased) and were trained using PyTorch and Hugging Face Trainer.
| Model Name | Label Smoothing | Validation Loss | Epochs | Learning Rate |
|---|---|---|---|---|
model_no_smoothing |
β No | 0.1792 | 1 | 2e-5 |
model_label_smoothing |
β Yes (0.1) | 0.5413 | 1 | 2e-5 |
distilbert-base-uncased
/
βββ model\_no\_smoothing/ # Model A - no smoothing
βββ model\_label\_smoothing/ # Model B - label smoothing
βββ tokenizer/ # Tokenizer files (shared)
βββ README.md
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = "Koushim/distilbert-agnews/model_no_smoothing"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
inputs = tokenizer("Breaking news in the tech world!", return_tensors="pt")
outputs = model(**inputs)
pred = outputs.logits.argmax(dim=1).item()
model_name = "Koushim/distilbert-agnews/model_label_smoothing"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
Apache 2.0
transformers.Trainer