RAPTOR, short for Recursive Abstractive Processing for Tree-Organized Retrieval, is a retrieval indexing method that builds a hierarchical tree of summaries over a document collection, so a query can match fine-grained passages and high-level themes at the same time. In artificial intelligence, and specifically in the area of retrieval & knowledge, it addresses a known weakness of standard retrieval-augmented generation: flat chunk retrieval sees only short, isolated fragments of long texts.
The method was introduced in 2024 by researchers at Stanford University. It clusters semantically similar chunks, asks a language model to summarize each cluster, and repeats the process on the summaries until a compact root layer remains. The result is a retrieval index that supports questions requiring synthesis across many distant parts of a document.
How RAPTOR builds its summary tree
RAPTOR builds its index bottom-up in repeated layers. The leaf layer contains the original text chunks, and every higher layer contains abstractive summaries of clusters from the layer below. Construction stops when the remaining nodes are too few to cluster meaningfully.
- Chunking: the source text is split into short chunks, about 100 tokens in the original work, while keeping sentences intact.
- Embedding: each chunk is converted into a dense vector, originally with an SBERT-style embedding model.
- Clustering: vectors are reduced in dimension with UMAP and grouped with Gaussian mixture models.
- Summarization: a language model writes one summary for each cluster.
- Recursion: summaries are embedded and clustered again, producing the next layer.
The clustering step uses soft clustering, so one chunk can belong to more than one cluster when it touches several themes. The number of clusters is chosen with the Bayesian information criterion, and a global pass followed by a local pass captures both broad and narrow groupings. Oversized clusters are split again so that each summarization call fits the model’s context window.
The table below summarizes what each layer of a typical tree contains.
| Layer | Content | Best suited for |
|---|---|---|
| Leaf layer | Original text chunks | Exact facts, quotes, figures |
| Intermediate layers | Summaries of related chunk clusters | Section-level themes and events |
| Upper layers | Summaries of summaries | Document-wide arguments and plot |
| Root layer | A few highly condensed nodes | Very broad overview questions |
Querying the tree: traversal and collapsed modes
RAPTOR offers two retrieval strategies over the finished tree, and the choice affects both answer quality and token usage. Both rely on cosine similarity between the query embedding and node embeddings.
Tree traversal starts at the top layer, selects the k most similar nodes, then descends to their children and repeats until it reaches the leaves. It enforces a fixed ratio of general to specific information but cannot adapt that ratio to the question. Collapsed tree retrieval flattens all layers into one pool and selects the most similar nodes until a token budget is filled, regardless of their layer.
| Mode | Selection rule | Strength | Weakness |
|---|---|---|---|
| Tree traversal | Top-k per layer, descending | Predictable layer mix | Fixed granularity per query |
| Collapsed tree | Global top nodes up to a token limit | Adapts detail level to the query | Searches every node |
The original experiments found that the collapsed tree mode performed better on most benchmarks, with a budget of about 2,000 tokens. Because every node lives in the same vector index, it can use standard approximate nearest neighbor search and scales to large collections.
RAPTOR compared with other retrieval approaches
RAPTOR is one of several methods that add structure on top of flat chunk retrieval. Its distinguishing feature is that the structure is built from semantic clusters and abstractive summaries rather than from document layout or extracted entities.
| Method | Index structure | Handles broad questions | Indexing cost |
|---|---|---|---|
| Standard RAG | Flat list of chunks | Poorly | Low |
| Parent document retrieval | Small chunks linked to larger parents | Partly, within one section | Low |
| RAPTOR | Tree of cluster summaries | Well, across the document | Moderate to high |
| GraphRAG | Entity graph with community summaries | Well, across a corpus | High |
Parent document retrieval keeps the original document hierarchy, while RAPTOR groups content by meaning, so related passages from distant chapters can share one summary. GraphRAG extracts entities and relations first and is stronger for corpus-wide relational questions, but it usually costs more to build.
When to use RAPTOR and how to configure it
RAPTOR pays off for long, coherent documents such as books, contracts, technical manuals and research reports, where answers depend on information scattered across many pages. It adds little value for collections of short, independent records such as support tickets or product listings.
Practical configuration centers on a few parameters. Chunk size controls leaf detail, the summarization model controls the faithfulness of every upper layer, and the token budget in collapsed mode balances context richness against cost and latency. Teams usually test several budgets with a RAG evaluation set before production.
| Situation | Recommendation | Reason |
|---|---|---|
| Questions about whole books or reports | Use RAPTOR, collapsed mode | Summaries capture distributed themes |
| Mostly factoid lookups | Keep standard chunk retrieval | Leaf chunks already suffice |
| Frequently updated corpus | Use with caution | Changes force partial tree rebuilds |
| Strict factual accuracy required | Verify summaries or cite leaves | Summaries can contain errors |
Limitations and failure modes
The main risk of RAPTOR is that summaries are generated text, not source text. Errors introduced by the summarization model propagate upward, and a confident but wrong summary can be retrieved ahead of the correct leaf chunk.
- Indexing cost grows with corpus size because every cluster requires a language model call.
- Incremental updates are awkward: new documents change clusters, so affected branches must be rebuilt.
- Citation is harder, since a summary node does not map to one exact passage in the source.
- Clustering quality depends on the embedding model; poor embeddings produce incoherent summaries.
A common mitigation is to keep links from each summary to its child chunks, so the generator can quote the original evidence after a summary node has matched the query.
A plain-language summary
Most search tools for AI cut a long text into small pieces and look only at those pieces. That works for simple facts. It fails when the question needs the big picture. RAPTOR adds layers of summaries on top of the pieces.
Think of a textbook with notes on each page, a summary for each chapter and a short overview of the whole book. A question can be answered from whichever level fits best. Small details come from the pages, and broad themes come from the summaries.
An example from practice
A legal team at a mid-sized firm uses a retrieval-augmented assistant to review a 400-page supply agreement with many amendments. With standard chunk retrieval, the question about how liability caps changed over the contract’s life returns isolated clauses, and the assistant misses amendments located far apart in the document.
The team rebuilds the index with RAPTOR. Chunks of about 100 tokens are embedded, clustered and summarized, producing a tree with four layers. One intermediate summary groups every clause that mentions liability limits and their amendments, even though they appear in different appendices.
Using collapsed tree retrieval with a budget of 2,000 tokens, the assistant now retrieves that summary together with the most relevant original clauses. The lawyers receive an answer that traces the cap through three amendments, and they check each statement against the linked source clauses before relying on it.