Sub topic 3
Pointwise, pairwise and reference-based judging
This chapter assumes you have prompted an LLM before, can read Python, and know what an evaluation set is (inputs paired with expected behavior). It also assumes you know what a proportion is. You do not need to have built a judge yet. The chapter covers the three formats a judge can use, what each one needs, and where each one fails.
Three ways to ask the same question
A judge format is the shape of the question you put to the judge model. The format decides what data you must collect, what the judge can notice, and which biases you must guard against. The three common formats are:
- Pointwise: the judge sees one answer and grades it on its own.
- Pairwise: the judge sees two answers to the same input and picks the better one.
- Reference-based: the judge sees an answer and a trusted reference answer, and decides whether the answer matches the reference.
The formats can be combined. A reference-based check can be pointwise (one answer against one reference) or pairwise (two answers, each compared with the reference). The names describe what the judge is shown, so keep them separate in your head.
Pointwise judging
In pointwise judging, each answer is graded alone against a rubric. The output is a score (for example 1 to 5) or a pass/fail label. The first code example in this chapter's plan shows the pattern:
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["score"]
if not isinstance(score, int) or not 1 <= score <= 5:
raise ValueError(f"invalid score: {score!r}")
return dataThe parser rejects a reply that is not valid JSON, lacks a score key, or holds a score outside the range. A rejected reply should be counted and retried, not turned into a default score.
Strengths
- It scales linearly. N answers cost N judge calls.
- Scores are absolute, so you can track one system over time and set a release threshold such as "mean faithfulness at least 4.2".
- It has no position bias, because there is only one answer.
Weaknesses
- Numeric scales are poorly calibrated. A judge may give 4 to almost everything, which compresses the scale and hides real differences.
- A score of 3 from one run and a score of 3 from another model version may not mean the same thing.
- Without a comparison point, the judge has no anchor for "good".
Pass/fail labels with a precise definition tend to be more stable than 1-to-10 scales. If you do use a scale, define every level in the rubric, as the example does for levels 1, 3 and 5.
Pairwise judging
In pairwise judging, the judge sees two answers to the same input and says which is better, or whether they are tied. People find relative judgments easier than absolute ones, and models behave the same way. Pairwise is the usual choice when you compare two prompts, two models, or a candidate release against the current one.
Strengths
- Relative preferences are often more reliable than absolute scores, especially for open-ended tasks such as summarization or tone.
- The result maps directly to a decision: "ship B or keep A".
Weaknesses
- The judge is influenced by answer order. This is position bias, and the next chapters cover it in detail. A simple defense is to run both orders and accept a winner only when they agree:
def judge_pair(call_judge, question, a, b):
"""call_judge(question, first, second) returns "first" or "second"."""
r1 = call_judge(question, a, b)
r2 = call_judge(question, b, a)
win1 = "A" if r1 == "first" else "B"
win2 = "B" if r2 == "first" else "A"
return win1 if win1 == win2 else "tie"- Cost doubles, because every comparison needs two calls.
- Comparing K systems needs up to K(K-1)/2 pairs per input. Five systems mean ten pairs.
- A win does not say how good the winner is. B can beat A while both are poor.
- Preferences do not always chain. A beats B and B beats C does not guarantee A beats C, so be careful when you build a ranking from many pairs.
Reference-based judging
In reference-based judging, the judge also gets a reference answer: a known-good answer written or approved by a person. The judge decides whether the candidate agrees with the reference in the ways that matter. This turns an open question ("is this good?") into a narrower one ("does this say the same thing as the reference?").
A reference-based prompt looks like this:
def build_reference_prompt(question, reference, answer):
return (
"Decide whether the candidate answer is consistent with the reference answer.\n"
"Wording may differ. Mark it incorrect if it omits a key fact from the "
"reference or states anything that contradicts it.\n\n"
f"Question: {question}\nReference: {reference}\nCandidate: {answer}\n\n"
'Reply with JSON only: {"reasoning": "<one or two sentences>", '
'"verdict": "correct" or "incorrect"}'
)
print(build_reference_prompt(
"What year did the Apollo 11 landing happen?",
"1969",
"The landing took place in July 1969.",
))Strengths
- It is the format closest to ground truth, so it usually agrees best with human labels.
- It works well for question answering, extraction and other tasks that have a checkable answer.
- It reduces the judge's reliance on its own knowledge, which may be wrong or out of date.
Weaknesses
- You must build and maintain the references. This is the main cost.
- A single reference can penalize a valid answer that is phrased or structured differently. Allowing several acceptable references helps.
- If the reference itself is wrong, every verdict built on it is wrong in the same way.
- It suits tasks with a narrow set of correct answers. For creative writing or advice there is no one right answer to match.
When the answer is a number, a date or an exact string, skip the judge and compare in code. Use reference-based judging when equivalent meanings can be worded in many ways.
Choosing a format
| Situation | Usual choice | Reason |
|---|---|---|
| Monitoring one system in production | Pointwise | You need an absolute number per answer, with no second answer to compare |
| Choosing between two prompts or models | Pairwise | The decision is relative, and preferences are easier to judge |
| Question answering with known answers | Reference-based | The reference anchors the judgment |
| Checking a safety or format rule | Pointwise pass/fail | The rule is binary and testable |
| Open-ended writing, no references | Pairwise or pointwise with a tight rubric | There is nothing to match against |
| No budget for references or double calls | Pointwise | Cheapest per answer |
Ask three questions in order. First, is there a trusted reference? If yes, use it. Second, is the decision a comparison between candidates? If yes, use pairwise. Otherwise, use pointwise with a narrow rubric.
Common errors
- Using a 1-to-10 scale with no level definitions. The judge picks its own meaning for each number. Define the levels, or use pass/fail.
- Skipping order swaps in pairwise runs. A fixed order can add a bias to every result. Swap the order, or at least randomize it and record it.
- Asking pointwise judges to compare. A prompt like "is this better than a typical answer?" has no stable comparison point. Use pairwise instead.
- Trusting references blindly. Spot-check a sample of references. An error here is repeated across the whole run.
- Combining several criteria in one score. One number for "accuracy, tone and completeness" cannot be interpreted. The next chapter shows how to split these into separate narrow rubrics.
- Treating tied pairs as noise. A high tie rate after order swapping is information: the judge cannot reliably tell the systems apart, or the systems really are close.
Exercises
Exercise
You are comparing a new prompt against the current prompt on 200 inputs, using a pairwise judge. How many judge calls do you need if you swap the answer order on every comparison, and what do you report when the two orders disagree?
Show answer
You need 400 calls: 2 per input for 200 inputs. When the two orders name different winners, report a tie for that input, because the preference depends on position and not on answer quality.
Exercise
A team grades support answers on a 1-to-10 scale with a pointwise judge and finds that 90% of scores are 8 or 9. Name the problem and give two fixes.
Show answer
The scale is compressed, so it cannot separate good answers from great ones. Fixes: define each score level in the rubric with concrete criteria, switch to pass/fail with a precise definition, split the score into narrow single-criterion rubrics, or move to pairwise comparison against the current system.
Exercise
For each task, pick pointwise, pairwise, reference-based, or no judge: (a) checking that an answer to "What is 17 times 23?" is 391; (b) deciding which of two summaries reads more clearly; (c) checking whether a chatbot answer agrees with the company policy text in a stored FAQ entry.
Show answer
(a) No judge. Compare the number in code. (b) Pairwise, with order swapping, because clarity is relative and open-ended. (c) Reference-based, using the FAQ entry as the reference, because meaning can be worded many ways but there is a trusted source to match.