Skip to content

About

vectorless RAG

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

🌲 Vectorless RAG

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.

How It Works

Traditional RAG:  docs → chunk → embeddings → vector DB → similarity search
PageIndex RAG:    docs → hierarchical tree index → LLM reasoning traversal → retrieve sections
  1. Upload a PDF → PageIndex builds a hierarchical tree structure locally (using OpenAI)
  2. Ask a question → LLM navigates the tree, selecting relevant sections by reasoning over summaries
  3. Get an answer → text is extracted from the selected page ranges, and the LLM generates a cited answer

Why Not Vector RAG?

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

Quick Start

1. Install

pip install -r requirements.txt

2. Configure

cp .env.example .env
# Edit .env and set your OPENAI_API_KEY (and CHATGPT_API_KEY to the same value)

3. Run Backend

uvicorn backend.main:app --reload --port 8000

4. Run Frontend

python frontend/gradio_app.py

Open http://localhost:7860 → Upload a PDF → Ask questions!

CLI: Build Index Offline

python scripts/build_index.py path/to/document.pdf

Project Structure

vectorless-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

Tech Stack

  • 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

API Endpoints

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

About

vectorless RAG

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages