Downloads · 30 days
26
17% of all-time downloads
LakshmiNarayanan-sugumar/fake-news-bert-debiased
fake-news-bert-debiased is a text classification model from LakshmiNarayanan-sugumar. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
This model is a fine-tuned version of bert-base-uncased for binary fake news classification (real vs. fake), trained on a cleaned version of the WELFake dataset with a specific shortcut-learning bug fixed. It supersed…
Downloads · 30 days
26
17% of all-time downloads
All-time downloads
151
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
This model is a fine-tuned version of bert-base-uncased for binary fake news classification (real vs. fake), trained on a cleaned version of the WELFake dataset with a specific shortcut-learning bug fixed. It supersedes fake-news-bert, which achieved similar benchmark accuracy but for the wrong reasons — see below.
bert-base-uncasedThe original model (fake-news-bert) hit 99.53% test accuracy but performed poorly on real-world text outside the WELFake distribution — especially satire and hoaxes. A hand-built 26-example out-of-distribution (OOD) test set (satire, hoaxes, and real news from diverse sources) exposed this: overall OOD accuracy was only 53.8%.
Investigating further, a quantitative diagnostic on the training data revealed the cause: 61.8% of "real" articles in WELFake mentioned "Reuters," versus only 1.8% of "fake" articles. The model had learned to key off this single word rather than genuine signals of factuality — an easy, cheatable shortcut that inflated benchmark accuracy while masking real generalization failure. Secondary shortcut signals (ALL-CAPS phrases, excessive exclamation marks) were also present.
Training text was cleaned to remove these shortcuts: "Reuters" mentions stripped, ALL-CAPS phrases collapsed to normal case, and exclamation marks capped. The model was retrained for 2 epochs on this cleaned data.
| Category | Before Cleaning | After Cleaning |
|---|---|---|
| real_sensational_true | 100% (3/3) | 100% (3/3) |
| real_non_reuters | 87.5% (7/8) | 100% (8/8) |
| hoax | 33.3% (2/6) | 16.7% (1/6) |
| hoax_dry_tone | 33.3% (1/3) | 33.3% (1/3) |
| satire | 16.7% (1/6) | 16.7% (1/6) |
| Overall | 53.8% | 53.8% |
The fix worked as intended: real-news accuracy on non-Reuters-sourced articles went from 87.5% to 100%, confirming the shortcut is gone and the model now identifies real news on genuine content signals rather than source-name pattern-matching.
A known limitation remains: satire and hoax detection did not improve, and hoax accuracy on the small sample slightly declined. This is not a regression from the fix — it reflects a genuine data diversity gap. WELFake's "fake" class is dominated by aggressively-toned misinformation and contains little dry-toned satire or calmly-written hoaxes, so the model never learned to recognize that register as suspicious. Every misclassified OOD example was predicted "real" with high confidence (92–99%), indicating the model isn't confused — it's simply never seen this writing style labeled as fake before. Fixing this requires more diverse training data (e.g. incorporating ISOT or other satire-inclusive sources), not further text cleaning.
Given a news article's title and body text, the model predicts whether the article is real or fake. Intended for educational and portfolio demonstration purposes.
Not intended for production moderation or fact-checking decisions without human review. As documented above, the model has a known weakness on satire and dry-toned hoaxes.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("LakshmiNarayanan-sugumar/fake-news-bert-debiased")
model = AutoModelForSequenceClassification.from_pretrained("LakshmiNarayanan-sugumar/fake-news-bert-debiased")
text = "Your article title here. Your article body text here."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
logits = model(**inputs).logits
prediction = torch.argmax(logits, dim=-1).item()
print("Fake" if prediction == 1 else "Real")
WELFake dataset, cleaned to 62,200 deduplicated articles, split 80/10/10 (train/val/test, stratified). Training text additionally cleaned of shortcut signals (Reuters mentions, ALL-CAPS, excessive exclamation marks) as described above.
Title and body concatenated into a single input, tokenized with the BERT tokenizer (max length 512, truncation enabled). Fine-tuned for 2 epochs, batch size 16.
bert-base-uncased| Metric | Score |
|---|---|
| Accuracy | 99.49% |
| F1 | 99.42% |
| Precision | 99.64% |
| Recall | 99.20% |
Near-identical to the original model's in-distribution metrics (99.53% / 99.47% / 99.64% / 99.31%), confirming that removing the shortcut cost negligible in-distribution performance — the model was already learning real signal alongside the shortcut.
See the before/after table above. Full 26-example OOD test set (ood_test.csv) available in the GitHub repository.
BertForSequenceClassification (2 labels), built on bert-base-uncasedLakshmiNarayanan Sugumar — GitHub