A. Module overview
| Field | Value |
|---|---|
| Module ID | L2-M07 |
| Level | 2 - AI Quality Engineer (Evaluation) |
| Description | Compare two prompts or two models in a defensible way, then turn the comparison into a process that can be run again and again: a comparison plan written before the data (one factor, a pinned model id, a primary metric, a practical margin, a sample size, selection kept apart from confirmation, a correction when many variants are tried); a paired comparison (the exact sign test and McNemar test, a paired bootstrap interval for the difference, a verdict against the margin, several runs per item, power measured by repeated experiments; it continues the paired bootstrap of L2-M06-L02); a quality, cost and latency trade-off table with a Pareto front and constraint-based choice; an evaluation pipeline with a config check, a versioned dataset, a cache, a manifest and a regression gate that fails closed with an exit code; and a reproducible experiment report with numbers recomputed from the data and a person's decision. The lab continues the fictional HocVui Tutor product and runs offline with a simulated system with known real differences (no model calls, no API key). What is known about real practice 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 | Most "change the prompt" or "change the model" decisions rest on a single run, and a single run can be wrong even in sign. This module teaches the questions to ask: was it designed in advance, is the difference larger than the noise, does it matter, how much more expensive and slower is it, and does the gate block correctly. It fulfils the promises of L2-M01-L04, L2-M03-L05 and L2-M04-L04 about paired comparison and sample size. |
| Target professional competency | Level 2: "comparing models or prompts under variance" and "evaluation quality gates in CI". |
| Estimated duration | 5 lessons (120 + 120 + 105 + 135 + 105 minutes) ≈ 9.75 hours + module assignment ~4 hours + quiz 0.5 hours ≈ 14.25 hours for someone who has completed L2-M06. An estimate, not yet measured with real learners. |
| Prerequisites | L2-M06. The module reuses, without repeating: confidence intervals and sample size (L2-M01-L04), datasets and fingerprints (L2-M02), the release gate (L2-M02-L05), per-slice regression (L2-M03-L05), the judge that only flags while a person decides (L2-M04), the bootstrap interval (L2-M05-L02, L2-M06-L02), CI and exit codes (L1-M07-L04). High-school math. No API key needed. |
| Module output (deliverable) | A reproducible experiment report: a comparison plan frozen with a hash, an interval for the difference between two variants with an exact p-value and a verdict against the margin, a quality-cost-latency trade-off table, a working regression gate, and a report with the full run configuration, recomputable numbers, deviations from the plan and the person's decision |
| Cost | 0 VND |
What learners build. Step by step, in code-labs/l2-m07: (L01) a plan lint, a plan hash, a deviation check, sample size from δ, a dev and held-out split by item id, a winner's curse simulation, Holm correction; (L02) the exact sign test and McNemar test, the χ² approximation, a paired bootstrap interval, the limit when no items differ, a verdict against the margin, power measured by repetition; (L03) nearest-rank percentiles, cost per request and per pass, the Pareto front, constraint-based choice; (L04) a config check, a dataset registry with fingerprints, a cache keyed on every input, a manifest, a four-decision gate with an exit code, a lint for a sample manual-trigger workflow; (L05) a report built from the manifest, a lint and a number check, reproduction from the manifest. The lab is independent of the earlier labs and needs only pytest.
What the module does not do. It does not measure real models, it states no real prices or speeds, and it does not rank any model or vendor: every number in the lab describes the simulation. It does not create or edit an automatically running workflow in the repository: the GitHub Actions workflow exists only as sample text to run by hand. It gives no legal opinion. The gate and the tests only flag; a person decides on release.
B. Learning objectives
| ID | Objective |
|---|---|
| MO1 | Write a comparison plan before the data (one factor, a pinned model id, a primary metric, a margin, a sample size) and check it with a lint and a hash. |
| MO2 | Analyze a paired comparison with an exact p-value and a bootstrap interval, read the result against the practical margin and handle edge cases. |
| MO3 | Separate selection items from confirmation items, explain the winner's curse and correct when many variants are tried. |
| MO4 | Build a quality, cost and latency trade-off table and choose under constraints without ignoring the error. |
| MO5 | Run an evaluation pipeline with a gate that fails closed and write a reproducible report with the person's decision. |
C. Lessons
| ID | Lesson | Duration | Prerequisite | Concepts | Practical output |
|---|---|---|---|---|---|
| L2-M07-L01 | Designing an experiment to compare prompts and models | 120' | L2-M06-L05 | plan and hash, one factor, pinned model id, practical margin, sample size, dev and held-out, winner's curse, Holm | A pre-registered comparison plan |
| L2-M07-L02 | Comparing under variance: paired comparison and the bootstrap | 120' | L01 | discordant items, sign test and McNemar, paired bootstrap interval, no discordant items, the item is the unit, power measured by repetition | An interval for the difference between two variants |
| L2-M07-L03 | Trade-offs between quality, cost and latency | 105' | L02 | percentiles, cost per pass, Pareto front, constraint-based choice | A trade-off table |
| L2-M07-L04 | The evaluation pipeline and the quality gate in CI | 135' | L03 | config, versioned dataset, cache, manifest, gate with an exit code, fail closed, manual-trigger workflow | A regression gate |
| L2-M07-L05 | A reproducible experiment report | 105' | L04 | report from the manifest, number check, confirmatory and exploratory, deviations, the person's decision | A report with the full run configuration |
D. Hands-on assignment (module assignment)
The module assignment (a reproducible experiment report for one comparison: the plan, the paired analysis, the trade-off table, the gate and the report) is in exercises.md. The five standalone exercises for the individual lessons are in code-labs/l2-m07/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) | Quiz questions | Module assignment criteria |
|---|---|---|---|---|
| MO1 | L01 | exercises/test_l01_design.py |
Q1 (editing alpha after freezing: hash and lint), Q6 (a lint-clean plan does not count the correction into the sample size) |
AC1 (plan.json, hash, corrected_n, deviations table) |
| MO2 | L02 | exercises/test_l02_paired.py |
Q2 (verdict at the boundary), Q8 (no items differ), Q9 (exact p and the minimum number of wins) | AC2 (min_wins_to_reject, paired.md) |
| MO3 | L01 | exercises/test_l01_design.py (TODO 2: false positive probability); the dev/held-out split, the winner's curse and Holm appear only in §8.3 of L01 |
Q7 (Holm versus Bonferroni), Q10 (winner's curse and false positive probability) | AC1 (dev/held-out, selection.repeat) and AC2 (Holm, Bonferroni) |
| MO4 | L03 | exercises/test_l03_tradeoff.py |
Q3 (Pareto front), Q11 (nearest-rank percentile and the latency threshold) | AC3 (share_within, meets_slo, tradeoff.md) |
| MO5 | L04, L05 | exercises/test_l04_gate.py, exercises/test_l05_report.py |
Q4 (the gate's exit code), Q5 (reproducible versus correct), Q12 (gate, different datasets and || true) |
AC4 (policy.json, sample workflow, gate.md), AC5 (decision.json, report.md), AC6 (reproduction) |