Minideas

Idea 13 of 15 · The Claude API

RAG: answers from your documents

Retrieval-augmented generation: cut documents into chunks, find the right ones for each question, and hand them to Claude.

a long document1234small overlaps keep sentences whole
1 / 4

Give Claude your documents, in chunks

Claude doesn’t know your documents, like manuals, policies or a wiki, so to answer from them it needs the relevant parts in its prompt. They’re too long to send whole, so split them into chunks: by section, or every few hundred words, overlapping a little. Each chunk should stand alone.

What does error E-1042 mean?by meaning(embeddings)Fixing connection issuesby keyword(BM25)Error codes: E-1042best of both
2 / 4

Search by meaning and by keyword

A user asks “What does error E-1042 mean?”, which only your internal docs explain. Find chunks to put in Claude’s context. Embeddings match meaning, as in “Words as points on a map”, but miss exact codes like E-1042; keyword search (BM25) catches those but misses rephrasings. Together, they work best.

in the documentE-1042: connection timed outWait 30 seconds, then check the cable.once cut outWait 30 seconds, then check the cable.which error? a search for E-1042 misses itClaude adds a lineError codes, E-1042 (connection timed out):Wait 30 seconds, then check the cable.nowfindableAnthropic calls this contextual retrieval
3 / 4

Optional: contextual retrieval

Cut out, a chunk can lose its context: “Wait 30 seconds, then check the cable” sat under the E-1042 heading but never names it, so search misses it. Anthropic’s fix: have Claude add a line to each chunk saying where it belongs. In their tests, failed searches fell by half.

What doesE-1042 mean?searchthe best 3 chunksError codes1Connection issues2Network setup3E-1042: the connectiontimed out [1].Check the network [3].answer only from these chunks, citing their numbers
4 / 4

The whole flow

Search both indexes, put the best few chunks into the prompt, and ask Claude to answer only from them and to say which chunk each fact came from. That’s RAG (retrieval-augmented generation), the open-book exam from “Making a model yours”.

Swipe the card, or use the arrow keys.

Go deeper

Each card stack gives you the idea. These open resources go into the detail.

Notes on the Claude Partner Network learning path on Anthropic Academy.