LLM-as-a-Judge: model ko judge banana, uske biases aur calibration
LLM-as-a-Judge strong model se answers score ya compare karwata hai - sasta, scalable, par biases hain. Yeh page teen judging modes, bias mitigations, judge-human agreement, aur pairwise se Bradley-Terry ranking batata hai।
यह पृष्ठ पूरा करने पर आप
- Pairwise comparison, single-answer scoring aur reference-guided teen judging modes alag karein; har ek ka mukhya problem batayein।
- Judge ke aam biases (position, length, math mis-judgment) batayein, aur experiments se dekhein woh kaise milkar asar karti hain।
- Order-swapping jaise upay se biases kam karein; agreement rate aur Cohen's kappa se judge reliable hai ya nahi naapein।
- Pairwise results ko Bradley-Terry aur Elo se leaderboard banayein।
इस पृष्ठ पर
- Judge kyun chahiye
- Teen judging modes
- Judge kahan galti karta hai
- Khud karein: position bias, length bias aur noise kaise judte hain
- Biases kam karne ke upay
- Judge reliable hai?: kaise naapein
- Pairwise se leaderboard: Bradley-Terry aur Elo
- Practice checklist
- Summary aur exercises
- Exercises
- Aage padhein
- अक्सर पूछे जाने वाले सवाल
LLM-as-a-Judge matlab ek (usually zyada strong) language model insaan ki jagah candidate answers ko score ya compare karta hai. Sasta, scalable, explanations bhi deta hai - isliye open-ended QA aur chat eval ka mainstream ban gaya; par judge khud biased hai: pehle position wala answer pasand, lamba answer pasand, math/reasoning galat judge karta hai. Yeh page judge kaise use kare, kahan galti karta hai, kaise kam karein aur naapein, aur pairwise comparisons se leaderboard - sab batata hai।
Judge kyun chahiye
Open-ended questions ke standard answers nahi hote; ROUGE/BLEU jaise reference-similarity metrics unpar lagbhag bekaar, aur human labeling mehnga-dheema. Zheng adi (2023) ne strong model ko judge banana study kiya - do fayde: scalable (human kam, faster iteration) aur explainable (judge comments bhi deta hai). Unka conclusion: GPT-4 jaisa strong judge human preference se 80%+ agree karta hai - humans ke beech ke agreement ke level par. Paper ne judge ki bias list bhi di - yehi is page ki main line hai।
Teen judging modes
| Mode | Kya karta hai | Fayda | Mukhya problem |
|---|---|---|---|
| Pairwise comparison | Judge ko question + do answers; kaun behtar ya tie | Relative comparison zyada stable | Models badhne par pairs square se - scale mushkil |
| Single-answer scoring | Judge seedha ek answer score kare (MT-Bench 1-10) | Scalable; har answer ek baar | Fine differences mushkil; judge badla to absolute scores zyada hilte |
| Reference-guided | Pehle reference answer prompt mein; phir score - math mein aam | Standard-answer wale par zyada accurate | Reference solution chahiye - aur woh khud galat ho sakta hai |
Teeno alag ya combined use ho sakte hain (Zheng adi, 2023, Section 3.1)।
Judge kahan galti karta hai
Neeche ke numbers sab Zheng adi (2023) se - judges tab-ke GPT-4, GPT-3.5, Claude-v1; sirf bias types aur magnitudes batane ke liye, aaj ke models nahi।
| Bias | Kaise dikhta hai | Paper ka evidence |
|---|---|---|
| Position bias | Kisi position wale answer ko pasand; mostly pehla | Do close answers ka order swap karne par GPT-4 sirf 65.0% consistent, GPT-3.5 46.2%, Claude-v1 23.8% (Table 2) |
| Length bias | Lamba, verbose answer pasand - chaan clear/accurate na ho | ”Repeat list” attack (koi naya info nahi; list dohra di) par Claude-v1 aur GPT-3.5 failure rate 91.3%, GPT-4 8.7% (23 answers, Table 3) |
| Self-preference | Apne hi answers ko pasand | GPT-4 self-win +10%, Claude-v1 +25%; par GPT-3.5 self-prefer nahi karta; data seemit - paper unsure hai ki bias exist karti hai |
| Math/reasoning mis-judgment | Khud kar sakta hai, phir bhi diya galat answer se bahar ho gaya | 10 math questions x 2 orders = 20 judgments; default prompt par GPT-4 ne 14 galat (Table 4) |
Paper ka guess: position bias training data se ya causal Transformer ke left-to-right structure se; aage study nahi. Yaad rakho: yeh biases ek saath judti hain, aur har ek ka alag ilaaj hai।
Khud karein: position bias, length bias aur noise kaise judte hain
Neeche wala widget ek judge simulate karta hai: “first answer wins” ka score = real quality gap + first-position preference + longer-answer preference + random noise. Teen approaches compare: sirf ek baar judge; order swap + sirf consistent conclusions; order swap + scores average. Sliders illustrative - koi real model nahi।
Yeh try karein:
- Position aur length biases 0; quality gap 1.0; noise 0.8. “Judge once” agreement lagbhag 78.5% = , jahan quality-gap std, noise std; swap+average se effective noise - agreement lagbhag 83.6%।
- Sirf position bias: “judge once” agreement girta hai, “first answer chosen” 50% se hat jaata hai; dono swap approaches position ka asar mita deti hain।
- Sirf length bias: swap kaam nahi karta - “longer answer chosen” abhi bhi 50% se bahut upar, kyunki length bias dono orders mein same direction; position hi swap par cancel hoti hai।
- Neeche wali curve: answers ki quality jitni kareeb, teeno approaches coin-flip ke kareeb. Paper ne real data par bhi same trend dekha: GPT-4 human-agreement model-pair ke win-rate difference ke saath 70% se lagbhag 100% (Figure 2)।
Biases kam karne ke upay
Sabse basic order swap (Zheng adi, 2023, Section 3.4). Conservative tareeka: har pair ko do baar judge; dono baar same answer tabhi win, warna tie:
Real judge call ki jagah ek stub function - logic bilkul same. Stub pehle position ko pasand karta hai (strength 0.5), noise 0.8; do answers ka real quality gap standard normal:
import numpy as np
rng = np.random.default_rng(0)
def make_judge(position_bias: float, noise: float):
"""Real judge call ka stub: dono qualities dekhta hai, par pehle wale ko pasand karta hai।"""
def judge(quality_first: float, quality_second: float) -> str:
score = quality_first - quality_second + position_bias + noise * rng.normal()
return "first" if score > 0 else "second"
return judge
def judge_once(judge, quality_x: float, quality_y: float) -> str:
"""Har pair ek hi baar; order random।"""
if rng.random() < 0.5:
return "x" if judge(quality_x, quality_y) == "first" else "y"
return "y" if judge(quality_y, quality_x) == "first" else "x"
def judge_swapped(judge, quality_x: float, quality_y: float) -> str:
"""Order swap, do judgments; dono consistent tabhi win, warna tie।"""
one = judge(quality_x, quality_y) # x pehle
two = judge(quality_y, quality_x) # y pehle
if one == "first" and two == "second":
return "x"
if one == "second" and two == "first":
return "y"
return "tie"
judge = make_judge(position_bias=0.5, noise=0.8)
gap = rng.normal(size=20000) # har pair ka real quality gap x - y
truth = np.where(gap > 0, "x", "y")
once = np.array([judge_once(judge, g, 0.0) for g in gap])
swapped = np.array([judge_swapped(judge, g, 0.0) for g in gap])
decided = swapped != "tie"
print(f"judge once: truth ke saath agree {np.mean(once == truth):.3f}")
print(f"order swap: ties {1 - decided.mean():.3f}, baaki agreement {np.mean(swapped[decided] == truth[decided]):.3f}")
# output:
# judge once: truth ke saath agree 0.753
# order swap: ties 0.380, baaki agreement 0.914
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
Order swap ke baad judge-ke-conclusions wali comparisons mein truth-agreement 75.3% se 91.4% - keemat: 38.0% comparisons tie ho gaye, koi conclusion nahi. Zyada aggressive tareeka: positions random - kaafi bade sample par position bias cancel. Swap ke alawa aam mitigations:
| Problem | Upay | Cost ya limit |
|---|---|---|
| Position bias | Few-shot judge: prompt mein teen judged examples (A better, B better, tie); paper mein GPT-4 consistency 65.0% se 77.5% | Prompt lamba, call cost lagbhag 4x; consistent = accurate nahi; nayi bias bhi aa sakti hai |
| Length bias | Rubric mein “length par bonus nahi” likho; ya win-rates par length-control: judge preference predict karne wala regression fit karke length-gap = 0 par predict | Extra model fit; assumption: length effect alag ho sakta hai; Length-Controlled AlpacaEval ne Chatbot Arena se Spearman 0.94 se 0.98 kiya (Dubois adi, 2024) |
| Math/reasoning mis-judgment | Judge se pehle khud solve karwao (CoT), ya independently nikala answer reference ke roop mein prompt mein | Default prompt: 14/20 galat; CoT par 6/20; reference-guided 3/20; par judge khud galat solve kare to reference bhi galat |
| Self-preference | Judge aur judged models alag families; ya multiple judges | Cost badhta hai; data bias ki existence prove nahi karta, par low-cost protection |
| Judge version change | Judge model version, prompt, temperature fix; report mein likho | Judge upgrade ke baad naye-purane scores seedha comparable nahi। |
Judge reliable hai?: kaise naapein
Judge ke verdicts ko human labels se compare - teen aam quantities:
- Agreement rate: judge aur human same conclusion ka ratio. MT-Bench paper ki definition: dono judge-types se randomly ek-alag individual uthao; random question par same conclusion ki probability; human-human agreement judge ke liye reference. Turn-1 data: ties chhod kar GPT-4 vs human experts 85%; human experts aapas mein 81%; ties sahit 66% aur 63%; do random judges - ties chhod 50%, ties sahit 33% (Table 5; 58 expert annotators, lagbhag 3K votes)।
- Cohen’s kappa: classes imbalanced hon to agreement fake-high; majority-class hamesha guess karne wala bhi high agreement le leta hai. chance-agreement minus karta hai - observed agreement, dono apne-apne label proportions se random label den par agreement. Kappa class proportions se bhi daba sakta hai: same do annotators, same error rate - kappa 0.811 se 0.144 ho sakta hai - building eval sets dekhein।
- Difficulty-wise stratify: same judge bade-gap comparisons par accurate, close comparisons par coin-flip. Ek total agreement yeh chhupa deta hai।
import numpy as np
# judge: A win B win tie
confusion = np.array([[40, 6, 4], # human: A win
[ 8, 30, 2], # human: B win
[ 3, 2, 5]]) # human: tie
n = confusion.sum()
p_observed = np.trace(confusion) / n
p_expected = (confusion.sum(axis=1) / n) @ (confusion.sum(axis=0) / n) # dono random-label par agreement
kappa = (p_observed - p_expected) / (1 - p_expected)
print(f"agreement {p_observed:.3f}, chance {p_expected:.3f}, Cohen's kappa {kappa:.3f}")
# judge hamesha majority guess kare: agreement high, kappa 0
confusion = np.array([[90, 0], [10, 0]])
n = confusion.sum()
p_observed = np.trace(confusion) / n
p_expected = (confusion.sum(axis=1) / n) @ (confusion.sum(axis=0) / n)
print(f"hamesha majority guess: agreement {p_observed:.3f}, kappa {(p_observed - p_expected) / (1 - p_expected):.3f}")
# output:
# agreement 0.750, chance 0.418, Cohen's kappa 0.570
# hamesha majority guess: agreement 0.900, kappa 0.000
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
Human labels kitne? Agreement ko error ke andar estimate karne ke lagbhag labels (). Agreement lagbhag 80%, points - lagbhag 246; lagbhag 50% par lagbhag 385 - to dozens ke spot-checks sirf obvious problems pakadte hain, judge reliability prove nahi karte. Yeh eval statistics wala hi confidence-interval formula hai।
Pairwise se leaderboard: Bradley-Terry aur Elo
Pairwise comparisons (judge insaan ho ya model) “kaun jeeta” records dete hain; leaderboard ke liye ek model chahiye jo win/loss ko strength mein translate kare. Bradley-Terry maanta hai har model ka strength coefficient ; model model ko beat karne ki probability:
Wahi formula reward models ki training ka bhi base hai: “model” ko “answer” aur strength ko reward kar do - reward models page ki preference probability; preference optimization bhi yahi use karta hai. Coefficients maximum likelihood (yaani logistic regression) se saare matches par jointly fit; sirf differences matlab rakhte hain, isliye ek model ko 0 fix. Elo sirf rescale: ; 400-point difference = 10x odds।
Chatbot Arena users ko do models ke answers anonymously compare karne deta hai; paper publish hone tak lagbhag 240K votes, lagbhag 90K users. Ranking Bradley-Terry coefficients use karti hai, online-update wale Elo nahi - pehla statistical estimation ke liye behtar; confidence intervals bootstrap ya sandwich variance se (Chiang adi, 2024). Neeche ka code simulated matches par wahi karta hai: pehle 3,000 matches generate; Newton’s method se coefficients fit; phir bootstrap intervals।
import numpy as np
rng = np.random.default_rng(0)
names = ["A", "B", "C", "D"]
true_elo = np.array([1000.0, 1050.0, 1120.0, 1250.0]) # models ki real strength (Elo scale)
beta_true = true_elo * np.log(10) / 400 # Bradley-Terry coefficients mein
m, n_battles = 4, 3000
i = rng.integers(m, size=n_battles) # har match par do alag models random
j = (i + rng.integers(1, m, size=n_battles)) % m
p_i_wins = 1 / (1 + np.exp(-(beta_true[i] - beta_true[j])))
win = (rng.random(n_battles) < p_i_wins).astype(float) # 1 = i jeeta
def fit_bt(i, j, win, m: int, iters: int = 50) -> np.ndarray:
"""Bradley-Terry coefficients ka MLE (Newton); model 0 ko 0 fix।"""
beta = np.zeros(m)
for _ in range(iters):
p = 1 / (1 + np.exp(-(beta[i] - beta[j])))
g = win - p
grad = np.bincount(i, g, m) - np.bincount(j, g, m)
w = p * (1 - p)
hess = np.zeros((m, m))
np.add.at(hess, (i, i), -w)
np.add.at(hess, (j, j), -w)
np.add.at(hess, (i, j), w)
np.add.at(hess, (j, i), w)
step = np.linalg.solve(-hess[1:, 1:], grad[1:])
beta[1:] += step
if np.abs(step).max() < 1e-9:
break
return beta
to_elo = lambda beta: 400 / np.log(10) * (beta - beta[0]) + 1000 # model 0 = 1000 fix
estimate = to_elo(fit_bt(i, j, win, m))
boot = [] # bootstrap: matches resample; intervals
for _ in range(500):
k = rng.integers(n_battles, size=n_battles)
boot.append(to_elo(fit_bt(i[k], j[k], win[k], m)))
low, high = np.percentile(boot, [2.5, 97.5], axis=0)
for k, name in enumerate(names):
print(f"{name}: real {true_elo[k]:6.0f} estimate {estimate[k]:7.1f} 95% CI [{low[k]:7.1f}, {high[k]:7.1f}]")
# output:
# A: real 1000 estimate 1000.0 95% CI [ 1000.0, 1000.0]
# B: real 1050 estimate 1031.0 95% CI [ 1006.8, 1052.3]
# C: real 1120 estimate 1118.6 95% CI [ 1095.0, 1140.9]
# D: real 1250 estimate 1246.8 95% CI [ 1223.2, 1270.5]
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
A 1000-fix kiya gaya reference hai - isliye uska interval zero-width; baaki models ke intervals A ke relative. 3,000 matches par B, C, D ke intervals half-width lagbhag 23 points; real values sab andar. Do models ka ranking reliable hai ya nahi - unke difference ka interval dekho, 0 contain karta hai ya nahi; unke alag intervals ka overlap nahi. B vs A ka gap lagbhag 31 points; difference interval [6.8, 52.3] - 0 nahi. Judge-model ke win/loss bhi aise rank ho sakte hain, par judge ki biases leaderboard mein waise hi ghus jaati hain - isliye pehle judge calibrate karo।
Practice checklist
- Scoring rubric achha likho: “length par bonus nahi” clearly; temperature 0 ya low; judge model version fix।
- Pairwise par order swap; single-answer par score distribution report karo, sirf average nahi।
- Math, code, factual questions: reference answers ya executable verification - judge ki subjective judgment ki jagah।
- Kuch sample human-label karo; agreement aur Cohen’s kappa nikaalo; difficulty ya category se stratify karke dekho।
- Judge aur judged models alag families se; zaroorat par multiple judges।
- Results ke saath confidence intervals; do models compare karte waqt paired analysis (eval statistics dekhein)।
- Judge ko approximation samjho, truth nahi: uski biases known hain - isliye human spot-checks se lagatar calibrate karo।
Summary aur exercises
- Judge sasta, scalable, explainable - par position, length, self-preference aur reasoning-misjudgment biases; use karte waqt ek-ek karke mitigate karein।
- Order swap position bias mitata hai; length bias nahi।
- Judge ko agreement rate (human-human ke against), Cohen’s kappa aur difficulty-stratified se naapo; spot-check sample size bhi kaafi ho।
- Pairwise comparisons ko Bradley-Terry se leaderboard banao, bootstrap intervals ke saath।
1. Judge ki “pehle position wala answer pasand” kaise mitayein?
- Judge ki sampling temperature badhayein
- Do answers ka order swap karke do baar judge karein; dono consistent tabhi win
- Judge se lambe comments likhwayein
- Prompt aur lamba likhein
Position bias “kaun pehle hai” se aati hai; swap ke baad preference do judgments mein cancel; temperature sirf randomness badhati hai - lambe comments/prompt position bias nahi badalte।
2. Kaun se kathan MT-Bench paper (Zheng adi, 2023) ke data se supported hain? (multiple)
- Do close answers ka order swap karne par GPT-4 sirf 65.0% consistent
- “Repeat list” attack par GPT-4 ka failure rate (8.7%) GPT-3.5 (91.3%) se bahut kam
- Paper ne prove kiya GPT-4 mein self-preference hai
- Reference-guided par judge ki math mis-judgments 14/20 se 3/20
Paper ne GPT-4 ka self-win +10% observe kiya, par data seemit, farq chhota - clearly kehta hai self-preference exist karti hai ya nahi, confirm nahi।
3. Real labels mein 90% “A win”; judge hamesha “A win” bolta hai. Uska agreement aur Cohen’s kappa?
- 90% aur 0.9
- 90% aur 0
- 50% aur 0
- 100% aur 1
Agreement 90%; chance agreement , isliye : judge ne “majority guess” se aage kuch nahi diya।
4. Bradley-Terry mein model A ka coefficient B se 1 zyada - A beats B ki probability?
- 50%
- 63.2%
- 73.1%
- 84.1%
. 63.2% = ; 84.1% standard normal ka 1 par CDF - dono is formula ke nahi।
5. Judge-human agreement ko ±5 points (95% CI) tak estimate karna hai; agreement lagbhag 80% - lagbhag kitne human labels?
- Lagbhag 60
- Lagbhag 250
- Lagbhag 1,000
- Lagbhag 5,000
।
Exercises
- Upar wale widget mein position bias 0, length bias 0.6; noise aur quality gap default. Kya order swap “longer answer chosen” ka ratio badlata hai? Kyun?
- Do models ka Elo difference 100 points - A beats B ki probability? Corresponding Bradley-Terry coefficient difference?
- Aap judge model se support-reply templates ke do versions compare karna chahte hain - eval plan likhein: judge setup, calibration, reporting।
Reference answers
- Kaafi nahi badlega. Length bias dono orders mein same direction - judge hamesha lamba chunta hai; order swap sirf order-linked “pehla position” bias cancel karta hai; length bias control karne ke liye rubric mein “length par bonus nahi” likhna padta hai, ya statistically length-control।
- ; coefficient difference ।
- Ek plan: judge judged-model se alag family ka strong model, temperature 0, version aur prompt fix; pairwise par order swap - dono consistent tabhi win, warna tie; rubric “length par bonus nahi” + factual accuracy; 250+ samples human-label karke agreement aur Cohen’s kappa, question categories se stratify; aakhir win rate, tie rate aur confidence intervals report; do versions same questions par paired analysis।
Aage padhein
-
Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (Zheng adi, 2023): judge types, biases, mitigations - is page ke zyada-tar numbers isi se।
-
Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference (Chiang adi, 2024): anonymous pairwise voting aur Bradley-Terry rankings।
-
Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators (Dubois adi, 2024): judge ki length bias ka regression correction।
-
Adding Error Bars to Evals (Miller, 2024): eval results par error bars ke statistical methods।
-
LLM evaluation methodology: benchmarks, contamination, eval process।
-
Mixtral of Experts: Arena Elo aur MT-Bench differences ko win rates mein badalne ka example।
-
Preference optimization: RLHF se DPO: pairwise preference data ki training usage - yahan ke pairwise comparisons usi type ka data hai।
-
QLoRA: GPT-4 judge ki order preference aur self-preference, judge-human agreement (Kendall tau 0.43, Fleiss kappa 0.25), aur Elo se win-rate ka arithmetic।
-
Zhou adi, IFEval (2023): programmatically-verifiable instruction-following rules se eval - judge ki subjectivity aur biases ko bypass।
अक्सर पूछे जाने वाले सवाल
- LLM-as-a-Judge bharosay-layak hai?
- Sahi settings mein kaafi: MT-Bench paper mein ties hatane ke baad GPT-4 vs human-expert agreement 85%; human-experts ke beech 81%. Par judge ke position bias, length bias, math mis-judgment hain - order swap, reference answers aur human spot-checks se mitigate/calibrate karein; ise approximation samjho, truth nahi।
- Judge ki position bias kam kaise karein?
- Har pair ko dono orders mein judge karo; dono baar same answer chuna tabhi win, warna tie; ya positions random assign karke bade sample se cancel. Prompt mein judged examples (few-shot) bhi madad karte hain - paper mein GPT-4 consistency 65.0% se 77.5% - par prompt lamba, call cost lagbhag 4x।
- Kya evaluate ho raha model khud judge ban sakta hai?
- Recommend nahi. Judge apne hi answers ko pasand kar sakta hai: MT-Bench paper ne GPT-4 ka self-win rate 10% zyada, Claude-v1 ka 25% zyada dekha - par sample seemit; paper confirm nahi kar pata ki yeh self-preference universal hai. Zyada safe: judge aur judged models alag families se; ya multiple judges।
- Pairwise comparison ya single-answer scoring?
- Pairwise fine differences par zyada sensitive, relative results zyada stable - par models badhne par pairs square se badhte hain; single-answer scalable, sasta - par close answers alag nahi kar pata, aur judge badalne par absolute scores zyada hilte hain. Math/coding jaise standard-answer wale questions: pehle reference answers ya executable verification।
- Bahut saare pairwise comparisons leaderboard kaise banein?
- Bradley-Terry model: har model ka ek strength coefficient; A beats B ki probability 1/(1+exp(-(xiA-xiB))); saare matches se maximum likelihood (logistic regression) se jointly fit; bootstrap se confidence intervals. Elo score sirf rescaled hai; Chatbot Arena Bradley-Terry le leti hai kyunki statistical estimation ke liye woh fit hai।