11.1.3 · Skill in AI engineering

Retrieval (RAG)

Giving a model the right context from your own data.

Retrieval-augmented generation finds relevant documents and adds them to the prompt. Answer quality depends mostly on retrieval quality: chunking, search and ranking. It has to be evaluated like any search system.

Your status · Retrieval (RAG)

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

Retrieval-augmented generation (RAG) finds the documents that matter and puts them in the model’s context, so it can answer from your data instead of its memory. The quality of the answer depends mostly on the quality of the search. That makes RAG a search problem, which engineers can measure and improve, and a permission problem, because a model can only keep secret what it never sees.

How to do it

  1. Apply access rules before search, so the model only sees documents the user may read.
  2. Split documents into chunks that make sense alone, and add a short context to each one.
  3. Combine search methods: embeddings for meaning, keyword search for exact terms and names.
  4. Rerank the top results before they go into the prompt.
  5. Evaluate retrieval on its own: for real questions, did the right passage come back?
  6. Ask for answers with citations, and let the model say when the documents do not answer.

Common mistakes

  • Judging only the final answers, so you cannot tell if search or generation failed.
  • Chunks cut in the middle of a table or a sentence.
  • Filtering by permission after search, when the model may already have seen the text.
  • Old documents that stay in the index after they change.

Example

Papermark’s data room assistant answers questions across a deal’s documents, with citations back to pages, and “only from documents the token is allowed to read”. In a data room, the permission check before retrieval matters as much as the answer. (Papermark in In practice)

Bars

Share of searches where the right chunk was missing from the top 20

  • Standard embeddings5.7%
  • With context added to each chunk3.7%
  • Plus keyword search (BM25)2.9%
  • Plus reranking1.9%

Each step fixes a different weakness of search. Together they cut failed retrievals by two thirds.

ReportedAnthropic, 'Contextual retrieval', Sep 2024

Sources: Contextual retrieval (Anthropic) ↗ · Papermark for agents ↗

Technical leverage

Build ingestion, chunking, embeddings and search, then evaluate retrieval separately from answer generation to locate the actual failure.

Evidence of mastery

Put it into practice
Practice
Build a source-linked answer feature for a small, permissioned knowledge base.
Artifact
A retrieval benchmark with expected sources, grounded answers and examples of abstention.

What good looks like

  • Access controls apply before documents reach the model.
  • Missing evidence, stale documents and conflicting sources are tested.

Use this evidence to assess your work. Your map status is a self-assessment, not a certification.

Resources

2
  • articleGo deeper
    Contextual retrieval ↗
    Anthropic · 2024 · 11 min

    A measured improvement to RAG: add context to each chunk before indexing, combine with keyword search and reranking.

  • articleGo deeper
    Effective context engineering for AI agents ↗
    Anthropic · 2025 · 14 min

    Choosing what goes into a model's limited context, and loading the rest only when needed.

Tools

2
Tools for AI engineering