What is parent-child or hierarchical chunking in RAG?
Parent-child chunking creates a hierarchy of document chunks at different granularity levels. Small child chunks of 128-256 tokens are used for precise retrieval since they represent focused topics that match well against specific queries. Each child chunk maintains a reference to its parent chunk which is typically 512-2048 tokens providing broader context. During retrieval, the system searches against child chunks for precision, then returns the parent chunks to the LLM for richer context. This combines the retrieval precision of small chunks with the contextual richness of larger chunks. LlamaIndex implements this as the auto-merging retriever which automatically combines child chunks back into parents when multiple children from the same parent are retrieved. This approach consistently outperforms single-level chunking because it avoids the trade-off between retrieval precision and context completeness.