Back to Portfolio

Agentic HybridRAG Knowledge Engine

Production-grade Retrieval-Augmented Generation system combining vector search, knowledge graphs, and intelligent agentic reasoning with local LLMs

Project Overview

A sophisticated RAG system that uses phi3:mini for intelligent routing between vector databases and knowledge graphs, with two-phase extraction to prevent relation loss across document chunks. The system achieves 97% relation preservation compared to 53% with traditional chunk-local methods.

Key Features

  • • Intelligent Agentic Routing: LLM-powered agent automatically selects optimal retrieval strategy - vector-only for explanations, graph-only for facts, or hybrid for comparisons
  • • Two-Phase Extraction Pipeline: Solves cross-chunk relation problem with global entity registry, reducing relation loss from 47% to just 3%
  • • Anti-Hallucination Grounding: Strict prompt engineering prevents LLMs from inventing facts or using external knowledge
  • • 100% Local Deployment: Runs entirely with Ollama - no API costs, ensuring data privacy and security
  • • Fully Tested: 56/56 comprehensive tests passing covering planning, vector retrieval, graph retrieval, and end-to-end integration
  • • Production-Ready: Docker-deployed with one-command setup, battle-tested on multi-document knowledge bases

Technical Stack

Python FastAPI React Ollama Neo4j ChromaDB Docker LangChain

Performance Benchmarks

The system demonstrates exceptional performance across key metrics:

  • • Entity Extraction: 95% accuracy with LLM-based extraction (phi3:mini), compared to 70% with spaCy NER
  • • Relation Recall: 92% with two-phase extraction vs 45% with traditional methods
  • • Cross-Chunk Relations: 97% preserved (up from 53% with chunk-local extraction)
  • • Query Response Time: 0.5s for factual queries, 1.2s for explanatory, 1.8s for hybrid comparisons

Implementation Highlights

This project showcases advanced AI engineering principles with a multi-agent architecture where specialized agents handle different aspects of the query processing pipeline:

  • • Phase 1 - Entity Discovery: Scans all document chunks to build a global entity registry with deduplication
  • • Phase 2 - Relation Extraction: Uses global entity context to extract relationships, preventing cross-chunk information loss
  • • Agentic Routing: Analyzes question semantics to determine optimal retrieval strategy (vector/graph/hybrid)

Key Contributions

  • • Solves the chunk boundary problem in multi-document RAG systems
  • • Global entity registry for cross-chunk entity tracking and relation validation
  • • Automatic database selection based on question semantics using agentic reasoning
  • • Comprehensive test suite ensuring production reliability
View on GitHub