Sub topic 9
Using and Calibrating a Model-Based Judge
Assume you understand user stories, evaluation datasets, and basic Python and JSON. You should also know that a language model can produce different valid answers for the same input.
A model-based judge is a language model that evaluates another model's output against a rubric. For example, a judge can decide whether a support answer is grounded in a retrieved refund policy. It returns a grade, a reason, or both.
A judge is useful when quality is difficult to check with exact string rules. It can assess relevance, clarity, completeness, or whether an answer follows a policy. However, the judge is another probabilistic system. Its decisions need testing and calibration.
Choose the judging method
Use the simplest grader that measures the quality dimension correctly.
| Quality dimension | Suitable grader | Main risk |
|---|---|---|
| Required phrase present | Code check | It may reward a phrase used incorrectly |
| Policy claim is supported | Human or model judge | The rubric may be interpreted inconsistently |
| Tone is respectful | Human or model judge | Cultural and stylistic bias |
| Response latency | Code check | It may miss perceived difficulty |
A model judge works best when the rubric describes observable behavior. “Good answer” is too vague. “Every factual claim about the refund policy is supported by the supplied policy text” gives the judge a clearer task.
For safety-critical failures, do not rely on a model judge alone. Combine it with deterministic checks or human review. A judge might overlook a prohibited promise even when the promise has serious consequences.
Write a structured rubric
Give the judge the same information that a careful reviewer would need:
- The user input.
- The retrieved context or reference answer.
- The generated output.
- A short list of criteria.
- The allowed score values.
- Instructions to cite evidence from the output.
Ask for structured JSON rather than free-form prose. Structured results are easier to aggregate and less likely to break an evaluation pipeline.
import json
def build_judge_request(question, context, answer):
rubric = {
"grounded": "Every policy claim in the answer is supported by the context.",
"complete": "The answer addresses the user's actual question.",
"safe": "The answer does not invent a refund amount, deadline, or guarantee."
}
return {
"system": (
"You are an impartial evaluator. Use only the supplied context. "
"Return valid JSON with scores from 0 to 2 and one short reason per criterion."
),
"user": json.dumps({
"question": question,
"context": context,
"answer": answer,
"rubric": rubric,
"score_meanings": {
"0": "fails",
"1": "partly meets",
"2": "fully meets"
}
})
}
request = build_judge_request(
"Can I return a damaged item after 45 days?",
"Damaged items may be returned within 60 days for a replacement.",
"Yes. The policy allows returns of damaged items within 60 days for a replacement."
)
print(json.dumps(request, indent=2))The judge's output might contain {"grounded": 2, "complete": 2, "safe": 2}. Validate that output before using it. Reject missing criteria, invalid scores, and explanations that do not contain the required evidence.
Calibrate against human labels
Calibration means measuring how well the judge matches trusted human judgments. Create a representative sample that includes normal, ambiguous, edge, and clearly failing answers. Have at least two reviewers label the sample independently, then resolve disagreements.
Run the model judge on the same sample without showing it the human labels. Compare the results. Agreement alone is not enough. If failures are rare, a judge can appear accurate by assigning “pass” to everything. Inspect false passes and false failures, especially for critical cases.
Calibration often reveals problems in the rubric or prompt:
- The judge rewards confident wording instead of evidence.
- It confuses a complete answer with a long answer.
- It gives higher scores to outputs shown first.
- It accepts a plausible claim that the reference text does not support.
- It applies different standards to different writing styles.
Reduce these effects by defining positive and negative examples, requiring evidence spans, randomizing comparison order, and separating criteria. For pairwise evaluation, ask which answer is better and include “tie” as an option.
Set a use boundary
After calibration, record the judge model, prompt version, rubric version, sample size, agreement results, and known blind spots. Recalibrate when you change the model, retrieval method, prompt, or product domain.
Use model-judge scores for broad trends and regression detection. Route low-confidence, disputed, or critical failures to human review. A judge is a measurement instrument, not the definition of quality.
Exercise
A model judge agrees with reviewers on 96% of ordinary cases but misses two critical policy contradictions. Should it be the only release grader?
Show answer
No. Keep the judge for broad quality dimensions, but add a deterministic or human-reviewed zero-tolerance check for policy contradictions.