AI / LlamaIndex Interview Questions
Which is better and why: sentence-window retrieval vs auto-merging retrieval for long documents?
Neither is universally better; the right choice depends on whether a typical query in your application needs a single pinpoint fact or a broader coherent passage, since the two techniques solve different failure modes of fixed-size chunking.
Sentence-window retrieval embeds individual sentences for precise matching, then expands to a fixed window of surrounding sentences only after retrieval. It shines when queries target one specific fact, like a single defined term or a specific figure, because the sentence-level embedding avoids the dilution a larger chunk would introduce. Its weakness is that the expanded window size is fixed, so if the relevant context genuinely spans more than that window, it stays truncated regardless of need.
Auto-merging retrieval uses a parent-child chunk hierarchy and merges child chunks up into their parent when enough of them are retrieved together, so the amount of context returned adapts to how much of a section is actually relevant, rather than being fixed in advance. It's the better fit for long, structurally coherent documents like contracts or manuals where the right answer often needs an entire clause or section, not one line.
| Sentence-window | Auto-merging |
| Best for single, pinpoint facts | Best for context spanning multiple adjacent chunks |
| Fixed context window size | Adaptive context size based on retrieval |
Teams that aren't sure which pattern dominates often benchmark both against a labeled query set using LlamaIndex's evaluators before committing to one in production.
More Related questions...