Explain contextual retrieval. What problem does it solve, and how does late chunking relate?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Both attack the same disease: chunks lose their document context when isolated. A chunk saying "The company's revenue grew 3% over the previous quarter" is unretrievable for "ACME Q2 2023 revenue growth" - nothing in the chunk says ACME or Q2. Pronouns, definite references ("the merger", "this policy"), and section-dependent meaning all break when a chunk is embedded alone.
Full worked answer with diagram
Both attack the same disease: chunks lose their document context when isolated. A chunk saying "The company's revenue grew 3% over the previous quarter" is unretrievable for "ACME Q2 2023 revenue growth" - nothing in the chunk says ACME or Q2. Pronouns, definite references ("the merger", "this policy"), and section-dependent meaning all break when a chunk is embedded alone.
Contextual retrieval (the term popularized by Anthropic's 2024 write-up) fixes this at ingest: for each chunk, an LLM is given the full document plus the chunk and generates a short situating blurb - "This chunk is from ACME Corp's Q2 2023 SEC filing, discussing quarterly revenue growth" - which is prepended to the chunk before embedding and before BM25 indexing (contextual embeddings + contextual BM25). Anthropic reported the combination cut top-20 retrieval failure rate by ~49%, and ~67% with reranking on top. The cost is one LLM call per chunk at index time; prompt caching makes it cheap because the full document is a shared cached prefix across all of its chunks' calls. It's a pure index-time cost - query latency is untouched.
Late chunking achieves related contextualization without an LLM: embed the entire document through a long-context embedding model, then mean-pool the contextualized token embeddings over each chunk's span. Because attention ran over the whole document, each chunk's vector already "knows" that "the company" is ACME. It requires a long-context embedder and only helps the dense side (BM25 still sees the bare chunk text), but it's cheaper than per-chunk LLM calls.
When to bother: corpora with heavy cross-references and entity ambiguity (filings, contracts, wikis) see big gains; self-contained chunks (FAQ entries, product descriptions) see little. A cheap approximation that captures much of the value: prepend document title + heading path to every chunk - do that unconditionally.
Worth sketching. Drawing both paths off the same document makes the cost and coverage difference obvious without a word of comparison.
flowchart TD
D["Full document"] --> A["LLM writes a situating<br/>line for each chunk"]
A -->|"helps dense and BM25;<br/>one cached call per chunk"| B["Prepend, then embed<br/>and index"]
D --> C["Long-context embedder<br/>over the whole document"]
C -->|"helps dense only;<br/>no LLM calls"| E["Mean-pool token vectors<br/>per chunk span"]
B --> F["Chunk vector now knows<br/>the company is ACME"]
E --> F
What a good answer covers
- Both attack the same disease: chunks lose their document context when isolated
- A chunk saying "The company's revenue grew 3% over the previous quarter" is unretrievable for "ACME Q2…
- Pronouns, definite references ("the merger", "this policy"), and section-dependent meaning all break…
- Contextual retrieval (the term popularized by Anthropic's 2024 write-up) fixes this at ingest
- Anthropic reported the combination cut top-20 retrieval failure rate by ~49%, and ~67% with reranking on top
Key terms: Contextual retrieval · Late chunking
In the glossary: Contextual retrieval · BM25 · Reranking · Prompt caching · Late chunking · Chunking
Interviewer follow-ups to expect
How does prompt caching make contextual retrieval affordable at 10M chunks - sketch the cost math. Why does contextual BM25 matter, not just contextual embeddings?
What's the re-indexing story when documents get edited?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep