23One call
Contextual retrieval
Before indexing, prepend to each chunk a short model-written note on where it sits in its document.
Merola and Singh, Anthropic, Amazon Web Services, Onyx
The problem
Split into chunks, a passage can lose the context that says what it is about.
In traditional RAG, documents are typically split into smaller chunks for efficient retrieval. While this approach works well for many applications, it can lead to problems when individual chunks lack sufficient context.
Therefore
Contextual Retrieval solves this problem by prepending chunk-specific explanatory context to each chunk before embedding (“Contextual Embeddings”) and creating the BM25 index (“Contextual BM25”).
Contextual retrieval enhances traditional RAG by adding chunk-specific explanatory context to each chunk before generating embeddings.
Contextual retrieval preserves coherence by prepending LLM-generated context to chunks, while late chunking embeds entire documents to retain global context before segmenting.
In use
Onyx
An LLM adds a short, document-aware summary to each chunk. This improves retrieval for chunks that are ambiguous on their own.
Where it breaks
It needs more computation than indexing the chunks alone.
Our results indicate that contextual retrieval preserves semantic coherence more effectively but requires greater computational resources.
Sources
- Reconstructing Context: Evaluating Advanced Chunking Strategies for Retrieval-Augmented GenerationCarlo Merola, Jaspinder Singh, Merola and Singh
- Contextual retrieval in AI systemsAnthropic, Sep 19, 2024
- Contextual retrieval in Anthropic using Amazon Bedrock Knowledge BasesSuheel Farooq, Sharon Li, Venkata Moparthi, Qingwei Li, Vinita Shadangi, Amazon Web Services, Jun 5, 2025
- Data Flows - Onyx DocumentationOnyx
Added Nov 14, 2026
