Skip to content

Latest commit

Β 

History

138 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ZeroFake v2.3

Advanced AI-powered Fake News Detection System with Dual Flow Architecture


Objective

ZeroFake is a real-time fact-checking system that verifies news claims as:

  • TIN THAT (TRUE NEWS)
  • TIN GIA (FAKE NEWS)

The system uses a multi-agent cognitive architecture with:

  • Dual Flow Routing (Recent News vs Old Info)
  • Google Fact Check API integration
  • LLM Evidence Filter (removes duplicates, social media, clickbait)
  • Adversarial CRITIC-JUDGE debate
  • Presumption of Truth principle

Architecture

System Flow Diagram

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   INPUT CLAIM   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    PLANNER      β”‚
                         β”‚ (Generate 5+    β”‚
                         β”‚  search queries)β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       Info Age?         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β–Ό                                           β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  RECENT NEWS  β”‚                         β”‚   OLD INFO    β”‚
    β”‚   (≀3 days)   β”‚                         β”‚   (>3 days)   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                         β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                                         β”‚
            β–Ό                                         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚    SEARCH     β”‚                         β”‚  FACT CHECK   β”‚
    β”‚  (Multi-src)  β”‚                         β”‚     API       β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                         β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                                         β”‚
            β–Ό                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β–Ό                   β–Ό
    β”‚    FILTER     β”‚               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  (Llama 8B)   β”‚               β”‚ Has Result  β”‚     β”‚  No Result  β”‚
    β”‚ Remove junk   β”‚               β”‚   β‰₯70%      β”‚     β”‚             β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
            β”‚                              β”‚                   β”‚
            β–Ό                              β”‚ Skip CRITIC       β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚    CRITIC     β”‚                      β”‚            β”‚   SEARCH    β”‚
    β”‚  (Adversarial)β”‚                      β”‚            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚                   β–Ό
            β”‚                              β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚                              β”‚            β”‚   FILTER    β”‚
            β”‚                              β”‚            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
            β”‚                              β”‚                   β–Ό
            β”‚                              β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚                              β”‚            β”‚   CRITIC    β”‚
            β”‚                              β”‚            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
            β”‚                              β”‚                   β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚     JUDGE       β”‚
                         β”‚ (Final Verdict) β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚     OUTPUT      β”‚
                         β”‚ TIN THAT/TIN GIAβ”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

API Keys Required

All API keys are configured in .env file:

# ============================================
# REQUIRED APIs
# ============================================

# Google Gemini API (PLANNER, CRITIC, JUDGE)
GEMINI_API_KEY=AIza...

# Google Fact Check Tools API (Fake news verification)
GOOGLE_FACT_CHECK_API_KEY=AIza...

# OpenWeather API (Weather claims)
OPENWEATHER_API_KEY=...

# ============================================
# CEREBRAS APIs (Primary models - 4 keys for rotation)
# ============================================
CEREBRAS_API_KEY_1=csk_...
CEREBRAS_API_KEY_2=csk_...
CEREBRAS_API_KEY_3=csk_...
CEREBRAS_API_KEY_4=csk_...

# ============================================
# GROQ APIs (Fallback models - 4 keys for rotation)
# ============================================
GROQ_API_KEY_1=gsk_...
GROQ_API_KEY_2=gsk_...
GROQ_API_KEY_3=gsk_...
GROQ_API_KEY_4=gsk_...

Key Features

1. Dual Flow System

Flow Type Condition Action
RECENT NEWS Claim within 3 days Search -> CRITIC -> JUDGE
OLD INFO Claim older than 3 days Fact Check API first
Fact Check >=70% High confidence verdict Skip Search + CRITIC -> JUDGE
Fact Check miss No results found Fallback: Search -> CRITIC -> JUDGE

2. Google Fact Check API Integration

  • Multi-query search: 3 English + 3 Vietnamese queries per claim
  • High confidence skip: If verdict >=70%, skip Search + CRITIC for speed
  • Combined analysis: JUDGE considers Fact Check evidence directly

3. Unified Search System

Search Flow Diagram

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    INPUT QUERY      β”‚
                         β”‚   (from PLANNER)    β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   GOOGLE NEWS       β”‚
                         β”‚ gnews VN + EN       β”‚
                         β”‚ (~20 results)       β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚     WIKIPEDIA       β”‚
                         β”‚ wikipedia-api       β”‚
                         β”‚ VN + EN lookup      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   results < 10?     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                               β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚      YES      β”‚               β”‚      NO       β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β–Ό                               β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
            β”‚  GOOGLE WEB   β”‚                       β”‚
            β”‚ googlesearch  β”‚                       β”‚
            β”‚ + TRAFILATURA β”‚                       β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
                    β–Ό                               β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
            β”‚ results < 5?  β”‚                       β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
                    β”‚                               β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
            β–Ό               β–Ό                       β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
    β”‚      YES      β”‚ β”‚    NO     β”‚                 β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜                 β”‚
            β–Ό               β”‚                       β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚                       β”‚
    β”‚  DDG FALLBACK β”‚       β”‚                       β”‚
    β”‚ News + Web    β”‚       β”‚                       β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚                       β”‚
            β”‚               β”‚                       β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  OUTPUT: 15-20    β”‚
                    β”‚  Evidence Items   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Libraries Used

