Module L2-M03 exercises: A metric and rubric pack for HocVui Tutor v2

Study time
≈ 4 h (estimate)
Updated
2026-11-03
Draft · reviewed by AI, not yet by a person. Content may change. English translation: AI-assisted, not human-reviewed.
On this page

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.deterministic, lab.similarity, lab.rubric, lab.criteria, lab.report, lab.validity in code-labs/l2-m03.

Main hands-on assignment

Business context

The HocVui team (fictional) is about to evaluate tutor v2 and needs to define its metrics and rubric before any number exists. The QA lead has left three things unfinished: an "states the right answer" metric that lets a few wrong answers through, no acceptance rule for paraphrased answers, and a report with a single average ("v2 is up almost 5 percentage points, ship"). You need to build a metric pack (metric functions with tests, a rubric with anchors, operational definitions for the criteria, and a sliced report) and answer: what do these numbers measure, where do they measure wrongly, and should v2 be released?

Problem to solve

A fast metric can still be wrong in predictable ways: it lets negated answers through, lets answers written as "1,000" through, and gives a high similarity score to an answer that is wrong by one number. A rubric that passes lint can still have meaningless anchors. An average can go up while a dangerous slice gets worse. Your job is to measure the metrics themselves with the labels provided, fix them under the fixed rules below, record what each metric does not check, and make an evidence-based decision.

Input data

All data is already in code-labs/l2-m03/data/ and is fictional, simulated with a seed; do not edit lab/, data/ or exercises/.

  • Task 1: data/l01_numbers.jsonl (30 answers with human labels, 16 correct).
  • Task 2: data/sim_pairs.jsonl (48 pairs of a reference and a system answer with human labels, 32 pairs correct).
  • Task 3: data/rubric_items.jsonl (40 items with a hidden true score) and lab.rubric.simulate_ratings.
  • Task 4: data/six_profiles.json, data/rag_cases.jsonl (13 answers, 26 labelled claims), data/passages.json.
  • Task 5: data/graded_runs.jsonl (425 cases, two versions), data/thresholds.json, data/production_mix.json, data/check_cases.jsonl, data/simpson_counts.json.

The fixed configuration (so that every submission is reproducible and comparable):

Item Value
Positive class when measuring a metric "the metric accepts the answer"; precision and recall computed with lab.validity
Threshold grid in Task 2 Fraction(i, 10) with i = 0, 1, ..., 10; accept when score ≥ threshold (inclusive); THRESHOLD must be an element of the grid
Two-rater simulation in Task 3 simulate_ratings(items, rubric, anchored=..., mode="analytic", rater="A" or "B", seed=0), run with both anchored=False and anchored=True
Three score sets in Task 3 order (correctness, pedagogy, clarity, tone): S1 = [3, 3, 2, 1], S2 = [0, 3, 3, 3], S3 = [3, 3, 3, 0]
Your rubric four criteria with the same ids as the lab's (so the simulation can run); positive integer weights; a 0-3 scale (four levels) for each criterion; correctness is the only critical criterion; pass_score in [0.6, 0.8]; anchors and examples written in Vietnamese, not copied from rubric_tutor.json
Sensitivity table over pass_score 0.6, 0.7 and 0.8 plus your rubric's pass_score, with anchored=True
Sliced report in Task 5 slices by intent, the v1 and v2 fields of graded_runs.jsonl, min_n = 30, 95% Wilson interval

