reference / llm-as-a-judge
Next task →
Reference Lessons/LLM-as-a-Judge: Designing Trustworthy Model-
evaluation · advanced · reference study

LLM-as-a-Judge: Designing Trustworthy Model-Based Evaluation

How to use an LLM as a grader without being fooled by position bias, verbosity, self-preference or uncalibrated confidence.
All reference lessons

Treat the judge like a fallible human rater. Before trusting its scores, you must check repeatability (same input → same score), position invariance (swapping candidate order should not swap the winner), and criterion validity (agreement with expert labels). A judge that merely sounds confident is not a measurement device.

1. Define the measurement target

Choose the construct before the prompt: factual correctness, helpfulness, harmlessness or style. Write a rubric that distinguishes them. If the rubric says 'quality', the judge will invent its own.

2. Pointwise versus pairwise

Pointwise scores drift between prompts because each call anchors on a different context. Pairwise comparisons are usually more reliable for ranking. Use P(a>b)=11+e−(sa−sb)P(a>b)=\frac{1}{1+e^{-(s_a-s_b)}} if you convert scores to a ranking model, but verify the conversion on human labels.

3. Position-swap debiasing

Run both orders: w1=j(a,b)w_1=j(a,b) and w2=j(b,a)w_2=j(b,a). Accept a preference only if both orders agree. The swap agreement rate ρ=1N∑i1[w1(i)=w2(i)]\rho=\frac{1}{N}\sum_i \mathbb{1}[w_1^{(i)}=w_2^{(i)}] is a direct bias diagnostic; a low ρ\rho invalidates the judge regardless of raw accuracy.

4. Agreement with humans

Let pop_o be observed agreement and pep_e chance agreement. Then κ=(po−pe)/(1−pe)\kappa=(p_o-p_e)/(1-p_e). For more than two raters use Krippendorff's α\alpha. Report the confidence interval with a bootstrap over examples, not over individual tokens.

5. Calibration

Ask for a confidence alongside the label. Bin predictions by confidence and compare mean confidence to empirical accuracy. Apply temperature scaling on the judge's logits if it is overconfident: p=σ(z/T)p=\sigma(z/T) with T>1T>1.

6. Statistical comparison

Compare judge-based rankings to human rankings with a paired bootstrap: resample examples, recompute the metric, and report the distribution of the difference. Never report a single accuracy number without uncertainty.

Reference lessons are written for this topic specifically. Generated lessons elsewhere on the platform are labelled with a quality score and review status; do not treat them as equivalent.