AI MOOC
✦ Grow togetherInvite 3 friends, earn 1 month of membership · Up to 12 monthsInvite friends →

Library / My reading notes

Run retrieval and inspect the candidates

Execute retrieval and distinguish filtering, recall, ranking and no results.

Back to the RAG course plan: Build a searchable, cited RAG knowledge base

Chapter 4 / 8 · Read and take notes

Execute retrieval and distinguish filtering, recall, ranking and no results.

Understand the method

Run the command from the extracted folder. --retrieve does not call a model or generate an answer. Inspect IDs, versions, audience, text and scores in evidence; these are the basis for diagnosis.

retrieve() excludes archived records, filters applicability, scores overlap, removes zero matches and returns the top three. Ties use IDs for reproducibility. Linear scanning is sufficient for this tiny corpus, not a claim about large-scale performance.

With intern selected, P1 is excluded while P2 and general rules may remain. A candidate is not automatically supporting evidence. P2 helps explain a missing cap; it does not supply one.

For a miss, check corpus inclusion, filters and wording in that order. Only the wording problem may improve with synonyms or semantic search. Raising top_k cannot recover a rule that does not exist.

The lab fixes top_k at three. More candidates can increase recall and noise; fewer may drop a source required for a multi-part answer. Q10 checks whether both repair and booking evidence are present.

Save outputs with the exact question, audience, corpus version and candidate order. A final answer alone cannot distinguish retrieval and generation defects. Real systems should also log latency and errors while limiting private data.

  1. 1Status
  2. 2Audience
  3. 3Rank
  4. 4Inspect

Included material

Run supplied cases against the same Chinese corpus:
python3 rag_lab.py --case Q2
python3 rag_lab.py --case Q5
python3 rag_lab.py --case Q12

Work through the steps

  1. Run the intern question and confirm that P1 and P1-old are absent.
  2. Check that P4 is retrieved and inspect the full text.
  3. Observe the no-evidence query and save its actual JSON.

Worked example

Expected structure, not a simulated model answer:
mode: retrieval-only
evidence: candidate list
Intern case includes P2 and excludes P1.
The supplied out-of-scope case has no matches; a changed question may accidentally overlap.

Your exercise

Run a paraphrase and a multi-part question. Record expected sources, actual sources and the reason for any difference.

Check before delivery

  • Locate filtering before scoring and avoid treating scores as confidence.
  • Use actual command output with inputs and versions.
Finish the exercise, then view the reference

Only P4 retrieved is a coverage failure. Both P4/P5 retrieved but only repair answered is a generation omission. Candidate logs distinguish the repairs.

An original course with teaching exercises. Reading records, practice outcomes and independent certification are distinct.

References and further reading

The lessons are original. The following sources are provided under their respective permissions.

Article / guide

Prompt Engineering Guide

DAIR.AI · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned 57673726
Article / guide

RAG and Vector Databases

Microsoft · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned d45da912
Whitepaper / report

NIST AI 600-1: Generative AI Profile

NIST / Autio et al. · en

NIST Technical Series reprint policy

Original PDF provided under the institution’s reprint policy.

License checked: 2026-10-16
Article / guide

Ollama Chat API

Ollama · en

Official documentation link; no full-text reproduction

Original link only; full text is not mirrored.

License checked: 2026-10-20