RAPTOR
Recursive Abstractive Processing for Tree-Organized Retrieval. Standard RAG indexes flat chunks — RAPTOR builds a tree. Starting from raw document chunks at the leaves, it recursively clusters and summarizes upward, producing branch nodes that capture related groups and root nodes that abstract entire documents or topic domains. Retrieval can enter the tree at any level, matching the question's scope to the right layer of abstraction.
The Tree Structure
Leaf Nodes
Raw document chunks — the same granular splits used in standard RAG. Each leaf contains a small passage with source metadata. Leaf nodes are best for precise, detail-level questions.
Branch Nodes
Abstractive summaries of related leaf clusters. Nearby or thematically linked chunks are grouped and condensed into a single branch node that captures the shared meaning of the group without repeating all the detail.
Root Nodes
High-level abstractions of entire documents or topic areas. Root nodes compress a full document's meaning into a compact representation — ideal for broad questions that need a panoramic answer, not granular detail.
How Retrieval Works
Top-Down
Start at the root with a broad question. Identify relevant root and branch nodes first, then descend into the matching subtrees to retrieve supporting detail. Efficient for queries where the high-level topic is clear upfront.
Bottom-Up
Find matching leaf chunks first, then ascend to their parent branch and root nodes to gather broader context. Useful when a specific fact is known but surrounding context is needed to interpret it correctly.
Hybrid
Retrieve simultaneously at multiple tree levels — leaves for precision, branches for thematic context, roots for document-level framing. Combines both strategies to optimize for recall on broad questions and precision on specific ones.
Benefits
Multi-granularity
Answer both specific and broad questions from the same index. A question about a single function and a question about an entire system architecture both find the right level of abstraction in the tree.
Compression
Summarized branch and root nodes pack more meaning into fewer tokens. High-level answers can be synthesized from compact summaries rather than injecting dozens of raw chunks into the context window.
Coherence
The tree structure preserves document organization. Retrieved nodes carry awareness of their position in the hierarchy, so answers reflect the logical structure of the source material rather than treating all chunks as equal.