Tasks

  1. Deterministic metric (L01). Write metrics.answer_ok(reply, gold): it passes when the answer states gold as a whole number, reading numbers the way Vietnamese writes them (a comma is the decimal separator; a period followed by exactly three digits is a thousands separator, so 1,000 is one and 1.000 is one thousand), and does not contain a negation or hedging phrase from a list you write. An empty answer returns False; a non-string answer raises TypeError; a non-numeric gold raises ValueError. Measure three metrics (naive_contains, contains_number, answer_ok) on the 30 answers: a table of tp, fp, fn, tn, precision, recall and the lists of false-accept and false-reject ids for each metric. Write new_replies.json: at least 6 new answers (not in the data file) with id, gold, reply, truth, error ("false_accept", "false_reject" or null, exactly matching the result of answer_ok) and note (at least 8 words naming the blind spot), including at least one false accept and one false reject of answer_ok itself.
  2. Similarity and guards (L02). Write metrics.accept_similar(pred, ref, threshold=THRESHOLD) that combines a similarity score with two deterministic checks of your choice. Sweep the threshold grid for token_f1 alone and for the combined rule, and report the tables of tp, fp, fn, tn, precision, recall; choose THRESHOLD, give the reason and list the ids still falsely accepted and still falsely rejected (with the pair type). Write new_pairs.json: at least 4 new pairs on which accept_similar is wrong, including at least one false accept and one false reject, each pair with a note saying why.
  3. Rubric (L03). Write rubric.json for the tutor's responses according to the configuration table, then run lint, score the three score sets, and run the two-rater simulation. Report: exact agreement, within-1-level agreement and the leniency gap per criterion with anchored=False and anchored=True; the number of items each rater passes, the number of items on which the two raters disagree about pass/fail and the number of items rejected by the critical criterion, for each pass_score of the sensitivity table. State what lint does not check.
  4. Six criteria (L04). For the "answer from the textbook" mode, write criteria.json: feature, criteria (at least three criteria, including faithfulness and groundedness; each criterion has inputs, definition, pass_example, fail_example, confusable_with, blind_spots), dropped (criteria dropped and why) and scorable_on_rag_cases. Run the six checks on six_profiles.json (against the human labels), compute the faithfulness and groundedness of the 13 answers in rag_cases.jsonl, name the answers that are faithful but not fully grounded, and measure the "unsupported claim" detector with the labels of the 26 claims (positive class = unsupported).
  5. Slice report (L05). Build the v1 and v2 reports with report.build_report, print them with report.render, and state the three averages, the slices that regress from v1 to v2 (a drop of 0.05 or more), the trivial baseline of the right/wrong-verdict metric on check_cases.jsonl (the whole set and the balanced set), the smallest number of cases for which n/n reaches SHIP at thresholds 0.95 and 0.97, and Simpson's paradox on simpson_counts.json. Conclude in one sentence: whether v2 is released, and because of which slice.
  6. Reproduction. Write build_pack.py, which generates the five reports in reports/ (every number comes from lab, none typed by hand), and test_build_pack.py, which checks the constraints of AC1-AC5 on the text of the reports you generate. Write notes/decisions.md with exactly five sections.

Deliverables

metric_pack/
  __init__.py                    (file rỗng)
  metrics.py                     (Nhiệm vụ 1 và 2: answer_ok, accept_similar, THRESHOLD)
  new_replies.json               (Nhiệm vụ 1)
  new_pairs.json                 (Nhiệm vụ 2)
  rubric.json                    (Nhiệm vụ 3)
  criteria.json                  (Nhiệm vụ 4)
  build_pack.py                  (Nhiệm vụ 6; chạy: python -m metric_pack.build_pack)
  test_build_pack.py             (Nhiệm vụ 6; chạy: python -m pytest metric_pack)
  notes/
    decisions.md                 (năm mục: Metric tất định, Tương đồng, Rubric, Tiêu chí, Điều bộ metric không kiểm)
  reports/                       (sinh bởi build_pack.py)
    metric_validity.md           (Nhiệm vụ 1)
    similarity.md                (Nhiệm vụ 2)
    rubric.md                    (Nhiệm vụ 3)
    criteria.md                  (Nhiệm vụ 4)
    slices.md                    (Nhiệm vụ 5)

Put the metric_pack/ folder in code-labs/l2-m03 so that import lab works. Run from the lab folder.

Acceptance criteria (required)

