Zenaique

Contextual retrieval, in one move at ingestion time

Flashcard·Easy·4.0 · 0·~30s·Relevant atElasticGleanHebbiaNeo4j
Attempt it
TL;DR

Contextual retrieval prepends an LLM-generated context summary to each chunk before embedding, so isolated chunks keep the entities a query needs to find them.

Memory aid
Sign in for the mnemonic that makes this stick. See Pro pricing.
Easy to grasp

Imagine cutting a long letter into paragraphs and filing each one separately. One paragraph just says 'it went up 3% that quarter.' Months later you search for it, but the slip never mentions who or what or when, so you can never find it again. Now picture writing a sticky note on the top of every slip first: 'From Acme's Q3 2024 report, about product revenue.' Suddenly the slip carries enough to match your search. That is contextual retrieval: before filing each chunk away, a smart helper writes a little 'where this came from' note on top, so a search later can still land on it.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.

Sign in for 5 free unlocks/day or go Pro for unlimited. See Pro pricing.

2–4 min · Everything important, quickly.

Lead with the timing: this is an ingestion-time step, before embedding. State the failure it fixes with a concrete dangling-pronoun example. Describe what the LLM generates and that it is prepended, not substituted. Note it feeds both dense and BM25 indexes. Close with the cost and the prompt-caching mitigation.

Real products, models, and research that use this idea.

  • Anthropic's Contextual Retrieval guide popularized prepending LLM-generated chunk context and reported large drops in retrieval failure rate.
  • Voyage and Cohere embedding models are common choices for re-embedding the context-augmented chunks in production RAG stacks.
  • Anthropic's prompt caching feature is the standard way teams keep the per-chunk LLM call affordable across a large corpus.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does prompt caching make the per-chunk LLM call affordable at corpus scale?
Sign in or go Pro to see the approach for this follow-up.
QWhy does contextual retrieval help the lexical BM25 index too, not just dense embeddings?
Sign in or go Pro to see the approach for this follow-up.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Thinking contextual retrieval runs at query time. It is an ingestion-time step: the context has to be baked in before the chunk is embedded, or the vector never carries it.

Sign in or go Pro to see all red flags and common mistakes. See Pro pricing.

60-second night-before-the-interview bullets. Scan these on the way to the call.

Sign in for 5 unlocks/day or go Pro for unlimited revision sheets. See Pro pricing.

Primary sources. Skim if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Which metric best measures whether a RAG answer is grounded in the retrieved context?
MCQ·Medium