How LLM-as-a-Judge works, and when not to use it

Study time
≈ 1.5 h (estimate)
Needs
L2-M03-L05
Updated
2026-11-03

Progress is saved in this browser only. No account, nothing is sent to a server.

Draft · reviewed by AI, not yet by a person. Content may change. English translation: AI-assisted, not human-reviewed.
On this page

Module: L2-M04 · Duration: ~90 min (estimate, including the independent exercise) · Previous: L2-M03-L05 · Next: L02

1. Introduction

L2-M03 gave you deterministic metrics, rubrics and per-slice reports. Some criteria cannot be written as a function: does the tutor's reply sound condescending, does an explanation suit a grade 3 student. A person reading every reply is accurate but slow and expensive. That gap is where the judge comes in: a language model (LLM) that scores another model's answer against a rubric. L2-M01-L03 introduced it; this lesson goes further: what a judge receives, what it returns, where it breaks, and when not to use it.

The lab's judge is a simulation, not an LLM: a seeded function that makes no network calls and needs no API key, and every bias it has is a parameter the lab sets. The numbers the lab prints describe the simulation, not the properties of any real model. What real models can do is quoted from sources that were read, with access dates (§12).

The output of this lesson is a decision checklist for each criterion: score it with code, a human, a judge or a judge plus a human, with the reason. This is part of the Level 2 target competency: "implementing and calibrating judges".

2. Learning objectives

  1. Explain what a judge receives, what it returns and at which step of the scoring chain it breaks. Practice: §8.2 part B.
  2. Distinguish the four ways to score a criterion and apply the decision checklist to six criteria. Practice: §8.2 part A, §8.3.
  3. State at least four cases where a judge should not be used, each with a reason. Practice: §8.3, §9 (TODO 1, 4).
  4. Compare a code grader with the simulated judge on the same criterion using a confusion matrix, and point out what each one cannot see. Practice: §8.2 parts B, C, §9 (TODO 3).
  5. Estimate the cost of calling a judge by the number of calls. Practice: §8.2 part D.

3. Prerequisites and tools

  • L2-M01-L03: the three kinds of grader, the confusion matrix (tp, fp, fn, tn), raw agreement; the lab re-implements them briefly so it can run on its own.
  • L2-M03: deterministic metric functions, rubrics with anchors, per-slice reports.
  • Python 3.12 or later, pytest, the code lab code-labs/l2-m04 (self-contained, no API key, no model calls).

4. Concepts

4.1 What a judge is and why people use it

A judge (a model-based grader; also called LLM-as-a-Judge or model-graded) is a model-based grader (L2-M01-L01), one of the three kinds of grader. It receives three things: the question or context, the answer to be scored, and a rubric. It returns a verdict: a score on a scale, a pass or fail label, or "answer A is better than answer B". Zheng et al. (2023) named this method when they used strong LLMs as judges for open-ended questions [R1]. Their reasoning: most questions in MT-bench and Chatbot Arena are open-ended with no reference answer, so a rule-based program is very hard to write, and metrics based on text overlap (ROUGE, BLEU) do not work well on that kind of question [R1 §3]. They name two benefits: scalability and explainability, because the judge returns an explanation and not just a score [R1 §3.2]. OpenAI writes that using a model to grade "is cheaper to run and more scalable than human evaluation" [R4].

For HocVui Tutor (the fictional product of L2-M01 to L2-M03: a chatbot that helps grade 3 to 5 students with math), a judge is worth it for subjective criteria that a metric function cannot read: tone, how well an explanation fits the student.

4.2 The price of a judge

Anthropic lists the strengths of a model-based grader as flexible, scalable, able to capture nuance and able to score free-form output; the weaknesses are that it is non-deterministic, more expensive than code and needs calibration against human graders [R2]. The Zheng group adds a quality weakness: a judge can be biased (position, verbosity, self-preference; lesson L03) and scores math and reasoning questions poorly. In their experiment, GPT-4 graded ten math questions, each in two orders (20 judgments); with the default prompt it was wrong 14 times, that is, it praised the wrong answer [R1, Table 4]. A small sample, but the message is clear: a judge without a reference answer can be fooled by a wrong answer that sounds confident (§5.2).

Anthropic advises choosing deterministic graders where possible, LLM graders where necessary, and using humans sparingly for additional verification [R2]. The rule from L2-M01-L03 ("code first, a judge for what code cannot score, humans as the standard") still holds; this lesson turns it into a decision checklist that runs.

