Small-to-big retrieval
Parent document retrieval · Parent retrieval
Search over small, precise chunks, then hand the model the larger section or page each match came from.
In DocSlurpGlossary entry
On this page
Small chunks match precisely: a 100-word chunk about jet booking times has an embedding that is about jet booking times, not diluted by everything else on the page. But a small chunk is a poor thing to read. “The Learjet is wheels-up within three hours of the request” means more next to the paragraph that says who can book it and who approves trips over $40k.
Small-to-big retrieval uses two sizes. You search over the small units and, for each hit, hand the model the larger unit it came from: the section, the page or a fixed parent chunk. The match stays sharp and the model gets enough surrounding text to answer and cite correctly. Sentence-window retrieval is the same idea with sentences as the small unit.
The gotcha
Parents are big, so they fill the context window fast, and two hits from the same page bring the same parent twice unless you merge them. Expanding also brings in unrelated text from the same page, which the model has to ignore.
DocSlurp calls this parent retrieval, and it is on by default (attachParentText in core/server/src/search/session-execution.ts). Each hit gets its whole page attached as parentText. When the page text isn’t available, it uses the neighboring chunks instead: the chunks on the hit’s page and the following page, or, without a page number, the chunks just before and after the hit. Chat sends the parent text to the model as surrounding context for the matched passage. Set parentRetrieval: false for smaller prompts and faster answers, at the cost of less context (see chat).
In DocSlurp
In DocSlurp
Parent retrieval is on by default. Each hit gets its whole page attached as parentText; when the page text is missing it falls back to neighboring chunks (attachParentText in core/server/src/search/session-execution.ts). Chat puts the parent text into the prompt as surrounding context. Turn it off with parentRetrieval: false (see chat).