Skip to main content

Pattern · Retrieval and RAG

Parent-child chunking

Search small, precise chunks, but send the model their larger parent section so it has the full context.

Say it in the interview

I would index small child chunks for precise matching but send their parent sections to the model, de-duplicated, so it sees the whole clause or table. That trades some tokens for fewer half-answers.

When to use it

  • Answers need surrounding context (a table, a clause and its exceptions)
  • Small chunks retrieve well but read badly

How it works

  1. Document → Parent sections
  2. Parent sections → Small child chunks
  3. Small child chunks → Index
  4. Question → Search child chunks
  5. Search child chunks → Index
  6. Search child chunks → Fetch their parents, de-duplicate
  7. Fetch their parents, de-duplicate → Prompt

Trade-offs

  • Precise matching with readable context
  • Uses more prompt tokens per answer
  • More bookkeeping in the index

Pitfalls interviewers probe

  • Parents so large they crowd out other evidence
  • Forgetting to de-duplicate when two children share a parent

Practise it on these questions

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.