liveBook · Manning

ParentDocumentRetriever

As explained in AI Agents and Applications

ParentDocumentRetriever is a LangChain retriever that indexes smaller child chunks while returning their larger parent chunks as retrieval context.

ParentDocumentRetriever improves retrieval context by embedding small child chunks while returning their larger parent chunks. Child chunks match detailed queries precisely; parent chunks preserve surrounding meaning for answer generation. section 8.4.1

Build the retriever from separate search and context layers:

  • Split documents into coarse parent chunks for synthesis, then split each parent into smaller child chunks for granular matching. section 8.4.1
  • Store child chunks and embeddings in a vector store such as Chroma, while storing parent documents in an InMemoryStore. section 8.4.1
  • Configure ParentDocumentRetriever with both splitters and both stores, then ingest the source documents through add_documents(). section 8.4.1
  • Choose child size for search granularity and parent size for context; benchmark against standard vector search before deployment because storage and computational costs increase. section 8.8

Retrieving context for a detailed query

After ingesting travel-guide pages, invoke the retriever with "Cornwall Ranger". Although the precise match resides in a small child chunk, the result is the larger South Cornwall document context rather than only the matching passage. section 8.4.1

Figure 8.4 Child chunk embeddings. A coarse document chunk is indexed with its own embedding and the embeddings generated from its smaller child chunks, allowing it to match effectively with both broad and detailed queries.
figure

Use the child-embedding diagram to see how one coarse parent chunk supports both broad and detailed query matching. section 8.4.1

How AI Agents and Applications covers it

How deep it goes
Explains splitters, stores, ingestion, verification, and querying, but defers systematic performance evaluation to dataset benchmarking.
Examples
Demonstrates Chroma, InMemoryStore, RecursiveCharacterTextSplitter, HTML ingestion, and a Cornwall Ranger search.
What you can do after
Build it from scratch with LangChain components, ingest documents, query child embeddings, and inspect returned parent context.
How it connects
Connects embeddings, vector stores, document stores, text splitting, multi-vector retrieval, and context expansion.

Also explained in

Compare how 2 books explain ParentDocumentRetriever →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.