Skip to main content

Overview

Once you’ve generated a PageIndex tree structure, you need effective strategies to search and retrieve relevant sections. Unlike traditional vector-based RAG (Retrieval Augmented Generation), PageIndex leverages hierarchical structure for more targeted retrieval.
  • Structural Awareness: Understand document hierarchy and relationships
  • Explainable Results: Clear reasoning for why sections were selected
  • Context Preservation: Retrieve parent/child sections together when needed
  • Expert Knowledge Integration: Easily incorporate domain-specific search preferences
  • No Embedding Drift: Structure is explicit, not dependent on embedding model semantics
Tree search excels when:
  • Documents have clear hierarchical structure
  • Section relationships matter for understanding
  • You need to explain retrieval decisions
  • Domain expertise can guide search priority
The simplest strategy is to use an LLM to analyze the tree structure and select relevant nodes.

Simple Tree Search Prompt

Retrieving Node Content

Once you have selected node IDs, retrieve their content:

Advanced Search Strategies

1. Hierarchical Expansion

When a parent node is relevant, include its children:
Search at different granularity levels:
1

Level 1: Top-Level Selection

First, identify relevant top-level sections:
2

Level 2: Subsection Selection

For each selected top-level section, search its subsections:
3

Level 3: Final Content Retrieval

Retrieve the most specific relevant content.

3. Similarity + Structure Hybrid

Combine embedding similarity with structural search:

Integrating Expert Knowledge

Unlike vector-based RAG, PageIndex makes it easy to incorporate domain expertise and user preferences.
1

Define Expert Knowledge

Create domain-specific search rules:
2

Match Query to Knowledge Domain

Identify which expert knowledge applies:
3

Enhanced Search with Preferences

Incorporate knowledge into the search prompt:

Advanced: Monte Carlo Tree Search (MCTS)

PageIndex’s dashboard and retrieval API use a combination of LLM tree search and value function-based Monte Carlo Tree Search (MCTS). Full implementation details will be released soon.

MCTS Overview

MCTS is a search algorithm that:
  1. Selection: Navigate the tree using a value function
  2. Expansion: Expand promising nodes
  3. Simulation: Evaluate node relevance
  4. Backpropagation: Update node values

Simplified MCTS Example

Retrieval Best Practices

Summary-First Approach: Use if_add_node_summary=yes for search, then retrieve full text only for selected nodes.
Context Window Management: When retrieving multiple nodes, consider:
  • Parent node context (prefix_summary)
  • Sibling nodes for completeness
  • Total token count for LLM context window
Avoid Over-Retrieval: Don’t retrieve entire subtrees unless necessary. Be selective to stay within context limits.
Cache Embeddings: If using hybrid search, cache node embeddings to avoid recalculating for every query.

Evaluation Metrics

Evaluate your search strategy:

Precision and Recall

Mean Reciprocal Rank (MRR)

Next Steps