RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval

algorithm 2401.18059
ragretrievalhierarchical-summarizationgmm-clusteringlong-document-qa

RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval — L2 #

1. TL;DR #

RAPTOR builds a bottom-up tree over a corpus by recursively embedding, soft-clustering (UMAP+GMM), and LLM-summarizing chunks, so retrieval can pull context at multiple abstraction levels. Coupled with GPT-4 it lifts QuALITY from 62.3% → 82.6% absolute.

2. Q1 / Q2 / Q3 #

Q1 — 痛点 (problem formulation) #

Standard retrieval-augmented LMs index a corpus as short (~100-token) contiguous chunks and return the top-k by cosine similarity. This works for locally-answerable factoid questions but fails on thematic / multi-hop questions that require synthesizing evidence spread across a long document (e.g. "How did Cinderella reach her happy ending?" over an entire fairy tale). The top-k contiguous chunks simply do not co-locate the needed facts. Prior recursive-summarization fixes (Wu et al. 2021; LlamaIndex) group text by adjacency, so they miss distant interdependencies. The algorithmic object here is not a loss — it is an index construction procedure plus a retrieval policy: one build step consumes a document and produces a multi-layer tree; one query step consumes a question embedding and produces a token-bounded context set.

Q2 — 方法 (the novel mechanism) #

The one novel mechanism: retrieve from a tree whose non-leaf nodes are LLM summaries of semantically-clustered (not adjacent) children, so a single similarity search can select nodes at whatever abstraction level the query needs. Concretely, cluster leaf embeddings with a Gaussian Mixture Model over UMAP-reduced vectors (soft membership → a chunk can join multiple summaries), summarize each cluster with gpt-3.5-turbo, re-embed, and recurse until clustering is infeasible. At query time the collapsed tree flattens all layers into one pool and greedily fills a 2000-token budget by cosine similarity.

核心技术壁垒: the soft, semantic, dimensionality-aware clustering pipeline — UMAP (global-then-local n_neighbors) → GMM with BIC-selected component count → EM. This is what lets nodes belong to multiple parents and lets summaries capture distant interdependencies rather than merely adjacent ones. Reproducing the headline numbers depends on getting this clustering right, not on the (trivial) tree traversal code (see §7).

Q3 — 结果 (results) #

Across NarrativeQA, QASPER, QuALITY, RAPTOR added to any retriever (SBERT / BM25 / DPR) beats that retriever without it, and RAPTOR+SBERT+GPT-4 sets new SOTA on QASPER (55.7 F1) and QuALITY (82.6% test, 76.2% hard), plus a new NarrativeQA METEOR SOTA with UnifiedQA (19.1). The QuALITY gain (+20.3 absolute over prior best) is far larger than the single-digit gains on QASPER/NarrativeQA.

3. 架构 / 方法图 #

Figure 1: RAPTOR tree construction — cluster, summarize, recurse

Paper's Figure 1, verbatim (caption: "Tree construction process: RAPTOR recursively clusters chunks of text based on their vector embeddings and generates text summaries of those clusters, constructing a tree from the bottom up. Nodes clustered together are siblings; a parent node contains the text summary of that cluster.").

