Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 63/ 160
04. Evals

LLM as a Judge

Using a strong model to score outputs with rubrics when human labels are scarce.

IntermediateJudge Model · Rubric3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

You ask a strong AI to grade other AI answers using a checklist, and you check its grading against human graders to make sure it's fair.

Think of it like…

A teaching assistant marking essays with a grading sheet: fast and consistent, but you spot-check their marking against the professor's, and you watch for habits like rewarding length or favouring the first essay in the pile.

Where you’ve seen it

A team evaluates 1,000 support answers per release. They write a judge prompt with three binary criteria (factually consistent with the provided policy, answers the question asked, follows tone guidelines), each with a definition and two examples, use a strong model at temperature 0 and require a one-sentence reason before the verdict. They validate it on 200 answers labelled by two support leads: on "faithful to policy" the judge agrees with the human consensus 91% of the time (Cohen's κ = 0.78) but on "tone" only 72% (κ = 0.41), so tone stays human-reviewed on a sample while faithfulness is fully automated.

Words you’ll hear

Judge prompt / rubric
Instructions defining criteria, scale and output format for the grader.
Position bias
Preferring an answer because of where it appears (often the first).
Verbosity and self-preference bias
Favouring longer answers, or text produced by the same model family.
Agreement with humans
How often the judge matches human labels, measured with accuracy and Cohen's kappa.

Visual diagram

Loading interactive diagram

Theory & deep dive

Designing a reliable judge

Break quality into specific, observable criteria ("every factual claim is supported by the provided context", "the answer addresses all parts of the question") rather than a vague "is this good?". Prefer binary or 3-level scales with clear definitions over 1–10 scores, which are noisy and poorly calibrated. Include the reference answer or source context when judging correctness, give 2 to 4 labelled examples (including borderline ones), ask for a short justification before the verdict (it improves accuracy and makes errors debuggable), request structured JSON, and use temperature 0.

Use a capable judge model, ideally different from the model being judged to limit self-preference, and keep separate judges per criterion instead of one mega-prompt. For comparing two outputs use pairwise judging with randomised order. Use judges where they're strong (style, completeness, consistency with provided context) and not where they need ground truth they don't have (facts outside the context, arithmetic), which need references, retrieval or code checks.

A judge prompt skeleton

"You grade a support answer. Criterion: FAITHFUL = every factual claim is supported by the CONTEXT. Examples: [...]. First write one sentence of reasoning, then output JSON {\"reason\": ..., \"faithful\": true|false}. CONTEXT: ... QUESTION: ... ANSWER: ..."

Key takeaway: Specific binary criteria, examples, reasoning first, temperature 0, and a judge from another model family.

Biases, validation and limits

Known biases: position bias (the first of two answers wins more often), verbosity bias (longer looks better), self-preference (a model rates its own style higher), authority and formatting bias (confident tone, markdown) and sensitivity to prompt wording. Mitigations: randomise or swap order and keep only consistent verdicts, control for length (instruct that length isn't quality; compare length-matched pairs), use a different model family, and test the judge on adversarial examples (a long wrong answer versus a short right one).

Validate with a human-labelled set (100 to 300 cases): report accuracy and Cohen's kappa for each criterion, and the confusion matrix, since a judge that says "pass" 95% of the time may look accurate while missing most failures (check true negative rate on the fail class). Re-validate when you change the judge prompt, judge model or task distribution. In production use, sample judged outputs for human audit, monitor the pass rate for drift, and remember a judge adds noise: use enough cases and confidence intervals when comparing versions. Treat judge scores as evidence, and keep human review for high-stakes decisions.

Checking the fail class

On 200 human-labelled answers (40 truly unfaithful), the judge flags 29 of the 40 (true negative rate 72.5%) and wrongly flags 6 of 160 faithful ones. Overall accuracy is 91%, but one in four bad answers slips through, so the team tightens the rubric and adds failing examples to the prompt.

Key takeaway: Measure agreement per criterion, check the failing class, control biases and re-validate.

How it works, step by step

Step 1 of 4
Eval design

1. Define criteria

Write specific, observable criteria with definitions, and choose binary or short scales.

FAITHFUL · ANSWERS_QUESTION · TONE
Key numbers at this step
One
criterion per judge

When to use it & trade-offs

What it is

LLM-as-a-judge uses a language model to grade another model's output against a rubric, producing a pass/fail, a score or a preference, with a short explanation. It scales evaluation of open-ended outputs (summaries, answers, tone) where exact-match metrics fail and human review is too slow or costly. Judges have systematic biases (preferring longer answers, the first option shown, or text from their own model family), so a judge is only trustworthy after you validate it against human labels and keep checking it.

Why it matters: Most useful AI behaviours have no single correct string, so teams need automated graders to run evals on every change. A calibrated judge gives fast, cheap, consistent scoring across thousands of cases; an uncalibrated one confidently rubber-stamps bad outputs and misleads the team. Knowing how to write judge prompts, measure agreement with humans and avoid known biases is now a core eval skill.

When to reach for it

  • Scoring faithfulness, relevance and tone at scale
  • Pairwise comparison of prompt or model variants
  • Triage before human review

When to avoid or be careful

  • Using a judge without validating it against humans
  • Vague 1–10 scores with no definitions
  • Judging facts the judge cannot verify

Ways to grade open-ended outputs

LLM judge with rubric
Best for: Scalable scoring of quality criteria

Strengths: Fast, cheap, consistent; explains verdicts.

Watch out: Biases and calibration work needed.

Human review
Best for: Gold standard, high-stakes and subjective quality

Strengths: Trusted and nuanced.

Watch out: Slow and costly; annotators disagree.

Programmatic checks (regex, schema, tests)
Best for: Objective, checkable properties

Strengths: Deterministic and free.

Watch out: Can't judge meaning or tone.

Interview signals & numbers to know

When this topic comes up

  • “How do we evaluate open-ended answers automatically?”
  • “The judge always says it's fine”
  • “Position bias”
  • Cohen's kappa for judges
  • Self-preference

Benchmarks & rules of thumb

91% / κ 0.78 -
judge agreement on faithfulness in the example
72% -
fail-class detection that exposed misses
100 – 300 -
human-labelled cases to validate

Common mistakes & follow-ups

Common interview mistakes

  • Trusting a judge that agrees 95% because 95% of answers were fine.
  • Using the same model for generation and judging and getting inflated scores.
  • Changing the judge prompt and comparing scores with the previous version.

Likely interviewer follow-ups

  • How would you validate an LLM judge?
  • What biases do LLM judges have and how do you mitigate them?
  • When would you not use an LLM judge?
Interview tip: Report agreement per criterion and the detection rate on the failing class. It's the detail that shows you know how a judge can look accurate while being useless.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply LLM as a Judge with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Error Analysis
Next topic
Pairwise Comparison