Course contentsShow
← AI Engineering
Lesson 384 of 1,88610. RAG - Improving RetrievalFree lesson

Parent-Child Document Chunking

Retrieve small chunks for precision while providing larger context windows to the LLM for generation.

Parent-Child Document Chunking

What you'll learn: How to retrieve small, precise chunks while giving the LLM larger context for better answers.

The Core Idea

Parent-child document chunking is a two-tier strategy where you index small chunks (children) for retrieval precision, but return their larger parent chunks to the LLM for generation. Think of it like using a detailed table of contents to find the exact section you need, then reading the entire chapter (not just the paragraph) to understand the full context.

When you search, you match against the small, focused child chunks—ensuring high relevance scores. But when you send context to the LLM, you provide the broader parent chunk that contains richer surrounding information.

Why This Matters

Small chunks (100-200 tokens) are great for retrieval: they're specific and match queries precisely. But they're often too narrow for the LLM to generate complete, coherent answers—they lack necessary context.

Large chunks (500-1000 tokens) give LLMs more context but often dilute retrieval quality—they contain irrelevant information that reduces similarity scores.

Parent-child chunking gives you both: precision at retrieval time, richness at generation time.

The Pattern

  1. Split documents into large parent chunks (e.g., paragraphs or sections)
  2. Sub-divide each parent into smaller child chunks (e.g., sentences or sentence groups)
  3. Index and embed the child chunks in your vector database
  4. Store references linking each child to its parent
  5. At query time, retrieve top matching child chunks
  6. Return the parent chunks to the LLM as context

Key Takeaway: Parent-child chunking separates retrieval precision (small children) from generation quality (large parents), giving you the best of both worlds without compromising either.