# PageIndex

> Vectorless, reasoning-based RAG that builds a tree index from long documents

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: MIT
- Repository: https://github.com/VectifyAI/PageIndex
- Website: https://pageindex.ai
- Canonical page: https://ai-tldr.dev/tools/pageindex/

## In short

PageIndex is an open-source RAG system that works without a vector database and without chunking. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed MIT. To get started: install dependencies.

## Overview

PageIndex is an open-source RAG system that works without a vector database and without chunking. Instead of matching text by vector similarity, it builds a hierarchical tree index from a long document, much like a table of contents, and lets an LLM reason over that tree to find the sections that are actually relevant.

The approach is aimed at long, professional documents such as financial reports, regulatory filings, legal manuals, and academic textbooks that exceed an LLM's context window. Because retrieval is driven by reasoning and grounded in explicit page and section references, every result is traceable and easier to explain than opaque vector search.

You can self-host the project with this repository using standard PDF parsing, or use the hosted cloud service and API for enhanced OCR and tree building.

## What it does

- No vector database: retrieval uses document structure and LLM reasoning instead of vector similarity search
- No chunking: documents are organized into natural sections rather than artificial fixed-size chunks
- Builds a semantic tree (table-of-contents style) index from long PDFs, with node IDs, summaries, and page ranges
- Traceable, explainable retrieval grounded in explicit page and section references
- Context-aware retrieval that can take conversation history and domain knowledge into account
- Markdown input support and multi-LLM support via LiteLLM

## Getting started

Self-host PageIndex to generate a tree structure from a PDF document. You need Python and an LLM API key.

1. Install dependencies

   Install the required Python packages from the repository's requirements file.

```bash
pip3 install --upgrade -r requirements.txt
```

2. Set your LLM API key

   Create a .env file in the root directory with your LLM API key. Multiple LLM providers are supported through LiteLLM.

```bash
OPENAI_API_KEY=your_openai_key_here
```

3. Generate a PageIndex tree for your PDF

   Run the script against your document to build its tree structure index. A --md_path flag is also available for Markdown files.

```bash
python3 run_pageindex.py --pdf_path /path/to/your/document.pdf
```

4. Try the agentic vectorless RAG demo

   Install the optional dependency and run the included end-to-end example, which uses self-hosted PageIndex with the OpenAI Agents SDK.

```bash
pip3 install openai-agents
python3 examples/agentic_vectorless_rag_demo.py
```

## When to use it

- Question answering over long financial reports, SEC filings, and earnings disclosures
- Reasoning-based retrieval across regulatory, legal, or technical manuals that exceed an LLM context window
- Searching and extracting answers from academic textbooks and other complex long-form PDFs
- Building agentic RAG pipelines where retrieval needs to be traceable and explainable instead of relying on vector similarity
