RAPTOR · retrieval

Also known as: Recursive Abstractive Processing for Tree-Organized Retrieval

On this page 7

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.

  1. Chunking: the source text is split into short chunks, about 100 tokens in the original work, while keeping sentences intact.
  2. Embedding: each chunk is converted into a dense vector, originally with an SBERT-style embedding model.
  3. Clustering: vectors are reduced in dimension with UMAP and grouped with Gaussian mixture models.
  4. Summarization: a language model writes one summary for each cluster.
  5. 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.

LayerContentBest suited for
Leaf layerOriginal text chunksExact facts, quotes, figures
Intermediate layersSummaries of related chunk clustersSection-level themes and events
Upper layersSummaries of summariesDocument-wide arguments and plot
Root layerA few highly condensed nodesVery broad overview questions
Layers of a RAPTOR tree

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.

ModeSelection ruleStrengthWeakness
Tree traversalTop-k per layer, descendingPredictable layer mixFixed granularity per query
Collapsed treeGlobal top nodes up to a token limitAdapts detail level to the querySearches every node
Comparison of RAPTOR retrieval modes

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.

MethodIndex structureHandles broad questionsIndexing cost
Standard RAGFlat list of chunksPoorlyLow
Parent document retrievalSmall chunks linked to larger parentsPartly, within one sectionLow
RAPTORTree of cluster summariesWell, across the documentModerate to high
GraphRAGEntity graph with community summariesWell, across a corpusHigh
RAPTOR and neighboring retrieval methods

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.

SituationRecommendationReason
Questions about whole books or reportsUse RAPTOR, collapsed modeSummaries capture distributed themes
Mostly factoid lookupsKeep standard chunk retrievalLeaf chunks already suffice
Frequently updated corpusUse with cautionChanges force partial tree rebuilds
Strict factual accuracy requiredVerify summaries or cite leavesSummaries can contain errors
Decision guide for adopting RAPTOR

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.