Sub topic 12
Practical mitigations and when each helps
This chapter assumes you can read Python, have prompted an LLM, know what an evaluation set is, and understand proportions and averages. It also assumes you know the judge biases from earlier chapters: position, verbosity and self-preference bias, plus run-to-run variance.
Match the mitigation to the problem
No single fix covers every failure. Each mitigation targets one weakness, and each has a cost. Pick based on what your validation against human labels shows.
| Problem | Mitigation | Cost |
|---|---|---|
| Position bias | Run both answer orders, call disagreements ties | 2x judge calls |
| Verbosity bias | State "ignore length" in the rubric, compare answers of similar length | Some answers cannot be matched |
| Self-preference | Use a judge from a different model family | Extra vendor or model to manage |
| Run-to-run variance | Temperature 0, repeated runs, majority vote | More calls, still not fully deterministic |
| Low human agreement | Narrow the rubric, add examples, re-validate | Human labeling time |
Swap the order
In a pairwise comparison, run the judge twice with the answers in opposite positions. Report a winner only if both runs agree.
def judge_pair(call_judge, question, a, b):
"""call_judge(question, first, second) returns "first" or "second"."""
r1 = call_judge(question, a, b)
r2 = call_judge(question, b, a)
win1 = "A" if r1 == "first" else "B"
win2 = "B" if r2 == "first" else "A"
return win1 if win1 == win2 else "tie"In the second call, b is shown first. So "first" means B won, and "second" means A won. A judge with a strong position preference produces many ties here. A high tie rate tells you the judge cannot separate your two systems, which is useful information.
Reduce variance by voting
Set temperature to 0 where the API allows it. Many hosted models still vary slightly. For a score that matters, run the judge an odd number of times and take the median score or the majority verdict. Record how often the runs disagree. If they disagree on more than a few percent of items, the rubric is probably ambiguous, and voting only hides that.
Control for length and judge family
Add an explicit line such as "Judge faithfulness only. Ignore length and writing style." Then check it. Compute the correlation between answer length and judge score on your evaluation set. A strong correlation after you added the instruction means the instruction is not enough. Consider length-matched pairs or a rubric with concrete pass conditions.
For self-preference, avoid grading a model with itself or a close relative. If you cannot, say so when you report results.
Verify that the mitigation worked
A mitigation is a hypothesis. Re-run the human agreement check after each change.
from collections import Counter
def cohens_kappa(human, judge):
n = len(human)
observed = sum(h == j for h, j in zip(human, judge)) / n
hc, jc = Counter(human), Counter(judge)
expected = sum(hc[k] * jc[k] for k in hc) / (n * n)
return (observed - expected) / (1 - expected)
human = ["pass", "pass", "fail", "pass", "fail", "fail"]
judge = ["pass", "pass", "fail", "fail", "fail", "pass"]
print(round(cohens_kappa(human, judge), 3))This prints 0.333. Raw agreement is 4 of 6, but kappa removes the agreement expected by chance. Compare kappa before and after the change, using the same labeled items.
Common errors
- Applying every mitigation at once, so you cannot tell which one helped.
- Treating a tie from order swapping as a failure instead of a result.
- Using majority voting to fix a vague rubric.
- Skipping re-validation after changing the judge prompt or model.
Exercise
Your pairwise judge returns "first" for both orderings of the same two answers on 40% of items. What does this indicate, what does judge_pair report for those items, and what would you do next?
Show answer
It indicates strong position bias, because the judge picks whichever answer comes first regardless of content. judge_pair reports "tie" for those items, since the two runs name different winners. Next, check human agreement on the non-tie items, consider a sharper rubric or a different judge model, and report the tie rate alongside the win rates.
Exercise
After adding "ignore length" to the rubric, the correlation between answer length and score is still high. Name two actions you could take.
Show answer
Compare only answers of similar length, or rewrite the rubric with concrete pass conditions that do not reward detail for its own sake. You could also check against human labels whether the longer answers really are better, since the correlation may be genuine.