4.3 Four ways to score, and when not to use a judge

The lab sets four possibilities: code (a metric function), human (reads everything), judge, and judge plus human (the judge only ranks or flags; a human reviews and decides). The function checklist.recommend(c) takes seven fields (name, whether there is a deterministic rule, whether there is a reference answer, whether it is subjective, risk level, volume per week, number of human labels) and applies four rules in order:

  1. There is a deterministic rule: code, even at high risk. Code is cheaper and repeatable.
  2. High risk: human if the volume is 100 items per week or fewer (a person can read everything); above 100, judge plus human, and this branch is also blocked when there are fewer than 50 human labels (rule 4).
  3. No rule, not subjective, no reference answer: human, because the judge has nothing to compare against and would only guess.
  4. Everything else: judge; if there are fewer than 50 human labels, judge plus human and the function records what is blocking ("50 human labels (have 49)"). This rule also applies to the high-risk, high-volume branch.

The thresholds of 100 items and 50 labels are chosen by the lab, written out so they can be argued with; they are not an industry standard. From the rules follow the cases where a judge alone should not be used: (a) there is a deterministic rule; (b) high risk, especially when everything can be read; (c) there are no human labels yet to calibrate against (L04); (d) there is nothing to compare against except the judge's own opinion; (e) the judge is from the same model family as the system being scored (self-preference, L03).

Decision diagram for one criterion: is there a deterministic rule? Yes: grade with code. No: is the risk high? Yes with a small volume: a person reads everything; yes with a large volume: check for 50 human labels, enough means the judge ranks or flags and a person decides, not yet means judge plus person but still blocked; not high: if the criterion is not subjective and has no reference answer a person grades it, otherwise check for 50 human labels: enough means use the judge, not yet means judge plus person, still blocked.
Diagram: Four ways to score, and when not to use a judge

5. Technical deep dive

5.1 The scoring chain and the lab's simulated judge

One scoring pass goes through five steps: build the prompt from the rubric and the answer (L02), call the judge, receive the raw output (a text string), parse (read) the verdict out of that string, then aggregate many verdicts into a figure (L04). Each step breaks in its own way: an ambiguous prompt, output that cannot be read, bias (L03), wrong calibration (L04), a version change that nobody recorded (L05).

lab/judge.py has SimJudge: not an LLM. It adds up an internal score (0 to 100) from the content of the answer: 55 points if it has the right number (or if it is "misled" with probability p_misled: 30% with no reference answer, 5% with one), 25 points if it has an explanation, 20 points if it is not read as condescending, plus the bias terms (length, position, self-preference, leniency) and a seeded random number, then converts to a scale of 1 to 5 (a 5 from 90 upward). It outputs exactly the format that a real judge's prompt asks for (Rating: [[4]]). The size of the parameters is made up for teaching, so that probes can later be checked against a known truth.

Data: data/replies.jsonl has 200 fictional replies, each with a "human" label (pass or not) set by the data generator according to the rubric; data/questions.json has 14 questions with answers. These labels are synthetic, not real humans.

5.2 One criterion, two graders

Take the criterion "the reply states the right number". In this lesson the positive class is "judged to have the right number" (L04 uses the positive class "the reply PASSES", and each place says so explicitly). In L2-M01-L03 the positive class was the curt reply (the bad one), so fp there was a false alarm; here fp is a false accept. pipeline.code_grader (whole-number match) gives tp = 140, fp = 0, fn = 0, tn = 60: exact on this set, and cheap. The simulated judge without a reference answer gives tp = 140, fp = 16, fn = 0, tn = 42 (2 unreadable outputs are dropped and counted separately): it gave a score of 4 or more to 16 wrong replies. The figure 16 is a consequence of the p_misled that the lab set, but its direction matches the report of Zheng et al.: a judge is fooled by a wrong answer when it has no reference answer to compare against [R1 §3.3]. Their fix (a reference answer in the prompt) is the topic of L02.

To be fair to code: this set has no traps (no negations such as "Không phải 4"), so the number-matching function scores perfectly. code_grader does not read negation (§8.3), and the simulated judge uses the same number matcher so it does not read it either. A real judge may be able to read negation; that is a limit of the simulation, not of judges.

