Course contentsShow
← Machine Learning and Deep Learning
Lesson 1994 of 3,53842. Retrieval-Augmented Generation: FoundationsFree lesson

Parent-Child Chunking

Storing small chunks for retrieval while maintaining links to larger parent contexts for generation.

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:

  1. Store small chunks (children) in your vector database with their embeddings
  2. Retrieve based on these focused children—they match queries precisely
  3. 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.