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. It covers the three formats a judge can use and how to choose between them.
Three formats
A judge format is the shape of the question you put to the judge model.
- Pointwise: the judge sees one answer and gives it a score or a pass/fail verdict against a rubric.
- Pairwise: the judge sees two answers to the same question and picks the better one.
- Reference-based: the judge sees the answer plus a trusted reference answer, and decides whether the answer matches it. This can be combined with either of the formats above.
Pointwise judging
Pointwise judging suits monitoring, because each output gets a score on its own. It needs a rubric with clearly defined score levels. Without anchors, the judge drifts toward middle scores.
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 malformed or out-of-range verdicts. Silently accepting them would corrupt your averages.
Pairwise judging
Models often compare two answers more reliably than they score one in isolation. Pairwise judging therefore fits A/B tests between two prompts or models. It gives a win rate, not an absolute quality level. It also exposes position bias, where the judge favors whichever answer appears first. The standard fix is to run both orders and report 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"This doubles your judge calls. Count the disagreements as ties, and track how often they happen. A high tie rate means the judge is unsure or the answers are close.
Reference-based judging
When a correct answer is known, give it to the judge. The task changes from "is this good?" to "does this agree with the reference?", which is easier and more consistent. The cost is that you must write and maintain references. The judge can also wrongly penalize a correct answer that is worded differently from the reference, so tell it to compare meaning, not wording.
Choosing a format
| Format | Best for | Main risk |
|---|---|---|
| Pointwise | Monitoring, absolute thresholds | Score drift, vague rubrics |
| Pairwise | Choosing between two systems | Position bias, 2x cost |
| Reference-based | Tasks with known answers | Reference upkeep, rigid matching |
Exercise
A team wants a dashboard that tracks answer faithfulness every day on live traffic, where no reference answers exist. Which format fits, and why?
Show answer
Pointwise. Each output is scored on its own, so scores can be tracked over time. Pairwise needs a second answer to compare against, and reference-based needs reference answers, which live traffic does not have.