Contextual Retrieval
Contextual retrieval fixes a structural failure of naive chunked RAG: when you split a document into chunks and embed each in isolation, a chunk loses the context that made it findable. A paragraph that says "the margin rose to 34%" no longer says whose margin or which quarter, so a query about "ACME Q3 gross margin" may never retrieve it. The corrective is to prepend a short, chunk-situating gloss — generated from the whole document — to each chunk before it is embedded (and before it is indexed for keyword search), so the stored vector and the keyword tokens both carry the document context, not just the isolated span. It is a preprocessing move on the index side, orthogonal to what happens at query time: it composes with Hybrid Retrieval (contextualize the text feeding both the vector and the BM25 channel), Rank Fusion, and a downstream Reranking pass. The trade is index-build cost (one LLM pass per chunk to write its context) against a materially higher retrieval hit-rate.
Anthropic's Claude Cookbooks carry this under
capabilities/contextual-embeddings/; the technique is
attributed here as the source's recipe, and it slots into the vault's
existing retrieval spine rather than replacing any of it.
Claims
- Embedding chunks in isolation strips the document context that makes them retrievable. principle — durable structural limit of naive chunked RAG: relevance to a query often lives in context the chunk no longer carries, so the miss is inherent to isolated chunking, not a tuning problem. This is the retrieval-side analogue of Semantic Retrieval's literal-string blind spot named in Hybrid Retrieval.
- Prepend a document-derived, chunk-situating context to each chunk before embedding and indexing. best practice — context: chunked RAG over documents where chunks lose their referents; "best" because it repairs the failure at index time where the whole document is still available, at the cost of an extra LLM pass per chunk. Contingent on the corpus being chunk-and-embed RAG (not, e.g., grep-over-code).
- Contextualize the text feeding both retrieval channels, then fuse and rerank. best practice — context: a Hybrid Retrieval stack; the situating gloss helps keyword and vector search alike, so apply it before the split rather than to one channel only.
Related
- Hybrid Retrieval — contextual retrieval feeds both the keyword and semantic channels; it is an index-side complement to hybrid's query-side fusion.
- Semantic Retrieval — the embedding channel whose isolated-chunk weakness contextualization patches.
- Reranking — the model-scored pass applied after retrieval; contextualization improves what reaches the reranker.
- Rank Fusion — merges the two channels contextualization has strengthened.
- Retrieval Maturity Levels — a further refinement of the ladder: better chunks, not just more channels.
- Distillate: Anthropic's
Claude Cookbooks — the canonical recipe index —
capabilities/contextual-embeddings/recipe.