Sub topic 7
Write reference answers and rubrics
This chapter covers how to attach the "right answer" to each test case. It assumes you have the JSONL case schema from the earlier chapter, can read basic Python, and know what an LLM judge is, though you don't need to have calibrated one yet.
Why labeling decides what you measure
A test case without a label is only an input. The label tells the grader what "correct" means, so every weakness in a label becomes noise in your scores. A reference that is wrong marks correct outputs as failures. A reference that is too narrow penalizes valid paraphrases. A reference that is vague lets a judge pass almost anything.
Your task definition already says what success looks like. Labeling turns that definition into something checkable on one case at a time. There are two main forms:
- A reference answer is a known-good output for the input.
- A rubric is a list of criteria that any good output must satisfy.
You can use both on the same case, and many datasets do.
Reference answers
Use a reference when the task has a small set of correct outputs, such as classification, extraction, policy lookup, or short factual answers. In the schema from the earlier chapter, the reference field holds it.
Choose the right kind of reference
| Reference type | Example | Works with | Main risk |
|---|---|---|---|
| Exact value | `"refund"` (a class label) | Exact match | None if label set is closed |
| Normalized value | `"2025-03-14"` (a date) | Code grader after parsing | Output formats you did not anticipate |
| Key facts | "30 days", "from delivery" | Substring checks or a judge | Facts present but contradicted elsewhere |
| Full sentence | "No. Returns are accepted within 30 days of delivery." | Judge or human comparison | Penalizing correct paraphrases |
Prefer the most constrained form your task allows. A reference like "refund" is cheap to grade and has no ambiguity. A full-sentence reference invites the grader to compare wording, which is rarely what you care about.
Write references that survive paraphrase
When outputs are free text, store the facts the answer must contain, not one particular phrasing. Two practical patterns:
- Keep a short canonical
referencefor humans to read, and add amust_includelist of facts. - Add
acceptablealternatives when a closed set of valid answers exists, for example["no", "no, it is past the 30-day window"].
Here is a case that uses both. The earlier schema stays intact, and the new fields are additions.
{"id": "refund-001", "input": "Can I return a laptop after 45 days?", "reference": "No. Returns are accepted within 30 days of delivery.", "must_include": ["30 days"], "must_not_include": ["yes"], "tags": ["returns", "policy"], "source": "production_log", "difficulty": "easy", "labeler": "ana", "labeled_on": "2026-11-20"}The labeler and labeled_on fields help later. If a reference turns out to be wrong, you can find who wrote it and which other cases share that author or date.
Reference pitfalls
- Stale references. A reference that quotes a policy is wrong the day the policy changes. Store a pointer to the source document or policy version in the case, and re-check references when it changes.
- Model-written references copied unchecked. If you let the model under test write its own reference, the eval measures self-agreement. A human must verify any model-drafted reference.
- Hidden ambiguity. "Can I return it?" may have different correct answers depending on missing context. Either add the context to the input or mark the case as needing clarification.
- Over-long references. Every extra sentence is another claim that can be wrong or arbitrarily required.
Rubrics
Use a rubric when there is no single right answer: summaries, support replies, explanations, or multi-step agent behavior. A rubric breaks "good" into separate criteria, each of which a grader can answer yes or no.
Anatomy of a good criterion
A good criterion has three properties:
- Observable. A reader can decide it from the output alone. "Mentions the 30-day window" is observable. "Feels trustworthy" is not.
- Binary. It is a yes/no question. Scales such as 1 to 5 hide disagreement between graders. If you need gradations, split them into several binary criteria.
- Single-purpose. "Is accurate and polite" mixes two things. If the output is accurate but rude, the grader cannot answer fairly.
Mark criteria that must hold regardless of everything else as required. A reply that is friendly and well formatted but states the wrong refund window should fail, however many other points it earns.
A rubric in the dataset
{"id": "support-014", "input": "My order arrived broken and I want my money back.", "rubric": [{"id": "apology", "text": "Acknowledges the problem in the first two sentences.", "weight": 1, "required": false}, {"id": "refund_path", "text": "States how to request a refund or replacement.", "weight": 3, "required": true}, {"id": "no_blame", "text": "Does not suggest the customer caused the damage.", "weight": 2, "required": true}, {"id": "length", "text": "Is under 120 words.", "weight": 1, "required": false}], "tags": ["support", "damaged"], "source": "expert_written", "difficulty": "medium"}Note that length could be checked by code instead of a judge. A good rubric labels which criteria are deterministic, because the next chapter's graders are chosen per criterion, not per case.
Scoring a rubric
Once each criterion has a pass/fail verdict from a grader, combine them. This function takes the rubric and a dict of verdicts. It fails the case if any required criterion fails, and otherwise passes it when the weighted score reaches a threshold.
def score_rubric(rubric, verdicts, threshold=0.7):
total = sum(c["weight"] for c in rubric)
earned = sum(c["weight"] for c in rubric if verdicts.get(c["id"], False))
required_ok = all(
verdicts.get(c["id"], False) for c in rubric if c["required"]
)
fraction = earned / total
return {
"score": fraction,
"passed": required_ok and fraction >= threshold,
}
rubric = [
{"id": "apology", "weight": 1, "required": False},
{"id": "refund_path", "weight": 3, "required": True},
{"id": "no_blame", "weight": 2, "required": True},
{"id": "length", "weight": 1, "required": False},
]
verdicts = {"apology": False, "refund_path": True, "no_blame": True, "length": True}
print(score_rubric(rubric, verdicts))This prints a score of about 0.857 and passed: True. A missing verdict counts as a fail, which is the safe default.
Choose weights sparingly
Weights feel precise but are guesses. Start with 1 for everything plus required flags. Add weights only when you see the rubric ranking two outputs differently from how a human would. Report the per-criterion pass rates alongside the total, because they show which behavior regressed.
Checking labels before you rely on them
Run a cheap validator over the dataset. It catches missing labels before they turn into silent failures.
import json
def validate_labels(path):
problems = []
with open(path, encoding="utf-8") as f:
for n, line in enumerate(f, start=1):
if not line.strip():
continue
case = json.loads(line)
cid = case.get("id", f"line {n}")
if "reference" not in case and "rubric" not in case:
problems.append(f"{cid}: no reference or rubric")
for c in case.get("rubric", []):
if c.get("weight", 0) <= 0:
problems.append(f"{cid}: criterion {c.get('id')} has no positive weight")
return problemsA validator checks only that labels exist and are well formed. Whether they are correct is a question for people, and the next chapter covers measuring that with annotator agreement.
A labeling workflow that holds up
- Write guidelines first. One page: what counts as correct, how to treat partial answers, and what to do when the input is ambiguous. Include three worked examples.
- Label from the input, not the model output. Seeing the model's answer first anchors the labeler on it and biases references toward what the app already says.
- Draft with a model, then verify. A model can propose a reference or rubric to save time. A person must read each one against the source material.
- Record uncertainty. Add a field such as
label_confidenceor aneeds_reviewtag. Unsure cases are better flagged than guessed. - Double-label a sample. Have a second person label a subset independently, so you can compute agreement.
Common errors
- Rubric criteria that restate the prompt. If the app's prompt says "be concise" and the rubric checks "is concise", you measure instruction following but call it quality. That may be fine, but name it.
- Too many criteria. Ten or more criteria per case make labeling slow and judges inconsistent. Aim for three to six.
- Reference as the only truth. For tasks with several valid answers, a single reference makes a correct but different answer look like a failure. Add alternatives or move to a rubric.
- Unlabeled negative cases. Include cases where the correct behavior is to refuse, ask a question, or say "I don't know". Their reference is the behavior, such as "declines and points to support", not an answer.
Exercise
A case asks "Summarize this 500-word incident report for an executive." You are tempted to write one 60-word summary as the reference. Name two problems with that choice, and describe what to write instead.
Show answer
Many different summaries are valid, so a single reference will mark good paraphrases or differently focused summaries as failures. The writer's wording also anchors the grader on style instead of content. Write a rubric of binary criteria instead, for example: states the root cause, states customer impact, states the current status, contains no facts absent from the report (required), and is under 80 words. Mark the factual-accuracy criteria as required.