WinnieProMaxAI GUIDE
Menu

LESSON

Build a knowledge workflow and test retrieval separately

Intermediate · Find answers in a document

Advanced — design and evaluate AI workflows · Lesson 3 of 8

A folder is not an answer system

Base showed how to ask about a supplied document. A larger knowledge system must first find the right material. Retrieval-augmented generation, or RAG, combines retrieval with answer generation. The model is given selected source content at response time; the documents do not become its trained parameters.

Think of the system as two contracts. Retrieval must return relevant, permitted evidence with enough identity and context to use it. Generation must answer from that evidence, preserve uncertainty and expose sources. If either contract fails, a fluent answer can still be wrong.

Prerequisites: AD01 and A08. This lesson includes a small collection you can search by hand or use with the accompanying offline retrieval lab. The lab is deliberately a keyword baseline, not a vector search engine or a live language model.

Follow the document pipeline

A practical pipeline collects approved documents, extracts readable content, attaches metadata, divides long material into useful passages and builds a search index. At question time it checks the user's scope, retrieves candidates, may rerank them and passes selected passages to the answering step.

Metadata should include document identity, version or date, access scope and enough location information to open the passage. Chunking means dividing a document into pieces; boundaries should not separate a condition from its exception without retaining surrounding context.

Keyword search can be strong for exact names or identifiers. Embeddings represent content numerically to support semantic similarity. A hybrid system may use both. Similarity is not authority: an obsolete policy may be very similar to the question. Reranking can improve ordering but does not replace access control or resolve which version is current.

Work with a complete small collection

All documents are fictional. D1, project Pine, current: “Comparison page scope must be approved by the project manager before a delivery date is promised.” D2, Pine, superseded: “Developers may confirm a delivery date directly.” D3, project Birch, current: “Comparison page is included in the existing package.” The user has access to Pine only.

Question: “Can we promise a delivery date for the comparison page?” First filter to the permitted project. Then preserve the status of D1 and D2. A suitable answer says that the current Pine rule requires manager approval, cites D1 and does not use D3. D2 is useful only to explain a known superseded conflict, not to overrule D1.

Now ask “What date should we promise?” None of these documents supplies a date. The answer should report that gap. A perfectly retrieved rule cannot supply information it does not contain.

Evaluate retrieval and answers separately

Make two checks for each question. Did retrieval include the required current evidence without leaking another project's content? Did the answer actually follow that evidence without inventing a date? This separates a search failure from an answering failure.

For a tiny labelled set, retrieval recall asks how much of the required evidence was found; precision asks how much returned evidence was relevant. Define your counting unit first: documents, passages or required facts. An attractive aggregate score can conceal a dangerous cross-project leak, so preserve individual failures as well.

Include a question requiring two passages, an unknown answer, conflicting versions and a question with different wording. Our keyword lab will miss some wording changes. That is an expected limitation to observe, not proof that RAG is useless or that vector search will solve every case.

Complete the retrieval exercise

Run the supplied retrieval_lab.py with Python 3, or reproduce its cases on paper. It has no network access, account or external packages. Inspect D1–D3, run a Pine query and then change the allowed project. Notice that the allowed scope comes from the simulated application, not a phrase inside the user's question.

Write an answer using only the returned evidence. Add a new question that keyword overlap cannot handle, record the miss and propose an evaluation before choosing an embedding provider. Do not label the lab a working AI assistant: it tests the evidence stage only.

You finish when you can locate a failure in retrieval or generation, preserve document/version identity and explain an unanswered question without fabrication. For deeper implementation, the linked Anthropic cookbook shows a larger RAG pipeline; its historical model results are not predictions for today's service. Next: AD03 follows evidence across images, audio and tables.

Sources

Read the original sources to explore the topic and check specific claims.

Claude Cookbook: RAG pipeline and evaluation ↗

Claude documentation: embeddings ↗

Go deeper when you are ready

The basic explanation is enough to continue. Choose a more detailed article if you want the mechanics; original documentation is linked in Sources.

Download the offline retrieval exercise (Python 3, no account) →

← Back to articles