Conversely, against the holistic "human" label (number, explanation, tone), the code grader reaches raw agreement of 0.740 and a false-accept rate of 0.464: it lets through 52 of the 112 replies that humans failed, including 20 condescending replies, 20 replies with only a bare number and 12 borderline replies that were failed. That is what a judge can add, if it is calibrated (L04).

5.3 Cost

Code makes 0 calls; a judge makes one call per reply. A pass over 200 replies with the lab's pointwise prompt (the real prompt for each reply plus 12 output units) is 200 calls and 44396 units (words, standing in for tokens); at an illustrative price of 0.01 dollars per 1000 units, the cost is 0.444. This price is made up: real price lists are per token and price input separately from output [R5]. The real cost is also multiplied by the number of order swaps and repeats (L05).

6. The QA perspective

6.1 What the decision checklist does not know

checklist.recommend only reads the seven fields you declare. It does not know: whether the product is really high risk; whether the human labels are good (50 bad labels are still "50 labels"); whether 50 labels are enough to trust (with 50 items, raw agreement of 0.80 has a 95% confidence interval from 0.67 to 0.89, which is wide); whether a good enough judge exists; whether the thresholds of 100 and 50 suit your organisation. A missing field or one of the wrong type raises an error and is not guessed.

6.2 Four questions before accepting a number scored by a judge

  1. Does this criterion have a deterministic rule? If so, why use a judge?
  2. Are there human labels on your data, sampled how, how many? (L2-M01-L03: a biased sample cannot estimate a rate.)
  3. Which model is the judge, which version, which prompt and rubric? (L05)
  4. Who reads the replies the judge fails, and the ones the judge lets through on a high-risk criterion?

"92% of answers are friendly" without these four answers is the judge's opinion, not a measurement.

7. Real-world scenarios

Scenario 1 (fictional): "Let the judge score the final number too". The HocVui Tutor team found the judge convenient and used it to score the criterion "the final number is right" as well. A sampler saw that a few wrong replies still got high scores because they sounded confident. They moved this criterion back to the number-matching function (cheap, deterministic) and kept the judge only for tone: rule 1 of the decision checklist.

Scenario 2 (fictional): "Child safety, 40 items per week". The criterion "does not give unsafe advice to a child" is high risk and has only 40 items per week. The team planned to add a judge to "save people time". The decision checklist returns human: one person can read all 40 items, and an uncalibrated judge on a high-risk criterion only adds uncertainty. They kept the human reading.

8. Hands-on tutorial

8.1 Setup

cd academy-content/code-labs/l2-m04
python3 -m venv .venv && source .venv/bin/activate     # Windows: .venv\Scripts\activate
python -m pip install -r requirements.txt
python -m pytest            # 79 passed

8.2 Run the demo

python -m lab.demo l01

Output (copied from a real run on Python 3.14.6 and 3.12.14, 2026-11-03; the two versions give identical output):

A. decision checklist for six criteria of the fictional HocVui Tutor
   answer_is_correct                -> code        blocked_until: None
   reply_is_not_condescending       -> judge       blocked_until: None
   explanation_suits_grade_3_to_5   -> judge+human blocked_until: 50 human labels (have 20)
   no_unsafe_advice_to_a_child      -> judge+human blocked_until: None
   mentions_the_unit                -> code        blocked_until: None
   hint_does_not_give_the_answer    -> judge       blocked_until: None
B. criterion 'the reply states the right number' (positive = judged correct; judge: score 4 or more), 200 replies
   code grader   tp=140 fp=0 fn=0 tn=60  precision 1.000 recall 1.000
   judge, no ref tp=140 fp=16 fn=0 tn=42  precision 0.897 recall 1.000  (2 unreadable dropped)
C. the same code grader against the overall human verdict (answer + explanation + tone)
   tp=88 fp=52 fn=0 tn=60  agreement 0.740  false-accept 0.464
D. one pointwise pass over 200 replies (real prompt per item + 12 output units): 200 calls, 44396 units, illustrative cost 0.4440 (code grader: 0 calls)

Reading the output:

  • A. Six criteria go through the decision checklist. The third criterion has only 20 human labels so it is blocked; the high-volume safety criterion is "judge plus human", and not blocked because there are already 300 labels.
  • B. The judge without a reference answer gave a score of 4 or more to 16 wrong replies (fp = 16); 2 unreadable outputs are counted separately and are not turned into scores.
  • C. The code alone against the holistic label: 52 false accepts, no false rejects.
  • D. The cost of one pass over 200 replies with a judge, at an illustrative price.

