What is sentence-window retrieval?
Sentence-window retrieval is a retrieval technique that splits a document into single sentences, embeds each separately, searches at sentence level and passes the matched sentence to the language model with a set number of preceding and following sentences.
Unlike parent document retrieval, which fetches a predefined parent unit such as a section, sentence-window retrieval opens a fixed-width window around the matched sentence. As the window ignores section borders, it can sometimes take in unrelated neighbours.
- Topic
- Embeddings, document processing and RAG
- Also known as
- Sentence window
How sentence-window retrieval works
- The document is split into sentences, each stored in its document order.
- Each sentence is embedded and indexed separately, with its neighbours kept as metadata.
- At query time the most similar sentences are found.
- Each match is joined with its window neighbours into the context; overlapping windows merge.
In more detail
Index inflation and HNSW memory cost
Indexing every sentence individually multiplies the number of vectors compared with classic chunks, proportionally increasing ingestion compute, HNSW RAM usage and metadata storage. Sentence-window retrieval therefore trades significantly higher index memory for sharper query-to-sentence matching.
Top-k collapse and the order of window merging
Sentence-level search often returns multiple consecutive sentences from the same passage, consuming several top-k slots with overlapping windows. Applying window deduplication before the final cut or using Maximal Marginal Relevance (MMR) and reranking on the expanded windows prevents context collapse onto a single paragraph.
Sentence splitting errors on abbreviations and section boundaries
Rule-based sentence splitters frequently misfire on technical abbreviations (such as 'Md.', 'No.', 'Dr.'), decimal numbers, bulleted lists and tables, producing broken fragments. Additionally, windows should be clamped at section or document boundaries in metadata so unrelated headers or next chapters do not leak into the prompt.
Context-free sentences and embedding with heading prefixes
Because a bare sentence may lack the subject noun or section title needed for semantic matching (e.g., 'It must be tightened to 40 Nm'), prepending lightweight structural context, such as the document and section heading, when embedding or storing only the raw sentence for retrieval while passing the expanded window to a cross-encoder reranker, markedly improves precision.
Commonly confused terms
| Term | How it differs |
|---|---|
| Proposition indexing | Proposition-based indexing (Dense X Retrieval) decomposes text into self-contained atomic facts with pronouns already resolved before embedding, whereas sentence-window retrieval embeds raw sentences verbatim and relies on neighbouring sentences at retrieval time to restore missing context. |
| Auto-merging retrieval | Auto-merging retrieval builds a hierarchy of chunk sizes and automatically merges child chunks into their parent chunk only when enough siblings match the query, whereas sentence-window retrieval unconditionally expands every matched sentence by a fixed window. |
Why sentence-window retrieval matters for on-premises AI
A single sentence can match a query very precisely, yet one containing a pronoun, abbreviation or condition is not enough on its own to answer. A study of retrieval units shows the choice of indexing unit markedly affects retrieval and question answering, with fine-grained units improving answer quality under a given compute budget. Sentence-window retrieval pairs this fine-grained search with a small context expansion. Window width should be tuned on validation questions: a narrow window leaves context out, a wide one adds needless tokens.
A railway operator searches its maintenance manuals at sentence level, passing each matched instruction with the sentences before and after so safety warnings are not lost from answers.
Common questions
How does it differ from parent document retrieval?
Sentence-window retrieval opens a fixed window around the matched sentence. Parent document retrieval fetches a predefined parent unit such as a section.
How is window width chosen?
By testing on validation questions. A narrow window leaves context out; a wide one adds needless tokens.
Related terms
- Parent document retrieval
- Sentence embedding
- Chunking
- Chunk overlap
- Retrieval
- Retrieval-Augmented Generation
Sources
- Chen et al., Dense X Retrieval: What Retrieval Granularity Should We Use?, 2023
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, 2020
In the glossary: Glossary, R to Z