Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“° Factify

AI-Powered Fact Verification System using Semantic Retrieval & Natural Language Inference

Python Django Transformers SBERT License

Factify is an AI-powered fact verification platform that analyzes user-submitted claims by retrieving evidence from trusted news sources, ranking the most relevant information using semantic similarity, and verifying the claim through Natural Language Inference (NLI).

Unlike traditional fake news classifiers that rely solely on supervised text classification, Factify follows a retrieval-augmented verification pipeline, making every prediction explainable through supporting evidence.


πŸ“‘ Table of Contents

  • Overview
  • Motivation
  • Features
  • AI Verification Pipeline
  • System Architecture
  • Technology Stack
  • Project Structure
  • Installation
  • Usage
  • Future Improvements
  • License

πŸ“– Overview

The rapid spread of misinformation across digital platforms has made automatic claim verification increasingly important.

Traditional fake news detection models classify an article directly as real or fake, often without providing any explanation behind their predictions.

Factify approaches this problem differently.

Instead of relying only on a classification model, it:

  • retrieves evidence from trusted sources,
  • measures semantic similarity between the claim and retrieved information,
  • reasons over the evidence using Natural Language Inference,
  • combines multiple credibility signals,
  • produces an evidence-backed final verdict.

This makes the verification process more transparent and easier to interpret.


πŸš€ Features

  • πŸ” AI-powered claim verification
  • 🌐 Retrieves evidence from Google News
  • 🧠 Semantic search using Sentence-BERT embeddings
  • πŸ“Š Cosine similarity based evidence ranking
  • 🎯 Cross-Encoder re-ranking for improved relevance
  • πŸ€– Natural Language Inference (NLI) reasoning
  • ⭐ Source credibility scoring
  • πŸ“ˆ Topic-aware trust boosting
  • βš–οΈ Weighted ensemble for final verdict generation
  • πŸ“‘ Displays supporting evidence with confidence scores
  • πŸ‘€ User authentication and profile management
  • πŸ“° Latest news feed integration

🧠 AI Verification Pipeline

Factify follows a multi-stage Retrieval-Augmented Verification (RAV) pipeline.

User Claim
      β”‚
      β–Ό
Retrieve External Evidence
      β”‚
      β–Ό
Clean & Preprocess Articles
      β”‚
      β–Ό
Generate SBERT Embeddings
      β”‚
      β–Ό
Semantic Similarity Ranking
      β”‚
      β–Ό
Cross Encoder Re-ranking
      β”‚
      β–Ό
Natural Language Inference
      β”‚
      β–Ό
Source Credibility Scoring
      β”‚
      β–Ό
Weighted Ensemble
      β”‚
      β–Ό
Final Verdict

πŸ—οΈ System Architecture

flowchart TD

A[User Claim]

A --> B[Google News API]

B --> C[Article Retrieval]

C --> D[Text Cleaning]

D --> E[Sentence-BERT Embeddings]

E --> F[Cosine Similarity Ranking]

F --> G[Cross Encoder Re-ranking]

G --> H[Natural Language Inference]

H --> I[Source Trust Scoring]

I --> J[Weighted Decision Engine]

J --> K[Final Verdict + Supporting Evidence]
Loading

πŸ” How Factify Works

1. Claim Submission

The user submits a claim through the web interface.

Example:

"WHO has officially declared chocolate as a cure for diabetes."


2. Evidence Retrieval

Relevant articles are retrieved using Google News APIs and trusted news sources.

Examples include:

  • Reuters
  • BBC
  • AP News
  • WHO
  • Al Jazeera
  • Wikipedia

3. Text Processing

Retrieved articles are cleaned before analysis.

This includes:

  • removing HTML artifacts
  • whitespace normalization
  • chunking articles
  • preprocessing text

4. Semantic Retrieval

Factify converts both the claim and evidence into dense vector representations using Sentence-BERT.

Model used:

all-MiniLM-L6-v2

The embeddings are compared using cosine similarity to identify the most relevant evidence.


5. Cross Encoder Re-ranking

The top retrieved articles are passed through a Cross Encoder model.

Unlike SBERT, the Cross Encoder evaluates the claim and evidence together, producing a more accurate relevance score.

This improves evidence quality before reasoning.


