Skip to content

Contextual Retrieval: Adding Context to Chunks

Why chunks lose meaning when cut from their documents, and how prepending context improves retrieval accuracy.

Editorial team 2 min read

A chunk that reads "Revenue grew 3% over the previous quarter" is ambiguous on its own: which company, which quarter? Retrieval struggles to match it to a specific question.

The Problem

Chunking separates text from the context that gives it meaning: the document title, the section, the entity being discussed, the time period.

Simple Fixes

  • Prefix each chunk with the document title and section headings before embedding.
  • Include key metadata (date, product, region) in the indexed text.

Generated Context

A more thorough approach uses a language model to write a short description situating each chunk within its whole document — "This chunk is from Acme's Q2 2025 earnings report and discusses revenue growth compared with Q1" — and prepends it before embedding and keyword indexing.

Costs

Generating context for every chunk means a model call per chunk at indexing time. Prompt caching of the full document across calls for the same document can reduce the cost substantially.

Measure the Gain

Compare retrieval recall with and without added context on your test questions. Gains are typically largest for documents with many similar-looking passages, such as reports, contracts and manuals.

Keep the Original Text

Store the original chunk text separately so the language model sees the real content, with the added context kept clearly distinguishable.

More in RAG

All RAG guides →
RAG Guide · 1 min

RAG Architecture: The Components End to End

A map of a complete retrieval-augmented generation system, from ingestion to answer, and what each component is responsible for.

RAG 1 min read 6 Dec 2025

RAG Guide · 2 min

Document Parsing for RAG

Turning PDFs, slides, HTML and scans into clean, structured text — the unglamorous step that decides RAG quality.

RAG 2 min read 5 Dec 2025

RAG Guide · 2 min

Chunk Size and Overlap Tuning

How to choose chunk size and overlap for retrieval by testing against real questions rather than guessing.

RAG 2 min read 4 Dec 2025

RAG Guide · 2 min

Hybrid Search for RAG

Combining keyword and vector search so RAG finds both exact terms and paraphrased meaning.

RAG 2 min read 3 Dec 2025