CoolFace
Apppublic

Danielchris145/TruthCheck-AI

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
App README

TruthCheck: AI-Powered Fact Verification System

Status Python License

A state-of-the-art Automated Fact-Checking System that uses a multi-stage neural pipeline to verify text claims in real-time. It combines Web Scraping, Semantic Search, and Natural Language Inference (NLI) to determine the truthfulness of statements with high precision.


๐ŸŒŸ Key Features

๐Ÿง  Advanced AI Core

  • โ€”Multi-Model Consensus: Aggregates judgments from RoBERTa-large-MNLI and DeBERTa-v3-large for robust accuracy.
  • โ€”Semantic Filtering: Uses Sentence-Transformers to ensure only relevant evidence is analyzed.
  • โ€”Credibility Weighting: Automatically assigns higher trust scores to .gov, .edu, and scientific domains.

๐Ÿ’ป Modern "Cyber-Noir" Interface

  • โ€”Futuristic UI: deep space blue theme with neon cyan/purple accents using Tailwind CSS.
  • โ€”Real-Time Dashboard: Track system stats, truth rates, and scan history in the Command Center.
  • โ€”Interactive Visuals: Animated confidence gauges, evidence streams, and live "scanning" effects.

โš™๏ธ Enterprise-Ready

  • โ€”REST API: Fully documented endpoint (/api/verify) for external integration.
  • โ€”Persistence: Built-in SQLite database stores all verification history.
  • โ€”Scalable Architecture: Modular design separating Extraction, Retrieval, and Classification layers.

๐Ÿ›๏ธ System Architecture (Top-to-Bottom)

The application follows a strictly layered pipeline architecture:

  1. 1.Input Layer:
  2. 2.User submits a claim via the Web UI or API.
  3. 3.The ClaimExtractor identifies factual statements using spaCy.
  1. 1.Retrieval Layer:
  2. 2.KeywordExtractor pulls search terms (Entities/Nouns).
  3. 3.EvidenceRetriever scrapes trusted sources (Wikipedia, Google, DuckDuckGo).
  4. 4.Evidence is filtered by domain credibility and semantic similarity.
  1. 1.Inference Layer (The "Brain"):
  2. 2.Filtered evidence is paired with the claim (Premise + Hypothesis).
  3. 3.NLI Models classify each pair as Entailment, Contradiction, or Neutral.
  4. 4.A weighted voting algorithm calculates the final Verdict and Confidence Score.
  1. 1.Presentation Layer:
  2. 2.Results are returned to the user with a color-coded verdict (Green/Red/Amber).
  3. 3.Data is archived in the history.db SQLite database.

๐Ÿš€ Installation & Setup Guide

Follow these steps to deploy the system locally.

Prerequisites

  • โ€”Python 3.10+ installed.
  • โ€”Git installed.
  • โ€”Internet connection (for downloading models).

Step 1: Clone the Repository

bash
git clone https://github.com/CHRISDANIEL145/truth-check.git
cd truth-check

Step 2: Create Virtual Environment

Isolate dependencies to avoid conflicts.

bash
# Windows
python -m venv venv
.\venv\Scripts\activate

# Linux/Mac
python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

This will install PyTorch, Transformers, spaCy, and Flask.

bash
pip install -r requirements.txt

Step 4: Download Language Models

Pre-download the necessary NLI and spaCy models.

bash
python -m spacy download en_core_web_sm

Note: The Transformer models (RoBERTa/DeBERTa) will automatically download on the first run (approx. 3GB).

Step 5: Run the Application

Start the Flask server.

bash
python run.py

You should see output indicating the server is running on http://127.0.0.1:5000.


๐Ÿ“– Usage Guide

1. Using the Analyzer

  • โ€”Navigate to http://127.0.0.1:5000.
  • โ€”Type a factual claim (e.g., "The Great Wall of China is visible from space").
  • โ€”Click INIT_SCAN.
  • โ€”View the Verdict, Confidence Score, and supporting/contradicting Evidence.

2. The Dashboard

  • โ€”Click Dashboard in the top navigation.
  • โ€”View global statistics (Truth Rate, Total Scans).
  • โ€”Review your complete verification history.

3. API Integration

Invoke the verification engine programmatically:

Endpoint: POST /api/verify

Request:

json
{
  "claim": "Water boils at 100 degrees Celsius."
}

Response:

json
{
  "label": "True",
  "confidence": 0.99,
  "evidence": "..."
}

๐Ÿ“‚ Project Structure

TruthCheck/
โ”œโ”€โ”€ app.py                 # Main Flask application & routes
โ”œโ”€โ”€ run.py                 # Entry point
โ”œโ”€โ”€ history.db             # SQLite database (auto-created)
โ”œโ”€โ”€ models/                # AI Core
โ”‚   โ”œโ”€โ”€ claim_extractor.py # Identifies claims
โ”‚   โ”œโ”€โ”€ evidence_retriever.py # Web scraping logic
โ”‚   โ”œโ”€โ”€ keyword_extractor.py  # NLP keyword extraction
โ”‚   โ””โ”€โ”€ nli_classifier.py     # RoBERTa/DeBERTa inference pipeline
โ”œโ”€โ”€ static/                # Frontend Assets
โ”‚   โ”œโ”€โ”€ css/style.css      # Custom animations & styles
โ”‚   โ””โ”€โ”€ js/main.js         # Frontend logic
โ”œโ”€โ”€ templates/             # HTML Views
โ”‚   โ”œโ”€โ”€ index.html         # Analyzer UI
โ”‚   โ”œโ”€โ”€ dashboard.html     # Stats & History
โ”‚   โ”œโ”€โ”€ how_it_works.html  # Architecture Docs
โ”‚   โ””โ”€โ”€ api.html           # API Docs
โ””โ”€โ”€ utils/                 # Helpers
    โ””โ”€โ”€ config.py          # App configuration

๐Ÿค Contributing

Contributions are welcome! Please fork the repository and submit a Pull Request.

๐Ÿ“„ License

This project is licensed under the MIT License.