10 Evaluation 2 / 6
  1. अध्याय विषय-सूची
  2. LLM evaluation methodology
  3. Eval statistics
  4. LLM-as-a-Judge
  5. Eval set banana
  6. Benchmark contamination
  7. LLM production evaluation
सभी अध्याय →

अध्याय 10 · Evaluation 10.2

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।

मध्यम पढ़ने का समय: 11 मिनट अपडेट किया गया सहायक कोड ↓

यह पृष्ठ पूरा करने पर आप

  • 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।
इस पृष्ठ पर
  1. Code eval ka metric: pass@k
  2. Score mein kitna error
  3. Do models compare: paired differences
  4. Gap detect karne ke liye kitne questions
  5. Practical advice
  6. Summary aur exercises
  7. Exercises
  8. Aage padhein
  9. अक्सर पूछे जाने वाले सवाल

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 kk answers; ek bhi saare tests pass kare to question sahi; benchmark score = per-question results ka average (Chen adi, 2021). k=1k=1 single-sample pass rate; kk bada - “model ko kk chances” wali ceiling।

Sirf kk samples lo to variance bada. Paper har question par n≥kn \ge k samples leta hai, cc pass ginta hai, aur yeh unbiased estimate use karta hai, phir questions par average:

pass@k=1N∑i=1N[ 1−(n−cik)(nk) ]\mathrm{pass@}k = \frac{1}{N}\sum_{i=1}^{N}\left[\,1 - \frac{\binom{n-c_i}{k}}{\binom{n}{k}}\,\right]

NN questions, cic_i ii-th question ke passes. Matlab: nn samples se bina-replacement kk uthao - sab-fail ki probability (n−ck)/(nk)\binom{n-c}{k}/\binom{n}{k}; 1 minus = kam-se-kam-ek-pass. n−c<kn-c<k ho to kk picks mein guarantee pass - result 1।

Na-use-karne wala tareeka: p^=c/n\hat p = c/n lo, phir 1−(1−p^)k1-(1-\hat p)^k. (1−p^)k(1-\hat p)^k convex hai p^\hat p mein; Jensen inequality se uska expectation (1−p)k(1-p)^k 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 k=5k=5 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 kk “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 kk 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 nn, kk aur sampling temperature likho. Temperature zyada - samples diverse - bade kk par better; paper mein 679M model ka pass@1 optimal temperature 0.2, pass@100 0.8।

Widget dono cheezein ek saath: upar nn samples mein cc pass se per-question pass@k + naive comparison; neeche per-question difficulty alag hone par poore benchmark ka pass@k vs kk।

Score mein kitna error

Benchmark ke questions saare possible questions ka ek sample hain; questions badle to score badlega. Accuracy pp, questions nn, har question sirf sahi/galat, independent - standard error aur 95% interval:

SE=p(1−p)n,p±1.96 SE\mathrm{SE}=\sqrt{\frac{p(1-p)}{n}},\qquad p \pm 1.96\,\mathrm{SE}

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 sA−sBs_A-s_B; gap ka variance:

Var(μ^A−μ^B)=Var(sA)+Var(sB)−2 Cov(sA,sB)n\mathrm{Var}(\hat\mu_A-\hat\mu_B)=\frac{\mathrm{Var}(s_A)+\mathrm{Var}(s_B)-2\,\mathrm{Cov}(s_A,s_B)}{n}

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 δ\delta detect karna hai to questions kaafi hon chahiye. Significance α=0.05\alpha=0.05, power 1−β=0.81-\beta=0.8:

n=(z1−α/2+z1−β)2 Var(sA−sB)δ2n=\frac{(z_{1-\alpha/2}+z_{1-\beta})^2\,\mathrm{Var}(s_A-s_B)}{\delta^2}

Jismein z0.975≈1.96z_{0.975}\approx 1.96, z0.8≈0.84z_{0.8}\approx 0.84, (1.96+0.84)2≈7.85(1.96+0.84)^2\approx 7.85. Dono accuracy lagbhag 80%, har question sirf sahi/galat:

GapPaired (corr 0.5)Unpaired (corr 0)
5 points548 questions1,091 questions
3 points1,472 questions2,940 questions
2 points3,256 questions6,507 questions
1 point12,792 questions25,580 questions

Gap aadha - questions lagbhag 4x, kyunki nn δ2\delta^2 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:

  1. Mean ka standard error CLT se nikaalo, score ke saath report karo।
  2. Questions groups mein (jaise ek article ke baad kai questions) - clustered standard errors।
  3. Per-question repeat sampling aur next-token probability analysis se variance kam karo।
  4. Do models compare: per-question paired differences par inference।
  5. 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 1−(n−ck)/(nk)1-\binom{n-c}{k}/\binom{n}{k} se; 1−(1−c/n)k1-(1-c/n)^k 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 n=10n=10 samples; kisi question ke c=1c=1 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 n−c=9<k=10n-c=9<k=10 branch). 65.1% naive 1−(1−0.1)101-(1-0.1)^{10} 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 (Var(sA)+Var(sB)−2Cov(sA,sB))/n(\mathrm{Var}(s_A)+\mathrm{Var}(s_B)-2\mathrm{Cov}(s_A,s_B))/n; 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 n=(z1−α/2+z1−β)2Var(sA−sB)/δ2n=(z_{1-\alpha/2}+z_{1-\beta})^2\mathrm{Var}(s_A-s_B)/\delta^2 par 3,256; unpaired lagbhag 6,507।

Exercises

  1. Kisi question ke n=20n=20 samples, c=3c=3 pass. k=1,5,10k=1,5,10 ke liye pass@k ke unbiased aur naive estimates nikaalein।
  2. Internal eval set 500 questions; purana model 82%, naya 85%; correctness correlation 0.6 assume. Kya 3-point improvement bharosay-layak hai?
  3. 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
  1. Unbiased 0.1500, 0.6009, 0.8947; naive 0.1500, 0.5563, 0.8031. Misal k=5k=5: 1−(175)/(205)=1−6188/15504≈0.60091-\binom{17}{5}/\binom{20}{5}=1-6188/15504\approx 0.6009, jabki 1−0.855≈0.55631-0.85^5\approx 0.5563 - naive low।
  2. Paired: Var=0.82×0.18+0.85×0.15−2×0.6×0.1476×0.1275≈0.1105\mathrm{Var}=0.82\times0.18+0.85\times0.15-2\times0.6\times\sqrt{0.1476\times0.1275}\approx 0.1105; SE 0.1105/500≈0.0149\sqrt{0.1105/500}\approx 0.0149; 95% half-width lagbhag 2.9 points; z≈2.02z\approx 2.02, p≈0.044p\approx 0.044 - bas 5% line ke paar, evidence kamzor. Unpaired: SE lagbhag 0.0235, half-width lagbhag 4.6 points, z≈1.28z\approx 1.28, p≈0.20p\approx 0.20 - 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।
  3. 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 ∣δ∣/SE≥1.645|\delta|/\mathrm{SE}\ge 1.645, yaani n≥1.6452×Var/δ2=1.6452×0.1797/0.032≈540n\ge 1.645^2\times\mathrm{Var}/\delta^2=1.645^2\times 0.1797/0.03^2\approx 540 - slider 500-600 ke beech le jaakar verify karein।

Aage padhein

अक्सर पूछे जाने वाले सवाल

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।