Evaluation-Driven Development › A Worked Loop: Diagnosing a "Net Improvement"
Language AI HandbookAll chapters Use a second synthetic comparison to see how an aggregate threshold can miss a protected slice regression.
These traces have explicit fixture scores. The candidate improves the technical and multilingual means while reducing the billing mean.
PythonIn [32]Expand
# Baseline: passes two billing cases and one technical case
def make_trace(case_id, score):
t = Trace(case_id, [])
t.score = score
t.steps.append(Step("retrieve", {"found": True}))
return t
slices_for = {
"c001": "billing",
"c002": "billing",
"c003": "technical",
"c004": "technical",
"c005": "multilingual",
"c006": "multilingual",
}
baseline = [
make_trace("c001", 1.0),
make_trace("c002", 1.0),
make_trace("c003", 1.0),
make_trace("c004", 0.0),
make_trace("c005", 0.0),
make_trace("c006", 0.0),
]
candidate = [
make_trace("c001", 0.0),
make_trace("c002", 0.0),
make_trace("c003", 1.0),
make_trace("c004", 1.0),
make_trace("c005", 1.0),
make_trace("c006", 0.0),
]
meta = [Case(cid, "", slice=s) for cid, s in slices_for.items()]PythonIn [33]Expand
b = aggregate(baseline)
c = aggregate(candidate)
print(f"Aggregate baseline={b['mean']:.3f} candidate={c['mean']:.3f}")
print("By slice (baseline -> candidate):")
bs, cs = by_slice(baseline, meta), by_slice(candidate, meta)
for s in bs:
print(
f" {s:14s} {bs[s]['mean']:.2f} -> {cs.get(s, {'mean': 0})['mean']:.2f}"
)ConsoleOut [33]Expand
Aggregate baseline=0.500 candidate=0.500 By slice (baseline -> candidate): billing 1.00 -> 0.00 technical 0.50 -> 1.00 multilingual 0.00 -> 0.50
Both aggregates equal 0.50. Billing falls from 1 to 0 while technical and multilingual each gain 0.50. An aggregate-only threshold sees no change.
ConsoleOut [34]Expand
Gate passed: False - Slice 'billing' fell 1.000 - Regression on case c001 - Regression on case c002
The point pairs below show which direction each slice moved. The thin connectors pair the two measurements for a slice without combining the cases across slices. The aggregate appears as a fourth row so you can see where the change vanishes.
PythonIn [35]Expand
worked_groups = ["Overall", "Billing", "Technical", "Multilingual"]
baseline_rates = [
b["mean"],
*(bs[group.lower()]["mean"] for group in worked_groups[1:]),
]
candidate_rates = [
c["mean"],
*(cs[group.lower()]["mean"] for group in worked_groups[1:]),
]
worked_rows = list(range(len(worked_groups)))VisualizationOut [36]Expand

The slice gate flags the billing drop and the case gate names c001 and c002. The threshold expresses a policy decision about these cases.
The failed gate identifies billing and names c001 and c002. Start with the recorded answer and trace for each case. Those records tell you which component to inspect next. The gate localizes the observed regressions; the diagnosis comes from checking the evidence.
The protection policy matters as much as the plot. Suppose a team prioritizes an increase in multilingual coverage without reducing billing accuracy. A requirement for zero loss on protected billing fixtures is easy to state once the cases are tagged. A different team might allow a specified loss in an inexpensive low-risk route if latency also drops. Both policies need clear scope and a known baseline. Telling readers which policy was chosen lets them judge the decision from the same table.
A case-wise check can grow too brittle if prompts are stochastic and the only record for a baseline case is one successful sample. For hard requirements, test the observable policy or invariant directly when possible. For a stochastic quality measure use a repeated sampling plan and a predefined aggregate. Keep those results distinct from pinned deterministic fixtures.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!