Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 38 ยท Evaluation and Testing Prompts

LLM-as-Judge and Scoring Rubrics

Use a model to grade open-ended outputs: write clear rubrics, request structured verdicts, avoid judge bias and calibrate the judge against human labels.

Some qualities have no simple code check: Is this summary faithful? Is the tone polite? Is the explanation helpful for a beginner? For these, you can ask a person to grade, or ask another model. Using a model as the grader is called LLM-as-judge. It is fast and cheap enough to run on every prompt change, but it is itself a prompt, with its own flaws, and must be tested.

The judge calls below are stand-ins: simple Python functions that follow the same input and output contract as a real judge prompt. The surrounding logic (rubrics, parsing, agreement measures) is real.

Start with a rubric

A vague question ("Is this good?") gets vague, inconsistent scores. A rubric breaks quality into separate criteria, each with levels described in observable terms.

Criterion 0 1 2
Faithful Contains claims not in the source Minor unsupported detail Everything supported
Complete Misses the main point Covers some key points Covers all key points
Concise More than 3x needed length Slightly long Tight

Good criteria are independent (one idea each), observable (a stranger could apply them) and few (3 to 5). Score each criterion separately, rather than asking for one overall grade.

The judge prompt

TEXT
You are grading a summary against its source text.

<source>{source}</source>
<summary>{summary}</summary>

Score each criterion using the rubric below. Think about the evidence
first, then give the scores.

Rubric:
- faithful: 0 = contains claims not in the source, 1 = minor unsupported detail, 2 = fully supported
- complete: 0 = misses the main point, 1 = covers some key points, 2 = covers all key points

Reply as JSON only:
{"reasoning": "<two sentences>", "faithful": 0-2, "complete": 0-2}

Notes on this design: the rubric is spelled out, reasoning comes before the scores so the verdict is grounded in evidence, and the answer is JSON so code can read it. Use low temperature so the judge is as steady as possible.

Parsing and validating verdicts

The judge may wrap JSON in prose or return a score outside the range. Treat its reply like any untrusted output:

Python Parse judge verdicts safely (stand-in judge)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

When parsing fails, count it as a judge error and retry once; never silently treat it as a pass.

Known judge biases

LLM judges are useful but biased in predictable ways:

  • Position bias: in pairwise comparisons ("which answer is better?"), judges often prefer the first or the second. Run both orders and keep only consistent verdicts.
  • Length bias: longer answers tend to score higher regardless of quality. Put conciseness in the rubric and compare lengths.
  • Self-preference: a model tends to rate text written by itself or similar models more highly. Prefer a different judge model from the one being tested where you can.
  • Overconfidence on facts: a judge without the source cannot verify claims. Give it the source (reference-based grading), not just the answer.
Python Debias a pairwise judge by swapping order

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

An inconsistent verdict becomes a tie, which is honest: the judge could not tell them apart without being swayed by position.

Calibrate against humans

Before trusting a judge, grade 30 to 100 outputs yourself and compare. Report agreement: the share of cases where judge and human give the same score, or a chance-corrected measure such as Cohen's kappa for fairness.

Python Judge versus human agreement

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the disagreements. They usually reveal an ambiguous rubric level; sharpen the wording, rerun, and repeat. If agreement stays low, use the judge only for coarse screening and keep humans for decisions that matter.

When not to use a judge

Do not use a model judge where code can decide (JSON validity, length, exact labels), where stakes are high and no human reviews, or where you have not calibrated it. A judge is one signal in the suite, alongside the metrics from the previous lessons.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why write a rubric with separate criteria?

    Independent criteria with described levels reduce ambiguity and show which quality dimension failed.
  2. 2. What is position bias?

    Judges can favour a slot; run both orders and accept only consistent verdicts.
  3. 3. How do you check whether a judge can be trusted?

    Calibration against human grading, measured as agreement, shows how far the judge can be trusted.
  4. 4. The judge's reply cannot be parsed. What should you do?

    Silently passing unparseable output hides failures; treat it as an error.

Summary

  • A judge is a prompt: give it a rubric, the source, reasoning first and a JSON verdict.
  • Validate its output like any untrusted data.
  • Watch for position, length and self-preference bias; swap orders and use another judge model when possible.
  • Calibrate against human labels and read the disagreements.
  • Prefer code checks where they work; use judges for what code cannot see.

Next: Prompt Injection Attacks