Downloads · 30 days
8
6% of all-time downloads
naheelkk/fake-news-bert-liar
fake-news-bert-liar is a text classification model from naheelkk. 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 fake news detection.
Downloads · 30 days
8
6% of all-time downloads
All-time downloads
139
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 fake news detection.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "naheelkk/fake-news-bert-liar"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prediction function
def predict_fake_news(text):
inputs = tokenizer(text, truncation=True, max_length=128,
padding=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.softmax(logits, dim=-1)
prediction = torch.argmax(probs, dim=-1).item()
confidence = probs.max().item()
label = "REAL" if prediction == 1 else "FAKE"
return label, confidence
# Example usage
text = "The Federal Reserve announced an interest rate increase today."
prediction, confidence = predict_fake_news(text)
print(f"Prediction: {prediction} (Confidence: {confidence:.3f})")
The model was trained on the LIAR dataset, which contains fact-checked political statements:
This model should be used as a tool to assist human fact-checkers, not replace them. Always verify important information through multiple reliable sources.
If you use this model, please consider citing the LIAR dataset:
@inproceedings{wang2017liar,
title={LIAR: A benchmark dataset for fake news detection},
author={Wang, William Yang},
booktitle={Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics},
year={2017}
}