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
- Document → Parent sections
- Parent sections → Small child chunks
- Small child chunks → Index
- Question → Search child chunks
- Search child chunks → Index
- Search child chunks → Fetch their parents, de-duplicate
- 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