Sub topic 2
Deciding What to Measure and Where Ground Truth Comes From
An LLM judge can only grade what you ask it to grade, and you can only trust it as far as you can check it against something. This chapter covers both ends of that problem: choosing the quality you want to measure, and collecting the human labels that serve as ground truth. Later chapters cover judge formats, rubric wording and agreement statistics in detail.
This chapter assumes you have prompted a large language model (LLM) before and can read Python. It also assumes you know what an evaluation set is (inputs paired with expected behavior) and understand proportions and averages.
Start from a failure, not a metric
Teams often begin with a generic score such as "helpfulness" or "quality". These scores are easy to ask a judge for, and they are hard to act on. A drop from 4.1 to 3.9 does not tell you what to fix.
Start from observed failures instead:
- Read 50 to 100 real outputs from your system. Production logs are best. Hand-written test prompts are a weaker substitute.
- Write down each concrete problem you see. Examples are "invents a refund policy", "ignores the user's stated budget", and "answers in the wrong language".
- Group the problems into a few recurring failure types.
- Pick the types that matter most for users, and measure those.
This gives you a short list of targets that each map to an action. If the "invents a policy" rate rises after a prompt change, you know where to look.
Turn a quality into a narrow criterion
A criterion is a statement a grader can apply to one output and answer without guessing what you meant. Vague qualities become criteria by being narrowed and by naming the evidence the grader should use.
| Vague quality | Narrow criterion | Evidence the grader sees |
|---|---|---|
| Accurate | Every factual claim in the answer is supported by the retrieved context | Answer and context |
| Helpful | The answer addresses every question the user asked | Question and answer |
| Safe | The answer does not give step-by-step instructions for the listed prohibited topics | Answer and the policy list |
| Good tone | The answer contains no sarcasm, blame, or dismissive phrases toward the user | Answer |
Each criterion should pass three checks:
- One thing at a time. "Accurate and concise" is two criteria. A judge asked for one score will blend them, and you cannot tell which part moved.
- Observable from the inputs you provide. If the criterion depends on facts the grader cannot see, such as whether a price is currently correct, it cannot be graded reliably by a judge or by a human.
- Decidable by two careful humans. If two people reading the same output often disagree about the criterion, the problem is the criterion, and a better judge will not fix it.
Decide the label type
The label type shapes everything downstream, including how you collect ground truth and how you measure agreement.
- Binary (pass or fail). Easiest to define and to collect. Agreement statistics are simple, and the aggregate is a rate you can put a confidence interval on. Use it when the criterion is naturally a rule, such as "no unsupported claims".
- Ordinal scale (1 to 5). Gives more detail, but adjacent levels are hard to separate. Humans and judges disagree most between a 3 and a 4. If you use a scale, define every level in words.
- Preference (A is better, B is better, or tie). Suited to comparing two systems or two prompt versions, where absolute scores are hard to calibrate.
When in doubt, start with binary criteria. You can combine several binary checks into a profile of the output, and each one is easier to validate than a single 1 to 5 score.
Check whether you need a judge at all
Before you spend effort on a judge, ask whether code can do the check. The following criteria need no judge:
- The output must be valid JSON that follows a schema.
- The answer must contain a particular order number or must not contain a phone number.
- The output must stay under a length limit.
- A generated SQL query must return the same rows as a reference query.
Deterministic checks are cheap, repeatable, and have no judge bias. Use a judge for what remains: criteria that depend on meaning, such as faithfulness, relevance, or tone, where no simple rule captures the idea.
Where ground truth comes from
Ground truth for a judge evaluation is a set of outputs with trusted labels for your criterion. You compare the judge's verdicts against those labels. There are four common sources.
| Source | Strength | Weakness |
|---|---|---|
| Domain experts label outputs | Highest trust for specialized content | Slow, costly, and hard to scale |
| Trained annotators with written guidelines | Good consistency at moderate cost | Need guideline writing and quality checks |
| Existing user signals (thumbs, escalations, edits) | Free and plentiful | Noisy, biased toward vocal users, and often not tied to one criterion |
| Programmatic or synthetic labels (known-bad outputs made by injecting a defect) | Cheap, with labels known by construction | May not look like real failures |
No single source is enough. A common pattern is to use expert or annotator labels as the main reference. Synthetic defects can then add coverage, for example by altering a number in an otherwise faithful answer to create a known unsupported claim. User signals can help you decide which outputs to send for labeling.
Human labels are not perfect truth. They are the best reference you have, and you should treat them as evidence. If two annotators disagree on 25% of items, a judge cannot be expected to agree with "the" label more often than the humans agree with each other. Have at least two people label a subset, measure how often they agree, and resolve disagreements by discussion or by a senior reviewer. Record the reasons, because they often reveal gaps in your criterion.
Building the labeled set
A labeled set for validating a judge needs these properties:
- Realistic. Draw from real traffic, not only from clean examples you wrote.
- Covers failures. If only 3% of outputs fail, a random sample of 100 contains about three failures, which is too few to tell whether the judge catches them. Oversample suspected failures and hard cases.
- Split into development and test parts. You will tune the rubric and prompt against the development part. Keep the test part untouched until you want an honest estimate. Otherwise you are measuring how well you fitted the judge to those exact examples.
- Large enough for the claim you want to make. With 40 items, one flipped label moves a rate by 2.5 points. Chapter 13 covers confidence intervals. For now, plan for at least 100 labeled items per criterion, and more if you need to detect small differences.
The following code draws a sample with a cap per topic and splits it into development and test parts.
import random
from collections import Counter, defaultdict
def stratified_sample(items, key, per_group, seed=0):
"""Take up to per_group items from each value of items[...][key]."""
rng = random.Random(seed)
groups = defaultdict(list)
for item in items:
groups[item[key]].append(item)
sample = []
for name in sorted(groups):
members = groups[name]
sample.extend(rng.sample(members, min(per_group, len(members))))
return sample
def split_dev_test(items, dev_fraction=0.5, seed=0):
rng = random.Random(seed)
shuffled = list(items)
rng.shuffle(shuffled)
cut = int(len(shuffled) * dev_fraction)
return shuffled[:cut], shuffled[cut:]
traces = (
[{"id": i, "topic": "refund"} for i in range(40)]
+ [{"id": 100 + i, "topic": "shipping"} for i in range(25)]
+ [{"id": 200 + i, "topic": "account"} for i in range(3)]
)
sample = stratified_sample(traces, "topic", per_group=4)
dev, test = split_dev_test(sample)
print(Counter(t["topic"] for t in sample))
print(len(sample), len(dev), len(test))The sample has 4 refund items, 4 shipping items and all 3 account items, so the last line prints 11 5 6. The sample no longer matches the real traffic mix, because rare topics are overrepresented. That helps validation, because the judge sees enough of each topic. It also means you must not report the pass rate from this sample as the production pass rate. Estimate production rates from a separate random sample, or reweight each group by its real share.
Edge cases and common errors
- Criterion drift. Annotators gradually change how they apply a criterion. Keep a short guideline document with examples of borderline cases, and add to it whenever a disagreement is resolved.
- Labeling the judge's output. If annotators see the judge's verdict first, they tend to agree with it. Hide it until labels are final.
- Using the judge to create ground truth. Labels produced by an LLM cannot validate an LLM judge, because shared blind spots look like agreement. Use a judge for pre-labeling only if a human reviews every label.
- Labels without context. An annotator who sees only the answer cannot decide whether it is faithful to the retrieved passage. Show the same inputs the judge will see.
- Ambiguous items. Some outputs are borderline. Keep them in the set and mark them, because a judge will meet them in production. Report agreement on clear and ambiguous items separately.
Exercise
Your team wants a single "overall quality" score from 1 to 5 for a support chatbot. You read 60 real conversations and find three recurring problems: the bot invents policies, it ignores part of the question, and it sometimes exceeds the 120-word limit. Propose the measurements you would build, and say which ones need a judge and what label type each should use.
Show answer
Build three separate measurements. (1) "Invents policies": a judge criterion such as "every policy statement is supported by the provided policy text", with a binary pass/fail label, because it depends on meaning. (2) "Ignores part of the question": a judge criterion such as "the answer addresses every question the user asked", also binary. (3) Word limit: a deterministic check that counts words in code, with no judge. Validate the two judge criteria against human labels from a sample that oversamples failures, and split it into development and test parts. A single 1-5 score would mix these problems and would not tell you which one to fix.