Favicon of PageIndex

PageIndex

PageIndex builds a hierarchical tree index of long PDFs so LLMs can retrieve relevant sections through reasoning, not vector similarity.

PageIndex website screenshot
PageIndex GitHub repository preview

PageIndex is a Python library for building reasoning-based retrieval over long, complex documents like financial reports, legal filings, and technical manuals. Instead of chunking a document and storing vector embeddings, it parses a PDF into a hierarchical tree that mirrors the document's table of contents, then lets an LLM reason over that tree to find relevant sections. It's built for developers working on RAG systems who are hitting accuracy limits with similarity-based vector search on professional documents.

The core idea: similarity search finds text that sounds like the query, but professional documents often need retrieval based on relevance, which requires actual reasoning about structure and context. PageIndex generates a JSON tree with node titles, page ranges, and summaries, then an LLM (or agent) walks that tree the way a human expert would flip through a table of contents to find the right section.

Key features

  • No vector database: retrieval runs on document structure and LLM reasoning instead of embedding similarity search.
  • No chunking: documents are split into natural sections (chapters, subsections) rather than arbitrary fixed-size chunks.
  • Traceable retrieval: every result maps back to explicit page and section references, so you can audit why a section was picked.
  • Context-aware: retrieval can factor in conversation history and other context, not just the query text.
  • Tree structure output: generates a JSON "table of contents" tree with node IDs, page ranges, and per-node summaries.
  • Multi-LLM support: works with any LLM provider supported by LiteLLM, configured via API key in a .env file.
  • Markdown input support: can build a tree from markdown files using heading levels instead of PDF parsing.
  • PageIndex Flash (preview): an LLM-free mode for fast tree generation from PDFs without needing an API key.

Ideal use cases

PageIndex fits well when you're building RAG over long, structured professional documents: SEC filings, earnings reports, legal contracts, regulatory filings, medical literature, or technical manuals with clear sections and a table of contents. It's a good match if you need explainable retrieval, where you can point to the exact section an answer came from, rather than an opaque vector match.

It's also useful for agentic RAG setups, where an LLM agent performs multi-step tree search across a document (or, via the PageIndex File System approach, across many documents) instead of a single similarity lookup.

It's less of a fit for short documents, unstructured text without clear sections, or high-throughput low-latency search over huge corpora where a mature vector index already performs well. The open-source package also relies on standard PDF parsing, so complex or scanned PDFs with poor structure may need the hosted service's enhanced OCR pipeline for reliable results.

Installation

PageIndex is a Python package. Clone the repo, then install dependencies:

pip3 install --upgrade -r requirements.txt

Set an LLM API key in a .env file in the project root (multi-provider support via LiteLLM):

OPENAI_API_KEY=your_openai_key_here

Generate a tree structure from a PDF:

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

Optional flags let you control the model, table-of-contents detection, node size limits, and whether to add node IDs or summaries, for example --model, --max-pages-per-node, --max-tokens-per-node.

For markdown input instead of a PDF:

python3 run_pageindex.py --md_path /path/to/your/document.md

To try the agentic vectorless RAG example with the OpenAI Agents SDK:

pip3 install openai-agents
python3 examples/agentic_vectorless_rag_demo.py

Frequently asked questions

Share:

Stars
35.3K
Forks
3.1K
Last commit
15 hours ago
Repository age
1 year
License
MIT
Self-hosted
No
Activity score
84/100
View Repository
Built with:
Ad
Favicon

 

  
 

Similar to PageIndex

Favicon

 

  
 
Favicon

 

  
 
Favicon