Parent-Child Chunking
What you'll learn: How to store small, focused chunks for precise retrieval while maintaining access to broader context for richer generation.
The Core Problem
When you chunk documents for RAG, you face a dilemma: small chunks retrieve precisely but lack context, while large chunks provide context but match queries poorly. Parent-child chunking solves this by decoupling what you search from what you feed the LLM.
How Parent-Child Chunking Works
Think of a textbook with chapters (parents) and individual paragraphs (children). When you're searching for a specific fact, you read individual paragraphs. But when you need to understand that fact deeply, you read the entire chapter for context.
In parent-child chunking:
- Store small chunks (children) in your vector database with their embeddings
- Retrieve based on these focused children—they match queries precisely
- Return the parent (larger surrounding context) to the LLM for generation
The child chunk might be a single paragraph, while its parent could be the entire section or even full document containing that paragraph. Each child maintains a reference (like a document ID and offset) back to its parent.
Why This Matters
- Better retrieval precision: Small chunks have clearer semantic meaning
- Richer generation context: The LLM sees the full picture, not isolated fragments
- Reduced hallucination: Surrounding context helps the model understand nuances
- Flexible granularity: You can tune child size independently of parent size
This approach builds on metadata enrichment—you're essentially storing parent identifiers as metadata on each child chunk, then fetching parent text at query time.
Key Takeaway: Parent-child chunking retrieves with precision using small chunks but generates with understanding using their larger parent contexts, giving you the best of both worlds.