Suppose 10 programs are generated in response to some question, and one of them passes all tests. By HumanEval's definition, pass@10 would count one success. But if the program completed and pasted into the user's code was any other one of the 10, the user would regard the attempt as unsuccessful. So, in general, pass@k is the fraction of sets of k programs that include a program passing all tests, for as many questions as the benchmark comprises. For a user who gets one unselected sample, look for pass@1 with the same sampling settings. Chen and colleagues, HumanEval
How the user "gets" a program is another variable. They may take the top program returned, select from several after studying them, or have some other automatic process select. Each of these may use identical underlying models, and yet differ materially. So it is worth asking, of any claimed advance, how many good programs the model itself generates, and the accuracy of whatever process chooses between them.
Consider 10 programs in an envelope
Write out the desired properties of a function to find the minimum of several dates, returning some pre-specified value if there are none. Have the model generate 10 such functions, with fixed temperature and so on, number them 1 to 10, and seal them in an envelope. Run the tests; say, programs 4 and 7 pass. (Any numbers could be substituted, and no program need actually be written or run.)
| Action | Outcome |
|---|---|
| Take program no. 1 as listed | Fails |
| Draw at random | Probability of success 2/10 |
| Is there a program in the 10 passing all tests? | Yes, so count 1 success |
| Take the program of minimum length | Unknown, as we don't know the lengths |
All follow from knowledge of which of the 10 passed the tests. The pass@10 column of a HumanEval-style benchmark summarizes the third line across problems. The 2nd line could readily be added, given only the information used. To answer questions 1 and 4, one needs to know the order of the 10 programs, the length of each, and how length relates to passing the tests. None of this is apparent from a single column giving, for example, pass@10.
Note also the difference between the result for program 1, and the estimated probability that a program generated once, with the same parameters, would pass. The former is simply what happened once; the latter uses the fact that 2 out of 10 programs passed. It does not imply that the next program generated would fail, nor say where in the list of 10 it would appear. Both figures may be relevant, and should be clearly differentiated, in a table purporting to indicate expected performance.
Probability of success with more programs, assuming independence
As another example, assume each program generated has probability 1/5, independent of others generated, of passing all the tests. Then 10 would all fail with probability (4/5) raised to the tenth power, so at least one would pass with probability close to 89.3%. Of course the probability of success for any single one generated remains 1/5. So generating 10 programs increases the likelihood that one of them will pass. But if only the first generated is used, there is no benefit from generating 9 others.
Of course this depends on the programs actually being independently generated. At the other extreme, if 10 identical copies of 1 generated program were returned, the probability that one of the 10 passed would be 1/5. So there is a wide range of possibilities for the probability that one of 10 passes, given a 1/5 probability that any one of them does. An evaluator can record whether each observed group contains a passing program and estimate this rate across problems.
Furthermore, different questions will vary widely in difficulty. For example, if for half the questions all programs generated passed the tests, and for the remaining half none did, pass@1 would be 1/2, as would pass@10. On the other hand, if each question had probability 1/2 that an individual program would pass and its draws were independent, pass@10 would be close to 1. So it is important not to apply the formula above to the overall pass@1.
Sampling subsets of a larger number generated
As described above, the tests in HumanEval check various properties of the function generated. The reference evaluator takes samples generated for each problem and calculates an estimated pass@k for values of k the sample counts support. HumanEval reference implementation For example, if 20 programs were generated, 2 passing all tests, to calculate pass@10 it considers all combinations of 10 of the 20. The calculation counts the fraction of possible subsets drawn entirely from the 18 failing programs, then takes its complement.
In this example, rather than enumerate all combinations of 10 of 20 programs, note that 10 will not be selected. The probability of not selecting one particular successful program is 10/20; given that, the probability of not selecting the other is 9/19. Hence the probability of selecting neither is approximately 23.7%, so the estimated pass@10 is about 76.3%. This should be contrasted with the 89.3% calculated above, which assumed probability 1/5 of success for each new program generated.
The paper reports pass@100 of 70.2% over all questions, for the hundred-candidate success event under the reported sampling conditions. HumanEval paper There is nothing to conclude from this about, for example, the proportion of 10 programs that would pass if generated with some other set of parameters, let alone for some other model. Many details need to be compared before results from 2 sources can be meaningfully compared; k is just 1 of them.
Selection from several candidates
Again considering a function to find the earliest of several dates, suppose one of the examples given to the model shows 3 different dates. The test to return a pre-specified value for no dates input would then only be applied by the evaluator. Suppose 7 of the 10 programs generated would give correct answers to the examples given, 2 of which pass all the tests. Selecting the shortest program from those 7 would not ensure a program that did not fail on no input. So it was fortuitous that the model generated programs that passed, but examination against the examples alone might not have identified them.
Naturally the evaluators could have applied further tests derived from the specification, or had a person review all 7 programs. But then the combination of model and process selecting a program to return would be different. So they should have applied whatever selection process they wished, excluding only the actual tests to be applied for final evaluation, and evaluated the single program so selected. They could additionally report the proportion of questions for which at least 1 of all the programs generated passed. The difference would indicate the maximum benefit to be obtained by better selection.
Of course "passing" the tests only establishes correctness with respect to those tests. Other tests might show other faults, or a modification to the desired properties might require a different answer. So if a different set of criteria were applied to accept a program for use, it is desirable to state that too. For the example function, returning an empty string or throwing an error might both be reasonable. Generating more programs would be of no help if that was not specified.
Appropriate statistic to quote
Given just a table of results, it is therefore desirable to know whether successes counted are: the top program returned; any program out of some number generated; or the program or programs returned by whatever process selects from those generated. Also, are there as many rows as questions, or as many programs generated? The latter may exceed the former by 10, 100, or more. So, for example, one would be unjustified in stating that 70% of individual outputs passed, if the statistic was the proportion of questions with at least one successful program out of, say, 100.
Thus one would want to know the success rate of the program returned, using whatever method of selection is employed, if a single program is automatically inserted at the cursor. If several are displayed for a person to choose between, how many do they look at, and what criteria can they apply? If an automatic process will check programs generated, to select those suitable for further action or acceptance, how many good programs are generated and how effective is that process at eliminating unsuitable ones? So many different statistics may be appropriate, depending on the subsequent action to be taken on the set of programs generated.
One other consideration is time and cost. 10 programs may be generated in parallel, so not greatly increasing the time to the user, while still consuming resources for each attempt. Sequential attempts may instead exceed the user’s deadline. All these should be included in calculating the total time and cost of generating an acceptable program.
Report the fraction of problems with at least one passing solution among ten programs generated under the stated sampling conditions. If measured, separately report the fraction where the first program or the program chosen by the deployed selector passed. Failing that, there is no indication of the success rate for the first program a user would receive.