Agentic RAG · Multi-Agent System

An AI Exam Tutor
for Marine Structures

A LangGraph-powered multi-agent system with Self-RAG reflection, three-layer indexing, and knowledge graph reasoning — demonstrating the full evolution from naive RAG to production-grade agentic RAG.

From Naive RAG to Agentic RAG

This project is not a "plug data into LangChain" demo. It traces the full RAG evolution path.

Stage 1
Naive RAG
Dense + Sparse Hybrid
RRF Fusion
Stage 2
Advanced RAG
Cross-encoder Rerank
Multi-strategy Chunking
Stage 3
Agentic RAG
Supervisor + 5 Specialist Agents
Self-RAG Reflection Loop
Stage 4
Production
FastAPI SSE + Docker
RAGAS Evaluation + A/B Testing

Multi-Agent Orchestration

LangGraph state machine coordinates 6 specialized agents through a Supervisor pattern.

Interface CLI (Rich) · Gradio UI · FastAPI SSE
Agents
🧠
Supervisor
Plan & Route
🔍
Retrieval
Search + Self-RAG
📖
Concept
Explain Theory
📐
Calc
Solve Problems
📝
Exam
Generate & Grade
Critic
Validate Output
Tools Shared Tool Layer dense_search · sparse_search · graph_traverse · formula_lookup · rerank
Index Three-Layer Indexing Dense Vectors (ChromaDB+BGE-M3) · Sparse Keywords (BM25) · Knowledge Graph (NetworkX)
Infra Infrastructure Docker Compose · LangSmith · RAGAS · CI/CD

What Makes This Stand Out

Every component is deliberately chosen and production-hardened.

🤖

6-Agent System

Supervisor orchestrates Retrieval (with Self-RAG reflection), Concept, Calculation, Exam, and Critic agents — each specialized for its task.

🔄

Self-RAG Reflection

Retrieval agent evaluates result sufficiency and rewrites queries for re-retrieval — inspired by Self-RAG (Asai et al., 2023) and Corrective RAG (Yan et al., 2024).

🗂️

Three-Layer Indexing

Dense vectors (BGE-M3) + Sparse keywords (BM25) + Knowledge Graph (NetworkX, 79 nodes, 269 edges) for structured concept-formula-exam traversal.

🌐

Cross-lingual

BGE-M3 multilingual embeddings handle English lectures and Chinese study notes in one unified semantic space — no translation needed.

📊

Evaluation-driven

RAGAS metrics (faithfulness, context precision/recall, answer relevancy) with A/B strategy comparison — data-driven, not gut-feel.

🚀

Production-ready

FastAPI + SSE streaming + Docker Compose one-command deployment + LangSmith observability — not a notebook, a deployable system.

738 Chunks Across 5 Sources

Source-aware chunking strategy — the most critical hyperparameter for retrieval quality.

SourceDocumentsChunksStrategyMetadata
Lecture Slides21 PDFs · 582 pages2003-slide merged windowslecture_number, slide_range, topic_tags
Exam Papers9 years (2014–2025)25Question-boundary splityear, question_number, marks, content_type
Answer Keys3 years (2022–2025)15Sub-question paired chunksyear, question_number, sub_question
Seminar Solutions4 Tutorials23Tutorial → Question hierarchicaltutorial_number, language
Chinese Study Notes12 Markdown files475Markdown header-awarefile_topic, breadcrumb, language
Total738Each chunk carries rich metadata for filtered/scoped retrieval

Every Choice Has a Reason

No defaults-for-defaults'-sake. Each component selected via deliberate trade-off analysis.

DeepSeek V4 Pro
LLM — Strong Chinese+math reasoning
LangGraph
Agent Framework — State machine multi-agent orchestration
BGE-M3
Embedding — 1024-dim, multilingual, local & free
ChromaDB
Vector DB — Zero-ops, metadata filtering
BM25
Sparse Retrieval — Exact formula/term matching
BGE-Reranker-v2
Cross-encoder precision boost
NetworkX
Knowledge Graph — 79 nodes, 269 edges
FastAPI + SSE
Backend — Async streaming responses
Gradio + Rich
UI — Web interface + polished CLI
RAGAS
Evaluation — 5 ground-truth test cases
Docker Compose
One-command production deployment
LangSmith
Observability — Agent call chain tracing

5 Iterations, 10 Days

Each iteration builds on the last, deliberately growing complexity.

ITERATION 0

Basic RAG

Document processing, 738 chunks, three-layer indexing (dense+sparse+KG placeholder), hybrid retrieval with RRF fusion, CLI with Rich

ITERATION 1

Agentic Upgrade

LangGraph state graph, Supervisor agent with planning+routing, Retrieval agent with Self-RAG reflection loop, Concept & Calc specialist agents

ITERATION 2

Knowledge Graph

79-node, 269-edge knowledge graph (Concept↔Formula↔Lecture↔Exam), graph-traversal enhanced search, Exam Agent (generate + grade), Critic Agent (hallucination check)

ITERATION 3

Productionization

FastAPI backend with SSE streaming, Docker Compose deployment, RAGAS evaluation framework with 5 ground-truth cases, A/B strategy comparison

ITERATION 4

Polish

Gradio Web UI, comprehensive testing, bilingual README (Chinese+English), project website