Fake News BERT (8-bit ONNX)

bert-base-uncased fine-tuned to classify news text as Fake or Real, from my MSc dissertation Fake News Detection Using Transformer-Based and Traditional NLP Models (MSc Data Science and Artificial Intelligence, University of Liverpool). Exported to ONNX with 8-bit dynamic quantisation so it runs in the browser with Transformers.js.

Try it: Fake News Detector

Training

  • Data: Kaggle Fake and Real News dataset, 44,673 articles after de-duplication, split 80/10/10 (stratified, seed 42).
  • Input: title + body, cleaned (HTML/URLs removed, lower-cased, stop words and non-alphabetic tokens dropped, WordNet-lemmatised), truncated to 256 tokens.
  • 4 epochs, AdamW, learning rate 2e-5, batch size 16, on a Colab T4 GPU.

Results

On the dissertation's held-out test set (4,468 articles): accuracy 0.9935, F1 0.9931 for this 8-bit model, compared with F1 0.9936 for the full-precision model.

Usage

The model expects text cleaned the same way as in training; see model.js in the Space for the exact steps.

import { pipeline } from "@huggingface/transformers";
const classify = await pipeline("text-classification", "haithamd/fake-news-bert", { dtype: "q8" });
await classify("cleaned text here", { top_k: null }); // [{ label: "Real", score }, { label: "Fake", score }]

Limitations

The model judges writing style, not truth. About 99% of the "Real" training articles are Reuters wire copy, and all come from 2016โ€“2017, mostly US politics. A false claim written in a neutral wire-service style can be classified as Real, and short texts such as tweets are less reliable than full articles.

Downloads last month
98
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for haithamd/fake-news-bert

Quantized
(34)
this model

Space using haithamd/fake-news-bert 1