Use xenova ner/xnli for fact check
README.md

LiveFactCheck #

Browser extension (Firefox/Zen + Chrome, MV3) for real-time, on-device fact-checking on any web page. CPU-only, no LLM, no API keys. Multilingual (100+ languages).

I have too much free time, on my vacancy, sorry.

What it does #

  • Text fact-checking - detects check-worthy claims on any page, searches 7 sources, runs NLI cross-encoder, shows inline verdicts (TRUE / FALSE / UNCERTAIN / CONFLICTING) with evidence and source links
  • Image AI detection - scans page images with a ViT deepfake detector, shows badges (⚠ AI / ? UNCERTAIN / ✓ REAL) with confidence scores
  • Reverse image search - right-click any image → Google Lens or TinEye to find the original source

How it works #

No LLM. No text generation. All models are small classifiers running locally via Transformers.js (ONNX Runtime WASM):

Model Role Size (q8) Languages
mDeBERTa-v3-xnli (NLI) Claim verification - entailment/contradiction/neutral ~339 MB 100
multilingual-e5-small Dense evidence retrieval (embeddings) + PFCR semantic cache ~118 MB 100+
XLM-RoBERTa NER Named entity extraction for decontextualization ~178 MB 100
Deep-Fake-Detector-v2 (ViT) AI-generated image detection ~87 MB N/A

Models ship inside the extension (~760 MB bundled in dist/models/). First use loads from disk - no HuggingFace download, no slow first run. HuggingFace stays enabled only as a fallback for a missing file. NLI loads lazily on first claim; NER and the ViT detector load only when needed.

Pipeline (8 stages) #

  1. Claim detection - ClaimBuster-inspired structural scoring (numbers, entities, content density, TTR, punctuation density - no per-language word lists; threshold 2.5)
  2. Claim decomposition - clause splitting + normalization (whitespace, HTML entities, repeated punctuation)
  3. Evidence retrieval - 7 sources, each with a 5s AbortController timeout, cross-lingual Wikipedia (FR+EN)
  4. Evidence selection - TF-IDF cosine + temporal boost → top-8 → batch e5-small embeddings → RRF fusion → top-5
  5. Stance detection - sequential NLI (evidence [SEP] claim), temperature T=1.5, trust-weighted
  6. Confidence floor - abstain if <0.4 → UNCERTAIN
  7. Verdict aggregation - BiDeV weighted voting + CONFLICTING on entailment/contradiction co-occurrence (AVeriTeC 2.0)
  8. PFCR cache - semantic cache (0.92 cosine similarity threshold)

Search sources (7, no API keys) #

Source Type Real-time
Wikipedia (FR+EN) Encyclopedic full-text search ❌
Wikidata Structured (wbsearch + SPARQL) ❌
DBpedia Structured entity lookup ❌
Google News RSS News articles ✅
Hacker News Algolia Tech news ✅
DuckDuckGo Answers Instant answers ⚠️
OpenAlex Academic papers ❌

Architecture #

Content script (content.js)
  ├── Claim detection (claim-detect.js - shared with eval suite)
  ├── Image scanner (IntersectionObserver → image worker, incl. SPA/dynamic images)
  ├── Keepalive port (prevents MV3 SW idle-kill during long pipelines)
  └── Overlay (inline underlines + hover tooltips)
        │
Background service worker (service-worker.js)
  ├── Pipeline orchestration (search → NLI → verdict), AbortController cancellation
  ├── Context menu (Google Lens / TinEye reverse search)
  └── Worker routing
        │
        ├── NLI worker (nli-worker.js)
        │     ├── NLI cross-encoder (mDeBERTa)
        │     ├── Dense retrieval (e5-small embeddings + RRF)
        │     └── Verdict aggregation (shared verdict.js)
        └── Image worker (image-worker.js)
              └── Deep-Fake-Detector-v2 (ViT, WASM int8)

Features #

Text overlay #

  • Grammarly-style inline underlines (green/red/amber/dotted)
  • Hover tooltip: verdict label, confidence bar, atomic facts, source cards with trust levels
  • Verdict-colored tooltip border
  • Theme-aware (light/dark via prefers-color-scheme, CSS variables)
  • i18n (English, French, German, Spanish)
  • IntersectionObserver lazy redraw (only visible overlays reposition on scroll)

Image detection #

  • Badge on image corner: ⚠ (AI, red) / ? (uncertain, amber) / ✓ (real, green)
  • Hover tooltip: deepfake/real scores, confidence bar, Google Lens + TinEye links
  • 3-level threshold: >0.7 AI, 0.5-0.7 uncertain, <0.5 real
  • False positive warning (NewsGuard 2026: 40-50% FP rate)
  • Filters: skips icons (<100px), avatars, logos, SVG/GIF, nav/header/footer images
  • SPA / infinite-scroll images observed dynamically via MutationObserver

Reliability #

  • Lazy model loading (download on first use, not startup)
  • Real cancellation: per-tab AbortController aborts in-flight fetches on navigation
  • Debounced verdict-cache persistence (survives SW restarts) + size cap
  • MV3 keepalive: open port from content script keeps the SW alive during long pipelines
  • PFCR semantic cache (0.92 similarity → skip full pipeline)

Build & test #

npm install
npm test                 # unit tests (node:test) - pipeline logic + offline model check
npm run lint             # ESLint (flat config)
npm run build:firefox    # Firefox/Zen (MV3) - bundles models into dist/
npm run build:chrome     # Chrome (MV3) - bundles models into dist/

No separate model step: build downloads any missing model itself (resumable, ~760 MB total, cached in models/), verifies every file listed in scripts/models.json is present, and bundles them into dist/models/. A fresh checkout produces a fully self-contained extension. Output in dist/ (cleaned on every build). Load as unpacked extension.

npm test includes an offline release check: all four models load from dist/models/ with network access disabled and run real inference (NLI entailment, embeddings, NER, ViT). Run npm run build once first so dist/models/ exists.

Firefox/Zen #

  1. about:debugging#/runtime/this-firefox
  2. Load Temporary Add-on → select dist/manifest.json

Chrome #

  1. chrome://extensions/
  2. Enable Developer mode
  3. Load unpacked → select dist/

In-browser evaluation suite #

21 claims (historical / false / non-factual / uncertain / numerical / entity) covering both the claim detector and the full pipeline:

chrome.runtime.sendMessage({ type: 'eval' }, r => console.log(r))

Constraints #

  • No LLM - classifiers only
  • CPU-only - WASM inference everywhere (WebGPU removed: no fp16 variant is bundled, and it breaks in Firefox extension workers)
  • No cloud - all inference on-device; only search evidence retrieval hits the network
  • No API keys - all search sources are free and keyless
  • Universal - works on any page, not hardcoded to specific sites
  • Multilingual - 100+ languages; all text processing uses Unicode structural rules, no hardcoded per-language word lists

License #

MIT