Module L2-M01 exercises: Evaluation strategy for HocVui Tutor v2

Study time
≈ 4 h (estimate)
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.runner, lab.stats, lab.strategy, lab.report, lab.human, lab.judge in code-labs/l2-m01.

Main hands-on assignment

Business context

The HocVui team (fictional) wants to replace tutor v1 with tutor v2, because v2 is faster and cheaper. The product owner asks: "Should I put v2 live? I need an evaluation strategy written down before looking at the numbers, and a decision based on the data we have." You are assigned to write that strategy, run it on both versions and give a release recommendation.

Problem to solve

The data available is very small: 40 cases, of which only 5 check safety. If you look at a single "overall pass rate" number, you will ship wrongly or block wrongly. Your job is to show what can be concluded, what cannot, and how large the dataset needs to be to conclude.

Input data

  • Product and policy: data/tutor_policy.md (the source of every expectation).
  • Dataset: data/cases.jsonl (40 cases), human labels: data/human_labels.jsonl (60 labels, an oversampled sample, see L03 section 4.2).
  • Tools: SimulatedTutor("v1") and SimulatedTutor("v2"), runner.run_eval, runner.criterion_rates, stats, strategy.validate, report.render, human, judge.SimulatedJudge.
  • Required configuration for the main run: 10 runs per case, seed=1, both versions, the original dataset (fingerprint 47065d9256b4). The bootstrap by case uses seed=3.
  • Black-box rule: do not read lab/_behaviour.py. Every conclusion about the tutor must come from run results and the policy.

The product owner's eight requirements for Task 1:

# Requirement
R1 dataset.load rejects a case line that is missing source.
R2 For homework, tutor v2 does not state the answer in at least 90% of replies.
R3 states_any_number("Đáp số là 6.") returns True (a function you write yourself in Task 3).
R4 The tutor replies in a friendly, encouraging way.
R5 v2 is no worse than v1 at judging whether a student's answer is right or wrong.
R6 report.render writes the dataset fingerprint on the first line of the report.
R7 The tutor does not repeat a phone number the student gives.
R8 After release, the thumbs-down share on real traffic does not exceed 50%.

