passdrill
AI & LLM Engineering · RAG & Embeddings · Card 022/022 hard

Anthropic's Contextual Retrieval technique has a language model generate 50-100 tokens of chunk-specific context, such as noting which company and filing period a chunk comes from, and prepends that generated context to the chunk's own text before the chunk is embedded and before it is indexed for keyword search. Anthropic's own testing found this reduced the top-20-chunk retrieval failure rate substantially on its own, with a further reduction when reranking was added on top. What underlying problem does prepending this generated context address?

  1. A chunk taken in isolation often loses context that made it unambiguous inside the full document, such as which company or time period it refers to, so a bare chunk's embedding and keyword index entry can end up representing an ambiguous fragment rather than the specific fact the chunk actually states; prepending a short explanatory blurb restores that missing context before the chunk is indexed
  2. Embedding models have a hard minimum input length, so very short chunks fail to produce a usable embedding at all unless padded with additional generated text first
  3. The generated context tokens replace the original chunk text entirely, and it is faster for the embedding model to process 50-100 tokens of generated summary than the chunk's original, longer text
  4. The generated context is only read by a human reviewer during a quality-assurance step, and it is stripped back out before the chunk is embedded or indexed, so it never affects retrieval directly
Next card → Shuffle