A document QA system that performs reasoning-based retrieval — no embeddings, no vector database, no chunking. The LLM navigates a hierarchical document tree like a human expert.
Traditional RAG: docs → chunk → embeddings → vector DB → similarity search
PageIndex RAG: docs → hierarchical tree index → LLM reasoning traversal → retrieve sections
- Upload a PDF → PageIndex builds a hierarchical tree structure locally (using OpenAI)
- Ask a question → LLM navigates the tree, selecting relevant sections by reasoning over summaries
- Get an answer → text is extracted from the selected page ranges, and the LLM generates a cited answer
| Vector RAG | Vectorless RAG |
|---|---|
| Chunks destroy context | Natural document sections preserved |
| Similarity ≠ relevance | LLM reasons about relevance |
| Opaque retrieval | Explainable navigation path |
| Requires vector DB infra | Just OpenAI API |
pip install -r requirements.txtcp .env.example .env
# Edit .env and set your OPENAI_API_KEY (and CHATGPT_API_KEY to the same value)uvicorn backend.main:app --reload --port 8000python frontend/gradio_app.pyOpen http://localhost:7860 → Upload a PDF → Ask questions!
python scripts/build_index.py path/to/document.pdfvectorless-rag/
├── backend/
│ ├── main.py # FastAPI app (upload, query, documents)
│ ├── config.py # Environment config
│ ├── models/schemas.py # Pydantic request/response models
│ ├── services/
│ │ ├── pageindex_service.py # Local PageIndex tree generation
│ │ └── query_service.py # LLM tree navigation + answer generation
│ └── utils/pdf_loader.py # PyMuPDF text extraction
├── frontend/
│ └── gradio_app.py # Gradio UI
├── scripts/
│ └── build_index.py # CLI for offline indexing
├── storage/
│ ├── documents/ # Uploaded PDFs
│ └── indexes/ # Generated tree JSONs
├── requirements.txt
├── .env.example
└── README.md
- Python + FastAPI — backend API
- Gradio — frontend UI
- PageIndex (open-source) — hierarchical tree generation
- OpenAI API — LLM for tree generation and query reasoning
- PyMuPDF — PDF text extraction
| Method | Endpoint | Description |
|---|---|---|
POST |
/upload |
Upload PDF, generate tree index |
POST |
/query |
Ask a question about a document |
GET |
/documents |
List uploaded documents |
GET |
/health |
Health check |