Tasks

  1. Classify. For R1-R8, write test, eval or both, with one sentence of reasoning using the three questions of L01 section 6.1. For a requirement that must be split into two parts, state the two parts explicitly.
  2. Criteria. From policy §1-§7 and R2-R8, write at least six quality criteria. Each criterion has: id, an operational definition (stating what counts as a failure), a failing example, a passing example, a risk level, a source (policy section), a grader type (code, human, model) and a threshold. The product owner has confirmed one rule: every high risk criterion has a threshold ≥ 0.95. You choose the remaining thresholds, each with a one-line reason. safety and tone are required.
  3. Check the graders.
    • 3a. Run tutor v2 on the 14 homework cases (kind == "hint"), 10 runs per case, seed=1. Count the replies caught by no_leak, by no_final_answer and by the function states_any_number(text) that you write (a standalone number, including 1.000 and 3,5). Which grader misses what? Write a test for states_any_number.
    • 3b. Compare SimulatedJudge() with the adjudicated label for the "curt" flag (tone_ok is False) on all 60 labels and on the 40 random labels. Report the confusion matrix, precision and recall on each set, and the number of curt replies in the random sample. Conclusion: can the judge be used as a gate for tone? If not, what should be used instead?
  4. Sample size. Use lab.stats (do not type numbers by hand) to build a table for each criterion: the threshold, the margin of error by risk (strategy.MARGIN), the number of cases needed for that margin (required_n_margin), the number of cases needed for an all-pass run to reach a Wilson lower bound equal to the threshold (required_n_all_pass; validator S07 requires both), the number of cases currently available for that criterion, and the shortfall against the larger of the two needed numbers. Add two more numbers: the number of consecutive cases that must pass to conclude the safety failure rate is below 2%, and the number of cases per version needed to tell v1's observed pedagogy rate from v2's (the lab's unpaired calculation).
  5. Strategy. Write a complete strategy.json: use case, owner, dataset (source, version, planned_size ≥ the largest number needed for any one criterion (the S07 rule), and record in 04-sample-size.md the cases needed for each criterion), criteria, decision rule (using interval bounds, with an INCONCLUSIVE branch), offline plan, online signals with a caveat, limitations (at least three, honest), rerun conditions. strategy.validate reports no problems. Add a field validator_blind_spots (a list of at least three sentences) recording three things the validator does not check in your strategy, and explain briefly in notes/05-limitations.md.
  6. Run and report. Write make_reports.py that runs both versions and generates the reports (do not type numbers by hand): one per-criterion report per version using report.render with your strategy, and a comparison table that decides in two ways: the Wilson interval over runs (as in report.rows) and the bootstrap interval by case for each criterion (stats.cluster_bootstrap_ci, seed=3). Add the intervals for the overall pass rate of v1 and v2 both ways. Which criteria give the same conclusion both ways, and which change?
  7. Recommendation. Write release-decision.md: a decision for each criterion and each version under your rule; a recommendation for v2 (ship, block, or collect more data) and why; which conclusions are solid and which are fragile; at least three actions with a responsible person and an order; two online signals to monitor and why thumbs-down is not the error rate. End with 5-8 sentences of reflection: what in the conclusions is true only for the simulation (fixed rates, reproducible seeds), and what you would change with a real model (the number of runs, how samples are chosen, recording the model ID, the budget).

Deliverables

evaluation_strategy/
  __init__.py                    (file rỗng)
  strategy.json                  (qua validator: 0 vấn đề)
  make_reports.py                (sinh mọi con số bằng lab; chạy: python -m evaluation_strategy.make_reports)
  test_make_reports.py           (test cho hàm do bạn viết, ví dụ states_any_number)
  notes/
    01-classification.md         (Nhiệm vụ 1)
    02-criteria.md               (Nhiệm vụ 2: ví dụ lỗi/đạt, nguồn, lý do ngưỡng)
    03-grader-audit.md           (Nhiệm vụ 3: điểm mù, ma trận nhầm lẫn, kết luận về judge)
    04-sample-size.md            (Nhiệm vụ 4: bảng cỡ mẫu)
    05-limitations.md            (Nhiệm vụ 5: giới hạn, và giải thích ba điều validator không kiểm tra)
  reports/
    report-v1.md                 (sinh bởi make_reports.py)
    report-v2.md
    comparison.md
  release-decision.md            (Nhiệm vụ 7)

Put the evaluation_strategy/ folder in code-labs/l2-m01 so that import lab works. Run from the lab folder: python -m evaluation_strategy.make_reports and python -m pytest evaluation_strategy.

Acceptance criteria (required)

# Criterion How to check
AC1 strategy.json has at least six criteria including safety and tone; every high criterion has a threshold ≥ 0.95; strategy.validate returns an empty list; planned_size ≥ the largest number of cases needed for any one criterion (both S07 conditions) python -c "from lab import strategy; print(strategy.validate(strategy.load('evaluation_strategy/strategy.json')))" prints []; the grader cross-checks the table in 04-sample-size.md
AC2 Every criterion has an operational definition, a failing example, a passing example and a policy section as its source; R1-R8 are classified with reasons that fit the three questions of L01 The grader compares with the answer key; no criterion mixes two ideas
AC3 The grader audit states the number of replies caught by each grader, the confusion matrix, precision and recall on all 60 labels and on the 40 random labels, the number of curt replies in the random sample, and a conclusion about the judge that does not rest on raw agreement Recompute with human.confusion; the numbers must match
AC4 The sample-size table is computed by lab.stats, with two columns for the number of cases needed (margin of error and all-pass), a column for the cases currently available and the shortfall; it has the number of consecutive passing cases for safety below 2% and the number of cases to tell the two versions apart python -m pytest evaluation_strategy and recompute with lab.stats; the numbers must match
AC5 The two script-generated reports state the configuration (system, seed 1, 40 cases x 10 runs, fingerprint 47065d9256b4); the comparison table has both interval methods for every code-graded criterion; there is an overall interval for both versions Rerunning make_reports.py produces the same files; the grader compares the decisions with the table in the answer key
AC6 The recommendation rests on the strategy's decision rule per criterion, distinguishes solid from fragile conclusions, has actions, and does not rely on an "average score" The grader reads release-decision.md against the rubric

Grading rubric (100 points)

Dimension 0 1 2 3 Weight
Classification and criteria Does not meet AC2 Classifies ≥ 5/8 correctly, or has criteria but some definitions are vague Classifies ≥ 7/8 correctly, every criterion has an operational definition, failing/passing examples and a source As level 2, classifies 8/8 correctly (including splitting R7 and recognizing R8 as a tripwire), every threshold has a reason derived from risk 15
Checking the graders Does not meet AC3 Reports numbers but relies on raw agreement, or uses only the 60 labels Reports both sets, points out the blind spot of no_leak, states precision/recall As level 2, explains that precision drops because the random sample has few curt replies, states the limits of recall, concludes the judge is not a gate and proposes a concrete replacement 20
Sample size and uncertainty Does not meet AC4 Has numbers but typed by hand or not compared with the cases available Correct table, with the shortfall and the two extra numbers As level 2, states clearly that the unit of sampling is the case, points out which criteria are measured on too few cases and the consequence for the interval 20
Strategy and decision rule Does not meet AC1 Passes the validator but the rule only looks at the observed score or the limitations are token Passes the validator, the rule rests on interval bounds and has INCONCLUSIVE, limitations are concrete As level 2, names the three things the validator does not check, keeps thresholds from being lowered to dodge S07 20
Result analysis and release decision Does not meet AC6 States a decision without per-criterion evidence Decides per criterion and version, has actions As level 2, distinguishes solid from fragile conclusions using both interval methods, does not merge into one score, reflects correctly on the limits of the simulation 15
Reproducibility and reporting Does not meet AC5 Reports typed by hand or missing the configuration The script generates reports with the configuration and fingerprint, has tests for the self-written function As level 2, rerunning produces exactly the same files, the tests catch a deliberate bug (proving the tests are not meaningless) 10

Each dimension's score = (level reached / 3) × weight. Mapping to the module: practical = Checking the graders + Sample size + Reproducibility (50); applied QA analysis = Strategy + Result analysis (35); conceptual understanding = Classification and criteria (15).

Hints

Hint 1: counting the cases that apply to a criterion`criteria.verdicts("x", case)` returns the criteria that apply to that case; count by criterion over the 40 cases. This number is a number of cases, not runs.
Hint 2: precision and recall of the judge`human.confusion(predicted, truth)` returns `tp`, `fp`, `fn`, `tn` for the curt class. Precision is `tp / (tp + fp)`, recall is `tp / (tp + fn)`. Count how many curt replies the `random` sample has before trusting recall.
Hint 3: bootstrap by case for each criterionFor each criterion, group the rows of the same case into `(passes, runs)`, then pass that list to `stats.cluster_bootstrap_ci(per_case, seed=3)`. Decide with the same rule as `stats.decide`: SHIP if the lower bound ≥ threshold, BLOCK if the upper bound < threshold, otherwise INCONCLUSIVE.
Hint 4: when the decision changes between the two interval methodsAsk: how many cases does that criterion have? The interval over runs treats every run as independent, so it is narrower than reality when there are few cases. The bootstrap interval can also be narrower; then ask how close the bound sits to the threshold.

Independent challenge (practical challenge)

Less guidance. You do not need to run the tutor; you can use lab.stats to compute.

Context: MailBrief (fictional) is an assistant that summarizes work emails into three bullet points and lists the action items. The team has 150 emails already labeled (one run per email), a budget to label at most 100 more emails, and two people qualified to label. A serious failure is a summary that invents a date or name not in the email.

Tasks:

  1. Write at least five quality criteria (operational definition, failing and passing examples, risk) for MailBrief, including two high criteria: no invented dates/names (threshold 0.99) and complete action items (threshold 0.90).
  2. Choose the grader type for each criterion and say how you check that grader within the labeling budget.
  3. For the two high criteria, compute with lab.stats the number of cases needed for a ±0.03 margin of error and the number of cases needed for an all-pass run to reach a Wilson lower bound equal to the threshold, then compare with the 150 emails available. Say for which criterion the current data is enough to conclude (in which direction), and for which it is not.
  4. Trial results on the 150 emails: no invented dates/names 148/150, complete action items 131/150, at most three bullet points (low risk, threshold 0.90) 149/150. Apply the interval-bound decision rule to each criterion and state the next action.
  5. Write a three-sentence paragraph for the product manager, who only wants to hear "ship or not".

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

Dimension 0 1 2 3 Weight
Criteria Missing Vague criteria or no failing example Operational definition and risk, one idea per criterion As level 2, plus failing/passing examples and the source of the expectation 25
Choosing graders and checking them Missing Chooses types but does not say how to check Reasonable choice, with a checking plan As level 2, uses the label budget with reasoning (random sample, confusion matrix, two raters) 20
Sample size and statistics Missing Has numbers but the wrong formula Correct numbers for both criteria and compared with 150 As level 2, plus the consequence (for example 150 is not enough for ±0.03 at a threshold of 0.90) and how to handle it 30
Decision and communication Missing Decides by the observed score Decides by interval bounds, correct for all three criteria As level 2, a concrete next action and a paragraph for the manager that is honest about what is unknown 25

Rules

  • Do not use real data or a real API in your submission.
  • Do not edit data/cases.jsonl, data/human_labels.jsonl or data/tutor_policy.md. Proposed changes go in notes/.
  • Do not read lab/_behaviour.py.
  • Do not lower a threshold to pass the sample-size check (S07) or to change a decision; increase planned_size or say plainly that the dataset is not enough.
  • Every number in the reports comes from a script; state the seed and the dataset fingerprint.