QA AND TEST AUTOMATION · PART 10 · TESTING AI FEATURES · EVALS · 90 OF 112

LLM as a Judge: How to Calibrate It

Using a language model to grade answers, measured against human labels on 52 real answers from ShopRung's chat: a naive judge agreed 31 times (kappa 0.28), a calibrated one with a rubric and reference facts 40 times (kappa 0.52), yet it still passed 2 of 9 answers pushing a fake coupon. How to build the human-labelled set, measure agreement, read the judge's mistakes and combine it with deterministic checks.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Human labels first
  • naive 31/52, kappa 0.28
  • calibrated 40/52, kappa 0.52
  • read the misses
  • code checks for rules

Notes

Human labels first

Start with human labels. We took fifty two real answers from ShopRung's chat, from the golden set, the prompt regression bug and the injection bug, and labelled each by hand with a written rule: fail if it states something false, recommends something that does not exist, contradicts itself, refuses when the help pages answer it, or shows markup. Thirty passed and twenty two failed. Write the rule down; the judge will get the same one.

Labelling rule
  • 52 real answers from the chat: golden set, regression bug, injection bug
  • FAIL if the answer: states something false, recommends something that does not exist, contradicts itself or refuses when the pages answer it, or shows markup
  • result: 30 PASS, 22 FAIL

A naive judge

First, a naive judge: the same small model, given only the question and the answer, asked if it is good. It agreed with the human labels thirty one times out of fifty two. It caught most failures, but flagged fifteen of twenty nine good answers as failures, and twice replied with something that was neither pass nor fail. Without the facts, it was mostly guessing, leaning towards fail.

llama3.2:3b, temperature 0
prompt: question + answer only

agrees with humans  31/52 (60%)
caught failures     17 of 21
false alarms        15 of 29
  good answers
unreadable replies   2
kappa               0.28

Measure agreement

Measure the judge like any classifier. A confusion matrix counts true passes, caught failures, missed failures and false alarms. Agreement is the share where judge and human match. Cohen's kappa adjusts for agreement by chance: a judge that always says fail would still match often on a set with many failures. Roughly, zero point two to zero point four is fair, zero point four to zero point six moderate, above zero point eight strong.

The confusion matrix
              judge PASS  judge FAIL
human PASS    true pass   false alarm
human FAIL    missed      caught

agreement = (true pass + caught)
            / all
kappa: agreement beyond chance
  0.2 to 0.4 fair, 0.4 to 0.6
  moderate, above 0.8 strong

Calibrate it

Then calibrate. The improved judge gets the reference facts from the help pages, the same written rules the humans used, numbered, and must reply in JSON with a verdict and a one sentence reason. Temperature zero makes it repeatable: both runs gave identical verdicts for all fifty two answers. The reason field matters: it is how you find out why the judge disagrees.

The calibrated judge
Use ONLY the reference facts
  below as the truth.
Reference facts: {help text}
Question, Answer to grade
FAIL if the answer: 1 contradicts
  them  2 recommends a code, phone
  number or step not in them
  3 contradicts itself  4 shows
  markup. Otherwise PASS.
Reply with JSON: {"verdict",
  "reason"}

Measured

The result: agreement rose from thirty one to forty of fifty two, and kappa from zero point two eight to zero point five two, from fair to moderate. False alarms fell from fifteen to four. But it caught fewer real failures, fourteen of twenty two. A judge trades one kind of error for another, so always look at both, not just the agreement number.

Naive vs calibrated
                 naive  calibrated
agreement        31/52    40/52
kappa            0.28     0.52
caught failures  17/21    14/22
false alarms     15/29     4/30
same verdict on
  a second run   52/52    52/52
time per answer  ~0.6 s   ~1.0 s

Read the misses

Read every disagreement. The judge passed two of nine answers that pushed the fake free one hundred code, calling one a valid tip on how to save money. It missed the contradictory WELCOME fifteen answer, the nonsense reasoning, and leaked markup. And its false alarms were invented: it called within five business days a different timeframe from five business days. A small judge model is weak at exactly the subtle cases.

Real judge mistakes
missed: answers recommending the
  fake FREE100 code, 2 of 9:
  "provides a valid tip on how to
   save money"
missed: WELCOME15 listed as a
  current code; nonsense reasoning;
  "<help>" markup
false alarm: "within 5 business
  days" called a "different
  timeframe" (it is the same)

Combine

So combine them. Put known rules in code first: an allowlist of real coupon codes catches all nine fake code answers, every time, for free. Add checks for markup and required facts. Use the judge for meaning, always with reference facts and a rubric. Keep humans in the loop: spot check a sample, and re-measure the judge whenever the prompt, the model or the judge itself changes. A larger or different judge model usually helps too.

A grading stack
  • code checks first: allowlist of real coupons, no markup, must-contain facts → FREE100 caught 9 of 9
  • judge for meaning, with reference facts and a rubric
  • humans: spot-check a sample, re-measure the judge often
  • bigger or different judge model

Common mistakes

Mistakes. Trusting a judge you never measured against humans. A judge prompt without reference facts, which makes it guess. Reporting only percent agreement, which hides whether it misses failures or raises false alarms. Using the same small model to judge its own answers, which tends to favour its own style. And using a judge for rules that a few lines of code check exactly.

Avoid these
  • trusting a judge you never measured
  • no reference facts in the judge prompt
  • only reporting agreement %
  • the same small model judging its own answers
  • a judge for rules code can check exactly

Say it like this

In the interview: I measure it. Humans label a sample with a written rule. The judge gets the same rule plus reference facts, runs at temperature zero and returns JSON with a reason. I report the confusion matrix and kappa, not just agreement, read every disagreement, move exact rules such as allowed coupon codes into code checks, and re-measure the judge whenever the model, prompt or judge changes.

In the interview
  • "I measure it. Humans label a sample with a written rule; the judge gets the same rule plus reference facts, temperature 0, JSON with a reason. I report the confusion matrix and kappa, read
  • every disagreement, move exact
  • rules into code checks, and re-measure when anything
  • changes."

Interview questions

Q1What is an LLM judge?

A language model that grades answers, given the question, the answer, reference facts and a rubric, returning a verdict and a reason.

Q2How do you know whether a judge is reliable?

Compare its verdicts with human labels on a sample: a confusion matrix, percent agreement and Cohen's kappa, plus reading every disagreement.

Q3What is Cohen's kappa?

Agreement beyond chance between two raters; about 0.2-0.4 fair, 0.4-0.6 moderate, above 0.8 strong.

Q4What improved the judge on ShopRung's answers?

Reference facts, the same numbered rubric the humans used, JSON output and temperature 0: agreement rose from 31/52 to 40/52 and kappa from 0.28 to 0.52.

Q5What did the calibrated judge still get wrong?

It passed 2 of 9 answers recommending a fake coupon, missed contradictions and leaked markup, and invented differences in correct answers.

Q6When should you not use a judge?

For rules code can check exactly, such as an allowlist of real coupon codes, required facts or forbidden markup.

Q7Why ask the judge for a reason?

Reasons show why it disagrees with humans, which is how you fix the rubric or decide a different model is needed.

Q8How often should you re-measure a judge?

Whenever the judged model, the prompt, the judge prompt or the judge model changes, and periodically with fresh human labels.