---
title: "Contextual RAG"
sidebarTitle: "Contextual RAG"
description: "Prepend LLM-generated context to each chunk before embedding it."
---
Addresses the "lost in the middle" problem in retrieval. An LLM generates a
succinct piece of context for each document chunk, which is prepended to the
chunk before embedding -- so a chunk carries enough surrounding meaning to be
retrieved for the right queries.
This example is a runnable notebook in the
[vectordb-recipes](https://github.com/lancedb/vectordb-recipes) repository rather than a page here.
Run it end to end in the browser.
Read the source.