Retrieve without embeddings. Parse PDFs into a hierarchical document tree, then let a LangGraph agent reason through the structure to find answers with page-level citations. Zero vector database costs, zero chunking artifacts.
Start learning at learnwithparam.com. Regional pricing available with discounts of up to 60%.
- Build a layout-aware PDF parser that produces a hierarchical
TreeNodestructure - Replace vector similarity search with LLM reasoning over a document tree
- Design a LangGraph state machine that analyzes, routes, retrieves, and generates
- Cache document trees to disk so repeated questions skip expensive parsing
- Return grounded answers with page ranges and section titles as citations
- Python 3.11+ with
uvfor dependency management - LangGraph for agent state graphs and conditional routing
- PyMuPDF and pymupdf4llm for layout-aware PDF parsing
- OpenAI (or any OpenAI-compatible client) for reasoning calls
- Pydantic for typed state validation
- Docker for reproducible runs
- Python 3.11+
- uv (installed automatically by
make setup) - An OpenAI API key
# One command to set up and run
make dev
# Or step by step:
make setup # Create .env and install dependencies
# Edit .env with your API key
make run # Parse the PDF, build the tree, answer the sample questionsmake build # Build the Docker image
make up # Run the container
make logs # View logs
make down # Stop the container- Downloads the Google Bigtable paper on first run
- Parses the PDF into a
DocumentTreeand caches it atresults/document_tree.json - Renders the LangGraph workflow as
results/workflow.png - Answers the questions in
questions.py, printing reasoning, confidence, path, and sources
Edit questions.py to ask your own questions, or point main.py at a different PDF to index a new document.
Work through these incrementally to build the full system:
- PDF to Tree - Convert a raw PDF into a
TreeNodehierarchy using PyMuPDF4LLM - Tree Caching - Serialize the tree to JSON and reload it on subsequent runs
- Section Summaries - Generate a short summary per node so the agent can judge relevance cheaply
- Analyze Node - LLM call that scores how relevant the current node is to the query
- Conditional Routing - Decide between descending, retrieving, or backtracking based on confidence
- Retrieve and Generate - Collect the full text of selected nodes and synthesize the final answer
- Workflow Visualization - Render the state graph to a PNG for debugging
- Multi-Document Trees - Extend the system to search across many documents in one tree
make help Show all available commands
make setup Initial setup (create .env, install deps)
make dev Setup and run (one command!)
make run Run the vectorless RAG pipeline
make build Build Docker image
make up Start container
make down Stop container
make logs View container logs
make clean Remove venv, caches, and generated results
- Start the course: learnwithparam.com/courses/vectorless-rag
- AI Bootcamp for Software Engineers: learnwithparam.com/ai-bootcamp
- All courses: learnwithparam.com/courses