A. Module overview
| Field | Value |
|---|---|
| Module ID | L2-M06 |
| Level | 2 - AI Quality Engineer (Evaluation) |
| Description | Understand a RAG (Retrieval-Augmented Generation) application as four chained steps (chunking the documents, embedding and indexing, retrieval, generation) and evaluate retrieval and generation separately, then put them side by side: check the corpus and the chunks; retrieval metrics (recall@k, precision@k, hit@k, MRR, nDCG) with relevance labels derived from evidence spans, edge cases and bootstrap intervals; check answers claim by claim (faithfulness, groundedness by citation, relevance) with a simulated judge and a small manual spot check; attribute failures to retrieval or generation with rules and a rerun with oracle context; design a test set by group with a lint; and read a framework's metric critically by computing the same metric two ways. The lab continues the fictional HocVui Tutor product, in "answer from the textbook" mode, and runs offline with a fictional corpus, a simulated generator, a simulated judge and toy embeddings (no model calls, no API key). What is known about real systems and tools is quoted from sources read on 2026-11-04; sources that were only read as a summary are marked in each lesson. |
| Why this module matters | RAG is the common architecture for LLM applications that use private data, and a wrong answer from it has four suspects. A single "RAG quality" number mixes retrieval errors with generation errors and does not point to what to fix. This module teaches measuring each layer, stating what each metric does not say, and asking "how is it computed" before trusting a framework's score. |
| Target professional competency | Level 2: "Evaluate RAG retrieval and generation separately". |
| Estimated duration | 5 lessons × 120 minutes = 10 hours + module assignment ~4 hours + quiz 0.5 hours ≈ 14.5 hours for someone who has completed L2-M05. An estimate, not yet measured with real learners. |
| Prerequisites | L2-M05. The module reuses, without repeating: faithfulness and groundedness as the lab defines them (L2-M03-L04), the judge that only flags while a person decides (L2-M04), the bootstrap interval (L2-M05-L02). High-school math. No API key needed. |
| Module output (deliverable) | A RAG evaluation suite: an annotated map of a RAG application, retrieval metrics on a labelled question set with intervals, a claim-by-claim answer check with a comparison against human labels, a purposeful test set for retrieval misses and unsupported claims with a lint, and a comparison of the same metric computed two ways with an explanation |
| Cost | 0 VND |
What learners build. Step by step, in code-labs/l2-m06: (L01) sentence-based and word-based chunkers, a lint for the corpus and chunks, BM25, a toy character-hashing embedding, rank fusion, deterministic ranking, a simulated generator; (L02) recall@k, precision@k, hit@k, MRR, nDCG, relevance labels derived from evidence spans that stay valid when the chunking changes, merging duplicates, and a bootstrap interval plus a paired interval; (L03) claim checking, five citation statuses, relevance, a simulated judge, a confusion table against human labels and the probability that a manual spot check misses a wrong case; (L04) failure attribution, a rerun with oracle context, a scan for instructions inside chunks and a test-set lint; (L05) context precision and faithfulness computed two ways, a repeatability check for a model-based metric (simulated), and a descriptor with a lint for a tool's metric. The lab is independent of the earlier labs and needs only pytest.
What the module does not do. It does not measure a real retriever or model: every number in the lab describes the simulation. It does not rank or recommend any framework; L05 only gives sourced comparison criteria and a way to check for yourself. It gives no legal opinion. The "RAG is taught in L2-M06" promises of L2-M03 are fulfilled in L03; the judge here only flags and a person reviews, as in L2-M04.
B. Learning objectives
| ID | Objective |
|---|---|
| MO1 | Explain the four steps of RAG, chunk a corpus and run the lint to find duplicates, injected instructions and chunks that cut evidence in half. |
| MO2 | Compute and report retrieval metrics with intervals, handling edge cases (empty, large k, no correct chunk, duplicates, ties). |
| MO3 | Grade an answer claim by claim and by citation, compare it with human labels and compute the probability that a manual spot check misses a wrong case. |
| MO4 | Attribute a failure to retrieval or generation and design a test set with a lint aimed at retrieval misses and unsupported claims. |
| MO5 | Compute the same metric two ways, explain the difference and read a framework's metric with the seven questions the lab provides (answers quoted from the documents read). |
C. Lessons
| ID | Lesson | Duration | Prerequisite | Concepts | Practical output |
|---|---|---|---|---|---|
| L2-M06-L01 | RAG architecture: chunking, embedding, retrieval and answer generation | 120' | L2-M05-L04 | four steps, chunks and sentence-level evidence, corpus lint, BM25, toy embedding, rank fusion, deterministic ranking | An annotated map of a small RAG application |
| L2-M06-L02 | Evaluating retrieval: recall@k, precision@k, MRR and nDCG | 120' | L01 | five metrics, labels derived from evidence spans, undefined is not 0, overlap and duplicates, bootstrap interval | Retrieval metrics on a labelled question set |
| L2-M06-L03 | Evaluating generation: faithfulness, groundedness and answer relevance, with a judge and a manual spot check | 120' | L02 | claims, five citation statuses, confusion table, simulated judge, spot check sample size | A faithfulness check with a comparison against human labels |
| L2-M06-L04 | RAG failures and test set design: attributing a failure to retrieval or generation | 120' | L03 | failure modes, priority order, oracle context, question groups, test-set lint | A test set aimed at retrieval misses and unsupported claims |
| L2-M06-L05 | Using evaluation frameworks critically: the same metric, two ways to compute it | 120' | L04 | same name different computation, seven questions, repeatability check, descriptor | The same metric computed two ways, with the difference explained |
D. Hands-on assignment (module assignment)
The module assignment (a RAG evaluation suite for one feature: retrieval metrics with intervals, a claim-by-claim answer check, a test set with a lint, and the same metric computed two ways) is in exercises.md. The five standalone exercises for the individual lessons are in code-labs/l2-m06/exercises/ and in §9 of each lesson.
E. Module assessment
The module quiz quiz.md, the module assignment rubric in exercises.md, and the practice-0N.md practice for each lesson. The solutions and the instructor guide are for instructors only and are not published.
F. References
The shared list references.md; each lesson also has its own references table in §12 with the access date and how much of each source was read.
Objectives ↔ assessment matrix
| Objective | Lesson | Standalone exercise (§9) | Module quiz | Module assignment criterion |
|---|---|---|---|---|
| MO1 | L01 | exercises/test_l01_architecture.py |
Q1, Q6 | AC1 |
| MO2 | L02 | exercises/test_l02_retrieval_metrics.py |
Q2, Q7, Q9 | AC2 |
| MO3 | L03 | exercises/test_l03_generation_checks.py |
Q3, Q8, Q10 | AC3 |
| MO4 | L04 | exercises/test_l04_failures_testset.py |
Q4, Q12 | AC4 |
| MO5 | L05 | exercises/test_l05_frameworks.py |
Q5, Q11 | AC5 |