1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →
What is contextual retrieval, or contextual chunk enrichment?
30-second answerSay your answer out loud first, then reveal.
Example.
Original chunk: "The company's revenue grew by 3% over the previous quarter."
Contextualised: "This chunk is from ACME Corp's Q2 2026 10-Q filing, section on financial results. The company's revenue grew by 3% over the previous quarter."
Original chunk: "The company's revenue grew by 3% over the previous quarter."
Contextualised: "This chunk is from ACME Corp's Q2 2026 10-Q filing, section on financial results. The company's revenue grew by 3% over the previous quarter."
Implementation
- For each chunk, call an LLM with the full document plus the chunk: "Give short context situating this chunk within the document."
- Prepend the context to the chunk text.
- Embed it and add it to the BM25 index (contextual BM25).
- Use prompt caching so the full document is cached across all its chunks, which reduces cost a lot.
Simpler, cheaper variants
- Contextual chunk headers: deterministically prepend the document title + section path ("Leave Policy > Casual Leave > Eligibility") without an LLM.
- Document summary prepended to each chunk.
Trade-offs: one-time indexing cost per chunk (an LLM call), longer chunks, re-processing when documents change. Usually worth it when documents are long and chunks are context-dependent (financial filings, contracts, manuals).
Related
You understood something today that you didn't yesterday.