Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 16: Self-Improving AI Systems

Week 16 / Lesson 2

Measuring whether a change helps

Compare candidates against a baseline without repeatedly tuning to the final test.

Section 2.1 1 of 7

Overview

Focus

Compare candidates against a baseline without repeatedly tuning to the final test.

Your route through the lesson

  • 2.2 Development, selection, and untouched evaluation sets
  • 2.3 Paired outcomes, slices, and repeated runs
  • 2.4 Reward feedback and limits of improvement claims
  • 2.5 Put it into practice
  • 2.6 Guided comparison
  • 2.7 An apparent gain with a critical regression

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 2.2 2 of 7

Development, selection, and untouched evaluation sets

Focus

Separate development diagnosis, candidate selection, and reserved evaluation.

Development cases support debugging and candidate generation. Selection cases compare candidates under a fixed rule. Reserved evaluation cases measure the already chosen version after selection ends. These roles protect the meaning of a final result: it describes behavior on cases that did not guide the choice.

In the weekly fixture, development filters out weak thresholds. Selection then chooses among eligible versions, using success count and a declared tie-breaker. Only after selection is frozen does the program access reserved cases. A frozen copy prevents accidental mutation of the selected dictionary during evaluation. The baseline is evaluated on the same reserved cases for a paired comparison.

The separation is procedural as well as structural. Naming a file final does not help if an optimizer reads it repeatedly. Limit read access where practical and record when reserved data are opened. If a final result reveals a defect, it can inform the next development cycle, but that same set no longer supplies untouched evidence for the revised version. Retain the original result, declare the new cycle, and reserve fresh evaluation cases before making another generalization claim.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. An optimizer repeatedly uses final-case failures to choose thresholds. Are those cases reserved?
2. When should the selected version be fixed relative to final evaluation?
3. Why evaluate baseline and selected version on the same reserved cases?

Section 2.3 3 of 7

Paired outcomes, slices, and repeated runs

Focus

Report paired gains, regressions, slices, cost, and observed variation.

An aggregate gain can hide an unacceptable regression. Compare baseline and candidate on each case. A gain is baseline wrong and candidate right; a regression is baseline right and candidate wrong. Cases where both agree still matter for the denominator. Report counts and the actual cases, especially those representing critical safety or business conditions.

Suppose ten cases include two gains and one regression. Net success rises by one, but if the regression authorizes a forbidden export, promotion should still fail under a critical-case gate. A slice is a meaningful subgroup, such as long documents or low-confidence proposals. Slice results reveal where a candidate helps or hurts instead of averaging every risk together.

For nondeterministic model runs, repeat comparable conditions and report variation rather than selecting only the best run. Measure elapsed duration and calls or other actual cost units. A deterministic threshold fixture has zero output variation for fixed inputs and no model-call cost, but this does not imply zero execution time or production expense. Distinguish measured data from estimates and disclose small sample sizes so percentage changes do not appear more certain than their evidence allows.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Candidate fixes two cases but breaks one previously correct case. Net success change?
2. Overall success improves but one forbidden-export case regresses. Under a no-critical-regression gate?
3. A deterministic fixture has no model calls. What cost claim is appropriate?

Section 2.4 4 of 7

Reward feedback and limits of improvement claims

Focus

Distinguish reward-like scoring from reinforcement training of model weights.

A score can guide search without training a model. The threshold fixture returns one point for each correct accept-or-reject decision. Selecting a higher-scoring configuration is evaluation-driven optimization. It changes a chosen parameter, not a neural network's learned weights.

Reinforcement learning instead studies an agent choosing actions and receiving consequences represented by rewards, with a learning procedure updating its policy. The policy is the rule or model producing actions. A full trainer also needs trajectories, exploration choices, update rules, and careful evaluation. Calling a correctness count reward does not by itself implement that training process.