The leaf layer is 100-token SBERT-embedded chunks; each higher layer is formed by (1) clustering and (2) LLM summarization, and a node stores its summary text plus pointers to its child indices (e.g. node #8 = "summary of nodes 2 and 3"). The whole tree is the index — nothing is discarded, so both raw detail (leaves) and thematic abstraction (upper nodes) are simultaneously retrievable.

Figure 2: Tree-traversal vs collapsed-tree retrieval

Paper's Figure 2, verbatim (caption: "Illustration of the tree traversal and collapsed tree retrieval mechanisms... The nodes on which cosine similarity search is performed are highlighted in both illustrations.").

The reader should notice the key structural difference the authors exploit: tree traversal keeps a fixed ratio of nodes per layer (breadth/depth set by d,k), whereas the collapsed tree searches all nodes at once and thus adapts the granularity mix per-question — the stated reason collapsed tree wins.

flowchart TB A[Corpus] --> B[100-token chunks] B --> C[SBERT embed = leaf nodes] C --> D[UMAP reduce dim] D --> E[GMM soft-cluster
BIC picks K, EM fits] E --> F[gpt-3.5-turbo summarize each cluster] F --> G[Re-embed summaries] G -->|clustering still feasible| D G -->|infeasible| H[Root layer done]

The Mermaid adds the recursion/termination logic that the raster Figure 1 shows only implicitly.

4. 作者证明 #

RAPTOR has 无形式化作者证明 — 仅实证 for its central claim (a tree index improves retrieval): there is no convergence theorem, regret bound, or sample-complexity result. The only formal content is the GMM/BIC machinery used inside clustering, reproduced below. A desirable-but-absent guarantee would be a statement bounding retrieval recall of the "relevant abstraction level" as a function of tree depth and cluster purity.

Notation table

SymbolMeaning
$x$$d$-dim dense embedding of a text segment
$k$index of the $k$th Gaussian component (also: param count in BIC)
$K$number of Gaussian components (clusters)
$\mu_k, \Sigma_k$mean / covariance of the $k$th Gaussian
$\pi_k$mixture weight of the $k$th Gaussian
$N$number of text segments
$\hat{L}$maximized likelihood of the fitted GMM

方程物理意义

Per-component likelihood — probability that embedding $x$ was generated by cluster $k$; this is the basis of soft membership:

$$P(x \mid k) = \mathcal{N}(x; \mu_k, \Sigma_k)$$

Overall mixture — total density is a weighted sum over $K$ Gaussians, so a point carries nonzero membership in several clusters (the motivation for GMM over hard k-means):

$$P(x) = \sum_{k=1}^{K} \pi_k \, \mathcal{N}(x; \mu_k, \Sigma_k)$$

Model selection — BIC picks the cluster count by trading fit against complexity; $\ln(N)k$ penalizes parameters, $-2\ln(\hat{L})$ rewards fit:

$$\mathrm{BIC} = \ln(N)\,k - 2\ln(\hat{L})$$

6 minimum checks

  1. Assumptions: GMM assumes each cluster is Gaussian in the (UMAP-reduced) embedding space. The authors concede text embeddings are "sparse and skewed," so this is empirically-justified, not proven; it breaks when a cluster is multimodal or heavy-tailed.
  2. Soft-clustering validity: soundly requires $\pi_k \ge 0,\ \sum_k \pi_k = 1$; the "membership in multiple clusters" claim follows directly from nonzero posteriors, so it is internally consistent.
  3. BIC parameter count: $k$ in BIC is "a function of the dimensionality of the input vectors and the number of clusters." Since UMAP fixes dimensionality before BIC, the complexity penalty is well-defined per fit — but the paper does not spell out how UMAP dimension feeds $k$ (flagged in §6).
  4. Two-stage clustering: varying UMAP n_neighbors to do global-then-local clustering is a heuristic; there is no proof the global/local split recovers the true hierarchy, only the ablation that full-tree search beats single-layer (Table 8).
  5. Recursion termination: recursion stops when "further clustering becomes infeasible"; a local cluster exceeding the summarizer token limit triggers inner re-clustering, guaranteeing each summarization call stays within context — a well-defined stopping rule.
  6. Cost claim: linear token & time scaling (Appendix A) is empirical (12.5k–78k tokens on M1/16GB), consistent with each level compressing by ~72% so total work is a geometric series bounded linearly in input length.
  7. 5. 实验与数据 #

    RAPTOR + a fixed retriever beats that retriever without the tree, across all three datasets and metrics — the controlled "with vs without" comparison that isolates the tree's contribution.

    Table 1: NarrativeQA with/without RAPTOR

    Paper's Table 1 (UnifiedQA-3B reader). Every retriever (SBERT/BM25/DPR) improves once RAPTOR is added, e.g. BM25 ROUGE 23.52% → 27.93%; the biggest lift is for the weakest baseline (BM25), foreshadowing that RAPTOR's marginal value shrinks as the base retriever strengthens.

    Table 3: Controlled QASPER F-1 across readers

    Paper's Table 3. RAPTOR beats DPR by 1.8/2.7/4.5 F1 and BM25 by 6.5/5.5/10.2 F1 for GPT-3/GPT-4/UnifiedQA. Notice the GPT-4 margin over DPR (+2.7) is smaller than the UnifiedQA margin (+4.5) — retrieval quality matters less when the reader is stronger.

    Table 7: QuALITY test + hard subset vs SOTA

    Paper's Table 7. The load-bearing result: RAPTOR+GPT-4 hits 82.6% (vs prior best 62.3%) and 76.2% on the HARD subset (+21.5 over CoLISA). This is the single figure the abstract's "20% absolute" claim rests on.

    Table 8: querying different tree layers (Story 1, QuALITY)

    Paper's Table 8 (§4.1 ablation). Full 3-layer search (73.68) beats leaf-only (57.9), confirming upper nodes carry the thematic signal. Note the non-monotonicity: 2 layers from Layer 1 (52.6) is worse than leaf-only before the full tree helps — adding one intermediate layer alone can hurt.

    Figure 7: fraction of retrieved nodes per layer

    Paper's Figure 7 (Appendix I). Between 18.5% and 57% of retrieved nodes are non-leaf (peaking for DPR on NarrativeQA), quantitative evidence that the summary layers are actually used, not decorative.

    6. 论证链 #

    #ClaimSupport (paper-internal)
    1Chunk-only retrieval cannot answer thematic/multi-hop questions§1 Cinderella example; §2 adjacency-reliance critique of prior summarization trees
    2Semantic (not adjacent) soft-clustering + LLM summaries yield nodes at every abstraction level§3 method; Fig 1 construction; GMM soft-membership math (§3)
    3Adding this tree to any retriever improves QATables 1–4 with/without RAPTOR across SBERT/BM25/DPR
    4Collapsed-tree query > tree-traversal because it adapts granularity per question§3; Fig 3 (20 QASPER stories, collapsed@2000 tokens best)
    5The multi-layer structure (not just leaves) drives the gain§4.1 Table 8 (full-tree > single-layer); Appendix I Tables 18–21 & Fig 7 (18.5–57% non-leaf)
    6Errors do not compound under recursionAppendix E: ~4% summary hallucination, non-propagating, no QA impact
    7Therefore RAPTOR+GPT-4 sets new SOTATables 5–7 (QASPER 55.7, QuALITY 82.6/76.2, NarrativeQA METEOR 19.1)

    7. 实现 cross-reference #

    [实现未公开] at read time — the paper only states "code will be released" (footnote 1 / §6 Reproducibility). Concrete implementation anchors recoverable from the text:

    • Chunking: 100-token contiguous chunks, sentences never split mid-way (§3 Overview).
    • Embeddings: SBERT multi-qa-mpnet-base-cos-v1 for both leaves and summaries (§3).
    • Summarizer + prompt: gpt-3.5-turbo with the exact Appendix D prompt — system "You are a Summarizing Text Portal", user "Write a summary of the following, including as many key details as possible: {context}".
    • Retrieval config: collapsed tree, 2000-token budget ≈ top-20 nodes; 400 tokens for UnifiedQA (512 ctx limit) (§3).
    • kNN: FAISS suggested to make collapsed-tree search efficient (§3).

    核心技术壁垒 (dedicated note): the hardest part to replicate is the clustering pipeline, not the retrieval loop. Getting UMAP's global-then-local n_neighbors schedule, the BIC-driven $K$ selection, and the recursive inner-reclustering-on-token-overflow all consistent is what produces homogeneous, summarizable clusters; the ablation (Table 9, GMM 56.6% vs recency tree 55.8%) shows the clustering choice itself moves the number, so a naive adjacency tree will underperform even with identical embeddings and reader.

    关键实现细节 (easy-to-miss tricks):

    1. Inner re-clustering on overflow — if a cluster's combined text exceeds the summarizer's token limit, RAPTOR recursively clusters within that cluster before summarizing (§3 Clustering); skipping this silently truncates context and degrades upper-node quality.
    2. Token-based (not count-based) retrieval budget — the collapsed tree fills to a token limit because node sizes vary; note the Appendix F Algorithm 2 quirk where total_tokens is incremented unconditionally while append is gated by the if, so the running counter can include never-added nodes (verbatim from the paper's pseudocode).