# Criterion How to check
AC1 On the 30 answers, answer_ok has fp = 0 and fn no greater than the fn of contains_number; answer_ok("", gold) is False, answer_ok(None, ...) raises TypeError; new_replies.json has ≥ 6 new answers, the error field matches the real result of answer_ok, there is ≥ 1 false accept and ≥ 1 false reject, and each wrong case has a note of ≥ 8 words; reports/metric_validity.md has three rows of tp/fp/fn/tn/precision/recall and the false-accept and false-reject ids of each metric python -m pytest metric_pack; recompute the three confusion matrices with lab.validity.confusion; compare each number with the report
AC2 accept_similar rejects every flipped_or_negated pair and every wrong_number pair whose reference has a digit; THRESHOLD belongs to the grid; the threshold is respected (inclusive); new_pairs.json has ≥ 4 pairs, with both false accepts and false rejects, and error matches the real result; reports/similarity.md has two sweep tables (token F1 alone and the combined rule) with 11 thresholds, the chosen threshold and the lists of ids still falsely accepted and still falsely rejected run accept_similar on the 48 pairs; recompute each row with lab.validity and similarity.token_f1; compare the id lists
AC3 rubric.json passes rubric.lint (empty); exactly the four ids of the lab; correctness is the only critical criterion; each criterion has at least one anchor that names something countable (a digit or a quotation); no anchor repeats an anchor of rubric_tutor.json; reports/rubric.md has the exact normalised score (a fraction) of S1-S3, two agreement tables (anchored=False and anchored=True, each with exact agreement, within-1-level agreement and the leniency gap for the four criteria), the pass_score sensitivity table, and states the seed and pass_score python -c calling rubric.lint, rubric.score, simulate_ratings and agreement; the numbers must match the report; the grader reads the anchors against the rubric
AC4 criteria.json has ≥ 3 criteria including faithfulness and groundedness; inputs contains every field CRITERIA requires; definition is ≥ 8 words; confusable_with is another criterion among the six; pass_example is rated passing by the lab's check and fail_example failing (for the faithfulness and groundedness criteria, against the five passages in passages.json); scorable_on_rag_cases matches criteria.profile; reports/criteria.md has the 36-cell table, the 13-answer table, the 26-claim confusion matrix and the wrong ids python -c calling criteria.faithfulness, groundedness, profile; compare the numbers and ids
AC5 reports/slices.md contains the exact report.render output of v1 and v2, the three averages, the regressing slices, the baseline of the two constant answers on the whole set and the balanced set, the number of cases to SHIP at thresholds 0.95 and 0.97, the Simpson result, and the decision with the blocking slice; the decision must follow the verdict rerun build_report, regressions, trivial_baseline, balanced, decide, simpson_reversal; compare line by line with the report
AC6 Rerunning python -m metric_pack.build_pack produces exactly the five reports (compared byte by byte, for example with git diff or diff); python -m pytest metric_pack passes; the reports state the seed and the configuration; notes/decisions.md has all five sections, says every number is simulated and states what the metric 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
Deterministic metric (AC1) Does not meet AC1 answer_ok is correct but measured only on the 30 answers, there are no new answers, or the table lacks the false-accept and false-reject ids Meets AC1; the three-metric table matches the recomputation; the new answers include a false accept and a false reject As level 2, states clearly why fp = 0 on the 30 answers proves nothing about unseen answers (the rules were written after looking at three false accepts) and names the cost of each added phrase 20
Similarity and guards (AC2) Does not meet AC2 The rule runs but relies on the threshold alone, or there is no sweep table Meets AC2; the chosen threshold has a reason; the ids still falsely accepted and falsely rejected are named correctly As level 2, points out that the threshold barely changes the result once the guards are in place and names the cost of raising the threshold to remove the remaining false accepts; proposes an additional check for that case 15
Rubric (AC3) Does not meet AC3 The rubric passes lint but the anchors are meaningless or not countable; the sensitivity table is missing Meets AC3; the three score sets are correct; reads the agreement tables and the sensitivity table correctly As level 2, states clearly that the agreement numbers are a consequence of the simulation's assumptions, names what lint does not check and how to detect it (two independent raters), and explains why pass/fail is sensitive to pass_score 20
Six criteria (AC4) Does not meet AC4 The definition is missing parts or an example is in the wrong group Meets AC4; the faithfulness and groundedness criteria are told apart by examples; the blind spots are stated correctly As level 2, explains why missing inputs mean stopping instead of scoring, and names which criterion must be dropped and why 15
Slice report (AC5) Does not meet AC5 The report has all the numbers but concludes from the pooled number Meets AC5; the decision follows the verdict and the blocking slice As level 2, states clearly that the three averages answer three different questions, says what a 0.900 baseline means for the verdict metric, and names what the report does not say (small slices, a skewed dataset, no statistical test) 20
Reproduction and notes (AC6) Does not meet AC6 The reports are typed by hand or lack the seed/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 (for example removing a negation phrase from the list), and decisions.md is honest that every number is simulated 10