Reward design can create unwanted shortcuts. If the reward counts accepted proposals without checking validity, an optimizer can accept everything. If it rewards a passing evaluator and can edit the evaluator, it can redefine success. Align scoring with the real objective and constrain authority independently. The core lab demonstrates configuration search with fixed labels; it does not claim reinforcement training, improved language-model weights, or a general self-improving system. Those claims require additional actual execution and evidence beyond choosing among five scalar thresholds.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A script scores five thresholds and selects one without updating weights. What is it?
2. Reward equals number of accepted proposals, regardless of validity. Likely shortcut?
3. What is a policy in reinforcement learning?

Section 2.5 5 of 7

Put it into practice

Focus

Select a candidate before a single reserved comparison against the baseline.

Download week16.py, save it in an exercise folder, and run python week16.py --lesson 2. This single practice runs development filtering, selection, freezing, and reserved evaluation in one small processor-only script. No model, training package, or account is needed. It normally completes within seconds and performs no external effects.

Development and selection each contain confidence values paired with expected boolean decisions. True means accept; False means reject. score returns a list of zeros and ones, where one indicates the threshold decision matches the expected label. sum counts successes. max ranks eligible candidates by a tuple: selection success first, then negative threshold as the declared tie-breaker. Tuple comparison considers the first differing element.

The chosen version is v3 with threshold 0.5. A JSON serialization round trip makes a separate frozen dictionary before reserved cases are defined. The final report compares baseline and selected outcome lists, gains, regressions, and explicit fixture cost and variation fields. Read the code order as part of the evidence: selection never loops over reserved scores. A new candidate chosen after inspecting that report would require a fresh reserved set.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Selection ranks by (successes, -threshold). Two candidates tie on success. Which wins?
2. score returns [1,0,1,1]. What is the success count?
3. What would violate the fixture separation after its reserved report?

Section 2.6 6 of 7

Guided comparison

Focus

Interpret the selected threshold and paired reserved outcomes accurately.

The worked development filter admits candidates with at least three successes. Selection cases favor v3, threshold 0.5, over thresholds that accept too many low-confidence records or reject valid moderate-confidence ones. The program freezes v3 before opening the reserved cases, preserving the declared order of decisions.

Reserved confidences are 0.49, 0.51, 0.85, and 0.15, with expected decisions reject, accept, accept, reject. Baseline threshold 0.2 wrongly accepts 0.49 but handles the other three. Threshold 0.5 handles all four. The paired report therefore contains one gain and zero regressions, with success moving from three of four to four of four.

This is a complete calculation for a tiny deterministic classification fixture. It is not evidence that confidence values from a live model are calibrated, that real latency is unchanged, or that an agent team improves. The cost field explicitly records zero model calls; the script still takes measurable processor time. A real application comparison would add actual repeated model outputs, critical slices, elapsed durations, and authorized effects while preserving the same development-selection-final separation.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Baseline threshold 0.2 sees confidence 0.49 labeled reject. Its decision?
2. Selected threshold 0.5 gets four reserved cases right; baseline gets three. Paired result?
3. Does this threshold result prove a live model confidence is calibrated?

Section 2.7 7 of 7

An apparent gain with a critical regression

Focus

Block an apparent average gain when a critical slice regresses.

A routing candidate solves nine of ten routine requests, compared with a baseline solving eight. It also changes one high-risk request from safe denial to unauthorized execution. If the report combines everything into one average, the apparent improvement can conceal a boundary failure that the product explicitly forbids.

The worked gate separates routine quality from critical authorization cases. It reports the routine gain, records the critical regression, and rejects promotion under a zero-critical-regression constraint. The candidate remains a proposal for further development; rejection does not require pretending its useful gain never occurred. A revised candidate must be selected using development and selection evidence, then evaluated under an appropriately reserved protocol.

Critical slices should be declared before examining candidate outcomes. Inventing a slice only to favor a desired candidate creates another form of selection bias. The gate should also preserve legitimate task success so an always-deny system cannot claim victory solely by avoiding unauthorized effects. Improvement is therefore a constrained comparison: quality, safety, cost, and latency all have explicit roles rather than collapsing into whichever single score makes a candidate look strongest.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Routine success rises but a critical authorization case changes from deny to execute. Under the taught gate?
2. When should critical slices be defined?
3. An always-deny system prevents every unauthorized effect. What else must be measured?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Promoting and reversing an automated change →