Evaluation-Driven Development › Anatomy of a Task Suite
Language AI HandbookAll chapters The example uses invented support questions and an in-memory retrieval fixture. A toy answer may be a copied sentence or a scripted alteration. Neither retrieval nor generation calls an external service.
The case data model
The grader searches for required and forbidden substrings after lowercasing. It grants partial credit for some required matches and vetoes answers containing a forbidden substring. The labels are substrings that stand in for facts. This intentionally simple grader cannot assess meaning.
PythonIn [3]Expand
import math
from dataclasses import asdict, dataclass, field
@dataclass
class Case:
case_id: str
question: str
must_include: list[str] = field(default_factory=list)
must_exclude: list[str] = field(default_factory=list)
slice: str = "general"
provenance: str = "handwritten"
def score(self, answer: str) -> float:
"""Fraction of required matches, with a forbidden-substring veto."""
low = answer.lower()
if any(bad.lower() in low for bad in self.must_exclude):
return 0.0
if not self.must_include:
return 1.0
hits = sum(good.lower() in low for good in self.must_include)
return hits / len(self.must_include)ConsoleOut [4]Expand
1.0 0.0
The first answer scores 1 because both required substrings appear and the forbidden one is absent. The second scores 0 because the forbidden substring appears. The veto expresses this fixture's decision to give the forbidden phrase precedence.
With two required substrings and one match, the score is 0.5. The report keeps the mean graded score and the binary full-credit count as separate measures. The analytical Bernoulli formula below concerns a mean of binary outcomes. The later descriptive bootstrap resamples differences in the graded scores.
The grading method is the function mapping a system output to a score. It can be exact-match, substring/fact-presence (as here), a rubric applied by an LLM judge (see LLM-as-Judge), or a programmatic check. Every grading method is an operationalization of "correct" with known failure modes; choosing one is choosing which errors you can see.
Assembling a small suite
The six invented cases have two items each in billing, technical help, and multilingual support. This teaching lab uses a single, disjoint slice label per case. A production case can carry several tags, such as both billing and Spanish.
PythonIn [5]Expand
SUITE = [
Case(
"c001",
"How long is the refund window?",
["30 days", "original"],
["60 days"],
"billing",
),
Case(
"c002",
"Can I get a refund after 45 days?",
["no.", "30 days"],
["60 days"],
"billing",
),
Case(
"c003",
"Reset password steps?",
["settings", "email", "link"],
[],
"technical",
),
Case(
"c004",
"App crashes on upload. What do I do?",
["logs", "version"],
["guaranteed"],
"technical",
),
Case(
"c005",
"¿Cuál es el plazo de reembolso?",
["30 días"],
["60 días"],
"multilingual",
),
Case(
"c006",
"Wie setze ich mein Passwort zurück?",
["Einstellungen", "E-Mail"],
[],
"multilingual",
),
]ConsoleOut [6]Expand
Total cases: 6
Per-slice counts: {'billing': 2, 'technical': 2, 'multilingual': 2}One changed outcome moves the pass rate in a two-case slice by 50 percentage points. Inspect the count next to each score before reading a small slice as a reliable estimate of a population.
Versioning the suite
Hash the serialized case records so the report can detect changed case inputs or labels. Store the scorer's release and configuration separately, since case bytes cannot identify changes to the scorer's implementation. Digests help detect changed bytes. NIST Secure Hash Standard
PythonIn [7]Expand
import hashlib
import json
def suite_hash(cases: list[Case]) -> str:
payload = [asdict(case) for case in cases]
blob = json.dumps(payload, sort_keys=True).encode("utf-8")
return hashlib.sha256(blob).hexdigest()ConsoleOut [8]Expand
Suite version: faf2c1e1350c0da74114a78bdd91e70b3f478416164a13ed8dd168142c2fa188
This digest binds all case fields and their order under the chosen encoding. Case order is part of this version. Matching digests support comparing the case inputs. The run must also hold the grading policy fixed.
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!