Module: L2-M08 (capstone) · Duration: ~12 hours (estimate) · Previous: Milestone 2 · Next: Milestone 4
1. Introduction
Deterministic metric functions only check what code can check. A criterion like "clear, appropriate for the age group" (T7) needs a judge, and the score of an uncalibrated judge is a number nobody has verified. Milestone 3 does three things:
read the raw output of the simulated judge with an integrity check; use noisy human labels to calibrate it (thresholds chosen on dev, reported on test);
then compare stable and rc as pairs on test and pass the result through a fail-closed gate. The output is a calibrated run: python -m evalplatform --out out runs to completion and returns the gate's exit code.
2. Objectives
- Read the judge's raw output with a strict parser and detect stale, unknown, duplicate and missing lines.
- Compute the gold label from human labels (majority, ties rejected) and measure agreement with kappa.
- Calibrate the judge: choose the threshold on
dev, report false accepts, false rejects and kappa ontest, and say whether the judge is usable. - Compare
stableandrcas pairs: exact p, bootstrap interval, practical margin, each slice; read correctly the small slice and the case where no item differs. - Run the A/A check and implement the fail-closed gate with exit codes 0, 1, 2, 3.
3. Prerequisites
- The milestone 2 dataset and runner work (
out/runs/has two record files). - Quick review: L2-M04 (reading judge output, calibration, kappa), L2-M05-L02 (agreement), L2-M07-L02 (paired comparison), L2-M07-L04 (the gate).
- Two new concepts in the capstone (earlier modules have not taught them): the judge line integrity check (a judge line contains the hash of the answer it graded; a different hash means the judge graded a different answer) and the A/A check (compare a version with itself in two runs to measure the background noise).
4. Parts of milestone 3
4.1 Reading the judge's output
Each line of data/judge/judge_raw.jsonl has version, case_id, reply_sha and raw. The parser parse_judge accepts only exactly one line Điểm: N ("Điểm" means "Score") with N from 1 to 5, or [[?]] alone
(the judge declines to score). Anything else (no score line, two score lines, "4/5", "Điểm: 7", extra text after the number) is never read as a score. The function attach adds the integrity check: a line whose reply_sha differs from the
record's is stale (the judge graded a different answer), a line with no record is unknown, two lines for one key are duplicate, and an item that needs grading but has no line is missing. Every item that cannot be used counts toward the
unparsed rate; above max_unparsed_rate in policy.json the gate is ERROR, because scores from a partly broken judge can be skewed without anyone noticing.
4.2 Human labels and agreement
Three simulated annotators (A1-A3, fictional) label a sample of items 0/1, with noise and missing labels. The gold label (the label settled by the majority of annotators; different from the "gold item" of L2-M05) is the majority of the labels present; an item with fewer than 2 labels or a tie is rejected, not guessed. How far two annotators agree with each other decides
how far the gold label can be trusted: use Cohen's kappa for each pair on the items both labeled, computed exactly with Fraction. Kappa is None when both use a single label (undefined, not 1).
Raw agreement can overstate the real agreement because it does not subtract the agreement that happens by guessing; kappa can understate agreement too much because of its assumptions (McHugh, 2012 [R2]; details in L2-M05-L02).
So the report prints both (raw agreement and kappa, for each pair) and does not treat one number as the truth.
4.3 Calibrating the judge
For each threshold t from 1 to 5 (the judge "accepts" when the score ≥ t), compute the false accept rate (the judge accepts but the gold label is not accept) on dev. Choose the lowest t whose false accept rate is defined and does not exceed the limit
(max_false_accept_dev; exactly equal to the limit is acceptable). The positive class is "accept" (as in L2-M04-L04), so the negative label is an item the humans rated as not accept. Then report the false accept rate, the false reject rate (the judge does not accept an item the humans rated accept) and the judge-versus-human kappa on test, not on dev: measuring on the data used to choose the threshold is grading your own homework. The judge is usable when there are enough labeled items on test, the false accept rate does not exceed max_false_accept, kappa is not below min_kappa and the unparsed rate is within the limit; otherwise the gate is ERROR.
Why false accepts matter more than false rejects here: a false reject usually lowers the numbers of both versions in a similar way, while a false accept hides a bad answer. The number of negative-label items on test is small, so the Wilson interval of the false accept rate is wide: the report prints the interval and not only the point estimate, and a judge declared "usable" on just 7 negative-label items can still have a true false accept rate of more than half. Zheng et al. (2023) survey the use of judges and name biases such as position bias, length bias and self-preference [R3, summary only read]; the judge here is simulated, so it only shows you how to measure,
not how a real judge would be biased.
4.4 Paired comparison and the practical margin
The unit is the item. Each item has a final pass flag: the deterministic checks all pass and, for slices with a judge (concept, hint), the judge score is not below the threshold (an item with no score counts as not passing). With two versions
graded on the same items, count the items rc wins and loses (tied items are not counted), then:
- the exact p of the sign test (exact McNemar) from the number of wins and losses; if no item differs then p = 1, which means "no evidence yet", not "no difference";
- the paired bootstrap interval for the difference
rc - stable, resampling the items; - the practical margin ("biên thực tế",
margin) of 0.05 inpolicy.json: PASS when the lower bound is not below -0.05; FAIL when the whole interval is below -0.05; otherwise INCONCLUSIVE. Exactly -0.05 at the lower bound is PASS; at the upper bound it is not yet FAIL.
Three cases to read carefully. A small slice: fewer than min_slice_n items is INCONCLUSIVE, because the interval is too wide. No losses seen: when rc loses no item, the lower bound of the interval must not be higher than the "none seen" bound for n items: one win in 30 items must not look better than 30 identical items (both INCONCLUSIVE with a margin of 0.05). No item differs: the bootstrap collapses to [0, 0] and claims certainty; use the "none seen" bound
(L2-M01-L04, L2-M07-L02): with 30 identical items, the true difference can still be off by about 0.095, so it cannot be PASS with a margin of 0.05. Miller (2024) treats evaluation as an experiment and gives recommendations on how to report in order to reduce statistical noise and give the most information; the title is
"Adding Error Bars to Evals" [R1, summary only read].
4.5 The A/A check and the gate
A/A: run stable today against the earlier stable run (data/prior/stable_prior.json, a different seed) on the shared items. If there is already a significant difference between two runs of the same version,
the background noise is larger than you thought and every rc - stable difference is suspect. The intersection by item id must report the shared-item rate (min_prior_coverage; different from the coverage of a confidence interval and the coverage of the dataset); below that level the runs cannot be compared (ERROR). The report also prints how many items changed result between the two runs: a p that is not small does not mean there is no noise.
The gate takes the worst part among the whole and the critical slices (safety, hint, check); looking only at the whole is how a small but serious slice gets hidden by a large slice that is improving.
Any input problem and any unexpected exception is ERROR, code 3; a gate result that is not recognized also gives code 3, never 0. The gate releases nothing: it only reports whether a person needs to look closely (L2-M07-L04). If the gate is PASS but A/A is not consistent, the result is lowered to INCONCLUSIVE (reason AA_DRIFT).
Do not change the margin to get a PASS; changing the margin needs a written reason and the signature of the decision maker (milestone 4).
5. Hands-on: try the computations on a small example
Create try_m3.py in the root folder of starter/, next to evalplatform/:
from fractions import Fraction
from evalplatform import calibrate, compare, human, stats
print(stats.sign_test_p(2, 8))
print(round(float(stats.zero_discordant_bound(30)), 3))
print(human.cohen_kappa([1, 1, 1, 0], [1, 1, 0, 0]))
print([round(x, 3) for x in calibrate.wilson(5, 10)])
m = Fraction(1, 20)
print(compare.decide(-m, Fraction(1, 10), m), compare.decide(-m - Fraction(1, 1000), Fraction(1, 10), m))
p = {"bootstrap_reps": 200, "margin": m}
r = compare.analyze([1, 0] * 15, [1, 0] * 15, p, "toy", 10)
print(r["decision"], r["degenerate"], r["p"])
r = compare.analyze([0] + [1] * 29, [1] * 30, p, "toy", 10)
print(r["decision"], r["wins"], r["losses"])
Output (copied from a real run with the reference solution, 2026-11-04, Python 3.14.6 and 3.12.14, identical results):
7/64
0.095
1/2
[0.237, 0.763]
PASS INCONCLUSIVE
INCONCLUSIVE True 1
INCONCLUSIVE 1 0
Reading line by line: 2 wins and 8 losses give p = 7/64 (about 0.109, not reaching 0.05 even though there are four times as many losses); 30 identical items give a bound of about 0.095; kappa is 1/2; the Wilson interval for 5 out of 10 is very wide; a lower bound of exactly -0.05 is PASS, one thousandth lower is INCONCLUSIVE; 30 identical items are INCONCLUSIVE, and one win in 30 items (no losses) is also INCONCLUSIVE. Then run the whole platform:
python -m evalplatform --out out
echo "exit=$?"
Expected: one line gate: ... and the gate's exit code. Before trusting the result: compute by hand (with a short script that reads out/runs/*.jsonl and out/judge/attached.json, without using your own functions) the wins, the losses and the rate of one slice,
then compare with out/compare/result.json. The two numbers must match. Write down the method and the result in deliverables/hand-check.md (the grader reads it; the test suite does not check it).
6. Classifying results
A failed check is not automatically a product defect. Classify before reporting:
| Class | Sign | What to do |
|---|---|---|
| Product defect | rc fails while stable passes, repeatable with the same seed |
Report with counts, name the clause |
| Shared defect | Both versions fail | Report as a shared defect; do not use as comparison evidence |
| Oracle defect | Your check is wrong (for example a number compared by substring) | Fix the check, add a boundary check |
| Data defect | A wrong, duplicate or contaminated item | Reject it in the dataset manager |
| Judge skew | High false accepts, low kappa, many unparsed lines | Do not use the judge; the gate is ERROR |
| Noise | A/A is significant, the difference is small compared with the interval | Do not conclude; add items or run again |
| Environment or tooling | Missing file, path, Python version | Fix the environment, not the product code |
7. Milestone 3 deliverables
- Code:
judge.py,human.py,calibrate.py,stats.py,compare.py. python -m evalplatform --out outruns to the end, writesout/judge/andout/compare/and returns the gate's exit code.deliverables/hand-check.md: the judge threshold you chose ondev, false accept, false reject and kappa ontest, two limits of the calibration, and the hand computation of one slice.
Criteria: pass tests/test_m3_judge.py and tests/test_m3_compare.py (AC3.1-AC3.34); you can compute one slice by hand and it matches the platform's result.
8. Self-check questions
0/14 done · Results are kept in this browser only.
P01 · Short answer
Each row of judge_raw.jsonl has a reply_sha field. What is it for, and what does a row whose reply_sha differs from the record of the same key tell you?
P03 · Match
P04 · Fill in the blank
P05 · Multiple choice
P06 · Put in order
P07 · Select all that apply
P09 · Essay
On 7 negative-label items of test (simulated), the judge accepts 1 item: the false accept rate is 1/7, about 0.143, not above the limit of 0.20. Write 5-8 sentences answering the question of the decision maker: "Is this judge usable yet, and what do you report along with that number?"
P10 · Recall
Lesson: L2-M04-L04P12 · Short answer
The practical margin is 0.05 and the confidence level is 95%. A slice has n items on which rc and stable give identical results on every item. Using the "not seen once" bound of L2-M01-L04 §4.3 (1 - 0,05^(1/n)), find the smallest number of items n that makes decide give PASS for that slice, and say what n = 30 gives.
P13 · True or false
P14 · Fill in the blank
9. Summary
- The judge output is read strictly and checked for integrity; the unparsed rate is a quality signal.
- The judge threshold is chosen on
devand reported ontest; false accepts matter more than false rejects, and the interval must be printed. - Paired comparison uses the exact p, the bootstrap interval and the practical margin; a small slice and the case where no item differs are INCONCLUSIVE.
- The gate takes the worst part of the critical slices and fails closed; A/A measures the background noise.
10. References
See this module's references.md.