Run the code
Code can be checked by running it. HumanEval has 164 Python problems, each a function signature and docstring with hidden unit tests; a program is right if it passes all of them, whatever its text looks like. Here Qwen2.5-Coder-0.5B-Instruct writes programs for 20 of them (every eighth, HumanEval/0, /8 … /152), with EvalPlus's instruct prompt: the problem in a markdown block and the answer already begun with an opening ```python fence. The program is what it writes up to its closing fence.
Each problem gets a greedy program and 20 sampled programs at each of two temperatures. The 20 sampled programs and the greedy one panel lists them with their test results and shades the selected program's tokens by how surprising each draw was. Below the test run, Where the samples left the greedy program shows the step where a sample first chose a different token from the greedy program, and the distribution it drew from.
HumanEval/0 asks whether any two numbers in a list are closer than a threshold. The greedy program compares only neighbours in the unsorted list and fails. At = 0.2, 14 samples do the same and the 6 that compare every pair pass; at = 0.8, 8 compare every pair and 3 of the 4 that sort the list first pass.
Sampling n programs
A sample draws every token from the model's distribution after dividing the logits by a temperature , keeping the 50 most likely tokens and then the smallest set whose probability reaches 0.95 (top-p, Holtzman et al.). Each program has its own stream of uniforms (program of HumanEval/ is seeded ), and the same stream is used at both temperatures, so = 0.2 and = 0.8 differ only in the distribution each uniform falls on. Every recorded token reproduces from its logits and its seed.
At = 0.2 the distribution is sharp and samples repeat the greedy program: 161 of the 400 samples are exactly the greedy program, and the 400 hold 177 different programs (counted per problem). At = 0.8, 15 are the greedy program and 373 differ.
The sandbox
A program is untrusted code, so each one runs in a fresh temporary folder under macOS's sandbox-exec, which denies network access, forking and writing outside that folder, with Python in isolated mode and HumanEval's limit of 3 seconds. The Running it against the tests panel shows the program as HumanEval's harness assembles it: the prompt's imports, the code, the tests and check(entry_point); it passes if it exits cleanly. Before trusting it, the recorder checked the sandbox: HumanEval's reference solutions all pass in it, an empty function body never does, and probe programs could neither reach the network nor write outside their folder.
Of the 820 programs (20 greedy and 800 samples), 478 passed. A wrong answer, an AssertionError from the tests, is by far the most common failure (264); then NameError (28) and IndexError (18). No program ran out of time.
The unbiased estimator
pass@k is the probability that at least one of programs passes, averaged over problems. Drawing exactly programs per problem gives a noisy estimate; Chen et al. draw , count the that pass, and compute the chance that of the , picked without replacement, include a passing one:
This is unbiased: its expectation over the samples is the true pass@. The tempting , which treats the draws as independent at the observed pass rate, is not: is convex in , so by Jensen's inequality the naive estimate is too low on average. It is also never above the unbiased one for any one problem, since . The pass@k chart draws both, and the draw k at random button estimates the formula by hand from the recorded results.
Over the 20 problems pass@1, the mean share of passing samples, is 62.8 % at = 0.2 and 53.8 % at = 0.8, where both estimators agree. pass@10 is 85.7 % and 79.8 % (naive: 83.9 % and 79.4 %). At the unbiased estimate is just the share of problems with some passing sample, 90.0 % and 80.0 %, where the naive one gives 87.4 % and 79.9 %. Greedy decoding solves 12 of the 20 problems (60 %).
The hotter samples did not pay here
A low temperature keeps samples close to the greedy program, which is good for pass@1 but adds little with each extra sample; a high temperature makes each sample worse on average but more varied, so it may solve a problem the cooler samples never do. Chen et al. found the best temperature rising with : 0.2 for pass@1 and 0.8 for pass@100, with Codex-12B.
Here = 0.2 is ahead at every from 1 to 20. The hotter samples solve 4 problems more often (HumanEval/0 in 11 of 20 against 6, HumanEval/72 in 17 of 20 against 14, HumanEval/104 in 10 of 20 against 3, HumanEval/128 in 4 of 20 against 2), but no problem only at = 0.8, and they lose two that the cooler samples solve: HumanEval/64 (1 of 20 at = 0.2) and HumanEval/80 (5 of 20 at = 0.2, and greedy). = 0.8's curve levels off at 80.0 % by = 13, while = 0.2's keeps rising to 90.0 %. With 20 samples per problem this run cannot say whether = 0.8 would overtake at the of 100 where Chen et al. found it best.
Two problems, HumanEval/32 and HumanEval/120, get no passing program at either temperature or from greedy decoding.
Where it came from
Kulal et al. (SPoC) counted a problem as solved if any of generated programs passed its tests. Chen et al. introduced HumanEval with Codex in 2021, with the unbiased estimator and its numerically stable form, and sandboxed execution. Liu et al. (EvalPlus) added many more tests per problem, which reject programs the original tests let through, and the instruct prompt used here. Brown et al. (Large Language Monkeys) followed coverage, pass@ for very large , over orders of magnitude of samples; the Self-consistency and Best-of-N tabs in the Reasoning Explainer spend the same kind of samples on maths and pick among them without a test to run.
Papers
- Evaluating Large Language Models Trained on Code Introduces HumanEval, runs sampled programs against unit tests, and derives the unbiased pass@k estimator and its numerically stable form.
- SPoC: Search-based Pseudocode to Code Where pass@k comes from: a problem counts as solved if any of k generated programs passes its tests.
- Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation EvalPlus: the instruct prompt used here, and many more tests per HumanEval problem, which catch programs the original tests let through.
- Qwen2.5-Coder Technical Report The model sampled here, Qwen2.5-Coder-0.5B-Instruct, evaluated on HumanEval with EvalPlus.
- The Curious Case of Neural Text Degeneration Nucleus (top-p) sampling, which keeps the smallest set of likely tokens whose probability reaches p.
- Large Language Monkeys: Scaling Inference Compute with Repeated Sampling Follows coverage, pass@k at very large k, over orders of magnitude of samples and uses the same unbiased estimator.
See also
- Post-trainingGRPO GRPO · group-relative policy optimization
- ReasoningSelf-consistency Self-consistency · a majority vote over sampled answers
- ReasoningRepeated sampling Repeated sampling compared · the vote and the reward model on the same answers
- AgentsCodeAct CodeAct · actions written as Python and run