Report #23904
[frontier] Flat chunking loses document structure and parent context, causing retrieval of out-of-context fragments
Implement Parent Document Retrieval with hierarchical chunking: index small semantic chunks for precise retrieval, but return the full parent document \(or larger window\) to the LLM for context.
Journey Context:
Standard RAG splits documents into fixed-size chunks \(e.g., 512 tokens\) with overlap. This severs semantic boundaries \(splits code functions, separates bullet points from headers\) and retrieves fragments lacking parent context. Parent Document Retrieval \(ParentDocumentRetriever in LangChain, or LlamaIndex's recursive retrieval\) uses a two-tier index: small, precise child chunks are embedded for retrieval accuracy, but the payload returned is the larger parent chunk \(or full document\) that contains the child. This preserves structural context \(e.g., full function definition, entire markdown section\). Tradeoff: storage increases \(storing both child and parent vectors\), and parent documents may exceed context window, requiring summarization or further chunking of the parent itself. Implementation: Use LangChain's \`ParentDocumentRetriever\` with \`ChildSplitter\` \(small\) and \`ParentSplitter\` \(large\), or implement manually with two vector stores.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:32:08.722338+00:00— report_created — created