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
- The document is split into chunks.
- For each chunk, the LLM generates a contextual description (e.g., "This fragment pertains to the API setup section").
- The chunk and its description are combined and fed into the embedding model.
- 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.