B.Tech Capstone Project: An enterprise-grade, verifiable knowledge engine that unites Knowledge Graph Topological Traversal (GraphRAG), Reciprocal Rank Fusion (RRF) across Dense and BM25 channels, and real-time Natural Language Inference (NLI) Hallucination Detection with sentence-level citation provenance.
Standard Retrieval-Augmented Generation (RAG) deployed in production fails across three fundamental dimensions:
- Context Fragmentation: Fixed-size token chunking breaks relational context between distant entities across sections.
- Multi-Hop Blindspots: Cosine distance in vector space captures single-step lexical-semantic proximity, but cannot traverse dependency chains (e.g.,
Entity A -> PREVENTS -> Phenomenon B -> REQUIRES -> Quorum C). - Hallucination & Non-Attribution: LLMs generate fluent, plausible answers containing fabricated statements with no direct grounding in source texts.
VeriGraph resolves these failure modes through an end-to-end multi-model architecture combining GraphRAG, Hybrid Retrieval (Dense + BM25Okapi), Cross-Encoder Reranking, and an automated NLI Attribution Guard.
┌───────────────────────────────┐
│ Next.js / Web Client │
│ (Real-time SSE Stream + Canvas│
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ FastAPI Gateway Router │
│ (Intent Decomposition Agent) │
└───────────────┬───────────────┘
│
┌─────────────────────────────────┼─────────────────────────────────┐
▼ ▼ ▼
┌───────────────────────┐ ┌───────────────────────┐ ┌───────────────────────┐
│ Dense Vector Store │ │ BM25Okapi Index │ │ Property Graph Engine │
│ (Cosine Semantic Sim) │ │ (Exact Lexical Match) │ │ (Multi-Hop Traversal) │
└───────────┬───────────┘ └───────────┬───────────┘ └───────────┬───────────┘
│ │ │
└─────────────────────────────────┼─────────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ Reciprocal Rank Fusion (RRF) │
│ Score = Σ 1 / (60 + rank) │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ Relevance Reranker │
│ (Breadcrumbs + Entity Density)│
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ Multi-Hop Synthesis Engine │
│ (Grounded Structured Claims) │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ NLI Attribution Guard │
│ (Entailment / Contradiction) │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ Verified Response + Provenance│
│ (Inline Citations + Subgraph) │
└───────────────────────────────┘
Preserves hierarchical heading breadcrumbs (e.g. Distributed Systems > Consensus > Leader Election) within chunk metadata, eliminating pronoun ambiguity during vector lookup.
Parses documents into Subject-Predicate-Object triples (PREVENTS, ELECTS, REPLICATES_TO, ENFORCES, REQUIRES). Uses NetworkX to calculate PageRank centrality and extract
Combines non-comparable similarity scores from vector dot products, BM25 TF-IDF frequencies, and graph degree hops:
Segments generated answers into atomic assertions and runs semantic entailment tests against the retrieved evidence:
-
ENTAILED: Directly corroborated by evidence
$\rightarrow$ Verified badge with inline citation link. -
NEUTRAL: Speculative assertion not in context
$\rightarrow$ Flagged. -
CONTRADICTION: Direct contradiction with corpus evidence
$\rightarrow$ Triggered warning.
Benchmarked across curated multi-hop systems queries comparing Naive Vector RAG vs. Hybrid RAG vs. VeriGraph:
| Evaluation Metric | Baseline 1 (Naive RAG) | Baseline 2 (Hybrid RAG) | VeriGraph (Proposed) | Improvement |
|---|---|---|---|---|
| Faithfulness | 75.9% | 80.4% | 92.0% | +21.2% |
| Answer Relevance | 72.0% | 81.0% | 88.0% | +16.0% |
| Multi-Hop Entity Recall | 65.0% | 80.0% | 95.0% | +46.2% |
| Avg Latency (p95) | 1,137 ms | 604 ms | 670 ms | Production Grade |
| Uncited Hallucinations | High (~24%) | Moderate (~19%) | Zero | 100% Citation Grounded |
- Python 3.12+ (or Docker)
- Git
# 1. Clone the repository
git clone https://github.com/leetcodez/verigraph.git
cd verigraph
# 2. Run based on your Operating System:
# On Windows (Command Prompt or PowerShell):
run.bat
# or:
python run.py
# On Linux / macOS / WSL:
chmod +x run.sh
./run.sh
# or:
python3 run.pyThe launcher will:
- Automatically create a Python virtual environment (
.venv) if one doesn't exist. - Install all required dependencies from
requirements.txt. - Check port availability (defaults to
8080, with automatic fallback if busy). - Launch the server and provide direct dashboard URLs.
Open your browser at:
- Interactive Web Dashboard: http://localhost:8080
- OpenAPI Interactive Documentation: http://localhost:8080/docs
Tip
Seeing the Previous UI or Stale Styles?
If you previously visited localhost:8080, your browser may have cached the older CSS. Perform a Hard Refresh in your browser:
- Windows / Linux:
Ctrl + Shift + RorCtrl + F5 - macOS:
Cmd + Shift + R
python3 -m venv .venv
# Activate environment:
# On Windows:
.venv\Scripts\activate
# On Linux/macOS:
source .venv/bin/activate
pip install -r requirements.txt
python run.pydocker compose up --build# Run 15 unit and integration tests
pytest
# or:
./test_runner.sh.
├── verigraph/
│ ├── config.py # Application settings and environment management
│ ├── core/ # Domain models, exceptions, and logging
│ ├── parsers/ # Markdown, Text, and PDF layout-aware parsers
│ ├── chunking/ # Semantic chunker with heading breadcrumbs
│ ├── embeddings/ # Local deterministic and remote embedders
│ ├── vector_store/ # MemoryVectorStore and BM25Okapi index
│ ├── knowledge_graph/ # NetworkX Property Graph & Entity Extractor
│ ├── retrieval/ # Reciprocal Rank Fusion & Relevance Reranker
│ ├── verification/ # Atomic claim splitter, NLI verifier, attribution
│ ├── llm/ # Multi-hop synthesizer with frontier & local fallbacks
│ ├── engine/ # Central orchestration pipeline and query router
│ └── api/ # FastAPI routes (REST + SSE streaming)
├── frontend/ # Interactive single-page dashboard & SVG visualizer
├── sample_data/ # Reference datasets (Consensus, Zero Trust, GraphRAG)
├── evaluation/ # Empirical benchmark dataset and evaluation runner
├── tests/ # Comprehensive pytest unit and integration test suite
├── Dockerfile # Container image specification
├── docker-compose.yml # Container orchestration manifest
├── run.py # Universal cross-platform launcher (Windows, Mac, Linux)
├── run.bat # Windows 1-click batch launcher
├── run.sh # Linux / macOS launcher
└── test_runner.sh # Automated test and benchmark execution script
Answer: Vector embeddings map text to continuous semantic space, excelling at fuzzy paraphrase matching. However, vector distance cannot capture discrete multi-hop relational dependencies across documents. By coupling Knowledge Graphs with Vector Search via Reciprocal Rank Fusion, VeriGraph performs topological graph traversals (
Entity A -> PREVENTS -> Entity B) while retaining dense semantic search.
Answer: VeriGraph employs an automated NLI (Natural Language Inference) Verification Guard. Responses are decomposed into atomic claims. Each claim is evaluated against retrieved context passages for directional entailment and contradiction. Only claims that satisfy the entailment threshold receive verified attribution badges.
Answer: VeriGraph uses a hybrid architecture: high-speed local semantic embeddings and rule-guided entity extraction run on CPU in milliseconds. All state components (inverted index, property graph, vector store) are memory-mapped and persist to disk, yielding sub-700ms p95 query latency with zero cloud API dependencies.