6. Natural Language Inference

The selected evidence is analyzed using an NLI model to determine whether it:

  • βœ… Supports the claim
  • ❌ Contradicts the claim
  • βšͺ Provides insufficient evidence

Rather than simply predicting "Fake" or "Real", the model reasons over retrieved evidence.


7. Credibility Scoring

Factify considers source reliability during verification.

Examples:

Source Trust Score
WHO 1.00
Reuters 0.96
BBC 0.95
AltNews 0.98

Topic-specific trust boosts further improve evidence weighting.


8. Final Verdict

The final decision combines multiple signals:

  • Semantic Similarity
  • Cross Encoder Score
  • NLI Confidence
  • Source Trust
  • Topic Relevance

These scores are combined using a weighted ensemble to generate the final confidence score and verdict.


πŸ’» Technology Stack

Backend

  • Django
  • Python

Frontend

  • HTML
  • CSS
  • JavaScript

AI / Machine Learning

  • Hugging Face Transformers
  • SentenceTransformers
  • Scikit-learn

NLP

  • Sentence-BERT (all-MiniLM-L6-v2)
  • Cosine Similarity
  • Natural Language Inference

Data Collection

  • Google News API
  • BeautifulSoup
  • Requests

Database

  • SQLite

πŸ“ Project Structure

Factify/
β”‚
β”œβ”€β”€ Factify/                # Django configuration
β”‚
β”œβ”€β”€ news/
β”‚   β”œβ”€β”€ ml_model/           # ML models & vectorizers
β”‚   β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ utils.py
β”‚   β”œβ”€β”€ models.py
β”‚   β”œβ”€β”€ views.py
β”‚   └── urls.py
β”‚
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ manage.py
└── README.md

βš™οΈ Installation

1. Clone the Repository

git clone https://github.com/yourusername/Factify.git](https://github.com/Kevhand/Factify-Fact-Checking
cd Factify

2. Create a Virtual Environment

python -m venv venv

Activate it:

Windows

venv\Scripts\activate

Linux / macOS

source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

Create a .env file in the project root.

DJANGO_SECRET_KEY=your_django_secret_key

GOOGLE_NEWS_API_KEY=your_google_news_api_key

GOOGLE_SEARCH_API_KEY=your_google_custom_search_api_key

GENERAL_CX=your_general_search_engine_id
TECH_CX=your_tech_search_engine_id
MEDICAL_CX=your_medical_search_engine_id
FINANCE_CX=your_finance_search_engine_id
POLITICS_CX=your_politics_search_engine_id

Required API Keys

Variable Description
DJANGO_SECRET_KEY Secret key for Django
GOOGLE_NEWS_API_KEY Google News API access
GOOGLE_SEARCH_API_KEY Google Custom Search API key
GENERAL_CX Search Engine ID for general queries
TECH_CX Search Engine ID for technology-related claims
MEDICAL_CX Search Engine ID for medical claims
FINANCE_CX Search Engine ID for finance-related claims
POLITICS_CX Search Engine ID for political claims

5. Apply Database Migrations

python manage.py migrate

6. Start the Development Server

python manage.py runserver

Visit:

http://127.0.0.1:8000/

▢️ Usage

  1. Register or log in.
  2. Enter a claim to verify.
  3. Factify retrieves evidence from trusted sources.
  4. Relevant evidence is ranked using semantic similarity.
  5. NLI determines whether the evidence supports or contradicts the claim.
  6. The final verdict, confidence score, and supporting evidence are displayed to the user.

πŸš€ Future Improvements

  • Multi-language fact verification
  • Knowledge graph integration
  • Explainable AI visualizations
  • Fine-tuned domain-specific NLI models
  • Live social media claim verification
  • Vector database integration (FAISS)
  • RAG-based evidence summarization
  • LLM-generated natural language explanations
  • User feedback loop for continuous improvement

πŸ“œ License

This project is licensed under the MIT License.


πŸ‘¨β€πŸ’» Author

Developed by Yash Singh

If you found this project interesting, consider giving it a ⭐ on GitHub.

About

AI-powered claim verification platform using semantic retrieval, SBERT, Cross-Encoder reranking, and Natural Language Inference (NLI) to generate evidence-based verdicts from trusted sources.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages