Start studying
Module 9 · RAG Module contents
Module 9  ·  Card 5 / 19intermediate

Contextual Retrieval

A chunk pulled from the middle of a document often loses what it was about.

It says the limit was raised to fifty without ever naming the product or the year.

Contextual retrieval prepends a short generated description of where the chunk sits before embedding it.

That one or two sentences restore the subject, so the chunk matches the queries people actually type.

It costs a model call per chunk at index time and nothing at all at query time.

Learn in depth ↓
Module 09 · RAG · 19 concepts
In depth  /  15 lines

Contextual Retrieval, in more detail

Chunking cuts documents into pieces, and the cuts remove information that was never in the piece.

A paragraph in a financial report may say revenue grew by three per cent that quarter.

Which company, which quarter and which segment were established pages earlier and are simply gone.

Embedded on its own, that chunk matches almost nothing a user would actually ask.

Contextual retrieval fixes this at indexing time rather than at query time.

Before embedding, each chunk is passed to a model along with the document it came from.

The model writes one or two sentences saying what this chunk is and where it sits.

That context is prepended to the chunk text, and the combined text is what gets embedded.

Now the chunk carries its own subject, so a query naming the company and quarter retrieves it.

The same enriched text is indexed for keyword search, which improves sparse retrieval as well.

The cost is one model call per chunk when the corpus is indexed, which is a one-off.

Prompt caching over the shared document makes that far cheaper than it first sounds.

Query time is unchanged, since all the work has already been done.

Reported reductions in retrieval failure are substantial, especially combined with hybrid search and reranking.

The trade is index freshness: a changed document means regenerating the context for its chunks.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What does contextual retrieval add to a chunk before it is embedded?
RAG

19 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close