Library

Volume 2 · AI Evaluation Frameworks

Notebook
Sign in

Section 61

LLM-as-Judge (Implementation Patterns, Best Practices, Multi-Judge Ensembles, Bias Mitigation)

1,120 words · about 5 min

61.1 How LLM-as-Judge Works

Use a separate LLM — typically a strong, capable model — to evaluate the outputs of your production system against explicit rubric criteria.

JUDGE_PROMPT = """You are an expert evaluator. Rate the following AI response
on a scale of 1-5 for each criterion.

Question: {question}
AI Response: {response}
Source Documents: {sources}

Criteria:
1. RELEVANCE (1-5): Does the response directly address the question?
2. ACCURACY (1-5): Is the information correct based on the source documents?
3. COMPLETENESS (1-5): Does the response cover all aspects of the question?
4. CONCISENESS (1-5): Is the response appropriately brief without unnecessary info?
5. CITATION_QUALITY (1-5): Are sources properly cited and verifiable?

Provide your ratings as JSON:
{{"relevance": X, "accuracy": X, "completeness": X, "conciseness": X, "citation_quality": X, "explanation": "..."}}
"""

async def evaluate_response(question, response, sources):
    judge_response = await llm.complete(
        model="strong-judge-model",  # use a strong model as judge
        prompt=JUDGE_PROMPT.format(
            question=question, response=response, sources=sources
        ),
        temperature=0  # deterministic for consistency
    )
    return json.loads(judge_response)

61.2 Best Practices

  1. Use a stronger model as judge than the model being evaluated — a model judging its own outputs (or an equally capable/weaker one) is prone to leniency and self-preference bias.
  2. Temperature = 0 for reproducibility — a judge whose verdict changes between runs on identical input undermines any regression gate built on top of it.
  3. Provide explicit, granular rubrics — “rate the quality 1-5” produces noisy, inconsistent judgments; itemized criteria with clear definitions per score level produce far more reliable signal.
  4. Include source/ground-truth material in the judge prompt for factuality checking — a judge with no reference can only assess fluency and internal coherence, not correctness.
  5. Calibrate against human ratings — periodically run the same sample through both the LLM judge and human raters, and require judge-human agreement above a threshold (commonly targeted at >80%) before trusting the judge as a gate.
  6. Watch for known biases: LLM judges systematically prefer longer/more verbose answers, more formal tone, and (when applicable) outputs from their own model family — control for these explicitly, don’t assume they don’t apply to your setup.

61.3 Multi-Judge Ensembles

For high-stakes evaluation, a single judge call is a single point of failure — one run of noisy or biased judgment. Multi-judge ensembling reduces variance and surfaces disagreement as a signal in itself.

async def multi_judge_evaluate(question, response, sources):
    """Use 3 independent judge calls with varied prompts/framings, aggregate."""
    results = await asyncio.gather(
        evaluate_with_prompt_A(question, response, sources),
        evaluate_with_prompt_B(question, response, sources),
        evaluate_with_prompt_C(question, response, sources),
    )
    return aggregate_scores(results)  # majority vote or average, plus variance

Ensemble design patterns:

Pattern Description When to Use
Same model, varied prompts 3 different rubric phrasings/orderings, same judge model Cheap variance reduction, catches prompt-sensitivity noise
Different model families as judges e.g., two different providers’ models judge independently Reduces correlated model-family bias, more expensive
Panel-of-judges with specialization Different judges score different dimensions (one for factuality, one for tone, one for safety) High-stakes domains where each dimension needs deep expertise in the rubric
Judge + reference model agreement check Compare judge verdict against a smaller reference/rule-based check Cheap sanity check layer before trusting the LLM judge fully

High variance across ensemble members on a given case is itself useful signal — it flags genuinely ambiguous or borderline outputs that deserve human review, rather than being silently averaged away.

61.4 Bias Mitigation Techniques

Bias Mitigation
Verbosity preference Explicitly instruct the judge to penalize unnecessary length; normalize by length in scoring; compare responses of similar length when doing pairwise comparisons
Position bias (in pairwise A/B judging) Randomize which response is shown first; run both orderings and check for flips
Self-preference (judge favors its own model family’s style) Use a different model family as judge than the system under test where feasible; calibrate against human ratings to catch this
Sycophancy (judge agrees with confident-sounding but wrong content) Provide ground-truth/source material explicitly rather than relying on the judge’s own knowledge; use reference-based rather than reference-free metrics for factuality
Score clustering (judge overuses middle scores) Use well-anchored rubrics with concrete examples per score level; consider pairwise comparison instead of absolute scoring, which is often more discriminating

Interview Q&A — Section 61

Q1: How do you validate that your LLM-as-judge is actually trustworthy before relying on it as a CI/CD gate? A: I run a calibration study: take a representative sample (100+ examples) spanning the full quality range, have human experts score them against the same rubric, and compute agreement between the LLM judge and human consensus (percentage agreement plus a correlation/kappa-style statistic). I require judge-human agreement above roughly 80% before trusting the judge as an automated gate, and I re-run this calibration periodically (e.g., whenever the judge model version or the rubric changes) since drift can silently erode trustworthiness. I also deliberately test the judge against known bias probes — pairs of responses that differ only in length, or differ only in confident tone vs. hedged tone with the same underlying correctness — to check whether it’s exhibiting the verbosity/sycophancy biases documented in the literature.

Q2: Design a multi-judge ensemble for evaluating a high-stakes agent’s final outputs, and explain why a single judge isn’t sufficient. A: A single judge call is one noisy sample from a distribution — it can be swayed by phrasing of the rubric, by which response happens to be more verbose, or by model-family self-preference, and it gives no signal about how confident that verdict actually is. I’d run three judges: two using the same strong judge model but differently-phrased/ordered rubrics (to catch prompt-sensitivity noise) and one using a different model family entirely (to reduce correlated bias), then aggregate via majority vote for pass/fail decisions and flag high-variance cases (where the three disagree) for mandatory human review rather than silently averaging them into a passing score. This turns judge disagreement itself into a useful triage signal instead of hidden noise.

Q3: Your LLM judge consistently rates longer, more verbose responses higher even when a shorter response is objectively better. How do you fix this? A: This is the well-documented verbosity bias in LLM-as-judge setups. First, I’d make the rubric explicit about penalizing unnecessary length — “CONCISENESS” as its own scored criterion rather than folding it into an overall impression. Second, for pairwise comparisons, I’d control for length by either normalizing scores by response length or by constructing comparison pairs where responses are length-matched. Third, I’d periodically re-calibrate against human ratings specifically on a “verbose-but-worse vs. concise-but-better” probe set to verify the bias is actually being corrected, not just theoretically addressed in the prompt — bias mitigation instructions in a judge prompt don’t reliably eliminate the underlying tendency, so measurement against a probe set is the only way to confirm the fix worked.