How fareedkhan-dev/complex-rag-guide works
This repository presents a document-question-answering RAG system built around a Harry Potter PDF. The documented workflow prepares and indexes the book, anonymizes a question, plans and executes retrieval tasks, replans as evidence arrives, and evaluates the final answer. The README also describes alternate chunking, subgraph-based retrieval and grounding, and answer-quality checks. The notebook is the documented pipeline implementation; helper_functions.py contains reusable text/PDF and evaluation utilities. The notebook source was not sampled, so component-level relationships below rely on the README’s workflow description.
Main entry points: RAG_pipeline.ipynb Task handler · Harry Potter - Book 1 - The Sorcerers Stone.pdf Book PDF · helper_functions.py Text and PDF helpers
Components 22
Document preparation
- Book PDF
Harry Potter - Book 1 - The Sorcerers Stone.pdf - Clean and chunk
RAG_pipeline.ipynb - Text and PDF helpers
helper_functions.py
Retrieval and grounding
- Vectorization
RAG_pipeline.ipynb - Context retriever
RAG_pipeline.ipynb - Retrieval subgraphs
RAG_pipeline.ipynb - Quote retrieval
RAG_pipeline.ipynb - Chunk retrieval
RAG_pipeline.ipynb - Chapter summaries
RAG_pipeline.ipynb - Grounding checks
RAG_pipeline.ipynb
Planning and answers
- Question anonymizer
RAG_pipeline.ipynb - Planner
RAG_pipeline.ipynb - Plan breakdown
RAG_pipeline.ipynb - Task handler
RAG_pipeline.ipynb - Direct answer
RAG_pipeline.ipynb - Replanner
RAG_pipeline.ipynb - Answer synthesis
RAG_pipeline.ipynb - Answer de-anonymizer
RAG_pipeline.ipynb
Evaluation
- RAGAS metrics
RAG_pipeline.ipynb - Metric reporting
helper_functions.py
Other components
- Questioner
- LLM providers
Connections 28
- Book PDF → Clean and chunk: loads and splits
README.md - Clean and chunk → Text and PDF helpers: uses utilities
- Clean and chunk → Vectorization: vectorizes
README.md - Vectorization → Context retriever: provides context
README.md - Context retriever → Retrieval subgraphs: supports focused retrieval
README.md - Questioner → Question anonymizer: asks question
README.md - Question anonymizer → Planner: anonymizes input
README.md - Planner → LLM providers: plans with
README.md - Planner → Plan breakdown: hands off plan
README.md - Plan breakdown → Task handler: creates tasks
README.md - Task handler → Quote retrieval: selects tool
README.md - Task handler → Chunk retrieval: selects tool
README.md - Task handler → Chapter summaries: selects tool
README.md - Task handler → Direct answer: selects tool
README.md - Quote retrieval → Context retriever: retrieves quotes
README.md - Chunk retrieval → Context retriever: retrieves chunks
README.md - Chapter summaries → Context retriever: retrieves summaries
README.md - Task handler → Replanner: submits progress
README.md - Replanner → Task handler: updates tasks
README.md - Replanner → Grounding checks: checks answerability
README.md - Grounding checks → Answer synthesis: permits synthesis
README.md - Answer synthesis → LLM providers: synthesizes with
README.md - Answer synthesis → Answer de-anonymizer: restores names
README.md - Answer de-anonymizer → RAGAS metrics: evaluates response
README.md - RAGAS metrics → Metric reporting: reports metrics
- LLM providers → Planner: returns plan
- LLM providers → Answer synthesis: returns response
- RAGAS metrics → Questioner: delivers verified answer
README.md