File size: 5,707 Bytes
56f3a8f ab60b70 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | ---
title: TruthCheck AI
emoji: π‘οΈ
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
---
# TruthCheck: AI-Powered Fact Verification System



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