Sub topic 9
Using an LLM as a Judge, and Where It Goes Wrong
This chapter assumes you have read the earlier chapters on claim-level faithfulness scoring. It also assumes you can read Python and know what precision and recall mean. Claim-level scoring needs a verifier, a function that decides whether a claim is supported by the context. This chapter covers the most common choice for that verifier: a second language model, called a judge. It also covers the ways a judge fails and how to reduce those failures.
Why use a model as a judge
Retrieval metrics such as precision@k need labelled relevant documents. Faithfulness has no such shortcut. The answer is free text, and "supported by the context" depends on meaning, not on matching words. The toy judge from the previous chapter, an exact substring match, marks "the warranty lasts two years" as unsupported when the context says "24 months".
Three options exist for checking support:
| Option | Strength | Weakness |
|---|---|---|
| String or overlap match | Fast, free, deterministic | Misses paraphrase and negation |
| Trained NLI model (natural language inference, which labels a claim as entailed, contradicted, or neutral given a text) | Cheap, stable, runs locally | Short input limit, weaker on multi-step reasoning |
| LLM judge | Handles paraphrase, long context, and custom criteria | Costs money, varies between runs, has systematic biases |
An LLM judge is a model that receives a task description, the material to grade, and a rubric, and returns a verdict. Use it when the criterion is semantic and no cheaper verifier is accurate enough. Always treat its output as a measurement with error, not as ground truth.
Judge design: a verifier you can plug in
The faithfulness_score function from the claim-level chapter takes an is_supported(claim, context) function. A judge fits that slot. The sketch below shows the shape of a judge prompt and a wrapper. The call_llm argument is any function that takes a prompt string and returns the model's text. It is passed in so you can use whichever provider you have.
def build_support_prompt(claim, context):
return (
"You are checking a claim against a source text.\n"
"Use ONLY the source text. Do not use outside knowledge.\n"
"Answer SUPPORTED if the source text states or directly implies the claim.\n"
"Answer UNSUPPORTED if the claim is contradicted, or if the source text\n"
"does not contain enough information to confirm it.\n\n"
f"Source text:\n{context}\n\n"
f"Claim:\n{claim}\n\n"
"Give one sentence of reasoning, then on a new line write\n"
"VERDICT: SUPPORTED or VERDICT: UNSUPPORTED."
)
def llm_is_supported(claim, context, call_llm):
reply = call_llm(build_support_prompt(claim, context))
last_line = reply.strip().splitlines()[-1].strip().upper()
if last_line == "VERDICT: SUPPORTED":
return True
if last_line == "VERDICT: UNSUPPORTED":
return False
raise ValueError(f"Unparseable judge reply: {reply!r}")
# Stub model for illustration so the code runs without a provider.
def fake_llm(prompt):
ok = "24 months" in prompt and "lasts 24 months" in prompt.split("Claim:")[1]
return "Reasoning here.\nVERDICT: " + ("SUPPORTED" if ok else "UNSUPPORTED")
context = "The warranty lasts 24 months. It covers manufacturing defects."
print(llm_is_supported("The warranty lasts 24 months.", context, fake_llm)) # True
print(llm_is_supported("It covers water damage.", context, fake_llm)) # FalseSeveral design choices in this prompt matter:
- Restrict the knowledge source. Without "use only the source text", the judge may mark a true but unretrieved claim as supported. That hides exactly the failure faithfulness is meant to catch: the generator answering from its own memory.
- Define the middle case. "Not enough information" is the most common borderline case. Say explicitly which label it gets.
- Ask for reasoning before the verdict. A short rationale usually improves accuracy and gives you something to read when you audit errors.
- Force a parseable format and fail loudly. The wrapper raises an error on a malformed reply instead of silently counting it as unsupported. Silent defaults bias your score.
- Judge one claim at a time. Grading a whole answer in one call tends to give a vague overall impression. Per-claim calls give a score you can decompose.
Known biases
A judge is a language model, so it inherits language-model habits. These are the ones to look for.
- Verbosity bias. Judges tend to prefer longer answers, even when the extra text adds nothing. This matters most for answer relevance and pairwise comparison.
- Position bias. In a pairwise comparison ("which answer is better, A or B?"), judges often favor whichever answer appears first, or sometimes second, regardless of content.
- Self-preference. A model may rate text written by itself, or by a model from the same family, higher than equivalent text from another source.
- Leniency toward plausible text. A fluent, confident claim that is almost in the context is often marked supported. This is the most damaging bias for faithfulness, because hallucinations are fluent by nature.
- Sensitivity to prompt wording. Small rubric changes can shift the average score. A score from one prompt is not comparable with a score from another.
- Nondeterminism. Even at temperature 0, outputs can differ across runs and across model versions.
Mitigations
Each bias has a practical countermeasure.
- Swap positions. For pairwise comparisons, run each pair twice with the order reversed. Count a win only when both orders agree. Treat disagreement as a tie and track how often it happens.
- Use a different model family for the judge. If your generator is from one family, judge with another. This reduces self-preference.
- Prefer binary or small-scale verdicts. "Supported or not" is more reliable than a 1 to 10 score. If you need a scale, give each level a written definition.
- Control for length. Report average answer length next to quality scores. If a change raises both, check whether the gain is real.
- Keep temperature at 0 and repeat borderline cases. For high-stakes comparisons, run the judge several times and take the majority verdict.
- Freeze the judge. Change the judge and the system under test in separate experiments, never together.
The next diagram shows how a judged evaluation run is arranged so that bias checks are part of it.
Failure modes in practice
The biases above show up as concrete problems in a faithfulness pipeline.
The judge uses outside knowledge
The claim "Paris is the capital of France" is true, but if the retrieved context never says it, the answer is not grounded in the context. A judge that knows the fact may mark it supported. Faithfulness measures grounding, not truth, so this is a measurement error. The "use only the source text" instruction reduces it but does not remove it. Test for it by adding to your evaluation set a few claims that are true in the world but absent from the context, and confirm the judge marks them unsupported.
The judge accepts partial support
A claim such as "The warranty lasts 24 months and covers accidental damage" has two parts. The context supports the first and not the second. A judge asked for one verdict may say supported because most of the claim matches. The fix is upstream: extraction should produce atomic claims, each with one fact. Judge quality cannot compensate for compound claims.
The extraction step is also an LLM
Claim extraction is usually done by a model too. If it drops an unsupported sentence or rewrites a claim more favorably, the judge never sees the problem. Spot-check extracted claims against the raw answer, not only the final verdicts.
Empty and degenerate cases
If extraction returns no claims, faithfulness_score returns None. Report these cases separately. An answer such as "I don't know" has no claims, and that is often a correct behavior when retrieval failed. Counting it as a perfect 1.0 hides it, and counting it as 0.0 punishes the system for refusing to guess.
Judge disagreement with itself
Run the same 100 claims through the judge twice. The share of claims with different verdicts is a direct estimate of its noise. If it is high, you need a clearer rubric, a stronger model, or repeated votes before you can trust small differences.
When not to use an LLM judge
A judge is not always the right tool.
- When a deterministic check exists, use it. Verifying that a cited document ID appears in the retrieved set needs a set lookup, not a model.
- When you have labelled relevance data, retrieval metrics such as precision@k and nDCG are cheaper and exact.
- When the decision is high-stakes, such as a legal or medical answer, use judge scores to find candidates for human review, not to replace it.
Summary
An LLM judge extends evaluation to criteria that need semantic reading, at the cost of noise and bias. Design the prompt to restrict the knowledge source, define the borderline case, and return a parseable verdict. Judge one atomic claim at a time. Expect verbosity, position, self-preference, and leniency biases, and use position swaps, a different model family, narrow scales, and a frozen judge to reduce them. Record the judge version with each score.
Exercise
Your RAG system's faithfulness score rises from 0.78 to 0.86 after you switch the judge prompt to a shorter rubric, with no change to the RAG system. Does this show an improvement? What do you do next?
Show answer
No. The system did not change, so the difference comes from the judge. A different prompt shifted how strictly claims are graded, which means scores from the two prompts are not comparable. Re-score the old outputs with the new prompt (or the new outputs with the old one) so both are measured by the same judge, and check the new prompt on a judge test set with known verdicts to see whether it became more lenient. Only compare scores produced by the same judge version.
Exercise
A judge marks the claim "The refund window is 30 days and refunds are issued to the original payment method" as SUPPORTED. The context only mentions the 30-day window. Name the likely cause and two fixes.
Show answer
The claim is compound, and the judge accepted partial support. Fix 1: change claim extraction to produce atomic claims, so this becomes two separate claims and the second is judged unsupported. Fix 2: add a rule to the judge prompt that all parts of a claim must be supported for a SUPPORTED verdict. You can also add this claim to the judge test set to catch the problem if it returns.