Library Source Purpose
gnews Google News Latest news articles
wikipedia-api Wikipedia Entity verification
googlesearch-python Google Web URL extraction
trafilatura Any URL Article content extraction
duckduckgo_search DuckDuckGo Fallback search

4. Multi-Agent Cognitive System

Agent Role Model (Primary -> Fallback)
PLANNER Generate 5+ search queries Qwen 3 32B (Cerebras) -> Llama 8B -> Gemma
CRITIC Adversarial analysis, find weaknesses Qwen 3 32B (Cerebras) -> Llama 8B -> Gemma
JUDGE Final verdict with Bayesian reasoning Llama 3.3 70B (Cerebras) -> Llama 3.3 70B (Groq) -> Gemma

5. Binary Source Ranking

Source Type Score Classification
Government (.gov) 0.95 USABLE
Major News (Reuters, BBC, AP) 0.95 USABLE
Quality News (VnExpress, VTV) 0.90 USABLE
Default Sources 0.55 USABLE
Social Media 0.30 BLOCKED
Tabloids/UGC 0.10 BLOCKED

Binary Rule: Score >= 0.5 = USABLE (layer_2), Score < 0.5 = BLOCKED (layer_4)


Installation

Requirements

  • Python 3.10+ (Python 3.11/3.12 recommended)
  • Windows/Linux/macOS

Setup

# Clone repository
git clone https://github.com/Minwsun/ZeroFake.git
cd ZeroFake

# Install dependencies
pip install -r requirements.txt

# Configure API keys
cp .env.example .env
# Edit .env with your API keys (see above)

Project Structure

app/
β”œβ”€β”€ main.py              # FastAPI server + orchestrator
β”œβ”€β”€ agent_planner.py     # PLANNER agent (query generation)
β”œβ”€β”€ agent_synthesizer.py # CRITIC + JUDGE agents
β”œβ”€β”€ fact_check.py        # Google Fact Check API integration
β”œβ”€β”€ search.py            # DDGS().news() + web search
β”œβ”€β”€ ranker.py            # Source trust ranking
β”œβ”€β”€ model_clients.py     # Multi-API model clients
β”œβ”€β”€ weather.py           # OpenWeather API
β”œβ”€β”€ tool_executor.py     # Tool orchestration + date routing
└── trusted_domains.json # 380+ trusted domains

prompts/
β”œβ”€β”€ planner_prompt.txt   # PLANNER instructions (5+ queries)
β”œβ”€β”€ critic_prompt.txt    # CRITIC adversarial prompt
└── synthesis_prompt.txt # JUDGE Bayesian reasoning

evaluation/
β”œβ”€β”€ test_dataset_1000.json  # 1000 test samples (500 true, 500 fake)
└── run_evaluation.py       # Evaluation script

gui/
└── main_gui.py          # PyQt6 Dark Mode GUI

Evaluation

Test Dataset

  • 500 TRUE news: Real events from 2024-2025
  • 500 FAKE news: Zombie news, fabrication, conspiracy theories, scams

Metrics

  • Accuracy, Precision, Recall, F1 Score
  • Confusion Matrix (TIN THAT vs TIN GIA)
  • False Positive/Negative Rate

Recent Updates (v2.3)

December 2025 (Latest)

  • Evidence Filter Agent: LLM-based filtering using Llama 8B (Groq) to remove duplicates, social media, clickbait before CRITIC/JUDGE
  • Filter Cache: Hash-based caching (200 entries) saves ~2s for duplicate claims
  • Skip CRITIC Logic: Auto-skip CRITIC for KNOWLEDGE claims with Wikipedia evidence (saves 5-8s)
  • Batch Evaluation: Concurrent processing (3 threads) for 3x faster evaluation
  • Snippet Optimization: 400 chars per evidence for balanced info extraction

Previous Updates (v2.2)

  • Unified Search System: Multi-source search with GNews + Wikipedia + Googlesearch + Trafilatura + DDG fallback
  • Google News Integration: gnews library for latest news (VN + EN)
  • Wikipedia API: Direct entity verification (wikipedia-api)
  • Article Extraction: trafilatura for full content extraction from URLs
  • Anti-block Measures: Random delays, user-agent rotation, WARP proxy support
  • English Query Translation: Comprehensive VN-to-EN translation dictionary
  • JUDGE AI Reasoning: Trust AI knowledge for old events (>1 year), trust evidence for new events (2025+)
  • Optimized Dual Flow: Old info (>3 days) with Fact Check verdict >=70% skips Search + CRITIC
  • Smart Search Skip: Saves latency when Fact Check API has high confidence result
  • Google Fact Check API: Multi-query (EN + VN) integration
  • PLANNER 5+ queries: Better search coverage (backup if Fact Check fails)
  • FAISS KB Cache: Semantic deduplication (85% similarity threshold)
  • Cerebras + Groq: Multi-key API rotation (4 keys each)

Author

Nguyen Nhat Minh
GitHub: @Minwsun
Repository: https://github.com/Minwsun/ZeroFake

About

Fake News Detect

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages