Why it matters
There is a direct conflict in chunk design: short spans produce sharp vectors and long spans contain the explanation. Choosing one sacrifices either recall or answerability. Parent-child retrieval resolves it by indexing children for matching while keeping a pointer to a parent that is fetched only after the match, so the embedding never has to represent more than a sentence or two.
Mental model
It is a library catalogue where each card describes one paragraph but points to the whole chapter on the shelf. You search the cards and read the chapter. The metaphor breaks when several cards point to the same chapter, so you may fetch the same book three times.
How it works
- 1Build an explicit hierarchy during parsing: document, section, paragraph, sentence, with stable ids at each level.
- 2Embed the smallest level that still carries meaning, usually a sentence or a short paragraph.
- 3Store a pointer from each child to its parent id, and store parent text once rather than duplicating it per child.
- 4At query time, retrieve children, then expand to parents and deduplicate by parent id.
- 5Cap parent size and fall back to the child when the parent exceeds the context budget.
- 6Order expanded parents by the best child score so the strongest match leads the context.
Step 1 of 6
Build an explicit hierarchy during parsing: document, section, paragraph, sentence, with stable ids at each level.
Figure. The mechanism in this page's own steps. The figure adds sequence, not new claims.
What to notice. A step can be read alone, but the order is the mechanism. The control lets you stop on any one.
Text version
The page's steps: 1. Build an explicit hierarchy during parsing: document, section, paragraph, sentence, with … 2. Embed the smallest level that still carries meaning, usually a sentence or a short paragr… 3. Store a pointer from each child to its parent id, and store parent text once rather than … 4. At query time, retrieve children, then expand to parents and deduplicate by parent id. 5. Cap parent size and fall back to the child when the parent exceeds the context budget. 6. Order expanded parents by the best child score so the strongest match leads the context.
- Build an explicit hierarchy during parsing: document, section, paragraph, sentence, with stable ids at each level.
- Embed the smallest level that still carries meaning, usually a sentence or a short paragraph.
- Store a pointer from each child to its parent id, and store parent text once rather than duplicating it per child.
- At query time, retrieve children, then expand to parents and deduplicate by parent id.
- Cap parent size and fall back to the child when the parent exceeds the context budget.
- Order expanded parents by the best child score so the strongest match leads the context.
Trade-offs
| Choice | Good for | Cost | Fails when |
|---|---|---|---|
| Sentence children, section parents | Sharp matching with readable context | Extra storage and a join at query time | Sections are very long or inconsistently parsed |
| Paragraph children, document parents | Good match quality and full context | Parents often exceed the context budget | Documents are long reports |
| Child-only retrieval | Simplest pipeline | Fragments reach the model without context | Answers need surrounding explanation |
| Parent-only retrieval | Rich context per hit | Vectors average several topics | Sections cover multiple subjects |
Good for
Sharp matching with readable context
Cost
Extra storage and a join at query time
Fails when
Sections are very long or inconsistently parsed
- Sections are very long or inconsistently parsed
- Documents are long reports
- Answers need surrounding explanation
- Sections cover multiple subjects
Figure. Each choice with what it buys, what it costs, and the case where it loses.
What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.
Text version
Four trade-offs: Sentence children, section parents is good for Sharp matching with readable context, costs Extra storage and a join at query time, and fails when Sections are very long or inconsistently parsed. Paragraph children, document parents is good for Good match quality and full context, costs Parents often exceed the context budget, and fails when Documents are long reports. Child-only retrieval is good for Simplest pipeline, costs Fragments reach the model without context, and fails when Answers need surrounding explanation. Parent-only retrieval is good for Rich context per hit, costs Vectors average several topics, and fails when Sections cover multiple subjects
Failure modes
- Parent expansion overflows the budget. Ten matched children expand to ten long sections and the prompt is truncated. Debug: log the token count after expansion and compare with the prompt budget.
- Duplicate parents in context. Several children of one section are retrieved and the same text appears repeatedly. Debug: count distinct parent ids in the final context and compare with the number of retrieved children.
- Broken hierarchy after re-parse. Parent ids change and children point at stale sections. Debug: join children to parents and count orphans after every re-index.
In production
Monitor expansion ratio — children retrieved to parents returned — and the token size of the expanded context. Alert on orphaned children, which indicate a hierarchy rebuild that did not finish.
Common misconceptions
People think: Parent-child retrieval is the same as overlap.
Actually: Overlap duplicates text inside the index; parent-child stores one parent and points to it from many children.
People think: Bigger parents are always better for answers.
Actually: A parent that exceeds the budget is truncated, which can cut the very passage that matched.
Interview angle
Explain the match-unit versus read-unit split and how the hierarchy is built during parsing. Cover deduplication and the budget cap on parents. Describing the return of the surrounding chunk, without saying how parents are stored or what happens when several children share one, is incomplete.
Sources
- Sarthi et al., RAPTOR — hierarchical summarisation and retrieval across levels of a document tree.
- LlamaIndex documentation — node hierarchies and auto-merging retrieval over child nodes.
- Chen et al., Dense X Retrieval — evidence that the retrieval unit and the answer unit need not be the same.