liveBook · Manning

Summary node

As explained in Retrieval Augmented Generation, The Foundational Ideas

A summary node is a node in a hierarchical retrieval structure whose content summarizes source chunks or lower-level nodes.

A summary node is an LLM-written abstraction over related source chunks or lower-level nodes. It adds a higher-resolution retrieval target to a hierarchy: leaves preserve specific facts, while summary nodes express themes and broader conditions. section 10.2 section 10.0

Summary nodes participate in a recursively built retrieval structure:

  • Related chunks are clustered and summarized into mid-level nodes; those summaries can be clustered again until a root summary covers the corpus. section 10.2
  • A thematic query can match a summary node, while a granular factual query can match a leaf through the same retrieval system. section 10.2 section 10.5.1
  • Soft clustering may let one chunk inform several summaries, making the hierarchy a directed acyclic graph rather than a strict tree. section 10.8
  • Summary generation moves cost to indexing: each summary requires an LLM call once, while later queries can use the resulting retrieval targets. section 10.8

One index, two resolutions

A question about a contract’s broad termination conditions can retrieve a summary node describing the termination clause. A question asking for the specific termination fee can retrieve the underlying leaf chunk instead. section 10.2

Flattening all levels into one vector index preserves summary and leaf content while retaining level, leaf status, and child-count metadata. This is a practical default below about 100,000 chunks; root-down traversal is slower but scales to much larger collections. Cross-document clustering requires boundaries or provenance, because a summary can otherwise merge similar content from different products or tenants. section 10.8 section 10.5.3

Listing 10.7 Collapsed Tree Indexing.
from langchain_core.documents import Document
from langchain_community.vectorstores import Chroma
 
def index_collapsed_tree(nodes: Dict[str, RaptorNode],
                         persist_directory: str) -> Chroma:
    documents = []
    for node_id, node in nodes.items():
        metadata = {
            "id": node.id,
            "level": node.level,
            "is_leaf": node.is_leaf(),
            "children_count": len(node.children)  #A
        }
 
        doc = Document(
            page_content=node.text,
            metadata=metadata
        )
        documents.append(doc)
 
    vectorstore = Chroma.from_documents(
        documents=documents,
        embedding=get_embeddings(),
        collection_name="raptor_collapsed",
        persist_directory=persist_directory
    )
    return vectorstore
 

The listing shows how to store summary nodes and leaves together in a collapsed Chroma index, including level, leaf status, and child-count metadata. section 10.5.1

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains recursive construction, soft clustering, metadata, and indexing tradeoffs, but defers detailed clustering mathematics and traversal implementation.
Examples
Uses contract termination questions, thematic-versus-factual retrieval, and a collapsed Chroma index with structural metadata.
What it assumes
Assumes embeddings and vector retrieval, while introducing recursive summarization, probabilistic clustering, and provenance concerns.
What you can do after
Build it from scratch as a hierarchical or collapsed retrieval index and choose summary traversal based on query resolution and corpus size.
How it connects
Connects hierarchical retrieval with RAG, vector search, soft clustering, summarization, and provenance filtering.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.