Each dimension's score = (level reached / 3) × weight. Mapping to the module: practical = Deterministic metric + Similarity + Reproduction (45); applied QA analysis = Rubric + Slice report (40); conceptual understanding = Six criteria (15).

Hints

Hint 1: the three false accepts of contains_number`N04` is a negation, `N09` is a hedge and `N25` is `1,000` read the English way as a thousand. Each error has a cheap fix, but each fix has its cost: think of a **correct** answer that your rule would reject, then write it into `new_replies.json`.
Hint 2: two guards for Task 2`similarity.numbers_preserved` catches a changed number. For a reversed conclusion, compare the sets of negation words (`không`, `chưa`, `sai`...) of the two sentences, and remember to compare **after removing diacritics** (`text.strip_diacritics`) because answers typed without diacritics are in the data too. Run each guard alone on the 48 pairs to learn which ids it lets through before you combine them.
Hint 3: the normalised score and the boundary`rubric.score` returns an exact fraction. A normalised score exactly equal to `pass_score` passes (inclusive comparison); a critical criterion at the lowest level rejects the answer even when the total score is high. Pass `pass_score` as a string such as `"0.7"` to avoid floating-point error.
Hint 4: pass and fail examples for faithfulnessCheck your examples with the lab's own check, using all five passages of `passages.json` as `sources`: the pass example must give a ratio of 1, and the fail example must give less than 1. Answer `G09` is an example of what the check does not catch, so do not use it as a fail example.
Hint 5: testing your own testOnce the tests are green, try removing a phrase from the negation list or changing `THRESHOLD` and rerun: if the tests stay green, they are only comparing the report with itself. A good test compares against a number **computed independently with `lab`**, not against the output of the function under test.

Independent challenge (practical challenge)

Less guidance. You do not need to run any system; use lab.deterministic, lab.rubric, lab.criteria, lab.report and lab.validity to compute. Submit one challenge.md file.

Context: NauAn (fictional) is an assistant for converting cooking quantities ("how many cups is 250 g of flour?"). A one-person team, no API. The rule for every comparison: a result exactly on the boundary passes (inclusive), and every computation uses fractions or decimal strings, not floating-point numbers.

