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

each chunkwritesDocumentModel callLLMContextExplanatorycontextToolEmbeddingToolBM25 index
How to read this

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.
AnthropicContextual retrieval in AI systemsSep 19, 2024

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”).
AnthropicContextual retrieval in AI systemsSep 19, 2024
Contextual retrieval enhances traditional RAG by adding chunk-specific explanatory context to each chunk before generating embeddings.
Amazon Web ServicesContextual retrieval in Anthropic using Amazon Bedrock Knowledge BasesJun 5, 2025
Contextual retrieval preserves coherence by prepending LLM-generated context to chunks, while late chunking embeds entire documents to retain global context before segmenting.
Merola and SinghReconstructing Context: Evaluating Advanced Chunking Strategies for Retrieval-Augmented Generation

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.
OnyxData Flows - Onyx Documentation

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.
Merola and SinghReconstructing Context: Evaluating Advanced Chunking Strategies for Retrieval-Augmented Generation

Sources

  1. Reconstructing Context: Evaluating Advanced Chunking Strategies for Retrieval-Augmented GenerationCarlo Merola, Jaspinder Singh, Merola and Singh
  2. Contextual retrieval in AI systemsAnthropic, Sep 19, 2024
  3. Contextual retrieval in Anthropic using Amazon Bedrock Knowledge BasesSuheel Farooq, Sharon Li, Venkata Moparthi, Qingwei Li, Vinita Shadangi, Amazon Web Services, Jun 5, 2025
  4. Data Flows - Onyx DocumentationOnyx

Added Nov 14, 2026