Skip to content
bits
Retrieval without tears · Lesson 1 of 9

Paste it or search it?

Tutor:

Claude knows a lot, but it doesn't know your stuff: your docs, your tickets, the decision your team made yesterday. Its training is frozen, so the only way to give it a fact it lacks is to put that fact in the prompt.

Retrieval is a way to pick which facts go in. You search your documents for the passages that match the question, and send Claude only those. People call this RAG, retrieval-augmented generation.

Before you build a search pipeline, check that you need one.

Tutor:

Every current Claude model has a 1M-token context window (as of October 2026). That's roughly 555,000 words. Anthropic's own advice, from when the window was a fifth of that: if your knowledge base is under about 200,000 tokens (around 500 pages), skip retrieval and put all of it in the prompt.

The catch is cost, and the fix is prompt caching. Your documents sit at the start of every request, unchanged, so Claude can cache them. On Claude Haiku 5.5, a cache hit costs $0.01 per million tokens, a tenth of the normal $0.10 (prices checked October 2026, for prompts up to 100,000 tokens). A 60,000-token handbook read from the cache costs 60,000 ÷ 1,000,000 × $0.01 = $0.0006 per question.

Tutor:

So when does retrieval win?

It doesn't fit. Two million support tickets won't go in any window, and on Haiku 5.5 a prompt over 100,000 tokens costs five times as much per token.

More isn't better. Anthropic's docs warn that as the prompt grows, accuracy and recall drop. They call it context rot. Five passages that answer the question often beat a million tokens of everything.

It changes, or it's per user. Docs that change hourly, or each customer's own files, are easier to index than to re-paste.

One more option: let the model search for itself. Agents can call a search tool when they need something. Claude Code finds files with grep and glob instead of a prebuilt index. That's still retrieval, done just in time. This course builds the classic pipeline, because it powers most "ask my docs" features and every idea in it carries over to search tools.

quick check+10 neurons
Tutor:

Which of these most needs a retrieval pipeline?

    Type your answer or tap an option · Enter checks

    Tutor:

    Your turn: the "just paste it" approach. The policy is already in the box. Add a question, and tell Claude to answer only from the policy, and to say so if the policy doesn't cover it. Try a question it can't answer, like one about shipping.

    Your turn

    Run your prompt and the replies land here.

      • Includes the policy, not yet
      • Asks a question, not yet
      • Limits Claude to the policy, not yet
      • Says what to do if it isn't there, not yet
      • Ran at 1.0, not yet
      run at
      ~0 tokens

      Turn on JavaScript to run prompts.