Skip to content

Contextual Retrieval

Definition

Contextual Retrieval — an approach where each document fragment is supplemented with a brief contextual description, generated by an LLM, before vectorization. This enhances semantic search accuracy as embeddings become more informative and less dependent on local context.

Process

  1. The document is split into chunks.
  2. For each chunk, the LLM generates a contextual description (e.g., "This fragment pertains to the API setup section").
  3. The chunk and its description are combined and fed into the embedding model.
  4. The resulting vectors are indexed in a vector database.

Benefits

  • Improved recall when searching short or ambiguous fragments.
  • Reduced impact of the 'lost middle'.
  • Enhanced quality of responses in RAG systems.

See also

← All terms