What is RAPTOR and how does it improve RAG for long documents?
RAPTOR or Recursive Abstractive Processing for Tree-Organized Retrieval is a technique that builds a hierarchical tree of summaries over document chunks. Starting with leaf-level chunks, RAPTOR clusters semantically similar chunks, generates summaries of each cluster, and recursively repeats this process to create higher-level summaries covering broader document themes. The resulting tree has detailed chunks at the leaves and increasingly abstract summaries at higher levels. During retrieval, the system can match queries against both detailed chunks for specific questions and high-level summaries for thematic or abstract questions. This addresses a fundamental limitation of standard RAG which struggles with questions requiring synthesis across multiple document sections. RAPTOR effectively captures both local details and global document themes, improving answer quality for questions ranging from specific facts to broad analytical queries about long documents.