Tasks:

  1. Tolerance. The gold is 250 (grams of flour). With (a) an absolute tolerance of 5 and (b) a relative tolerance of 2% (computed on the gold), state which of the following eight values are accepted: 250, 255, 245, 255.01, 244.99, 260, 25, 250.0. Repeat with gold 40 (grams of salt) and the five values 40.8, 40.81, 39.2, 45, 34.99. Choose the rule for salt and say why; name two things numeric_close does not check.
  2. Measuring a metric. A tolerance-based metric accepts (Y) or rejects (N) 12 answers; the human labeller decides whether each answer is correct (Y or N). Compute the confusion matrix (the positive class is "the metric accepts"), precision and recall, and list the false-accept and false-reject items. When the gold is an amount of an allergen, which kind of error is more dangerous, and which measure do you want higher?
  3. Rubric. A rubric has two criteria, scale 0-3: safety (weight 3, critical) and clarity (weight 1); pass_score = 3/4; an answer passes when its normalised score ≥ pass_score and no critical criterion is at level 0. (a) Write four observable anchors for safety (level 0 to 3), each with one countable thing. (b) Compute the exact normalised score and the result for four score sets (safety, clarity): (3, 0), (0, 3), (2, 3), (1, 3). (c) Which set passes exactly on the boundary, and what does that say about the sensitivity of pass_score? (d) State what lint does not check.
  4. Six criteria. NauAn has three features, each with the following columns: "quantity conversion" (question, reply, gold), "recipe suggestion from a book" (reply, sources), "answer repeated 5 times per question" (answers). For each feature, name the criterion among the six of L04 that those columns can score; for the "quantity conversion" feature, also name the columns still missing to score relevance and completeness. Pick one feature and write a four-part operational definition for its main criterion.
  5. Slices. Two versions are graded on three kinds of dish (passes / cases; threshold; true share in the product):
Slice Threshold True share v1 v2
canh 0.90 0.5 195/200 168/200
nuong 0.80 0.3 140/200 190/200
chien 0.85 0.2 18/20 19/20

(a) Compute the three kinds of average (pooled, per-slice, weighted) for both versions. (b) With min_n = 30 and the 95% Wilson interval, state the status of each slice and the verdict of the two versions. (c) Which slice regresses by 0.05 or more? (d) The team says "pooled is up almost 6 points, ship v2". Respond. (e) System C passes 9/10 on the easy slice and 30/90 on the hard slice; system D passes 80/100 on the easy slice and 3/10 on the hard slice. Who wins on each slice, who wins pooled, and what phenomenon is this? (f) The 80-case recipe check set has 72 correct recipes; how much does a constant answer "The recipe is correct." score on the "right verdict" metric, and on a set of 8 correct plus 8 wrong? 6. Write a three-sentence paragraph for the project owner, who only wants to hear "is this metric pack usable yet".

Data for task 2 (items 1-12; each row is the metric's result and the human label):

Item 1 2 3 4 5 6 7 8 9 10 11 12
Metric Y Y Y N N Y N Y Y N Y Y
Human Y N Y N Y Y N Y N N Y Y

Separate rubric (100 points, pass at ≥ 70):

Dimension 0 1 2 3 Weight
Tolerance and measuring a metric (tasks 1, 2) Missing One table correct, the other wrong or floats used so the boundary is wrong Both tables correct, including values exactly on the boundary; precision and recall correct As level 2, notices that a small gold makes the absolute tolerance too wide, chooses the measure by allergen risk and explains 30
Rubric (task 3) Missing The anchors are not observable or the score is wrong on one set Four anchors with countable things, four correct results As level 2, names the two sets that pass exactly on the boundary and says that this requires choosing pass_score deliberately 20
Six criteria (task 4) Missing One feature wrong Three features correct, the missing columns correct As level 2, the operational definition has all four parts and names the missing input needed to extend it 10
Slices (task 5) Missing The three averages are correct but the status or the regression is wrong The three averages, statuses, verdict, regression and Simpson are correct As level 2, explains why pooled goes up while v2 is still BLOCK and names what the Wilson interval at n = 20 does not allow concluding 30
Communication (task 6) 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 behaviour 10

Rules

  • Do not use real data or a real API in your submission. Every label, answer, the two raters and the two system versions in the data are simulated; do not infer the behaviour of real people or models.
  • Do not edit lab/, data/ or exercises/. Proposed changes go in notes/decisions.md.
  • Do not lower a threshold, change min_n or pass_score after seeing the results to get a wanted verdict; if you change one, record the reason and the result before the change.
  • Every number in the reports comes from a script; state the seed and the configuration. Do not let a similarity score, lint or a passing verdict stand in for reading each false-accept id.
  • No real person has graded the rubric yet and the metric pack has not been measured on real data; every statement about real quality is an assumption.