HumanEval › Worked Example
Language AI HandbookAll chapters HumanEval › Worked ExampleOne section · Sections in this chapter7 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let us walk through a concrete example to solidify the calculation. Suppose for a specific problem, we generate samples and find that of them pass all tests.
To calculate pass@1:
This matches our intuition: with 2 correct samples out of 5, the probability of randomly selecting a correct one is .
To calculate pass@2:
There is a 70% chance that at least one of two randomly selected samples is correct. This is substantially higher than the 40% single-sample probability. This shows the benefit of multiple attempts.
For pass@3:
With only 3 incorrect samples available, selecting 3 samples without replacement has only a 10% chance of getting all incorrect ones. This leaves a 90% chance of getting at least one correct solution. As approaches , the probability approaches 1. This shows the fact that with enough attempts, we will eventually examine all correct solutions in the pool.
Notice what happens at the boundary. When , we must select all 5 samples, so we are guaranteed to include the 2 correct ones. Pass@5 equals exactly 1.0. This behavior is automatically handled by the formula: since , so the ratio is 0 and pass@5 = 1. When , all samples are incorrect, so no matter how many we select, none will be correct. Pass@k = 0 for all when . These boundary cases give useful sanity checks when implementing the metric.