Skip to content

Praptii21/Truth-seeker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕵️‍♀️ Truth Seeker: AI-Powered Deep News Verification

Truth Seeker is a full-stack, state-of-the-art Fake News Detection application that combines Machine Learning style classification with Dense Semantic Retrieval-Augmented Generation (RAG) to verify the authenticity of news claims.

Unlike simple heuristic models, Truth Seeker leverages a dual-tier validation approach:

  1. Linguistic Style Profiling: Fast stylistic analysis to detect clickbait patterns, biased language, and typical fake news syntax using a machine learning model.
  2. Dense Semantic RAG (Fact-Checking): Fact verification using a vector database containing authenticated news, followed by an LLM-based reasoning engine that synthesizes proof into a final structured verdict.

🏗️ Architecture

                 +-------------------+
                 |  User Input Text  |
                 +---------+---------+
                           |
            +--------------+--------------+
            |                             |
            v                             v
  +--------------------+       +---------------------+
  |   Quick Style Scan |       |  Deep Verification  |
  |  (Linguistic ML)   |       |    (Semantic RAG)   |
  +---------+----------+       +----------+----------+
            |                             |
            v                             v
+-----------------------+     +-----------------------+
|  PassiveAggressive    |     | ChromaDB query using  |
|  Classifier (TF-IDF)  |     |  all-MiniLM-L6-v2     |
+-----------+-----------+     +-----------+-----------+
            |                             |
            |                             v
            |                 +-----------------------+
            |                 |  Semantic Matching    |
            |                 |   (L2 Distance < 1.25)|
            |                 +-----------+-----------+
            |                             |
            |                             v
            |                 +-----------------------+
            |                 |  Context Synthesis    |
            |                 |  Groq/Llama-3.3 LLM   |
            |                 +-----------+-----------+
            |                             |
            +--------------+--------------+
                           |
                           v
              +-------------------------+
              | React Frontend Dashboard|
              +-------------------------+

🚀 Key Features

  • Quick Style Scan (ML Predictor): Analyzes write-style patterns (trained on the WELFake dataset) to flag clickbait or suspicious text structures using a PassiveAggressive Classifier.
  • Deep Verification (Dense Semantic RAG):
    • Retrieves facts directly from ChromaDB using dense vectors generated by the all-MiniLM-L6-v2 transformer model (replaces old TF-IDF term-matching RAG).
    • Synthesizes retrieved evidence using Llama 3.3 (70B) via the Groq API (or Gemini API) to generate clean structured JSON outputs showing the verdict, reasoning, and confidence score.
    • Falls back gracefully to local vector distance heuristic evaluation if no API keys are provided.
  • Modern User Interface: A responsive React app offering clear interactive visualization of stylistic matches, confidence metrics, and context citation splits.

🛠️ Technology Stack

  • Frontend: React.js, Vanilla CSS
  • Backend: FastAPI, Uvicorn, Pydantic
  • Vector Store: ChromaDB (dense semantic indexing)
  • Embedding Model: sentence-transformers/all-MiniLM-L6-v2 (running locally via Hugging Face/Chromadb utilities)
  • LLM Synthesis: Llama 3.3 70B (via Groq API) or Gemini models
  • Stylistic Predictor: Python scikit-learn (PassiveAggressive Classifier, TF-IDF representation)
  • Dataset: WELFake (72,134 news records)

📂 Project Structure

├── backend/
│   ├── routes/             # FastAPI endpoint routers (predict, deep_predict)
│   ├── services/           # Business logic (RAG service, PAC ML predictor)
│   │   ├── predictor.py    # Linguistic style classification
│   │   └── rag_service.py  # ChromaDB query + LLM fact-checking synthesis
│   ├── utils/              # Helper utilities (text cleaning, diagnostics)
│   ├── ingest_chroma.py    # Populates ChromaDB vector store with factual news
│   ├── ingest_data.py      # (Legacy) TF-IDF index builder
│   └── main.py             # FastAPI App Entrypoint
├── frontend/               # React client app
├── models/                 # Saved ML weights (model.pkl, vectorizer.pkl)
├── notebooks/              # Jupyter notebooks for model training (WELFake PAC model)
├── chroma_db/              # Local Chroma vector database directory
├── data/                   # Dataset folder containing processed CSVs
└── requirements.txt        # Backend dependencies

⚙️ How to Run Locally

1. Environment Setup

Create a .env file in the project root based on .env.example:

GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama-3.3-70b-versatile
PORT=8000
HOST=0.0.0.0

2. Backend Setup

  1. Navigate to the backend directory and set up a virtual environment:
    cd backend
    python -m venv venv
    # On Windows:
    venv\Scripts\activate
    # On macOS/Linux:
    source venv/bin/activate
  2. Install Python requirements:
    pip install -r ../requirements.txt
  3. Ingest the Vector DB: Build the ChromaDB vector index from the factual dataset:
    python ingest_chroma.py
  4. Run the API server:
    python main.py
    The backend will start at http://localhost:8000.

3. Frontend Setup

  1. Open a new terminal window and navigate to the frontend directory:
    cd frontend
  2. Install Node packages:
    npm install
  3. Run the development server:
    npm start
    The React dashboard will open at http://localhost:3000.

🔬 Diagnostics

Verify that your RAG pipeline and Groq integration work correctly by running the diagnostic test script:

python backend/utils/verify_rag.py

This script queries the database with a test claim, invokes Groq, and reports the performance.


✨ Author

About

Dual-layer Fake News Detector: Passive-Aggressive style modeling combined with TF-IDF RAG

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages