Estimated time: ~4 hours for someone who has finished the five independent exercises of L01-L05 (an estimate, not yet measured with real learners). Main tools:
lab.checklist,lab.prompts,lab.parse,lab.judge,lab.pipeline,lab.probes,lab.calibrate,lab.opsincode-labs/l2-m04. The judge in the lab is a simulation with a seed: it calls no model and needs no API key.
Main hands-on assignment
Business context
The HocVui team (fictional) has tutor v2 and wants a judge that grades "the answer passes overall" (correct final answer, has an explanation, does not talk down to students in grades 3 to 5) so that nobody has to read every answer. The QA lead has left three things unfinished: nobody has measured the judge itself, no record says which configuration the judge ran with, and the question "can the judge block a release yet". You need to build a judge evaluator with a calibration check (a decision table, three prompt variants with a closed parser, a bias report, a calibration report, a configuration record for every run) and answer: what does this judge measure, where is it off, and what should it be used for?
Problem to solve
A convenient-looking judge can still be wrong in measurable ways: it is fooled by a wrong answer that sounds confident, it favours long answers or answers from its own model family, it is lenient at the default threshold, and it changes behaviour when one line of configuration changes. A figure like "82% agreement" can hide a false-accept rate above the ceiling. Your job is to measure the judge itself with the labels provided, under the fixed configuration below, record what each step does not check, and make an evidence-based decision: what the judge may be used for and what it may not yet be used for.
Input data
All data is already in code-labs/l2-m04/data/ and is fictional, simulated with a seed; do not edit lab/, data/ or exercises/.
- Task 1:
data/criteria.json(six criteria, each with the seven fields ofchecklist). - Task 2:
data/rubric.json,data/questions.json,data/replies.jsonl(200 answers with human labels),data/pairs.jsonl(typequality, 28 pairs). - Task 3:
data/pairs.jsonl(112 pairs, four typesquality,order,length,self, 28 pairs each) anddata/replies.jsonl. - Task 4:
data/replies.jsonl,data/questions.json. - Task 5:
data/replies.jsonl,data/rubric.json,lab.prompts.POINTWISE.
The fixed configuration (so that every submission is reproducible and comparable):
| Item | Value |
|---|---|
| Simulated judge | judge.SimJudge(name="judge-sim", version="v2", family="tutor-b", seed=7, w_pos=0, w_len=6, w_self=10, noise=4, tie_margin=6); the remaining parameters at their defaults. Control in Task 3: same name, version, family and seed but {**judge.FAIR, ...} |
| Single-answer grading | pointwise; passes when the score ≥ threshold; in Tasks 4 and 5 use reference=True; unreadable output ("ERROR", "UNKNOWN") is not turned into a score and is counted separately |
| Dev/test split | calibrate.split_dev_test with the defaults (test_fraction 1/2), on all 200 items (including unreadable ones); the positive class is "PASS" |
| Threshold choice | grid 1 to 5; chosen on dev with choose_threshold with a false-accept ceiling of 1/4 (inclusive); reported on test; sensitivity table with four ceilings 1/10, 1/5, 1/4, 3/10 |
| Release gate | release_gate(..., min_n=80, max_false_accept=1/4, min_kappa=3/5), the limits are the lab's choice |
| Bias | order, length, self pairs as the type names say; the judge's family is tutor-b; padding: 3 filler sentences on the first 100 answers of replies.jsonl; the default length flag of flag_length_gap |
| Canary | the first 60 readable test items by item id; the judge has the reference answer, threshold 5; the baseline is the judge of Task 4; three days with lenience 3, 6, 30 on 60 items, one day with lenience 0 on the first 24 items |
| Cost | 3000 items, prompt 250 and output 30 units, three ways to run: one pass; both orders; both orders and 3 repeats; the illustrative unit price of lab.ops |
| Hashes | prompt_sha and rubric_sha are the first 12 hex characters of the SHA-256 of the UTF-8 string (CRLF turned into LF) of prompts.POINTWISE and of the content of the file data/rubric.json; the dataset fingerprint is a hash of the same kind of data/replies.jsonl |
Tasks
- Decision table (L01). Write
decision.json:criteriamaps the name of each criterion indata/criteria.jsonto{"use", "why"}(whyat least 8 words saying which rule of the decision table applies) andnew_criterion, a new criterion with all seven fields thatchecklist.recommendsends to"judge"and that blocks nothing. Reportdecision.md: a table of the six criteria with how each is graded and what is blocking, four boundary rows (no_unsafe_advice_to_a_childat 100 and 101 items per week;explanation_suits_grade_3_to_5at 49 and 50 labels), and your reasons. - Prompt and parser (L02). Write
mine.pywithPAIRWISE_TEMPLATE: a pairwise prompt that considers only the criterion "a tone that does not talk down to students" ("coi thường" = talk down). Writeraw_outputs.json: at least 8 new raw outputs of the judge, each withid,variant("pointwise"or"pairwise"),rawandexpected(your predicted result ofparse.ratingorparse.pairwise). Reportprompts.md: lint of the three lab templates and your template, the sizes of the four filled prompts (questionQ02, the two answersR002andR003, the reference answerĐáp án: 56 cái bút.), a parser table (raw output, expectation, actual result), the three variants on the same data (pointwise with score 5 or above matching the human label over 200 answers, and pairwise in one order over the 28qualitypairs, each with and without the reference answer, with the number of unreadable outputs), andprompts.renderrejecting content that forges a closing marker. - Bias probes (L03). For the judge of the configuration table and for the control judge, report
bias.md: consistency, the number of verdicts in slot A, slot B, ties and the A share on theorderpairs; the number of verdicts choosing the longer answer, the shorter answer, ties on thelengthpairs; the number choosing the same-family answer, the other-family answer, ties on theselfpairs; agreement with the human winner in one order and in both orders over the 112 pairs (with the number of unreadable outputs); the effect of the 3 filler sentences; the number of pairs marked byflag_length_gap; the number of answers the human failed that the judge passes at threshold 4 and 5; thefamily_conflictresult. Innotes/decisions.mdsay which biases the numbers support, which are not proven yet, and what the both-orders rule does not fix. - Calibration (L04). Grade the 200 answers with the judge of the fixed configuration (with the reference answer), split dev/test, sweep the threshold on dev, choose the threshold with the 1/4 ceiling, make the sensitivity table with the four ceilings, report on test (confusion matrix, agreement with its interval, kappa, false-accept rate with its interval, false-reject rate, by
borderlinegroup), the always-pass baseline and the release gate. Writetriage(scored, threshold, gate)inmine.py(scoredis the result ofpipeline.score_itemsplusborderline,gateis the result ofrelease_gate): return{"auto_pass", "human_review", "unreadable"}(lists of ids;unreadableis insidehuman_review). The judge only flags or ranks; a person reviews and decides. Whengateis not exactly the string"READY"(fail closed), no item is auto-passed: every id goes tohuman_review. Whengateis"READY", only an integer score at or above the threshold (inclusive) and not a borderline case ("ca lưng chừng") isauto_pass; every remaining item, including"ERROR"and"UNKNOWN", goes tohuman_review.human_reviewis ordered by reading order: unreadable outputs first, then score ascending, ties by id. A threshold that is not an integer from 1 to 5 raisesValueError. Reportcalibration.mdstatestriagewith your real gate (the numbers ofauto_pass,human_review,unreadableitems on test) and, only for comparison, with a hypotheticalgateof"READY". - Configuration, cost and canary (L05). Write
config.json: a configuration with all nine keys ofops.REQUIREDfor your judge (passeslint_config,model_pinnedistrue,swap_ordersistrue,modeldiffers fromjudge-sim-1, both hashes correct per the fixed configuration table). Reportops.md: the configuration table, the lint result, the configuration hash,comparableof the run with itself and with a run after changing one anchor of the rubric, the cost table of the three ways to run, the stability of grading repeated 3 times over 200 answers (pointwise, without the reference answer), the canary baseline, four canary days with their status and thepass_rate_shiftbetween the baseline and day 3. - Reproduction. Write
build_pack.py, which generates the five reports inreports/(every number comes fromlabandmine, none typed by hand), andtest_build_pack.py, which checks the constraints of AC1-AC5 on the text of the reports you generate. Writenotes/decisions.mdwith exactly five sections: Decision table, Prompt and parser, Bias, Calibration and operations, What the judge pack does not check. The last section answers: what the judge may be used for and what it may not yet be used for.
Deliverables
judge_pack/
__init__.py (file rỗng)
mine.py (Nhiệm vụ 2 và 4: PAIRWISE_TEMPLATE, triage)
decision.json (Nhiệm vụ 1)
raw_outputs.json (Nhiệm vụ 2)
config.json (Nhiệm vụ 5)
build_pack.py (Nhiệm vụ 6; chạy: python -m judge_pack.build_pack)
test_build_pack.py (Nhiệm vụ 6; chạy: python -m pytest judge_pack)
notes/
decisions.md (năm mục: Bảng quyết định, Prompt và parser, Thiên lệch, Hiệu chuẩn và vận hành, Điều bộ judge không kiểm)
reports/ (sinh bởi build_pack.py)
decision.md (Nhiệm vụ 1)
prompts.md (Nhiệm vụ 2)
bias.md (Nhiệm vụ 3)
calibration.md (Nhiệm vụ 4)
ops.md (Nhiệm vụ 5)
Put the judge_pack/ folder inside code-labs/l2-m04 so that import lab works. Run from the lab folder.
Acceptance criteria (required)
| # | Criterion | How to check |
|---|---|---|
| AC1 | decision.json has exactly the six names of data/criteria.json, each use equals the result of checklist.recommend and each why is ≥ 8 words; new_criterion has all seven fields, its name does not duplicate the six criteria, it is sent to judge and is not blocked; reports/decision.md has a six-row table, four boundary rows (100 items: human; 101 items: judge+human; 49 labels: judge+human with 50 human labels (have 49); 50 labels: judge) and the reasons |
python -m pytest judge_pack; call checklist.recommend again for each criterion and each boundary; compare each row with the report |
| AC2 | PAIRWISE_TEMPLATE passes prompts.lint_template(..., "pairwise") (empty), contains the phrase "coi thường" (talk down), differs from prompts.PAIRWISE, and lint still reports an error when a slot is repeated or when [[C]] is replaced; raw_outputs.json has ≥ 8 entries with distinct ids, each expected equals the real result of the parser, there is ≥ 1 ERROR caused by two different verdicts, ≥ 1 UNKNOWN and ≥ 1 readable pairwise verdict; reports/prompts.md has the lint of four templates, the sizes of four prompts, a parser table with every row "yes", four k/n figures with the number of unreadable outputs and the rejection of the forged marker |
python -m pytest judge_pack; run lint_template, parse.rating, parse.pairwise and pipeline.score_items; compare each row |
| AC3 | reports/bias.md has, for both judges, every number of Task 3 (including the leniency part, item G) following the exact definitions of lab.probes, states the judge configuration (name, version, family, seed, the parameters) and says this is a simulation; the control gives 0 on the position probe (slot A, slot B), length, model family and padding; on the leniency probe the control is a reference point (52/112 at threshold 4, 12/112 at threshold 5), not 0 |
recompute each number with probes.run_pairs, position_stats, length_stats, self_stats, agreement_with_human, padding_effect, flag_length_gap; compare |
| AC4 | reports/calibration.md states the number of dev and test items and the number of unreadable outputs, the 5-threshold sweep table on dev, the threshold chosen on dev, the four-ceiling sensitivity table, the report on test (test not used to choose the threshold), the two borderline groups with n, the always-pass baseline, the release gate result with the reasons, and the numbers of auto_pass, human_review, unreadable items of triage with the real gate (no item auto-passed when the gate fails) and with a hypothetical READY gate; triage is inclusive at the threshold, never auto-passes unreadable output or a borderline case, fails closed when gate is not exactly "READY", orders human_review by reading order and rejects a wrong threshold |
recompute the confusion matrix and kappa with your own Fraction code; choose the threshold on test and see that it differs; call triage on a small hand-built score table, with gate as "READY", "NOT_READY" and an unknown string |
| AC5 | config.json has all nine keys, lint_config is empty, model_pinned and swap_orders are true, model differs from judge-sim-1, prompt_sha and rubric_sha match the real content of prompts.POINTWISE and data/rubric.json; reports/ops.md has the items of Task 5, every canary status computed with ops.canary, and the cost follows the formula of ops.estimate |
hash the two sources again; call lint_config, comparable, estimate, repeat_consistency, canary, pass_rate_shift; compute the cost and the canary status by hand |
| AC6 | Rerunning python -m judge_pack.build_pack produces exactly the five reports (compared byte by byte, for example with git diff or diff); python -m pytest judge_pack passes; every report that uses the judge (prompts.md, bias.md, calibration.md, ops.md) states the judge configuration and says this is a simulation; notes/decisions.md has all five sections, uses numbers that match the reports, and states what the judge pack does not check |
run twice and compare; the grader reads decisions.md against the rubric |
Grading rubric (100 points)
| Dimension | 0 | 1 | 2 | 3 | Weight |
|---|---|---|---|---|---|
| Decision table (AC1) | Does not meet AC1 | use is correct but why is generic, or the new criterion does not pass |
Meets AC1; each why names the rule that applies |
As level 2, explains why the boundary of 100 versus 101 items and of 49 versus 50 labels changes how a criterion is graded, and says what the table does not know (whether the labels are good or bad, the real risk, whether a good enough judge exists yet) | 10 |
| Prompt and parser (AC2) | Does not meet AC2 | The template passes lint but raw_outputs.json lacks hard cases, or the table lacks the number of unreadable outputs |
Meets AC2; the three variants are compared on the same data and read correctly | As level 2, says clearly that the difference with and without the reference answer is a consequence of the simulation parameters, and names what lint does not check for your own template | 15 |
| Bias (AC3) | Does not meet AC3 | The report has numbers but no control, or concludes a bias from one number | Meets AC3; tells apart biases with evidence (length, self-preference) from what is not proven (position) | As level 2, says clearly what the both-orders rule does not fix with the numbers, why noise alone lowers consistency, and the price of two calls | 20 |
| Calibration (AC4) | Does not meet AC4 | The threshold is chosen or reported on the same set, or triage auto-passes when the gate fails or passes unreadable output |
Meets AC4; the decision follows the gate and the borderline group is read correctly | As level 2, compares the false-accept rate on test with the ceiling and its interval and says the difference from dev may be chance, points out the always-pass baseline, and says that when the gate fails the judge only flags (a person reads every item) and what the condition for auto-pass is when the gate passes, with the human reading load in both cases | 25 |
| Configuration, cost, canary (AC5) | Does not meet AC5 | The configuration passes lint but the hashes do not match the real content | Meets AC5; the canary reads the four statuses correctly | As level 2, states what lint and the canary do not see (a pinned ID is only a claim, the canary only speaks about the canary set), and why pass_rate_shift with a small n detects nothing |
15 |
| Reproduction and notes (AC6) | Does not meet AC6 | The reports are typed by hand or lack the judge configuration | The script generates every report, rerunning gives exactly the same files, and the tests check the text of the reports | As level 2, a test catches a deliberate defect (change the seed, change >= to > in triage, let triage ignore a failing gate, choose the threshold on test), decisions.md is honest that every number is simulated |
15 |
Each dimension's score = (level reached / 3) × weight. Mapping to the module: practical = Prompt and parser + Configuration, cost, canary + Reproduction (45); applied QA analysis = Bias + Calibration (45); conceptual understanding = Decision table (10).
Hints
Hint 1: build a control to separate bias from noise
A single number says nothing about bias: the same probe run on the `FAIR` judge (every parameter equal to 0) gives a reference point to compare against. When the configuration has noise, consistency is below 1 without any position bias; what tells the two apart is the asymmetry between slot A and slot B, and with few non-tie verdicts that difference does not yet prove anything.Hint 2: which set to choose the threshold on
Split first, choose after. Try running `choose_threshold` on test with the same ceiling: if the result differs from the one on dev, you have just seen why test must not be used to choose. The split is by hash of the item id, so removing unreadable items before or after the split puts each on the same side; remove them **after** the split so you can report the number of unreadable outputs of each side.Hint 3: kappa by hand
With a table tp, fp, fn, tn: raw agreement is (tp + tn)/n; chance agreement is (the number the judge passes × the number the humans pass + the number the judge fails × the number the humans fail)/n²; kappa is (p_o − p_e)/(1 − p_e). Use `Fraction` to compare with the ceiling and the minimum kappa: a false-accept rate exactly equal to the ceiling still passes (inclusive comparison).Hint 4: hashes that match the real content
`lint_config` only checks that the keys are present and valid; it does not know whether `prompt_sha` is the hash of the real prompt. Hash with your own code and paste the result into `config.json`, and let `test_build_pack.py` hash the two sources again on every run: change one character of the rubric and the test must fail.Hint 5: testing your own test
Once the tests are green, try changing the judge's seed, changing `>=` to `>` in `triage`, letting `triage` auto-pass when the gate fails, or choosing the threshold on test and rerun: if the tests stay green, they are only comparing the report with itself. A good test compares against a number **computed independently** (your own `Fraction` code, one hand count), not against the output of the function under test.Independent challenge (practical challenge)
Less guidance. You do not need to run any judge; use lab.checklist, lab.probes, lab.calibrate and lab.ops to compute from the tables below. Submit one challenge.md file.
Context: NauAn (fictional) is a cooking assistant; a one-person team, no API. After the metric pack of L2-M03, the team wants to add a judge for the criteria that code cannot grade. The rule for every comparison: a value exactly on the boundary passes (inclusive), and every rate is computed with fractions, not floating-point numbers. The simulated judge does not take part: every record and table below is fictional data given to you.
Tasks:
- Decision table. The five NauAn criteria (columns: has a deterministic rule, has a reference answer, subjective, risk, items per week, human labels):
| Criterion | Rule | Reference | Subjective | Risk | Items/week | Labels |
|---|---|---|---|---|---|---|
unit_in_reply |
yes | no | no | low | 3000 | 0 |
allergen_warning_present |
no | no | no | high | 70 | 200 |
tone_is_friendly |
no | no | yes | low | 2000 | 49 |
step_order_is_logical |
no | yes (the recipe) | no | medium | 900 | 50 |
substitution_is_safe |
no | no | yes | high | 101 | 400 |
State how each criterion is graded and what is blocking (if anything). Choose two criteria that are not given to the judge alone and say why. 2. Order. Eight pairs (x, y) graded by a pairwise judge in both orders; the original order puts x in slot A, the swapped order puts y in slot A; "human" is the winner according to the labels.
| Pair | Original | Swapped | Human |
|---|---|---|---|
| T1 | [[A]] |
[[B]] |
x |
| T2 | [[A]] |
[[A]] |
tie |
| T3 | [[B]] |
[[A]] |
y |
| T4 | [[A]] |
[[B]] |
y |
| T5 | [[C]] |
[[C]] |
tie |
| T6 | [[A]] |
Không rõ. |
x |
| T7 | [[B]] |
[[B]] |
tie |
| T8 | [[A]] |
[[A]] |
x |
For each pair state the winning answer in each order and the result under the both-orders rule. Compute consistency, the number of verdicts in slot A, slot B and ties (over the pairs readable in both orders), and agreement with the human in one order and in both orders (state the number of pairs excluded). Does this data prove position bias? Why?
3. Choosing a judge. Two pointwise judges J1 and J2 grade the same 150 test items (the positive class is "pass"; the humans pass 90 items):
| Judge | tp | fp | fn | tn |
|---|---|---|---|---|
J1 |
78 | 15 | 12 | 45 |
J2 |
70 | 6 | 20 | 54 |
(a) For each judge compute raw agreement, kappa, false-accept rate and false-reject rate. (b) With a release gate n ≥ 100, false accept ≤ 1/5, kappa ≥ 1/2: which judge passes? (c) If "the judge plus a person" is used (a person reads every item the judge fails), how many items does each judge leave for the person to read and how many bad answers does each let through? Choose the judge for the gate and say why. (d) A third judge J3 grades 120 dev items (the humans pass 70 items) at five thresholds:
| Threshold | tp | fp | fn | tn |
|---|---|---|---|---|
| 1 | 70 | 50 | 0 | 0 |
| 2 | 70 | 44 | 0 | 6 |
| 3 | 68 | 30 | 2 | 20 |
| 4 | 60 | 14 | 10 | 36 |
| 5 | 41 | 4 | 29 | 46 |
Compute kappa and the false-accept rate at each threshold; choose the threshold with false-accept ceilings of 1/4, 3/10 and 1/20; say why kappa at threshold 1 equals 0.
4. Operations. (a) Three configurations C1, C2, C3: C1 = {model judge-sim-3, model_pinned true, version v3, prompt_sha 9f2a1c, rubric_sha 4be07d, temperature 0, swap_orders true, repeats 1, calibration_run cal-07}; C2 is like C1 but model is judge-latest and model_pinned is false; C3 is like C1 but repeats is 0 and calibration_run is null (the key is still present). State the lint_config result of each configuration. (b) Two runs use C1 and the same configuration except temperature 0.7; dataset fingerprints d-41 and d-42. Are they comparable, and why? (c) 2000 items per week, prompt 300 and output 40 units, the illustrative unit price of the lab, a budget of at most 5000 calls per week: compute the calls, units and cost of three ways to run (one pass; both orders; both orders and 2 repeats) and say which way fits the budget and which measure it keeps. (d) The canary baseline is 54/75; four days: 52/75, 49/75, 44/75 and 20/28. State the status of each day.
5. Write a three-sentence paragraph for the NauAn owner, who only wants to hear "can this judge block a release yet".
Separate rubric for the challenge (100 points, pass at ≥ 70):
| Dimension | 0 | 1 | 2 | 3 | Weight |
|---|---|---|---|---|---|
| Decision table (task 1) | Missing | Two criteria wrong | Five ways of grading and the blockers correct | As level 2, the two criteria not given to the judge alone come with reasons that match the rule (high risk, missing labels) | 15 |
| Order (task 2) | Missing | The result of each pair is correct but the totals are wrong | Every number correct (including the two different denominators of the two rules, because T6 is readable in only one order) | As level 2, says clearly that the three pairs T2, T7, T8 change their mind by slot but not in one direction, so position bias is not yet concluded | 25 |
| Choosing a judge (task 3) | Missing | One of (a) to (d) wrong | Every number and choice correct | As level 2, says clearly that the choice is made by the gate and not by raw agreement, that the price of a low false-accept rate is a high false-reject rate, and why the chosen threshold changes with the ceiling | 30 |
| Operations (task 4) | Missing | Two of the four parts correct | All four correct | As level 2, states what lint does not check and why a canary of 20/28 says nothing yet | 20 |
| Communication (task 5) | Missing | The paragraph only says "yes" or "not yet" | The paragraph states the decision and the reason | As level 2, honest about what is unknown and does not confuse simulated numbers with real model behaviour | 10 |
Rules
- Do not use real data or a real API in your submission. The judge, the "human" labels, the answers, the two tutor families and the biases in the data are all simulated; do not infer the behaviour of real models or people.
- Do not edit
lab/,data/orexercises/. Proposed changes go innotes/decisions.md. - Do not lower the false-accept ceiling, change the gate limits or the seed after seeing the results to get a wanted decision; if you change one, record the reason and the result before the change.
- Every number in the reports comes from a script; state the judge configuration and the gate limits. Do not let lint, kappa or a gate decision stand in for reading the answers the judge passes.
- No real person has labelled anything and no real model has been measured; every statement about the quality of a real judge is an assumption.