Live Fact-Checking System
Relevant source files
The following files were used as context for generating this wiki page:
The Live Fact-Checking System is a core component of the TrueLens platform designed to provide real-time verification of claims and news content. It utilizes a hybrid approach combining Large Language Models (LLMs), external knowledge bases like Wikipedia, and structured historical data from fact-check databases such as the Google Fact Check Tools API.
The system is primarily accessed through the Fact Check Portal, which orchestrates two parallel search paths: an AI Verdict generated via live web retrieval and an Independent Database Search for historical journalistic reviews.
System Architecture and Data Flow
The architecture follows a decoupled structure where the frontend interacts with backend services to perform concurrent evaluation of a query.
Information Retrieval and Evaluation Flow
The process begins when a user submits a query. The system triggers two simultaneous requests:
- AI Live Evaluation: Searches Wikipedia for current context and utilizes the Gemini 2.5 Flash model to synthesize a verdict.
- Historical Provenance: Queries the Google Fact Check API to find existing verdicts from established journalistic organizations.
Core Backend Services
Live Fact Checker Service
The live_fact_checker.py module manages the active web search and LLM evaluation logic. It cleans the search query by removing common interrogative prefixes (e.g., "did ", "is ") and question marks to improve search relevance on Wikipedia.
Key functions include:
search_web_for_claim: Retrieves up to 3-4 snippets and URLs from Wikipedia.evaluate_claim_live: Formats the gathered context into a rigorous journalistic prompt for the Gemini model.
Sources: truelens-backend/app/services/live_fact_checker.py:11-40, truelens-backend/app/services/live_fact_checker.py:65-90
Provenance and Fact-Check Integration
The provenance.py service handles external API integrations for historical validation. It primarily uses the Google Fact Check Tools API to find claims related to the user query. It also supports the Internet Archive's Wayback Machine to check URL availability and snapshot history.
Sources: truelens-backend/app/services/provenance.py:20-40, truelens-backend/app/services/provenance.py:58-90
News Analysis Pipeline
Within the broader ML pipeline, news content is specifically analyzed for journalistic integrity. This includes a "Fake News" weight within the ensemble scoring system.
| Analysis Type | Indicators Checked | Source File |
|---|---|---|
| Sensationalism | Use of words like "shocking", "bombshell", "scandal" | news_analysis.py |
| Clickbait | Phrases like "you won't believe", "what happens next" | news_analysis.py |
| Citations | Presence of "according to", "reported", "officials" | news_analysis.py |
| Provenance | Wayback Machine snapshots, Google Fact Check history | provenance.py |
Sources: truelens-backend/app/services/news_analysis.py:53-110, truelens-backend/app/tasks/ml_pipeline.py:35-45
Data Models and API Structures
Fact-Checking Verdicts
The system returns a structured response containing the rating, reasoning, and supporting evidence.
{
"available": true,
"rating": "FALSE",
"short_answer": "...",
"reasoning": "...",
"confidence": "High",
"sources": [
{ "title": "...", "snippet": "...", "url": "..." }
]
}
Sources: truelens-backend/app/services/live_fact_checker.py:105-115, truelens-app/src/app/fact-check/page.tsx:23-31
UI State Management
The frontend FactCheckPage utilizes a "badge" system to standardize ratings across different sources. It maps various textual ratings (e.g., "pants on fire", "misleading", "correct") into four visual categories: True, False, Misleading, or Unverified.
Scoring and Ensembles
Fact-checking signals are integrated into the main ml_pipeline.py through the analyze_provenance and analyze_news functions. The provenance signal, which includes fact-check hits, contributes 5% to the total ensemble trust score, while specific news analysis contributes 20% if the content is identified as news.
Sources: truelens-backend/app/tasks/ml_pipeline.py:32-40, truelens-backend/app/tasks/ml_pipeline.py:155-170
Summary
The Live Fact-Checking System provides a multi-layered defense against misinformation by combining immediate AI-driven context retrieval with historical journalistic records. By using Wikipedia for live context and the Gemini LLM for synthesis, the system offers real-time verdicts while maintaining technical transparency through the inclusion of direct source links and confidence scores.