8.3 Try it yourself

Save it as try_l01.py in the lab's root folder (next to lab/), run python try_l01.py, then delete the file:

from lab import checklist, judge, pipeline

base = {"name": "x", "has_rule": False, "has_reference": False, "subjective": True,
        "risk": "high", "volume_per_week": 100, "human_labels": 0}
print(checklist.recommend(base)["use"], checklist.recommend({**base, "volume_per_week": 101})["use"])
print(checklist.recommend({**base, "risk": "medium", "human_labels": 49})["blocked_until"])
print(checklist.recommend({**base, "has_rule": True})["use"])
try:
    checklist.recommend({**base, "risk": "critical"})
except ValueError as e:
    print("ValueError:", e)

# a reply that states the number and denies it
q = {"id": "Q01", "gold": "4"}
reply = "Không phải 4 viên đâu em."
print(pipeline.code_grader({"reply": reply}, q))
print(judge.SimJudge(**judge.FAIR).pointwise(q, reply, "tutor-b", reference=True))

Output (identical on Python 3.14.6 and 3.12.14):

human judge+human
50 human labels (have 49)
code
ValueError: risk must be high, medium or low
True
(mô phỏng) Nhận xét ngắn. Rating: [[4]]

Reading: 100 items is human, 101 items is judge+human; 49 labels blocks at 50; a rule means code even at high risk; an unknown risk level is rejected. The last two lines are a blind spot: "Không phải 4 viên đâu em." (roughly, "it is not four pieces") contains the number 4 so the number-matching function returns True, and the simulated judge (configuration FAIR, no bias, no noise) gives 4 points because it uses the same number matcher. Do not conclude that a real judge is blind in the same way.

8.4 Run the lesson's tests

python -m pytest tests/test_l01_checklist.py tests/test_data.py -v

Result: 14 passed (9 tests for this lesson, 5 data checks). Read test_high_risk_volume_boundary, test_a_judge_needs_enough_human_labels and test_the_code_grader_is_exact_on_the_number_but_blind_to_tone_and_explanation.

8.5 Troubleshooting

Symptom Cause Fix
ModuleNotFoundError: No module named 'lab' Run from another folder cd into code-labs/l2-m04; pytest.ini already sets pythonpath = .
ValueError: missing field 'risk' The criterion lacks one of the seven fields Add the field; the function deliberately does not guess

9. Independent exercise

Problem: Decide how to score six criteria, write a criterion of your own, and measure the blind spots of two graders.

Requirements: complete exercises/test_l01_checklist.py:

  1. TODO 1: fill in DECISIONS: each criterion name in exercises/criteria.json maps to "code", "human", "judge" or "judge+human".
  2. TODO 2: fill in MY_CRITERION: a dict with all seven fields for a new HocVui Tutor criterion that the decision checklist sends to "judge" and blocks nothing.
  3. TODO 3: fill in JUDGE_REF_ACCEPTS_WRONG (the number of "wrong" replies that the simulated judge, with a reference answer, scores 4 or more) and JUDGE_NOREF_WRONG_AT_5 (the number of "wrong" replies that the judge without a reference answer scores exactly 5).
  4. TODO 4: write NOTE: at least 25 words saying which criterion in criteria.json you would not use a judge for and what that decision rests on.

Test data: exercises/criteria.json, data/replies.jsonl, data/questions.json.

Deliverable: the four groups of variables at the top of exercises/test_l01_checklist.py; NOTE is a Python string in that same file.

Acceptance criteria: python -m pytest exercises/test_l01_checklist.py passes (4 tests, including test_note_has_enough_words, which counts the words of NOTE). The test only counts words; whether the reasoning is right is for a reviewer to judge.

Hint: reason through each criterion yourself first, then call checklist.recommend to compare; where the two disagree is where to reread the rules. For TODO 3, use pipeline.score_items, once with reference=True and once without. For TODO 2, think of a criterion with no rule, low or medium risk, and with more than 50 labels already.

10. Knowledge check

0/16 done · Results are kept in this browser only.

P02 · True or false

The thresholds of 100 items per week and 50 human labels in checklist.recommend are an industry standard for every product.

P04 · Select all that apply

Select every case that should not be left to a judge alone.

