AI / LlamaIndex Interview Questions
How does the SentenceWindowNodeParser improve retrieval quality?
SentenceWindowNodeParser splits Documents into Nodes at the individual sentence level, but instead of throwing away surrounding context, it stores a window of neighboring sentences in each Node's metadata under a key like window.
This matters because embedding a single sentence gives a very precise match at retrieval time, since the vector represents one focused idea rather than an average over a whole paragraph. But a single sentence alone is often too little context for the LLM to generate a good answer from.
The fix is a matching MetadataReplacementPostProcessor, attached as a node postprocessor, which swaps each retrieved Node's text with its stored window before synthesis. So retrieval stays precise at the sentence level, while the LLM still sees the fuller surrounding context it needs to answer well.
More Related questions...