ucsbai/liar
Updated • 2.62k • 32
A fine-tuned DistilBERT model for binary fake news classification (REAL vs FAKE), trained on the LIAR dataset.
from transformers import DistilBertTokenizerFast, DistilBertForSequenceClassification
import torch
model = DistilBertForSequenceClassification.from_pretrained("pranavlamkhade/factora-fake-news-detector")
tokenizer = DistilBertTokenizerFast.from_pretrained("pranavlamkhade/factora-fake-news-detector")
model.eval()
text = "NASA confirms the discovery of water on Mars"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=1)
prediction = torch.argmax(probs, dim=1).item()
confidence = float(probs.max()) * 100
label = "REAL" if prediction == 1 else "FAKE"
print(f"Prediction: {label} ({confidence:.1f}%)")
| Property | Value |
|---|---|
| Base Model | distilbert-base-uncased |
| Task | Binary Text Classification |
| Labels | 0: FAKE, 1: REAL |
| Training Data | LIAR Dataset (6-class to binary) |
| Epochs | 3 |
| Batch Size | 16 |
| Max Sequence Length | 512 |
The original LIAR 6-class labels were mapped to binary:
| Original Label | Binary Label |
|---|---|
false, pants-fire, barely-true |
FAKE (0) |
half-true, mostly-true, true |
REAL (1) |
This model powers FacTora -- a full-stack fake news detection platform with:
MIT License