Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Contextual retrieval

Definition

Adding a short, model-written note on where each chunk sits in its source document before embedding and indexing the chunk.

In more detail

A chunk such as 'revenue grew 3% over the previous quarter' is useless for retrieval if it does not say which company or quarter. Anthropic described contextual retrieval in 2024: a model reads the whole document and writes a sentence or two of context for each chunk, which is prepended before the chunk is embedded and added to a BM25 index.

In Anthropic's tests this cut failed retrievals by 49%, and by 67% when combined with reranking. Prompt caching keeps the cost down, because the full document is reused across all its chunks.

  • Chunking

    Splitting documents into pieces sized for embedding and retrieval, ideally along natural boundaries such as sections or paragraphs.

  • Hybrid search

    Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.

  • Prompt caching

    Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.

  • Reranking

    Re-scoring an initial set of retrieved results with a slower, more accurate model before passing only the best few on to the LLM.

  • RAG fundamentals: retrieval before generation

    What RAG is and how retrieval-augmented generation works, when it beats long context or fine-tuning, and a minimal working pipeline in about 80 lines of Python.

    TutorialBeginner30 min

  • Chunking

    Splitting documents into pieces sized for embedding and retrieval, ideally along natural boundaries such as sections or paragraphs.

    Glossary

  • Retrieval-augmented generation

    Fetching relevant documents and adding them to a prompt to ground answers.

    SkillIntermediate