Evaluation-Driven Development › Scoring, Aggregation, and Slice Ceilings

Michael BrenndoerferDecember 2, 20263 min read
Language AI HandbookAll chapters
Part 64 of 67Compound AI System Design
Chapter 487Evaluation-Driven Development › Scoring, Aggregation, and Slice Ceilings
Reading section 6 of 14 · Scoring, Aggregation, and Slice Ceilings · 3 minSection 6 of 14 · 3 min

Section 6 of 14 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The case score is between 0 and 1 and can be fractional. The mean case score gives every observed case equal weight. A pass rate uses a different variable: map full credit to one and every other score to zero. Report which measure you computed.

Aggregate scores and their variance

For nn independent, identically distributed binary outcomes with success probability pp, the mean pass indicator has variance p(1−p)/np(1-p)/n. Its standard error is the square root of that variance. A fixed set of six hand-authored cases has no random sampling model for production traffic. Report counts and descriptive means on these fixtures. If you need population uncertainty, define the target population, how you sampled it, and what dependence the estimate must account for.

PythonIn [17]
CollapseExpand
def aggregate(traces: list[Trace]) -> dict:
    scores = [trace.score for trace in traces]
    if not scores:
        raise ValueError("Cannot summarize an empty group.")
    return {
        "n": len(scores),
        "mean": sum(scores) / len(scores),
        "passes": sum(score == 1.0 for score in scores),
    }


def by_slice(traces: list[Trace], cases: list[Case]) -> dict:
    by_id = {case.case_id: case for case in cases}
    buckets: dict[str, list[Trace]] = {}
    for trace in traces:
        buckets.setdefault(by_id[trace.case_id].slice, []).append(trace)
    return {name: aggregate(group) for name, group in buckets.items()}
PythonIn [18]
CollapseExpand
dev_cases = splits["dev"]
dev_traces = [run_case(case, {}) for case in dev_cases]
print("Development cases:", aggregate(dev_traces))
for group, stats in by_slice(dev_traces, dev_cases).items():
    print(group, stats)
ConsoleOut [18]
CollapseExpand
Development cases: {'n': 4, 'mean': 1.0, 'passes': 4}
multilingual {'n': 1, 'mean': 1.0, 'passes': 1}
technical {'n': 2, 'mean': 1.0, 'passes': 2}
billing {'n': 1, 'mean': 1.0, 'passes': 1}

The slice ceiling

With disjoint slices the overall mean is a weighted average. Let nsn_s be the case count in slice ss, rsr_s its observed mean score, and nn the total case count. The aggregate RR weights each slice by its share ws=ns/nw_s=n_s/n.

R=∑swsrsR = \sum_s w_s r_s

The weights are nonnegative and sum to one. This places the aggregate between the smallest and largest slice means. If a slice of weight wsw_s stays at rsr_s while all scores lie in [0,1][0,1], the aggregate ceiling is 1−ws(1−rs)1-w_s(1-r_s), since even perfect performance elsewhere contributes at most 1−ws1-w_s. The ceiling depends on the mix.

Keep the underlying slice rates fixed in this synthetic example. With equal representation, the expected mean is (1+0.5+0)/3=0.50(1+0.5+0)/3=0.50. When billing accounts for 30 of 40 cases, the expected mean is (30+2.5)/40=0.8125(30+2.5)/40=0.8125. This increase comes entirely from reweighting unchanged slice rates.

PythonIn [19]
CollapseExpand
rates = {"Billing": 1.0, "Technical": 0.5, "Multilingual": 0.0}
mixes = {
    "Balanced mix": {"Billing": 10, "Technical": 10, "Multilingual": 10},
    "Billing-heavy mix": {"Billing": 30, "Technical": 5, "Multilingual": 5},
}
expected = {
    label: sum(rates[s] * count for s, count in counts.items())
    / sum(counts.values())
    for label, counts in mixes.items()
}
plot_labels = [*rates, "Balanced mix", "Billing-heavy mix"]
plot_rates = [*rates.values(), *expected.values()]
VisualizationOut [20]
CollapseExpand
The fixed slice rates are 100, 50, and 0 percent. The balanced and billing-heavy aggregates are 50 and 81.25 percent.
With fixed slice rates, raising billing's weight increases the expected overall score from 50 to 81.25 percent.

Compare releases on the same cases when possible. If the sample mix must change, show the slice values and estimate a weighted aggregate against a declared reference mix. Fixing weights alone cannot correct for a shift in difficulty within a slice.

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!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy