Overview
This guide will walk you through generating your first PageIndex tree structure from a PDF document. You’ll transform a lengthy PDF into a hierarchical, semantic tree index optimized for LLM-powered retrieval.PageIndex is ideal for financial reports, regulatory filings, academic textbooks, legal or technical manuals, and any document that exceeds LLM context limits.
1
Install Dependencies
Install the required Python packages using pip:This will install:
openai==1.101.0- OpenAI API clientpymupdf==1.26.4- PDF parsingPyPDF2==3.0.1- Additional PDF utilitiespython-dotenv==1.1.0- Environment variable managementtiktoken==0.11.0- Token countingpyyaml==6.0.2- Configuration file support
2
Configure Your OpenAI API Key
Create a
.env file in the root directory and add your OpenAI API key:3
Run PageIndex on Your PDF
Process your PDF document to generate the tree structure:PageIndex will:
- Parse your PDF and extract text content
- Detect the table of contents (if present)
- Generate a hierarchical tree structure with summaries
- Save the output as a JSON file in
./results/
4
Explore the Generated Tree
Open the generated JSON file to explore your document’s tree structure:Each node contains:
title- Section headingnode_id- Unique identifierstart_index/end_index- Page rangesummary- AI-generated section summarynodes- Nested subsections (if any)
Customization Options
PageIndex supports various optional parameters to customize tree generation:Available Parameters
Markdown Support
PageIndex also supports markdown files. Use the--md_path flag instead:
PageIndex uses
# markers to determine node hierarchy. Ensure your markdown file has proper heading structure (## for level 2, ### for level 3, etc.).Next Steps
Vectorless RAG Cookbook
Build a complete reasoning-based RAG system with PageIndex
API Reference
Explore the full Python API and configuration options
Tree Search Tutorial
Learn how to perform reasoning-based retrieval over the tree
Example Documents
See sample PDFs and their generated tree structures