Sub topic 4
Writing a Narrow, Testable Rubric
This chapter assumes you have prompted an LLM before, can read Python, and know what an evaluation set is. It also assumes you know proportions and averages. The previous chapters covered pointwise, pairwise and reference-based formats. Here the focus is the rubric: the written criterion the judge applies to each output.
Why the rubric decides the quality of the judge
A judge model does what its prompt says. If the prompt says "rate the overall quality," the model picks its own idea of quality. That idea can shift with answer length, tone, or the wording of the question. The score then mixes several properties you never asked about, and you can't tell which one moved.
A good rubric makes two promises:
- Narrow: it measures one property, such as faithfulness to a supplied context.
- Testable: two careful people, or one person on two different days, would give the same score to the same output.
Testability is the practical check. If humans can't apply your rubric consistently, a model can't either. You will measure that agreement formally in a later chapter. For now, treat it as a design rule.
The parts of a rubric
A usable rubric has five parts.
- One criterion. Name the property in a single phrase: "faithfulness to the context," "the answer states a refund deadline," "the tone is not condescending."
- A scale with anchors. Describe what each score point means, or at least the endpoints and the midpoint.
- Explicit exclusions. Tell the judge what to ignore. This is your first defense against verbosity and style bias.
- Edge-case rules. Say what to do with empty answers, refusals, answers that add true but unsupported facts, and so on.
- An output contract. Say exactly what to return, so the reply can be parsed.
Vague versus narrow
| Vague rubric line | Problem | Narrow replacement |
|---|---|---|
| "Is the answer good?" | Mixes correctness, style, and length | "Does the answer state the refund deadline given in the context?" |
| "Rate helpfulness from 1 to 10" | Ten points with no anchors; scores cluster at 7 or 8 | "Pass if the answer resolves the user's stated problem. Otherwise fail." |
| "Is the answer accurate and concise and polite?" | Three criteria in one score | Three separate judge calls, one per criterion |
| "Should be well-supported" | "Well" is undefined | "Every factual claim appears in the context. Claims not in the context count as unsupported." |
A worked rubric
The rubric below scores one property, faithfulness to a context, on a five-point scale with three anchors. It tells the judge to ignore length and style. The parser rejects anything that breaks the output contract.
import json
RUBRIC = """Score the answer from 1 to 5 for faithfulness to the context.
1 = contradicts the context; 3 = partly supported; 5 = fully supported.
Judge faithfulness only. Ignore length and writing style."""
def build_prompt(question, context, answer):
return (
f"{RUBRIC}\n\nQuestion: {question}\nContext: {context}\nAnswer: {answer}\n\n"
'Reply with JSON only: {"reasoning": "<one or two sentences>", "score": <integer 1-5>}'
)
def parse_verdict(text):
data = json.loads(text)
score = data.get("score")
if isinstance(score, bool) or not isinstance(score, int) or not 1 <= score <= 5:
raise ValueError(f"invalid score: {score!r}")
return data
print(parse_verdict('{"reasoning": "Matches the context.", "score": 5}')["score"])
for bad in [
'{"reasoning": "ok", "score": 7}',
'{"reasoning": "ok", "score": "5"}',
'{"reasoning": "ok", "score": 4.5}',
'{"reasoning": "ok", "score": true}',
'{"reasoning": "ok"}',
]:
try:
parse_verdict(bad)
except ValueError as err:
print("rejected:", err)The bool check matters. In Python, True is an instance of int and equals 1, so without the check a verdict of true would pass as a score of 1. The parser raises an error for malformed verdicts instead of coercing them. Count those rejections and report them. A rising rejection rate is an early sign that the prompt, the model, or the inputs have changed.
Anchors: how to describe score points
Anchors are descriptions of what each score point looks like. They are the main tool for reducing arbitrary variation between scores.
- Describe observable facts, not impressions. "Contains one claim not found in the context" is observable. "Somewhat unreliable" is not.
- Make the points mutually exclusive. A reader should be able to pick one score without hesitating between two.
- Write anchors for the boundaries you actually see. Look at 20 real outputs, find the ones that are hard to score, and write anchors that settle them.
- Use fewer points when you can't anchor them all. If you can't say how a 3 differs from a 4, your scale has too many points.
Many teams prefer a binary pass/fail verdict with a clear definition of "pass." Binary verdicts are easier to anchor, easier to compare against human labels, and easier to turn into a pass rate with a confidence interval. A five-point scale is worth the extra work only when you need to see partial progress.
One criterion per judge call
If you care about faithfulness, completeness, and tone, run three judge calls with three rubrics. Combining them in one prompt creates two problems:
- The model has to weigh the criteria against each other on its own. You can't see or control that weighing.
- A single score can't tell you which property failed.
Separate scores also let you validate each judge against human labels on its own. One criterion might agree well with humans while another doesn't.
Edge-case rules
Most rubric failures come from cases the author didn't think about. Write a rule for each of these:
- Empty or refusing answers. Decide whether a refusal is faithful (it claims nothing) or a failure. State your decision.
- True but unsupported claims. A faithfulness rubric should say whether facts that are correct but absent from the context count as supported. Usually they don't.
- Missing context. Say what to return when the context lacks the information the question needs.
- Partial answers. Say whether an answer that is right but incomplete is judged on faithfulness only, or whether completeness belongs to a different rubric.
Testing the rubric before using it
Treat a rubric as code that needs tests. The loop below takes less than an afternoon for a first version.
Follow these steps:
- Collect examples that cover easy passes, easy failures, and the borderline cases you worried about while writing.
- Label them yourself, or have two people label them independently. If the two people disagree often, the rubric is ambiguous. Fix the text before involving a model.
- Run the judge and read every disagreement. Decide whether the judge misread the rubric or the label was debatable.
- Change the rubric only in response to a pattern, not a single odd case. Otherwise you overfit to your small sample.
- Keep a held-out set of labeled examples that you never use while editing. Check the final rubric against it.
Store the rubric text, the judge model name, and the prompt template together under a version identifier. Later chapters on drift rely on being able to say exactly which rubric produced which numbers.
Common errors
- Quality words without definitions. "Good," "clear," "professional," and "appropriate" leave the judge to guess.
- Asking for reasoning after the score. If the JSON asks for the score first, the reasoning only justifies a number already chosen. Put the short reasoning field first, as in the example.
- Leaking the answer's origin. Don't tell the judge which system produced the answer. This feeds self-preference and brand bias.
- Length rules hidden in the criterion. If you want concise answers, write a separate conciseness rubric. Don't let length leak into a faithfulness score.
- Treating the parser as optional. A lenient parser that accepts
"5"or7hides prompt failures that later distort your averages.
Exercise
A team's rubric says "Rate the answer from 1 to 10 for accuracy, helpfulness, and tone." Scores are almost always 7 or 8, and two reviewers disagree on about half of the examples. Describe three specific changes that make the rubric narrow and testable.
Show answer
First, split it into three rubrics (accuracy, helpfulness, tone) and run one judge call per criterion, so each score has one meaning. Second, replace the 10-point scale with a binary pass/fail or a short scale where each point has an observable anchor, for example "pass only if every claim appears in the context." Third, add exclusions and edge-case rules, such as "ignore length and style" and how to treat refusals or missing context. Then hand-label 20 to 50 examples, check that two reviewers now agree, and keep a held-out set for the final check.
Exercise
Why does the parse_verdict function reject a score of true, and what would happen without the check?
Show answer
In Python, bool is a subclass of int, and True equals 1. Without the explicit isinstance(score, bool) check, true would pass the integer and range tests and be recorded as a score of 1, a silent error that lowers the average. Rejecting it surfaces the malformed output so you can count and investigate it.