P05 · Put in order

Put the five steps of one judge grading run in the order they execute.

  1. Parse the verdict from the raw output
  2. Aggregate many verdicts into a metric
  3. Call the judge
  4. Receive the raw output (a string of text)
  5. Build the prompt from the rubric and the answer

P06 · Match

Match each criterion (with its seven fields filled in for checklist.recommend) to the result of the decision table.

P07 · Spot the bug

The snippet below copies the high-risk branch of recommend but has one bug: a high-risk criterion with exactly 100 items per week is sent to the judge. Find the bug.

if c["risk"] == "high":
    if c["volume_per_week"] < 100:
        return {"use": "human", "reasons": ["high risk and a small volume: a human can read every item"],
                "blocked_until": None}
    use = "judge+human"

P08 · Short answer

The criterion "final answer matches the reference answer" has a numeric match function, high risk, 5000 items per week. A colleague wants to use a judge "for convenience". Write 2-3 sentences: what does the decision table return and why?

P09 · Essay

Write 5-8 sentences: choose the way of grading (code, human, judge or judge plus human) for three criteria of a study Q&A chatbot: (a) "the answer states the unit of measure", (b) "the explanation suits a grade 4 student", medium risk, 3000 items per week, 20 human labels, (c) "does not encourage students to skip homework", high risk, 150 items per week, 30 human labels. State what is still blocking.

P11 · Recall

Lesson: L2-M03-L05

A judge grades the tone criterion for a chatbot and reports "92% friendly" as one pooled average over all answers. According to L2-M03-L05, what is the correct way to report?

P12 · Recall

Lesson: L2-M01-L03

In L2-M01-L03 the positive class is the curt answer (the bad answer). There, what does one fp mean?

P13 · Multiple choice

Pointwise, one call per answer, 300 answers. The filled prompt is 231 units (words) long, the output is 12 units, the illustrative unit price is 0.01 dollars per 1000 units. What is the illustrative cost?

P14 · True or false

The judge agrees with the human labels on 45/50 answers (0.90). The 95% Wilson interval is 0.786 to 0.957, so you can be sure the true agreement is not below 0.95.

P15 · Select all that apply

Select everything checklist.recommend does not know.

P16 · Multiple choice

The criterion "is the praise specific" has no rule, is subjective, medium risk, 2000 items per week, 49 human labels: recommend gives judge+human and blocked_until is 50 human labels (have 49). What is the smallest change to get judge?

11. Summary

  • Concepts: a judge takes a question, an answer and a rubric and returns a verdict; useful for subjective criteria; non-deterministic, more expensive than code and needs calibration against humans; the decision checklist chooses code, human, judge or judge plus human.
  • Skills: apply checklist.recommend, compare code with a judge using a confusion matrix, count cost by number of calls.
  • Traps: using a judge for what code can score; trusting an uncalibrated judge on a high-risk criterion; treating the lab's thresholds as a standard; treating the simulated judge and labels as evidence about real models.
  • You can now: look at a criterion and say what to score it with, why, and what is still blocking.

12. References

ID Title Publisher URL Accessed Relevance
R1 Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (Zheng et al., 2023) arXiv (NeurIPS 2023 Datasets and Benchmarks) https://arxiv.org/abs/2306.05685 2026-11-03 Full-text PDF (29 pages, v4); used §3, Table 4
R2 Demystifying evals for AI agents Anthropic https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents 2026-11-03 Whole page; strengths and weaknesses of model graders
R3 Define success criteria and build evaluations Anthropic https://platform.claude.com/docs/en/test-and-evaluate/develop-tests 2026-11-03 Whole page; used from L02
R4 Evaluation best practices OpenAI https://developers.openai.com/api/docs/guides/evaluation-best-practices 2026-11-03 Whole page; the LLM-as-a-judge section
R5 Pricing Anthropic https://platform.claude.com/docs/en/about-claude/pricing 2026-11-03 The price table section: input and output priced separately

Key terms (English ↔ Vietnamese)

English Tiếng Việt
Judge (LLM-as-a-Judge) Judge: LLM chấm đầu ra của model khác
Decision checklist Bảng quyết định
Raw output / parse Đầu ra thô của judge / đọc phán quyết từ nó
False accept / false reject Lọt / oan
Simulated judge Judge mô phỏng (hàm có seed)
Tutor Gia sư