Eval statistics: pass@k, confidence intervals aur needed sample size
Benchmark score limited questions par estimate hai - error ke saath. Yeh page pass@k ka unbiased estimate, accuracy ka confidence interval, paired comparison, aur gap detect karne ke questions batata hai - code aur widgets ke saath।
यह पृष्ठ पूरा करने पर आप
- pass@k ka unbiased estimator likhein aur code se implement karein।
- Accuracy ka confidence interval nikaalein; benchmark score kitna error le jaata hai, batayein।
- Do models ko paired differences se compare karein; gap significant hai ya nahi, judge karein।
- Estimate karein kisi gap ko detect karne ke liye kitne questions chahiye।
इस पृष्ठ पर
Benchmark score limited questions par estimate hai - model capability ki true value nahi. Yeh page teen sawaal: pass@k kaise unbiased, accuracy ka error kitna, do models ka gap kab count hota hai. Teenon LLM evaluation methodology ke “error kitna” sawaal ka expansion hain।
Code eval ka metric: pass@k
Code questions auto-gradable hain, par model har sample mein alag answer deta hai - ek question ka score kaise? HumanEval ka tareeka pass@k: har question ke answers; ek bhi saare tests pass kare to question sahi; benchmark score = per-question results ka average (Chen adi, 2021). single-sample pass rate; bada - “model ko chances” wali ceiling।
Sirf samples lo to variance bada. Paper har question par samples leta hai, pass ginta hai, aur yeh unbiased estimate use karta hai, phir questions par average:
questions, -th question ke passes. Matlab: samples se bina-replacement uthao - sab-fail ki probability ; 1 minus = kam-se-kam-ek-pass. ho to picks mein guarantee pass - result 1।
Na-use-karne wala tareeka: lo, phir . convex hai mein; Jensen inequality se uska expectation se zyada - estimate systematically low; samples kam to zyada low; aur zyada-sampling results artificially achhe dikh jaate hain (Chen adi, 2021, Appendix A)।
from math import comb
def pass_at_k(n: int, c: int, k: int) -> float:
"""n samples per question, c pass: unbiased pass@k estimate."""
if n - c < k:
return 1.0
return 1.0 - comb(n - c, k) / comb(n, k)
correct = [10, 7, 3, 1, 0] # 5 questions, n=10 samples each, pass counts
n = 10
for k in (1, 5, 10):
exact = sum(pass_at_k(n, c, k) for c in correct) / len(correct)
naive = sum(1 - (1 - c / n) ** k for c in correct) / len(correct)
print(f"pass@{k:<2d} unbiased {exact:.4f} naive {naive:.4f}")
# output:
# pass@1 unbiased 0.4200 naive 0.4200
# pass@5 unbiased 0.6833 naive 0.6478
# pass@10 unbiased 0.8000 naive 0.7246
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
5 questions x 10 samples: pass@1 42%; pass@5 68.3%; pass@10 80% - matlab “10 mein se koi ek pass” wale questions ka 80%. Naive tareeka par 64.8% - lagbhag 3.5 points low. Real-model numbers se compare: Codex-12B HumanEval par pass@1/10/100 = 28.81%/46.81%/72.31% (Chen adi, 2021, Table 1)।
pass@k padhte waqt teen baatein:
- pass@1 “ek baar mein sahi” ki reliability naapta hai; bada “sample karke verify kar sakte ho” wali ceiling - dono alag sawaal।
- pass@k maanta hai oracle hai jo sahi/galat judge karta hai - paper mein unit tests. Tests na hon to answers mein se ek chunna scoring/voting/reranking se; paper ne paaya average-token-log-probability se sample chunna random se behtar।
- Report karte waqt , aur sampling temperature likho. Temperature zyada - samples diverse - bade par better; paper mein 679M model ka pass@1 optimal temperature 0.2, pass@100 0.8।
Widget dono cheezein ek saath: upar samples mein pass se per-question pass@k + naive comparison; neeche per-question difficulty alag hone par poore benchmark ka pass@k vs ।
Score mein kitna error
Benchmark ke questions saare possible questions ka ek sample hain; questions badle to score badlega. Accuracy , questions , har question sirf sahi/galat, independent - standard error aur 95% interval:
Accuracy 80% lekar benchmarks ke question counts: HumanEval 164 = ±6.1 points; GSM8K 1,319 = ±2.2; MMLU 14,079 = ±0.7. 164-question benchmark par 3-point farq wale do models lagbhag alag hi nahi kar sakte।
Yeh formula sirf “question sampling” ka error. Same question par model multiple attempts mein kabhi sahi kabhi galat ho sakta hai. Miller (2024) is variance ko alag todta hai: per-question repeat sampling se average, ya seedha next-token probabilities ka analysis - dono variance kam karte hain।
Do models compare: paired differences
A vs B - alag intervals banakar overlap mat dekho. Dono models same questions answer karte hain; mushkil questions par dono girti hain - correctness usually positively correlated. Per-question score difference ; gap ka variance:
Covariance positive to variance independent-maanne se kam (Miller, 2024). Neeche ka code simulated data se demo: dono models question difficulty share karte hain; correctness correlation lagbhag 0.5।
import numpy as np
rng = np.random.default_rng(2)
n = 164 # HumanEval ka question count
difficulty = rng.normal(scale=3.0, size=n) # question difficulty - shared
def answers(skill: float) -> np.ndarray: # 1 = sahi, 0 = galat
p = 1 / (1 + np.exp(-(skill - difficulty)))
return (rng.random(n) < p).astype(float)
a, b = answers(3.0), answers(2.2)
diff = a - b
se_a = a.std(ddof=1) / np.sqrt(n)
se_unpaired = np.sqrt(a.var(ddof=1) / n + b.var(ddof=1) / n)
se_paired = diff.std(ddof=1) / np.sqrt(n)
print(f"A {a.mean():.3f} +- {1.96 * se_a:.3f} B {b.mean():.3f} corr {np.corrcoef(a, b)[0, 1]:.2f}")
print(f"gap {diff.mean():+.3f} 95% CI half-width: unpaired {1.96 * se_unpaired:.3f}, paired {1.96 * se_paired:.3f}")
lo, hi = diff.mean() - 1.96 * se_unpaired, diff.mean() + 1.96 * se_unpaired
print(f"unpaired 95% CI [{lo:+.3f}, {hi:+.3f}]")
lo, hi = diff.mean() - 1.96 * se_paired, diff.mean() + 1.96 * se_paired
print(f"paired 95% CI [{lo:+.3f}, {hi:+.3f}]")
idx = rng.integers(0, n, size=(10000, n)) # bootstrap: questions resample; same question dono ke saath
boot = diff[idx].mean(axis=1)
print("paired bootstrap 95% CI:", np.percentile(boot, [2.5, 97.5]).round(3))
# output:
# A 0.829 +- 0.058 B 0.756 corr 0.50
# gap +0.073 95% CI half-width: unpaired 0.088, paired 0.062
# unpaired 95% CI [-0.014, +0.161]
# paired 95% CI [+0.011, +0.136]
# paired bootstrap 95% CI: [0.012 0.14 ]
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
Same data: unpaired interval [-1.4, +16.1] points 0 contain karta hai; paired [+1.1, +13.6] nahi karta; question-resampling bootstrap [1.2, 14.0] paired formula se match. Yeh fixed-seed ek simulation hai - seed badla to numbers badlenge; yeh paired kyun powerful hai woh dikhata hai, “A zaroor B se strong hai” nahi।
Gap detect karne ke liye kitne questions
Ulta: real gap detect karna hai to questions kaafi hon chahiye. Significance , power :
Jismein , , . Dono accuracy lagbhag 80%, har question sirf sahi/galat:
| Gap | Paired (corr 0.5) | Unpaired (corr 0) |
|---|---|---|
| 5 points | 548 questions | 1,091 questions |
| 3 points | 1,472 questions | 2,940 questions |
| 2 points | 3,256 questions | 6,507 questions |
| 1 point | 12,792 questions | 25,580 questions |
Gap aadha - questions lagbhag 4x, kyunki ke inverse mein hai. Yehi wajah hai ki hundreds-of-questions benchmarks par 1-2 points ka behas bekaar hai।
from math import ceil, sqrt
from statistics import NormalDist
z = NormalDist().inv_cdf
def half_width(p: float, n: int, level: float = 0.95) -> float:
"""Accuracy p on n questions: CI half-width."""
return z(0.5 + level / 2) * sqrt(p * (1 - p) / n)
def questions_needed(p_a: float, p_b: float, rho: float, alpha: float = 0.05, power: float = 0.80) -> int:
"""Dono models same questions answer karte hon: gap p_a - p_b detect karne ke questions. rho = correctness correlation."""
var = p_a * (1 - p_a) + p_b * (1 - p_b) - 2 * rho * sqrt(p_a * (1 - p_a) * p_b * (1 - p_b))
return ceil((z(1 - alpha / 2) + z(power)) ** 2 * var / (p_a - p_b) ** 2)
for name, n in [("HumanEval", 164), ("GSM8K", 1319), ("MMLU", 14079)]:
print(f"{name:9s} n={n:6d} accuracy 80% +- {100 * half_width(0.8, n):.1f} points")
for gap in (5, 3, 2, 1):
p_b = 0.80 - gap / 100
print(f"gap {gap} points: corr 0.5 needs {questions_needed(0.80, p_b, 0.5):6d}, corr 0 needs {questions_needed(0.80, p_b, 0.0):6d}")
# output:
# HumanEval n= 164 accuracy 80% +- 6.1 points
# GSM8K n= 1319 accuracy 80% +- 2.2 points
# MMLU n= 14079 accuracy 80% +- 0.7 points
# gap 5 points: corr 0.5 needs 548, corr 0 needs 1091
# gap 3 points: corr 0.5 needs 1472, corr 0 needs 2940
# gap 2 points: corr 0.5 needs 3256, corr 0 needs 6507
# gap 1 points: corr 0.5 needs 12792, corr 0 needs 25580
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
Upar sab maanta hai gold answers sahi hain. Gold answers mein errors hon to needed questions x multiplier: 4-choice, 6.49% label error - 1.198x; derivation aur experiment building eval sets mein।
Widget formulas ek saath: benchmark ka question count chuno, do models ki accuracy aur correlation set karo; dekho confidence interval, sahi-ranking ki probability, aur gap detect karne ke questions।
Practical advice
Miller (2024) paanch salah deta hai:
- Mean ka standard error CLT se nikaalo, score ke saath report karo।
- Questions groups mein (jaise ek article ke baad kai questions) - clustered standard errors।
- Per-question repeat sampling aur next-token probability analysis se variance kam karo।
- Do models compare: per-question paired differences par inference।
- Power analysis se judge karo eval set aapki hypothesis test karne ke kabil hai ya nahi।
Daily work mein: score ke saath question count + interval; do versions compare karte waqt same questions par paired analysis; eval set chhota hai to honestly maano chhota gap detect nahi hoga, phir decide - set badhaon ya zyada-power wali eval, jaise multiple sampling ka average।
Summary aur exercises
- Benchmark score limited-questions ka estimate; report mein question count + interval saath।
- pass@k unbiased se; se extrapolate na karein।
- Do models: paired analysis; 1-point gap = 10-hazaar+ questions; hundreds-of-questions benchmark 2-point ke andar kuch nahi dikhata।
1. Har question samples; kisi question ke pass. Is question ka pass@10 unbiased estimate?
- 10%
- 65.1%
- 100%
- 0%
10 samples mein se bina-replacement 10 uthao - woh passing sample guaranteed andar - isliye estimate 1 (formula ka branch). 65.1% naive ka result hai - systematically low।
2. 164-question benchmark par model A 80%, model B 77%. Kaun sa kathan sabse accurate?
- A clearly B se strong
- Sirf is gap se alag nahi kar sakte: har ek ka 95% interval lagbhag ±6 points; gap ka interval lagbhag ±9 points
- B clearly A se strong
- Interval sirf model size par, questions par nahi
SE = sqrt(p(1-p)/n); 164 questions par 80% accuracy ka half-width lagbhag 6.1 points; unpaired gap half-width lagbhag 8.9 - 3-point gap noise ke andar।
3. Same questions par paired analysis unpaired se narrow interval kyun deti hai?
- Do models ki correctness positively correlated - per-question difference ka variance chhota
- Pairing question count double karti hai
- Pairing dono models ki accuracy badha deti hai
- Pairing sirf significance level 5% se 10% karti hai
Gap ka variance ; positive covariance par independent-se kam।
4. Dono models ki accuracy lagbhag 80%, same questions, correctness correlation 0.5. 5% significance, 80% power se 2-point gap detect karne ke lagbhag kitne questions?
- Lagbhag 160
- Lagbhag 800
- Lagbhag 3,300
- Lagbhag 33,000
Formula par 3,256; unpaired lagbhag 6,507।
Exercises
- Kisi question ke samples, pass. ke liye pass@k ke unbiased aur naive estimates nikaalein।
- Internal eval set 500 questions; purana model 82%, naya 85%; correctness correlation 0.6 assume. Kya 3-point improvement bharosay-layak hai?
- Is page ke widget mein questions 164, accuracies 78% aur 75%, correlation 0.5. Sahi-ranking ki probability kitni? Ise 95% se upar karne ke liye lagbhag kitne questions?
Reference answers
- Unbiased 0.1500, 0.6009, 0.8947; naive 0.1500, 0.5563, 0.8031. Misal : , jabki - naive low।
- Paired: ; SE ; 95% half-width lagbhag 2.9 points; , - bas 5% line ke paar, evidence kamzor. Unpaired: SE lagbhag 0.0235, half-width lagbhag 4.6 points, , - not significant. Conclusion correlation assumption par tika hai; real per-question results se paired differences seedha calculate karo, bade eval set par re-check karein।
- Gap 3 points; paired SE lagbhag 3.3 points; agar real gap hi 3 points hai to measured-correct-ranking probability lagbhag 81.8%. 95%+ ke liye , yaani - slider 500-600 ke beech le jaakar verify karein।
Aage padhein
- Adding Error Bars to Evals (Miller, 2024): eval ke statistical methods aur paanch practices।
- Evaluating Large Language Models Trained on Code (Chen adi, 2021): HumanEval aur pass@k ka unbiased estimate - Appendix A।
- LLM evaluation methodology: benchmarks, contamination, eval process।
- LLM-as-a-Judge: open questions ka eval aur judge biases।
- Agents aur tool calling: pass^k - same task ke multiple runs sab safal - aur traces se agent evaluation।
अक्सर पूछे जाने वाले सवाल
- pass@k kaise, aur 1-(1-pass@1)^k kyun nahi?
- Har question par n samples, c pass: us question ka unbiased pass@k = 1 - C(n-c,k)/C(n,k); phir questions par average. Pehle pass@1 nikaal kar 1-(1-c/n)^k se extrapolate systematically low deta hai - samples jitne kam utna zyada, aur zyada-sampling wale results ko artificially achha dikhata hai।
- Do models 2 points ka farq - significant?
- Question count aur do models ke correctness correlation par nirbhar. Accuracy lagbhag 80% par 5% significance, 80% power se 2-point gap pakadna: same questions + correlation 0.5 - lagbhag 3,300 questions; bina pairing lagbhag 6,500. HumanEval ke sirf 164 - aisa gap pakad hi nahi sakte।
- Eval set mein kitne questions kaafi?
- Minimum gap jo detect karna hai us se; needed questions gap ke square ke inverse: gap aadha -> questions lagbhag 4x. Accuracy lagbhag 80%, same questions, correlation 0.5: 5 points lagbhag 550; 1 point lagbhag 12,800 (alpha 5%, power 80%)।
- Paired analysis kya hai, unpaired se zyada powerful kyun?
- Paired analysis do models ke per-question score differences par inference karti hai - alag intervals banakar compare nahi. Same questions par do models ki sahi/galat usually positively correlated - per-question difference ka variance chhota, interval narrow; same questions se chhota gap pakda ja sakta hai।
- Accuracy ka confidence interval kaise?
- Har question sirf sahi/galat aur independent: accuracy p ke n questions par standard error = sqrt(p(1-p)/n); 95% interval = p ± 1.96 x SE. Misal: 164-question HumanEval par 80% accuracy - interval lagbhag ±6.1 points. Questions groups mein aate hon to clustered standard errors chahiye।