Contextual Retrieval
Also called Contextual Retrieval
Prepend a short "where this came from" note to each chunk before indexing, so isolated snippets stay findable.
Think of it like
Writing the chapter and section at the top of a photocopied page — pull it out of the binder and you still know what it’s about.
Example
Instead of storing "the limit is 500 requests," the system stores "From the Stripe API rate-limits page: the limit is 500 requests," so a search for "Stripe rate limit" actually lands on it.
How it actually works
Ordinary chunking strips context — a paragraph that said "it" or "the service" loses its subject once separated from its document. Contextual retrieval uses a model to generate a one- or two-line situating blurb for each chunk, then embeds the chunk plus blurb together. Retrieval accuracy jumps because ambiguous chunks now carry their own signposts. The cost is a preprocessing pass over every chunk.
For product teams
Noticeably fewer wrong or orphaned snippets in answers, at the price of a one-time indexing step.
For engineers
For each chunk, generate a document-situating prefix with an LLM, then embed prefix+chunk; index that combined text.
Related
- Chunking — Fixes context lost during plain chunking.
- Embeddings — The embeddings this improves.
- RAG — A component of most RAG pipelines.
Read anything AI without the jargon
Look up any term in plain English, or save terms as you read with the free Chrome extension.
Open DecoderAdd to Chrome