IN THIS BREAKDOWN · 10 SECTIONS
You can read 20% of this breakdown.
The paper in one minute
Before this paper, generated code was usually graded by comparing it with a reference solution, token by token or with BLEU. A correct program that names its variables differently scores poorly; a broken program that looks like the reference scores well. The authors propose grading by execution: run the generated function against unit tests, the way a developer would accept a pull request.
To do that without training-set leakage they wrote HumanEval: 164 Python problems by hand, each with a function signature, a docstring, a reference body and an average of 7.7 unit tests. The problems test language comprehension, simple algorithms and arithmetic, some at the level of an easy interview question. They then fine-tuned GPT models of up to 12 billion parameters on 159 GB of Python collected from 54 million public GitHub repositories in May 2020, and called the result Codex. A descendant powered GitHub Copilot.
The metric is pass@k: draw k samples per problem and count the problem solved if any one passes. Computing it naively from exactly k samples is noisy, so the paper draws n = 200 samples and uses an unbiased estimator, 1 - C(n-c, k)/C(n, k) where c samples passed. With one sample, Codex-12B passed 28.8% of problems, GPT-J 11.4% and every GPT-3 model close to 0%. With 100 samples, at least one passed for 72.3%. A further fine-tune on about 50,000 standalone functions with tests, Codex-S, reached 37.7% with one sample and 77.5% with 100.
The paper also studies how to choose one sample without tests (mean log-probability works best), a docstring-writing model (Codex-D), the APPS contest benchmark, limitations on long specifications, and a broad hazard analysis.
Research notes: the problem, approach and results
Codex-12B, one sample against at least one passing sample among 100 (Table 1)
Codex-S-12B picking 1 of 100 samples by mean log-probability against picking by unit tests (Section 1)
95% interval on a 28.8% pass@1 measured on 164 problems (our calculation)
Code models were scored by BLEU or exact match against a reference solution. Neither tells you whether the code works, and many different programs are correct. Public benchmarks built from GitHub or contest sites were also likely to be in the training data.
Write 164 new Python problems by hand, each a signature, a docstring and unit tests, and count a problem solved when generated code passes the tests. Define pass@k, the chance that at least one of k samples passes, with an unbiased estimator from n samples.
Codex-12B, GPT fine-tuned on 159 GB of GitHub Python, solved 28.8% with one sample; GPT-3 solved none and GPT-J 11.4%. With 100 samples per problem 72.3% had a passing one. Fine-tuning on standalone functions (Codex-S) raised one-sample accuracy to 37.7%.
Why it matters to an FDE
Grade generated code by running it. When a customer wants a model that writes SQL, scripts or transformations, the evaluation that matters is whether the output executes and produces the right result on test inputs. The paper's Figure 8 shows that wrong programs often score higher BLEU than right ones, so a text-similarity score can rank the worse model first.
Pick the k that matches the product. An autocomplete shows one suggestion, so pass@1 is the number. An agent that can run tests and retry is closer to pass@k, because it can throw away samples that fail. The gap is large: 28.8% against 72.3% for the same model. Quoting pass@100 for a product that shows one answer overstates it by more than a factor of two.
Tune the temperature to k. The best temperature for pass@1 was 0.2 and for pass@100 was 0.8. If you sample many candidates and filter, low temperature wastes the budget on near-duplicates.
Run generated code in a sandbox. The authors executed untrusted code inside gVisor containers with eBPF firewall rules blocking network access. Any customer system that executes model-written code needs the same isolation before it needs a better model.
Know how wide your test set's error bar is. With 164 problems, a 28.8% score carries a 95% interval of about plus or minus 7 points. Two models a few points apart on HumanEval are not separated by it, and the same holds for a customer's own 150-item golden set.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 290 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
The benchmark, pass@k and its estimator, the model family, selection without tests, and limits
Free account - 04How it works
The data, the model, sampling and stop sequences, the estimator, the sandbox, and Codex-S
Premium - 05The numbers that matter
Table 1 by model, Codex-S, selection heuristics, APPS, Codex-D and the chained-docstring test
Premium - 06Try it yourself
Test the pass@k estimators, recheck Table 1 and its error bars, and run two of the paper's own specs
Premium - 07Where it breaks
Short standalone functions, small test suites, leakage over time, an oracle pass@k, and slips
Premium - 08Using it on a deployment
Build an execution-based eval, decide where sampling and tests sit, and size the test set
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
