Macalinao StudioLearnAll enriched lessons ↗
High school path · 7 sectionsSwitch to college ↗

High school / LONGER LESSON 20

RAG: retrieve evidence, then test the answer

Measure retrieval and grounding separately, including missing evidence and hostile passages.

Preparation: Fractions, ranking and basic language models.

Plan 20–35 minutes with the activities; this is a study estimate, not a timed requirement. Both paths have complete narration. Your notes and progress are kept separately for each level.

Section 01 / 07

Begin with an answerable question

High-school path. Measure retrieval and grounding separately, including missing evidence and hostile passages.

Preparation: Fractions, ranking and basic language models. Work through one section at a time. Predict the experiment result before changing its controls, then explain what the example leaves out.

Retrieval-augmented generation supplies selected documents to a generator. Retrieval can help an answer use external evidence, but neither retrieving nor citing a passage guarantees that the answer is supported. Find the relevant page before writing your response, then check that the page actually says what you claim.

Worked step 1. Write a question with a known supporting passage.

Worked step 2. Retrieve candidates.

Worked step 3. Compare the final answer with the passage.

Try it yourself. Can a correct-looking citation still be misleading?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. Yes. It may point to a real document that does not support the attached claim.

Section 02 / 07

Choose chunks with their context

Chunk boundaries can separate a statement from its condition, date or negation. Store enough metadata to recover the source and interpret the passage accurately. A sentence saying it is safe may depend on a previous sentence saying only under supervision.

Worked step 1. Split a paragraph before its exception clause.

Worked step 2. Read the isolated first chunk.

Worked step 3. Then restore the exception and compare the claim.

Try it yourself. Does larger overlap always improve the system?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. It can increase redundancy and cost. Evaluate whether the retrieved context preserves meaning.

Section 03 / 07

Measure precision and recall

Precision asks what fraction of retrieved passages are relevant. Recall asks what fraction of all relevant passages were retrieved. Increasing the retrieval count can affect them differently. A larger fishing net may catch more useful items and more unwanted items at the same time.

precision = hits/k; recall = hits/relevant-total

Worked step 1. Ranked relevance is [1,1,0,1,0,0,1,0].

Worked step 2. Top three has two hits: precision 2/3 and recall 2/4.

Worked step 3. Top four has precision 3/4 and recall 3/4.

Try it yourself. Can recall decrease when adding items to this fixed ranked prefix?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. Existing hits remain. Precision can rise or fall depending on the added item.

Section 04 / 07

Understand the discrete selection

Selecting the top-ranked passages is a discrete operation. Ordinary backpropagation through a generator does not automatically train every part of an arbitrary retrieval pipeline. Choosing three books from a shelf is different from smoothly turning a volume dial.

Worked step 1. Change a score slightly without changing the top three.

Worked step 2. The selected set remains fixed.

Worked step 3. Cross a rank boundary and the set changes abruptly.

Try it yourself. Does end-to-end branding prove gradients pass through hard top-k?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. Inspect the objective and implementation; separate training or approximations may be involved.

Section 05 / 07

Treat retrieved text as evidence, not authority

A retrieved document can contain instructions aimed at the assistant. Those instructions should not acquire permission to change the system’s task, reveal private data or operate tools. A quoted note saying ignore the teacher is still part of the note, not a new classroom rule.

Worked step 1. Retrieve a passage containing a fake system instruction.

Worked step 2. Ask for a factual summary.

Worked step 3. Verify the application treats the instruction as quoted content.

Try it yourself. Should a retrieved page authorize sending a private file?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. Tool permissions must come from the application’s trusted authorization flow.

Section 06 / 07

Know when evidence is missing

A useful system can state that the corpus does not support an answer. Evaluate missing, stale and contradictory evidence rather than forcing a confident response to every question. An honest blank space is better than inventing a page reference.

Worked step 1. Ask one supported and one unsupported question.

Worked step 2. Check claim-level citations.

Worked step 3. Record unsupported assertions and appropriate abstentions.

Try it yourself. What should a high retrieval score mean?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. It indicates the retriever’s ranking preference, not proof of truth. The supporting text must still be inspected.

Section 07 / 07

Mastery and transfer

Bring the pieces together. First answer the checkpoint without the worked solutions. Then explain the mechanism in your own words, using one numerical example from this lesson.

Retrieval recall is… Option 1: Relevant retrieved divided by all relevant items. Option 2: All retrieved divided by corpus size. Option 3: A guarantee of answer truth.

Pause here and choose an answer before continuing. The checkpoint explanation follows.

Reveal worked solution

The correct choice is option 1: Relevant retrieved divided by all relevant items. Recall measures coverage under the relevance judgments; grounding is another check.

Transfer task. Change one assumption in the worked example. State your prediction, calculate or test it in Workbench, then explain whether the result supports your prediction.

Reveal worked solution

Self-check rubric. Name the changed assumption, keep the other inputs fixed, show at least one intermediate calculation, and distinguish what the toy example guarantees from what would require a trained model or a real measurement.

Sources and scope

Original worked examples and teaching text, grounded in these primary references. Numerical fixtures explain mechanisms; model quality and hardware performance require separate measurements. Both levels share key examples, with different explanations and checkpoints.

Reset this high school path?

This removes only this path’s notes, progress and experiments from this browser.