Back to the curriculum

L2-M07 · Level 2 · ~14.25 h

Model Comparison and Evaluation Pipelines

What you build: Reproducible experiment report

lessons
5
lesson hours (estimate)
≈ 10 h
0/5 lessons marked done · Progress is saved in this browser only. No account, nothing is sent to a server.
In review. The curriculum, module overviews and Levels 1–3 lessons are drafts written with AI assistance and reviewed by AI. Human review is still pending. English translation: AI-assisted, not human-reviewed.

Levels 1–3 lessons, exercises and quizzes are published as drafts, in Vietnamese with an AI-assisted English translation. They may change after human review.

Module path

  1. Lesson 1 · L2-M07-L01≈ 2 h

    Experiment design for prompt and model comparison

    What you build: Pre-registered comparison plan

    Needs: L2-M06-L05

    Key terms (10)
    • Comparison planKế hoạch so sánh, viết trước dữ liệu
    • Pre-registrationĐăng ký trước: ghi kế hoạch trước khi thấy kết quả
    • Primary metricChỉ số chính: số duy nhất quyết định kết luận
    • Pinned model idMã model ghim: có ngày, khác bí danh
    • Effect sizeĐộ lớn hiệu ứng: ở đây là hiệu hai tỷ lệ pass
    • Statistical vs practical significanceÝ nghĩa thống kê / thực tế (so với margin)
    • Dev set / held-out setTập chọn lựa / tập xác nhận
    • Winner's curseLời nguyền người thắng: điểm của biến thể thắng bị thổi phồng
    • Family-wise error rateXác suất có ít nhất một dương giả trong cả họ phép thử
    • Holm correctionHiệu chỉnh Holm
  2. Lesson 2 · L2-M07-L02≈ 2 h

    Comparing under variance: paired comparisons and bootstrap

    What you build: Interval on the difference between variants

    Needs: L2-M07-L01

    Key terms (9)
    • Paired comparisonSo sánh có ghép cặp: hai hệ thống chấm trên cùng các mục
    • Discordant itemsMục khác nhau: chỉ một hệ thống pass
    • Sign testKiểm định dấu: đếm thắng và thua, bỏ mục hòa
    • McNemar's testKiểm định McNemar: kiểm định dấu cho điểm nhị phân ghép cặp
    • Exact vs approximate p-valuep chính xác (nhị thức) / p xấp xỉ (χ²)
    • Paired bootstrap intervalKhoảng bootstrap ghép cặp cho hiệu
    • Practical marginBiên thực tế: hiệu nhỏ hơn mức này không đổi quyết định
    • Unit of analysisĐơn vị phân tích: ở đây là mục, không phải lần chạy
    • Repeated-experiment powerPower đo bằng lặp thí nghiệm có khác biệt thật đã biết
  3. Lesson 3 · L2-M07-L03≈ 2 h

    Quality, cost and latency trade-offs

    What you build: Trade-off table

    Needs: L2-M07-L02

    Key terms (8)
    • Trade-off tableBảng đánh đổi chất lượng, chi phí, độ trễ
    • Cost unit (cu)Đơn vị chi phí giả của lab
    • Cost per request / per successChi phí mỗi yêu cầu / mỗi lần pass
    • Latency percentile (p50, p95)Phân vị độ trễ; lab dùng hạng gần nhất
    • Dominated / Pareto frontBị trội / mặt Pareto
    • Extra cost per pointChi phí thêm cho mỗi điểm chất lượng
    • Constraint-based choiceChọn theo ràng buộc, dùng cận dưới
    • Conservative choiceChọn bảo thủ: không hệ thống đạt thì trả `None` (cùng tinh thần fail closed, L04)
  4. Lesson 4 · L2-M07-L04≈ 2.5 h

    Evaluation pipelines and quality gates in CI

    What you build: Gate that blocks a regression

    Needs: L2-M07-L03

    Key terms (9)
    • Evaluation pipelinePipeline đánh giá: chuỗi bước chạy đánh giá (khác pipeline RAG)
    • Quality gateCổng chất lượng: trả mã thoát cho CI
    • Non-inferiorityKhông kém hơn: không tệ hơn baseline quá margin
    • Fail closedFail closed: thiếu hay lỗi thì chặn, không cho qua
    • Exit codeMã thoát: 0 PASS, 1 FAIL, 2 INCONCLUSIVE, 3 ERROR
    • Dataset fingerprint / versionDấu vân tay / phiên bản dataset
    • Cache keyKhóa cache: gồm mọi đầu vào làm đổi kết quả
    • Run manifestManifest lần chạy: cấu hình, dataset, seed, mã băm kết quả
    • Manual-trigger workflowWorkflow chạy tay (`workflow_dispatch`)
  5. Lesson 5 · L2-M07-L05≈ 2 h

    Reproducible experiment reports

    What you build: Report with full run configuration

    Needs: L2-M07-L04

    Key terms (8)
    • ReproducibleLặp lại được: cùng mã, cấu hình, dữ liệu cho kết quả tương tự (khác đúng và khác nhân rộng)
    • Experiment reportBáo cáo thí nghiệm
    • Run manifestManifest lần chạy (L04)
    • Results digestMã băm của kết quả
    • Exploratory vs confirmatoryKhám phá / xác nhận
    • Deviation (from the plan)Sai lệch khỏi kế hoạch, ghi cùng lý do
    • Recompute checkKiểm số: tái tính số của báo cáo từ dữ liệu
    • Decision recordBản ghi quyết định của người: tên, quyết định, lý do

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)