ArXiv: 2107.03374

🎯 Pitch

Simply sampling 100 solutions from Codex and picking the one that looks most plausible to the model itself solves 70.2% of coding problems that no prior language model could even touch. This brute-force strategy transforms a complete failure into a 77.5% solve rate, but only works because base competence already exists—a critical caveat for scaling hopes.


1. Executive Summary

This paper introduces Codex, a GPT language model fine-tuned on publicly available code from GitHub, and systematically studies its Python code-writing capabilities on a new hand-written evaluation set called HumanEval. The work establishes two core mechanisms for improving functional correctness: supervised fine-tuning on a distribution of correctly implemented standalone functions—producing Codex-S, which narrows the gap between pretraining and evaluation distributions—and repeated sampling from the model (generating multiple candidate solutions per problem and selecting one via oracle unit tests or mean log-probability ranking). A 12B-parameter Codex solves 28.8% of HumanEval problems with a single sample, while repeated sampling with 100 samples per problem pushes the Codex-S model to solve 77.5% of problems, establishing that accurate code samples can be selected via heuristic ranking without full test evaluation—though this amplification strategy succeeds only when the base model already possesses non-trivial capability on the target distribution.

2. Context and Motivation

The Core Problem: Code Generation from Natural Language Is Poorly Benchmarked

The fundamental challenge this paper addresses is deceptively simple: when a language model generates code from a natural language description, how do we know if it's actually correct? This matters because—unlike natural language generation where outputs are open-ended and evaluated subjectively—code has an objective correctness criterion: it either executes properly and produces the right outputs, or it doesn't. Yet the field, at the time of this paper's writing, was evaluating code generation models using metrics borrowed from natural language generation that fundamentally fail to capture this binary reality.

The paper identifies a clear gap between how code is evaluated in practice (by running it) and how generative code models were being benchmarked in the research community (by comparing generated text against reference solutions using surface-form matching). The consequence of this gap is that the research community lacked a reliable way to measure progress on the task of synthesizing correct programs from natural language specifications. If model A scores higher on BLEU than model B, does that mean it produces more functionally correct code? The paper demonstrates—through Figure 8's overlapping BLEU distributions for correct and incorrect solutions—that the answer is often no. A wrong program can have a high BLEU score (and vice versa), making surface-form metrics actively misleading as proxies for what users actually care about: does the code work?

Why This Problem Matters

The significance of this gap extends beyond academic benchmarking concerns into practical deployment realities. The paper frames this urgency along several dimensions:

1. Code generation models were already being deployed in production. The paper's research models descended into GitHub Copilot and the OpenAI API Codex models, meaning that the evaluation gap wasn't hypothetical—it directly affected how developers and organizations would assess whether these tools were reliable enough to integrate into their workflows. An evaluation framework that rewards models for producing syntactically similar but functionally wrong code could lead to overestimating model capability and premature or unsafe deployment.

2. Code correctness has downstream safety implications. Unlike generating a slightly inaccurate text summary, generating incorrect code that nevertheless looks plausible can introduce security vulnerabilities, logic errors, or system failures when executed. The paper's broader impacts analysis (Section 7) explicitly connects evaluation quality to safety: if users over-rely on code generation models because surface-level evaluations make them appear more capable than they are, the consequences can range from buggy software to exploitable security flaws.

3. The space of correct programs is inherently large and complex. As the paper notes in Section 2.1, match-based metrics are "unable to account for the large and complex space of programs functionally equivalent to a reference solution." Two programs can be correct solutions to the same specification while sharing almost no tokens in common—they may use different algorithms, different control flow structures, different variable names, different library calls, and different implementation strategies entirely. A metric that penalizes valid diversity by anchoring to a single reference solution is fundamentally misaligned with the task's evaluation requirements. This isn't a minor adjustment issue; it's a structural mismatch between the metric space and the correctness space.

4. The field needed a common, principled benchmark. At the time, different papers were evaluating code generation using different datasets, different metrics, and different evaluation protocols, making it impossible to compare progress across approaches. The paper's release of HumanEval—a hand-written, unit-test-based evaluation set with a precisely defined statistical estimator (pass@k)—aims to provide exactly this common ground. The authors explicitly frame this as enabling "others to evaluate functional correctness and measure the problem-solving capabilities of their models" (Section 2.2).

Prior Approaches and Their Shortcomings

The paper identifies several existing approaches to evaluating code generation, each with documented deficiencies:

1. Match-based metrics (exact match, BLEU score). The dominant approach in prior work was to compare generated code against a reference solution by treating code as text. BLEU score, originally developed for machine translation evaluation, measures n-gram overlap between generated and reference text. As the paper notes, Ren et al. (2020) "finds that BLEU has problems capturing semantic features specific to code, and suggests several semantic modifications to the score." More fundamentally, as discussed above, the sheer size of the functionally equivalent program space means that any fixed reference solution penalizes perfectly correct programs that happen to differ in implementation. The paper provides direct evidence for this claim in Figure 8: for four randomly selected HumanEval problems, the distributions of BLEU scores for correct and incorrect Codex-12B solutions overlap substantially. Since incorrect solutions are guaranteed to be functionally inequivalent to the reference (they fail at least one unit test), the overlap demonstrates that BLEU scores cannot cleanly separate working from non-working code.

The paper states this conclusion directly:

"Since an incorrect solution is guaranteed to be functionally inequivalent to the reference solution, we conclude that improvements in BLEU score may not indicate improved rates of functional correctness in practice."

This is a strong claim with direct methodological implications: if you optimize your model for BLEU score, you may be steering it away from functional correctness without realizing it.

2. Human evaluation. While human judgment avoids the surface-form problem, the paper implicitly argues that it doesn't scale for rigorous benchmarking. HumanEval's 164 problems with an average of 7.7 unit tests each would require human evaluators to carefully read, understand, and manually reason about the correctness of every generated candidate—a prohibitively expensive process, especially when evaluating pass@100 (where up to 100 samples per problem must be assessed). The paper's docstring generation evaluation (Section 5) illustrates this tension directly: for that task, where no automatic correctness check exists, the authors had to resort to hand-grading 10 samples per problem for 164 problems (1,640 total evaluations), and they explicitly note the "time consuming nature of this process." Functional correctness via unit tests sidesteps this bottleneck.

3. Existing benchmarks had data contamination problems. The paper argues that benchmarks built from publicly available coding problems (like competitive programming websites) are compromised for evaluating models trained on GitHub, because the training data "already contains solutions to problems from a variety of sources." Specifically:

"there are more than ten public repositories containing solutions to Codeforces problems, which make up part of the recently proposed APPS dataset"

This is a critical methodological point: if a model has already seen (and potentially memorized) solutions to evaluation problems during training, its test performance may reflect memorization rather than genuine synthesis capability. The HumanEval dataset was designed to avoid this by being hand-written by the authors specifically for this evaluation, with problems not programmatically copied from existing sources.

4. Prior code generation models showed limited capability. The paper positions its work against a backdrop where existing general-purpose language models (GPT-3, GPT-J, GPT-Neo) had demonstrated some rudimentary code generation ability but at very low success rates on rigorous evaluation. As stated in the introduction:

"our early investigation of GPT-3 revealed that it could generate simple programs from Python docstrings. While rudimentary, this capability was exciting because GPT-3 was not explicitly trained for code generation."

The paper's Table 1 quantifies this gap: GPT-Neo-2.7B achieves 6.4% pass@1 on HumanEval, while all GPT models score near 0%. The key question the paper investigates is: what happens when you deliberately train on code, at scale, and evaluate with the right metric?

5. The pass@k metric existed but was statistically flawed. Kulal et al. (2019) introduced the concept of pass@k in the context of pseudocode-to-code translation (SPoC), evaluating functional correctness by checking whether at least one of k generated samples passes unit tests. However, the paper identifies a subtle but important statistical problem with how pass@k was typically computed. The naive estimator—generate exactly k samples, check if any pass, and report the fraction of problems solved—has high variance because the binary outcome ("at least one correct in k samples") is a noisy estimate when k is small or the base success rate is low. More problematically, some practitioners were estimating pass@k using the formula 1(1p^)k1 - (1 - \hat{p})^k where p^\hat{p} is the empirical pass@1 rate—but the paper proves in Appendix A that this is a biased underestimate of the true pass@k. Figure 13 in the appendix visualizes this bias: the gap between the biased and unbiased estimators "doesn't fully close even when n>5kn > 5k."

The paper's key statistical contribution here is Equation 1, which provides an unbiased estimator for pass@k using nkn \geq k total samples per problem:

pass@k:=EProblems[1(nck)(nk)]\text{pass@k} := \mathbb{E}_{\text{Problems}} \left[ 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} \right]

where cc is the number of correct samples among nn total samples. The paper walks through why this is unbiased: it computes the probability that, when drawing kk samples without replacement from nn total samples (of which cc are correct), at least one is correct. This is 11 minus the probability that all kk drawn samples are incorrect—which is exactly the hypergeometric tail probability (nck)(nk)\frac{\binom{n-c}{k}}{\binom{n}{k}}. For cases where nc<kn - c < k (fewer incorrect samples than the number being drawn), the probability of drawing all incorrect samples is zero, so the estimator correctly evaluates to 1.01.0.

The implementation in Figure 3 further addresses the practical challenge of numerical stability: computing binomial coefficients directly with large nn and kk produces enormous numbers. The provided numpy code reframes the computation as a product of terms, each of which is a probability bounded between 0 and 1:

return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))

This is a genuinely useful methodological contribution: it enables researchers to fairly compare pass@k across experiments with different total sample counts nn, avoiding both bias and numerical instability.

How This Paper Positions Itself

The paper frames its contribution at the intersection of several research traditions while distinguishing itself along clear dimensions:

Relative to scaling laws work in language modeling. The paper explicitly builds on the scaling laws framework established by Kaplan et al. (2020) for language models, demonstrating that code fine-tuning follows a similar power law: test loss scales as (N/5.92×107)0.13(N / 5.92 \times 10^7)^{-0.13} where NN is non-embedding parameters (Figure 4, Section 3.3). This positions code generation as a domain where the same scaling principles apply, suggesting that the rapid progress observed in natural language through model scaling should also manifest in code. The paper doesn't claim to discover scaling laws—it shows they transfer to a new domain and modality, which is a validation of the scaling paradigm rather than a novel theoretical contribution.

Relative to program synthesis and induction research. The paper's Related Work section (Section 8) situates Codex within the broader program learning literature, acknowledging work on program induction (where models generate outputs directly from latent program representations) and program synthesis (where models explicitly generate programs from specifications). Historically, these approaches used techniques like probabilistic context-free grammars over abstract syntax trees (Maddison & Tarlow, 2014), character-level language models with latent predictor networks (Ling et al., 2016), and search-based methods guided by predicted program attributes (Balog et al., 2017). The paper positions Codex as a departure from these structured approaches: rather than imposing syntactic constraints through grammar-based decoding or representing programs through explicit intermediate representations, Codex generates raw text tokens and relies on scale and data to learn program structure implicitly. This is the same architectural philosophy that made GPT-3 successful—avoid hand-crafted inductive biases and let the model discover structure from data—applied to code rather than natural language.

Relative to contemporaneous code models. The paper acknowledges two closely related efforts: CodeBERT (Feng et al., 2020), which applied BERT-style masked language modeling to paired docstrings and functions for code search tasks, and PyMT5 (Clement et al., 2020), which used the T5 objective to train multi-mode translation between subsets of {signature, docstring, body}. The key distinction the paper makes is architectural and scale-driven: Codex uses autoregressive left-to-right generation (GPT architecture) rather than encoder-decoder or bidirectional architectures, and operates at a scale (up to 12B parameters) that was unprecedented for code-specific models at the time. The paper doesn't claim architectural novelty—it claims that deliberate code-focused training at scale, combined with rigorous functional correctness evaluation, reveals capabilities that general-purpose language models and smaller code models failed to demonstrate.

Relative to the APPS benchmark. Hendrycks et al. (2021) released the APPS dataset contemporaneously with this paper, also measuring functional correctness on coding problems. The paper benchmarks Codex on APPS (Section 3.5, Table 2) but positions APPS as measuring a different capability than HumanEval. APPS problems are drawn from competitive programming and typically require full-program synthesis (reading from stdin, printing to stdout), which differs from the single-function synthesis from docstrings that constitutes the main Codex training distribution and HumanEval evaluation. The paper's APPS results—which required appending an input/output example as a formatting hint ("1-shot") and using filtering based on public test cases—demonstrate that Codex's capabilities transfer to out-of-distribution problem formats, but with substantially lower success rates (e.g., 25.02% pass@1000 on introductory problems vs. 72.31% pass@100 on HumanEval). This reinforces the paper's implicit argument that distribution matching matters: the gap between in-distribution (HumanEval) and out-of-distribution (APPS) performance motivates the supervised fine-tuning approach (Codex-S) that explicitly aligns the training distribution with the evaluation task.

The paper's central thesis, restated. The paper's core argument is that code generation should be evaluated by functional correctness (does the code pass unit tests?), that the appropriate metric for this is the unbiased pass@k estimator, and that scaling a GPT model on code with distribution-matched fine-tuning produces models that perform well on this metric. The repeated sampling finding—that generating many samples and selecting the best one dramatically improves success rates—is presented not as a method in itself but as evidence that the model's internal distribution contains correct solutions for many more problems than a single sample reveals, motivating future work on better selection heuristics (mean log-probability, back-translation) and deployment strategies.

3. Technical Approach

3.1 Reader Orientation

The system is a large autoregressive language model—Codex—that generates Python code from natural language docstrings, evaluated by executing the generated code against unit tests rather than comparing it textually to a reference solution. The core problem it solves is synthesizing functionally correct programs from natural language specifications, and the "shape" of the solution is: take a GPT model pretrained on natural language, fine-tune it on a massive corpus of publicly available GitHub code, optionally further fine-tune it on a curated distribution of standalone correctly-implemented functions (producing Codex-S), and at inference time generate multiple candidate solutions per prompt, selecting the best one either via oracle unit tests or via heuristic ranking based on mean token log-probability.

3.2 Big-Picture Architecture (Diagram in Words)

The system has five major components:

  1. Base GPT model (pretrained on natural language) — provides strong natural language representations that serve as the starting point for code fine-tuning. The model family spans from 12M to 12B non-embedding parameters.

  2. GitHub code corpus (159 GB of Python) — the fine-tuning dataset, collected from 54 million public repositories, filtered to remove auto-generated files, unusually long lines, and files with low alphanumeric character density.

  3. Codex tokenizer (GPT-3 tokenizer + whitespace tokens) — extends the GPT-3 text tokenizer with additional tokens for representing runs of whitespace of different lengths, reducing token count by approximately 30% for code.

  4. Supervised fine-tuning dataset (10,000 + 40,000 problems) — a curated collection of standalone, correctly implemented functions sourced from competitive programming websites and from tracing continuous integration pipelines, used to further fine-tune Codex into Codex-S.

  5. HumanEval evaluation framework — 164 hand-written programming problems, each with a function signature, docstring, reference body, and an average of 7.7 unit tests. Models generate candidate completions; the sandbox (gVisor-based container runtime with eBPF firewall rules) safely executes them against unit tests; the unbiased pass@k estimator computes the fraction of problems solved with at most k attempts.

Information flows as follows: a natural language prompt (function signature + docstring) enters the system → the model samples tokens autoregressively using nucleus sampling (top p = 0.95) until a stop sequence is encountered (\nclass, \ndef, \n#, \nif, or \nprint) → the generated function body is concatenated with the prompt and executed in the sandbox against the problem's unit tests → correctness (pass/fail) is recorded → this process repeats n times per problem (typically n = 200) → the pass@k metric is computed from the counts of correct samples across all problems.

3.3 Roadmap for the Deep Dive

  • First, the data collection and filtering pipeline (Section 3.1), since the composition and quality of the training data directly determines what the model can learn.
  • Second, the training methodology—the GPT fine-tuning procedure, the tokenizer modifications, and the learning schedule—because these are the engineering levers that convert raw GitHub code into a functioning code generation model.
  • Third, the evaluation framework—the HumanEval dataset construction, the unbiased pass@k estimator and why it matters, and the sandbox execution environment—since the paper's central methodological contribution is redefining how code generation is evaluated.
  • Fourth, the inference-time sampling strategy—nucleus sampling parameters, temperature optimization per value of k, and stop sequences—because the choice of decoding strategy interacts strongly with the pass@k metric.
  • Fifth, the sample selection heuristics—mean log-probability ranking and back-translation—since these bridge the gap between the oracle pass@k metric and practical deployment without unit tests.
  • Sixth, the supervised fine-tuning pipeline (Codex-S)—data collection from competitive programming and continuous integration, problem filtering, and training—because this demonstrates how aligning the training distribution with the evaluation distribution yields substantial gains.
  • Seventh, the docstring generation model (Codex-D) as a byproduct that also enables back-translation-based sample selection.

3.4 Detailed, Sentence-Based Technical Breakdown

This is primarily an empirical scaling and evaluation paper whose core idea is that training a sufficiently large language model on code, and evaluating it by executing the generated code against unit tests rather than by surface-form matching, reveals capabilities that general-purpose language models and smaller code-specific models fail to demonstrate.


Data Collection and Filtering

The training dataset was collected in May 2020 from 54 million public software repositories hosted on GitHub, containing 179 GB of unique Python files each under 1 MB in size. The choice of Python as the primary language reflects its popularity, readability, and strong representation in open-source repositories, as well as the paper's focus on the specific task of synthesizing standalone functions from docstrings.

Raw GitHub repositories contain substantial noise unsuitable for training a code generation model. The paper applies four filtering criteria to remove low-quality files:

  1. Auto-generated file removal: files that were "likely auto-generated" are filtered out—though the paper does not specify the exact detection mechanism, typical approaches involve pattern matching against common code generation tool signatures or heuristics based on comment-to-code ratios.

  2. Average line length filter: files with average line length greater than 100 characters are removed, since unusually long lines often indicate minified code, data files, or machine-generated output rather than human-written source code.

  3. Maximum line length filter: files with maximum line length greater than 1000 characters are removed, capturing extreme outliers that would distort the tokenizer's whitespace handling and make the training distribution less representative of typical code.

  4. Alphanumeric density filter: files containing "a small percentage of alphanumeric characters" are removed, which filters out binary files, base64-encoded data, and other non-code artifacts that happen to have .py extensions.

After filtering, the final dataset totaled 159 GB—a reduction of approximately 11% from the raw 179 GB, indicating that the filtering is conservative and retains the vast majority of human-written Python code. The paper notes that this dataset represents "a significant fraction of publicly available Python code on GitHub" and contains "hundreds of millions of lines of code" (Section 6, Limitations), far exceeding what any human developer would encounter over an entire career.

A critical design choice the paper makes implicitly: no deduplication or contamination filtering against evaluation benchmarks is described in the data collection pipeline, beyond the removal of auto-generated files. This is notable because the HumanEval dataset was explicitly designed to be hand-written and not programmatically copied from existing sources, but the training data likely contains code that is functionally similar to HumanEval problems even if not identical. The paper's recognition of this issue—specifically calling out that "there are more than ten public repositories containing solutions to Codeforces problems" in the APPS dataset—motivates the hand-written nature of HumanEval but does not extend to filtering the training data itself. This means that some fraction of Codex's performance may reflect memorization of near-duplicate solutions rather than genuine synthesis from docstrings, though the paper's analysis of memorization in Section 7.7 (finding <0.1% identical code generation) suggests this effect is limited.


Training Methodology: From GPT to Codex

The paper's central training decision is to fine-tune from pretrained GPT models rather than training a code model from scratch. The stated motivation is that "Codex is evaluated on natural language prompts" and therefore benefits from GPT's "strong natural language representations." Interestingly, the paper reports a counterintuitive empirical finding:

"Surprisingly, we did not observe improvements when starting from a pre-trained language model, possibly because the fine-tuning dataset is so large."

In other words, training a randomly initialized model on the 159 GB code corpus yields comparable final performance to fine-tuning from GPT pretrained weights. However, the paper still uses GPT initialization because "models fine-tuned from GPT converge more quickly," which provides practical benefits in terms of training compute and experimentation velocity. This is an important qualification: the gains from natural language pretraining are about convergence speed rather than asymptotic performance, at least at the scale of the code fine-tuning dataset used.

The training procedure uses the same hyperparameter settings as the corresponding GPT models, with the following specifics:

  • Optimizer: Adam with β1 = 0.9, β2 = 0.95, ε = 10^{-8}, and a weight decay coefficient of 0.1. This is the standard GPT-3 optimizer configuration, chosen for consistency rather than through code-specific optimization.

  • Learning rate schedule: a 175-step linear warmup followed by cosine learning rate decay. The base learning rate matches that of the corresponding GPT model size. The paper does not report the specific learning rate values (these are model-size-dependent in the GPT-3 family), but the key design choice is that they are not re-tuned for code—the paper inherits the language model hyperparameters wholesale, presumably because the similarity between language modeling and code modeling objectives makes re-tuning unnecessary.

  • Training duration: a total of 100 billion tokens. This is the total number of tokens seen during code fine-tuning, not including the tokens seen during the original GPT pretraining. For context, 100 billion tokens at approximately 30% token reduction (from the whitespace tokenizer improvement) corresponds to roughly 70 billion tokens of original GPT-3 tokenizer equivalents, or about 159 GB / (average bytes per token). This suggests the model sees each token in the training corpus multiple times on average, though the paper does not report the exact number of epochs.

  • Model sizes: the paper trains models spanning from 12M to 12B non-embedding parameters. The non-embedding parameter count excludes the token embedding matrix and positional embeddings, following the convention established in Kaplan et al. (2020) for clean power-law fitting. For context, the 12B parameter model represents a scale that, at the time of publication, was among the largest publicly documented models specifically trained for code generation.

The training objective is standard autoregressive language modeling: maximize the log-likelihood of each token given all previous tokens in the sequence. There is no task-specific objective, no code-specific loss term, and no structural supervision (e.g., abstract syntax tree validity). The model learns code structure purely from the next-token prediction signal, relying on the scale of the model and data to capture syntactic and semantic regularities implicitly.


Tokenizer Modifications: Whitespace-Aware Encoding

A significant technical detail is the modification to the GPT-3 tokenizer to better handle code. The paper identifies a fundamental inefficiency in applying a text-trained tokenizer to code:

"Since the distribution of words in GitHub code differs from that of natural text, this tokenizer is not very effective for representing code. The largest source of inefficiency arises from encoding whitespace."

In natural language, whitespace is sparse and semantically simple—spaces separate words, and newlines separate paragraphs. In Python code, whitespace carries syntactic meaning (indentation determines block structure), and code contains long runs of spaces that consume many tokens when each space is encoded individually. For example, a line indented with 16 spaces would consume 16 tokens in the original GPT-3 tokenizer, one per space character.

The solution is to "add an additional set of tokens for representing whitespace runs of different lengths." Specifically, the vocabulary is extended with tokens that encode whitespace sequences of varying lengths—a single token might represent 2 spaces, 4 spaces, 8 spaces, etc., rather than requiring individual space tokens. The paper reports that this modification "allows us to represent code using approximately 30% fewer tokens."

The practical implications of this 30% reduction are significant:

  • Training efficiency: a 30% reduction in tokens means the model can process 30% more code per training step, effectively increasing the information density of each gradient update. For a fixed budget of 100 billion tokens, the model sees 30% more effective code content.

  • Context window utilization: the GPT architecture has a fixed context window (typically 2048 tokens for models of this era). By reducing the token count for a given amount of code, the model can fit longer functions, more context, or more in-context examples within the same window. This is particularly important for code, where a single function might span hundreds of lines and would otherwise fill the context window quickly due to indentation spaces.

  • Inference cost: generating code requires fewer tokens per function, reducing both latency and computational cost at deployment time.

The paper does not specify the exact number of whitespace tokens added, their precise encoding scheme (e.g., whether they use a fixed set of run-lengths or a more adaptive encoding), or whether the whitespace tokens are added to the vocabulary before or after the GPT-3 tokenizer's existing tokens. This is a notable omission given the practical importance of this modification—but the key takeaway is that a relatively simple vocabulary extension recovers substantial efficiency that would otherwise be lost when applying text-optimized tokenizers to code.


The HumanEval Dataset and Evaluation Framework

The HumanEval dataset is a collection of 164 hand-written programming problems designed specifically to evaluate functional correctness of code generation from docstrings. Each problem consists of:

  • Function signature: the Python function definition line (e.g., def words_string(s):), which specifies the function name and parameter names with type hints in some cases.
  • Docstring: a natural language description of what the function should do, including example input-output pairs in many cases (formatted as doctest-style >>> examples).
  • Reference solution: a correct implementation of the function, not shown to the model but used as a ground-truth comparison in some analyses.
  • Unit tests: an average of 7.7 tests per problem, implemented as assert statements that check the function's output against expected values for specific inputs.

The problems assess "language comprehension, reasoning, algorithms, and simple mathematics, with some comparable to simple software interview questions." The difficulty ranges from straightforward string manipulation tasks (like splitting a string on commas and spaces) to algorithmic problems requiring specific computational approaches (like prime checking or palindrome counting). Figure 2 in the paper shows three example problems at three difficulty levels, with single-sample solve rates of 0.9, 0.17, and 0.005 for Codex-12B.

The hand-written nature of the dataset is crucial for two reasons:

  1. Contamination avoidance: since Codex was trained on a large fraction of public GitHub repositories, any benchmark derived from existing public code (like competitive programming solutions) risks measuring memorization rather than synthesis. By writing problems from scratch, the authors ensure that exact solutions are not present in the training data—though functionally similar code almost certainly is.

  2. Controlled difficulty and scope: the problems are designed to test specific capabilities (language understanding, algorithmic reasoning, mathematical operations) in a way that enables systematic analysis of model strengths and weaknesses. The synthetic building-block experiments in Section 6 (where docstrings are constructed by chaining 13 basic string manipulation operations) leverage this controlled design to measure performance degradation as a function of specification complexity.

The authors release the dataset publicly at https://www.github.com/openai/human-eval along with an evaluation framework, establishing it as a community benchmark. This is a deliberate attempt to provide the field with a common, principled evaluation standard that the paper argues was missing.


The Unbiased Pass@k Estimator

The pass@k metric measures the probability that at least one of k generated samples passes all unit tests for a given problem. It captures a realistic deployment scenario: when a developer uses a code generation tool, they might generate multiple suggestions and evaluate each one, succeeding if any suggestion is correct. The paper makes both a statistical and a computational contribution to how this metric is estimated.

The naive estimator and its bias. A natural approach to estimating pass@k is to generate exactly k samples per problem, check if at least one passes, and report the fraction of problems solved. This estimator has high variance, especially when k is small and the per-sample success probability is low. A more serious problem arises when researchers try to estimate pass@k from pass@1 using the formula 1(1p^)k1 - (1 - \hat{p})^k, where p^\hat{p} is the empirical pass@1 rate computed from n samples. As the paper proves in Appendix A, this formula is a biased underestimate of the true pass@k. The bias arises because p^\hat{p} is estimated from the same pool of n samples that would be used for pass@k, creating a dependency that violates the independence assumption underlying the formula. Figure 13 in the appendix quantifies this: the bias persists even when n > 5k, and "results can seem better with more samples" if the biased estimator is used.

The unbiased estimator. The paper proposes estimating pass@k using n ≥ k total samples per problem, of which c ≤ n are correct (pass all unit tests). The unbiased estimator is:

pass@k:=EProblems[1(nck)(nk)]\text{pass@k} := \mathbb{E}_{\text{Problems}} \left[ 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} \right]

where (nck)\binom{n-c}{k} is the number of ways to choose k incorrect samples from the n-c incorrect samples, (nk)\binom{n}{k} is the number of ways to choose k samples from all n samples, and the expectation is taken over the set of evaluation problems.

What it computes: for a single problem with n total samples and c correct samples, the term (nck)(nk)\frac{\binom{n-c}{k}}{\binom{n}{k}} is the probability that, when drawing k samples uniformly at random without replacement from the pool of n samples, all k are incorrect. Then 1(nck)(nk)1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} is the probability that at least one of the k drawn samples is correct. Taking the expectation across problems converts this per-problem probability into the expected fraction of problems solved by the best-of-k strategy.

Why this form: the estimator is unbiased because it computes the exact hypergeometric probability of failure (drawing k incorrect samples without replacement) and subtracts from 1, rather than using the binomial approximation 1(1p)k1 - (1 - p)^k which assumes independent draws with replacement from an infinite population. The without-replacement formulation correctly accounts for the finite sample pool: if you have n = 200 samples and c = 50 correct ones, the probability of drawing k = 100 samples without finding a correct one is exactly (150100)(200100)\frac{\binom{150}{100}}{\binom{200}{100}}, not (10.25)100(1 - 0.25)^{100}. The estimator is unbiased regardless of n and k, provided n ≥ k, because it directly evaluates the probability under the true sampling procedure.

The numerically stable implementation (Figure 3). Computing binomial coefficients directly produces enormous intermediate values that cause numerical overflow. The implementation reframes the computation:

def pass_at_k(n, c, k):
    if n - c < k: return 1.0
    return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))

The expression np.prod(1.0 - k / np.arange(n - c + 1, n + 1)) computes the product of terms (1knc+1)×(1knc+2)×...×(1kn)(1 - \frac{k}{n-c+1}) \times (1 - \frac{k}{n-c+2}) \times ... \times (1 - \frac{k}{n}). Each term is a probability bounded between 0 and 1, making the computation numerically stable. The early return if n - c < k: return 1.0 handles the edge case where there are fewer incorrect samples than k—in this case, any draw of k samples must include at least one correct sample, so the probability of at least one correct is 1.0.

Practical usage in the paper. The paper generates n = 200 samples per problem and reports pass@k for k ≤ 100, meaning that even for pass@100 the estimator is based on 200 total samples per problem. This ensures low variance in the estimate while remaining computationally feasible. The choice of n = 200 represents a practical tradeoff: larger n would further reduce variance but increase evaluation cost quadratically (since each sample must be executed against unit tests).


Sandbox Execution Environment

Running model-generated code against unit tests poses a genuine security risk because "generated programs are often incorrect" and "GitHub is known to contain malicious programs that alter or change their environments" (Rokon et al., 2020). A model trained on public repositories may have learned to generate code that, intentionally or accidentally, performs harmful operations when executed—deleting files, making network connections, or exploiting system vulnerabilities.

The paper addresses this through a multi-layered sandbox environment built on the following components:

gVisor container runtime: selected as "the main host protection component." Traditional container runtimes like Docker share the host operating system kernel with containers, meaning a malicious container could potentially exploit kernel vulnerabilities to compromise the host. gVisor addresses this by emulating system resources (implementing the Linux kernel interface in user space) to introduce a security boundary between the host and its containers. The emulation layer intercepts system calls from the container and handles them in a restricted userspace kernel, preventing direct access to the host kernel.

eBPF-based firewall rules: network-adjacent hosts and services are protected by eBPF (extended Berkeley Packet Filter) rules that "prevent inbound and outbound connections except for those required for experiment control." eBPF allows programmable packet filtering at the kernel level without modifying kernel code. The firewall rules block all network traffic except explicitly whitelisted connections for experiment management, preventing generated code from exfiltrating data, contacting command-and-control servers, or performing network-based attacks.

Kubernetes and cloud integration: the sandbox is designed to operate within OpenAI's training infrastructure, which is "built on Kubernetes and cloud services." The sandbox design explicitly accounts for the "limitations of these environments while remaining idiomatic with their patterns of use," meaning it integrates with existing container orchestration, scheduling, and resource management without requiring special infrastructure.

The security model's scope is clearly stated: "Our goals were to prevent these programs from modifying, gaining persistence on, accessing sensitive resources on, or exfiltrating data from a host or network." It does not attempt to prevent all possible harms (e.g., infinite loops consuming compute resources are handled by separate timeout mechanisms), and it does not guarantee safety against determined adversaries exploiting zero-day vulnerabilities in the sandbox itself. The timeout for APPS evaluation is set to 3 seconds (Section 3.5), indicating that resource exhaustion is managed through execution time limits rather than the sandbox alone.


Inference-Time Sampling Strategy

At inference time, Codex generates code through autoregressive token sampling governed by several interacting mechanisms:

Prompt construction. Each HumanEval problem is assembled into a prompt consisting of a header (comments describing the task context), a function signature (e.g., def words_string(s):), and the docstring. The prompt ends with the start of the function body (typically a newline and the beginning of the docstring's closing triple-quotes). The model is expected to complete the function body and then stop. Figure 2 in the paper shows the exact prompt format: the header and signature appear on a white background, and the model-generated completion appears on a yellow background.

Stop sequences. The model does not inherently know when a function is complete—left unchecked, it would continue generating additional functions, classes, or comments. The paper defines a set of stop sequences that cause generation to terminate when encountered: \nclass, \ndef, \n#, \nif, or \nprint. These sequences indicate that the model has finished the current function and is beginning a new code construct, at which point further generation is not relevant to the current problem.

The choice of these specific sequences reflects an understanding of Python code structure. A \nclass or \ndef indicates the start of a new class or function definition—the model has moved on from the requested function. A \n# indicates a new comment block that is likely unrelated to the current function. A \nif indicates a top-level conditional that is probably part of a script or test harness rather than a continuation of the function. A \nprint similarly indicates script-level output rather than function logic. This heuristic is not guaranteed to be correct—a function body can contain nested if statements and print calls—but the leading newline before each token distinguishes top-level constructs from indented (function-body) ones.

Nucleus sampling. The paper uses nucleus sampling (Holtzman et al., 2020) with top p = 0.95 for all sampling evaluations. Nucleus sampling truncates the token probability distribution to the smallest set of tokens whose cumulative probability exceeds p = 0.95, then samples from this truncated distribution (with probabilities renormalized). This avoids sampling from the long tail of low-probability tokens while maintaining diversity by not deterministically selecting the single most likely token (as greedy decoding or temperature = 0 would do). The choice of p = 0.95 is the standard value from the original nucleus sampling paper and is used consistently across all Codex experiments, indicating that top-p was not tuned specifically for code generation.

Temperature optimization per k. A critical empirical finding is that the optimal sampling temperature depends on the number of samples k being generated. The paper explores this relationship in Figure 5:

  • For pass@1 (single sample evaluated), the optimal temperature is T* = 0.2 for the 679M parameter model, and T* = 0 for Codex-S-12B (which uses greedy decoding for k = 1). Lower temperatures produce more deterministic, higher-probability tokens, maximizing the chance that the single sample is correct.

  • For pass@100, the optimal temperature is T* = 0.8 for the 679M model and T* = 1.0 for Codex-S-12B. Higher temperatures increase sample diversity by reducing the probability gap between high-probability and low-probability tokens, making the model explore a wider range of possible solutions. This diversity is beneficial when many samples are generated because the metric only rewards whether any sample is correct.

The mechanism behind this tradeoff is straightforward: "higher temperatures are optimal for larger k, because the resulting set of samples has higher diversity, and the metric rewards only whether the model generates any correct solution." At low temperature, the model might generate the same (incorrect) solution 100 times—diversity is low, and pass@100 equals pass@1. At high temperature, the model generates a diverse set of solutions, increasing the probability that at least one is correct even though individual samples are lower-probability.

This temperature-k relationship is important for practical deployment: if you can afford to evaluate multiple samples, you should increase temperature to maximize diversity. If you can only show the user one suggestion, you should lower temperature to maximize the probability that the single suggestion is useful.

Scaling behavior of pass@k with model size. Figure 6 plots pass@1 (at T* = 0.2) and pass@100 (at T* = 0.8) as a function of model size. The paper observes that "performance appears to scale smoothly as a sigmoid in log-parameters." The sigmoid shape means that performance improvements from scaling are largest at intermediate model sizes and diminish at both very small and very large scales—the model eventually approaches some asymptotic performance level on this particular benchmark. Importantly, the gap between pass@1 and pass@100 widens with model size, indicating that larger models not only produce more correct first attempts but also have a broader distribution of correct solutions that repeated sampling can surface.


Sample Selection Heuristics: Beyond Oracle Access

The pass@k metric assumes oracle access to unit tests: given k samples, we can evaluate all of them and select the correct one. In practice, users of a code generation tool do not have unit tests for their specific problem (if they did, they might not need the tool). The paper therefore investigates heuristics for selecting a single sample from k candidates without access to ground-truth correctness.

Mean log-probability ranking. The primary heuristic is to rank samples by their mean token log-probability and select the highest-ranking sample. For a generated sequence of tokens t1,t2,...,tmt_1, t_2, ..., t_m, the mean log-probability is:

1mi=1mlogP(tit1,...,ti1)\frac{1}{m} \sum_{i=1}^{m} \log P(t_i | t_1, ..., t_{i-1})

This is the average per-token log-probability assigned by the model to its own generation. Intuitively, samples with higher mean log-probability are those that the model itself considers more likely—they represent "confident" generations. The paper finds (Figure 7) that this heuristic significantly outperforms random sample selection.

Sum log-probability performs worse than random. An interesting negative result: selecting the sample with the highest sum of log-probabilities (the total sequence log-probability, not normalized by length) can "perform slightly worse than picking randomly." This is because sum log-probability penalizes longer sequences—a short, incorrect solution will have higher sum log-probability than a longer, correct one simply because it has fewer terms in the sum, even if the per-token probabilities are lower. Mean log-probability normalizes for length and avoids this bias.

Back-translation. The paper explores a second heuristic: train a docstring generation model (Codex-D, described in Section 5) that can produce docstrings from code bodies, then use this model to score generated code samples. The back-translation score for a generated code sample is P(original docstringgenerated code)P(\text{original docstring} | \text{generated code}), computed by Codex-D—the probability that the original docstring would be generated from this particular code implementation. The intuition is that correct implementations should be more likely to "explain themselves" in a way that matches the original specification. However, Figure 7 shows that back-translation "underperforms mean log-probability ranking, though it outperforms random ranking," and "appears to overfit quickly." The weaker performance may reflect the fact that Codex-D is itself imperfect, and errors in docstring generation propagate to the ranking scores.

Oracle upper bound. The blue line in Figure 7 represents the theoretical best performance achievable by an oracle that always selects the correct sample when one exists in the pool. The gap between the mean log-probability curve and the oracle curve represents the headroom for better selection heuristics. For Codex-12B, the oracle achieves approximately 72% pass@100 (from Table 1), while mean log-probability ranking achieves approximately 44.5% (from Figure 1), leaving roughly 27.5 percentage points of potential improvement.


Test Loss Scaling and Power Laws

The paper examines whether code fine-tuning follows the same power-law scaling behavior observed in language modeling. Figure 4 plots test loss (cross-entropy) on a held-out validation split of the Python GitHub code corpus against model size, measured in non-embedding parameters.

The paper fits a power law of the form:

Test Loss=(N5.92×107)0.13\text{Test Loss} = \left( \frac{N}{5.92 \times 10^7} \right)^{-0.13}

where NN is the number of non-embedding parameters in the model.

What this equation means: test loss scales as a power law in model size with exponent -0.13. For example, doubling the model size reduces test loss by a factor of approximately 20.130.9132^{-0.13} \approx 0.913, or about 8.7% relative reduction. The constant 5.92×1075.92 \times 10^7 is the scale parameter—it's the hypothetical model size at which test loss would be 1.0 if the power law extrapolated perfectly to that point.

Why this matters: the power-law fit demonstrates that code modeling follows the same scaling principles as language modeling, suggesting that the empirical scaling laws established by Kaplan et al. (2020) transfer across domains. This is evidence for the generality of the transformer scaling paradigm—it's not specific to natural language but applies to any sequence modeling task with sufficient data. The exponent -0.13 is specific to this dataset and model family but is consistent with the general observation that performance improves smoothly and predictably with model size.

The paper notes this finding succinctly: "just as language model test loss follows a power law in model size, test loss after code fine-tuning follows a similar power law." This is presented as a validation of the approach rather than a novel theoretical contribution—the paper is demonstrating that code joins the set of domains where scaling laws hold, which in turn justifies the investment in training larger code models.


Comparative Analysis: Codex vs. General-Purpose Language Models

The paper benchmarks existing language models on HumanEval to establish baselines and quantify the benefit of code-specific training. The key comparison is in Table 1:

GPT-Neo (Black et al., 2021) is trained on The Pile (Gao et al., 2020), which contains 8% GitHub code among diverse text sources. GPT-Neo-2.7B achieves 6.4% pass@1 and 21.4% pass@100 on HumanEval. This is remarkable compared to GPT models (near 0%), but the paper notes it is "roughly equivalent to Codex-85M"—a model with approximately 30× fewer parameters. This parameter efficiency gap quantifies the benefit of focused code training over general-domain training with incidental code exposure.

GPT-J-6B (Wang & Komatsuzaki, 2021) achieves 11.6% pass@1 and 27.7% pass@100, which is "roughly equivalent to Codex-300M"—a model with approximately 20× fewer parameters. The consistent factor of 20-30× parameter efficiency advantage for code-specialized models over general-domain models with some code exposure is a strong empirical finding: code generation capability depends much more on training data composition than on raw model scale.

Tabnine (a leading commercial code autocomplete system) achieves 2.6% pass@1 and 7.6% pass@100 on HumanEval, which is "roughly equivalent to Codex-12M"—one of the smallest models in the Codex family. This comparison highlights the difference between models optimized for autocomplete (suggesting the next few tokens in an existing code context) and models capable of generating entire functions from natural language descriptions. The paper does not analyze this capability gap in detail, but it suggests that function synthesis from docstrings is a fundamentally harder task than token-level autocompletion, requiring different training objectives, data, or scale.

Temperature optimization for baselines. The paper notes that pass rates for GPT-Neo and GPT-J are "obtained by taking the best result from evaluating at temperatures 0.2, 0.4, and 0.8 for GPT-Neo, and from temperatures 0.2 and 0.8 for GPT-J." This means the comparisons are generous to the baselines—Codex is evaluated at its optimal temperature for each k, and the baselines receive the same optimization treatment.


APPS Benchmark Evaluation

The APPS dataset (Hendrycks et al., 2021) provides a complementary evaluation to HumanEval, testing coding challenge competence on problems that require full-program synthesis (reading from stdin, printing to stdout) rather than single-function synthesis. The paper benchmarks Codex-12B on APPS to assess out-of-distribution generalization, since the main Codex training data consists primarily of standalone functions rather than full programs with I/O handling.

Adaptation for distribution mismatch. To compensate for the fact that "Codex is not fine-tuned on APPS," the paper appends a single input/output example from the task description to the docstring as a formatting hint. This is denoted as "1-shot" in Table 2—the model sees one example of the expected input/output format before generating its solution. Without this hint, the model would likely generate function-style solutions (with def and return) rather than program-style solutions (with input() and print()), failing to match the evaluation format.

Sample filtering using public tests. A key methodological innovation for APPS evaluation is the use of the 3 public input/output examples included in each APPS problem description. The paper generates 1000 solutions from the model and "filters out only those that pass these 3 unit tests (if such solutions exist)," then calculates pass rates within this filtered set. This is called filtered pass@k. The idea is that the public tests serve as a coarse correctness check—solutions that fail the public tests are almost certainly incorrect and can be discarded without running the full hidden test suite. However, this filtering introduces a potential overfitting concern: solutions that pass the public tests but fail hidden tests may be selected, and the filtering process itself can amplify any bias in the public test cases.

The paper reports both raw pass@k (without filtering) and filtered pass@k in Table 2. For introductory problems, filtered pass@1 reaches 22.78% compared to raw pass@1 of 4.14%—a dramatic improvement from using the 3 public test cases as a filter. This demonstrates that even a small number of public test cases can substantially improve effective performance when many samples are generated.

Timeout handling. A practical concern in competitive programming is algorithmic efficiency: "a correct solution is found, but it is not algorithmically efficient enough to be considered passing." The paper reports the number of solutions that "do not fail on any unit test, but that do time-out on some of them" with a 3-second timeout per test. This acknowledges that correctness and efficiency are distinct criteria, and that models may generate correct-but-slow solutions that would not be acceptable in competition settings.

APPS results (Table 2). The results show a clear difficulty gradient: Codex-12B performs reasonably on introductory problems (25.02% raw pass@1000) but poorly on interview-level problems (3.70% raw pass@1000) and competition-level problems (3.23% raw pass@1000). For comparison, GPT-Neo-2.7B achieved 3.90% raw pass@1 on introductory problems against Codex-12B's 4.14% raw pass@1 in the 1-shot setting—a much smaller gap than on HumanEval, where Codex-12B (28.81%) dramatically outperforms GPT-Neo-2.7B (6.41%). This suggests that APPS's full-program format is challenging for Codex regardless of scale, consistent with the training distribution mismatch.


Supervised Fine-Tuning: From Codex to Codex-S

The core insight motivating supervised fine-tuning is distribution mismatch: "Python code found on GitHub contains class implementations, configuration files, scripts, and even files used to store data. This code is seemingly unrelated to synthesizing functions from docstrings." The model sees a wide variety of code during training but is evaluated on a narrow task—generating standalone functions from docstrings. The supervised fine-tuning step explicitly aligns the training distribution with the evaluation task by training on a curated dataset of correctly implemented standalone functions paired with their docstrings.

Data sources. The paper uses two complementary sources:

  1. Competitive programming and interview preparation websites (10,000 problems): these problems are "self-contained, come with well-written problem statements, and generally have excellent test coverage." They test "algorithmic reasoning over a broad range of core skills and difficulties." The problem statements are used as docstrings, and the solutions (often hidden in the original sources) are collected as reference implementations. Since complete test suites are frequently hidden, the authors "created unit tests from examples found in the problem statements, or extracted additional test cases through submitting incorrect solutions." The latter approach is clever: by submitting deliberately incorrect solutions to the online judges, the authors can observe which test cases fail and extract additional test inputs.

  2. Continuous integration (CI) tracing (approximately 40,000 functions): using sys.setprofile, the authors "trace and collect inputs and outputs for all functions called during integration tests" in open-source projects. sys.setprofile is a Python profiling hook that can be set to a callback function called on function entry and exit, enabling capture of argument values and return values during program execution. Projects that use Travis CI or tox (two popular continuous integration frameworks) are targeted, along with publicly available source code from PyPI packages. The CI configuration files specify build and test commands, which are followed to set up virtual environments, install dependencies, and run integration tests within the sandbox.

Why CI tracing produces different problems than competitive programming. The paper notes that traced functions "tended to be the building blocks of command-line utilities" because the tracing captured inputs and outputs for all invoked functions, including "builtin and library calls imported by the project." These problems require the model to "follow instructions to implement the functionality specified in the docstring" rather than knowing "advanced algorithms and data structures." This complements the algorithmic focus of competitive programming problems and broadens the training distribution.

The two data sources together provide approximately 50,000 training problems, though the exact number is somewhat less after filtering.

Filtering for quality. The automatically created training problems have potential quality issues: some prompts "underspecify the function that is implemented," meaning a valid solution might be wrongly penalized by the extracted unit tests (because the unit tests capture the behavior of one specific implementation but not all valid implementations). Some problems are "stateful, and subsequent executions can result in different outcomes," meaning that running the unit tests twice might produce different pass/fail results. These non-deterministic or ambiguous problems would provide noisy training signals.

The filtering procedure uses Codex-12B itself: "generate 100 samples per curated problem. If no samples pass the unit tests, we consider the task to be either ambiguous or too difficult, and filter it out." This filtering was "reran several times to remove stateful or non-deterministic problems." The assumption is that if Codex-12B, which has non-trivial code generation capability, cannot produce any passing solution in 100 attempts, the problem is likely ill-posed rather than genuinely difficult. This is a practical heuristic—it may filter out some valid but genuinely hard problems, but it prioritizes clean training data.

Training methodology for Codex-S. The supervised fine-tuning procedure is:

  • Prompt format: problems are assembled into the same format as HumanEval evaluation (header, signature, docstring), with the reference solution as the target completion. If there are prompts of varying length in a batch, shorter prompts are left-padded to the length of the longest prompt, "so that the first tokens in the reference solutions line up in context." This alignment ensures that the model's attention can focus on corresponding positions across examples.

  • Loss function: negative log-likelihood of the reference solution tokens, with "loss for any tokens in the prompt" masked out. This is standard sequence-level supervised fine-tuning—the model is trained only on generating the solution, not on predicting the prompt.

  • Learning rate: 1/10 as large as the learning rate used for the initial code fine-tuning from GPT. The reduced learning rate is a standard practice for fine-tuning: the model has already learned useful representations from the broader code corpus, and the supervised fine-tuning should make smaller, more targeted adjustments.

  • Schedule: same 175-step linear warmup and cosine decay as the initial fine-tuning.

  • Duration: training continues "until validation loss plateaus (less than 10B tokens)." The 10B token threshold indicates that the supervised fine-tuning dataset is relatively small compared to the 100B token initial fine-tuning—the model sees each training example multiple times, and early stopping prevents overfitting.

Results of supervised fine-tuning (Codex-S performance). The key finding is that Codex-S "outperforms the corresponding Codex by an average margin of 6.5 percentage points on pass@1 and by a larger average margin of 15.1 percentage points on pass@100 across model size" (Section 4.5). The larger improvement on pass@100 is particularly notable: it suggests that supervised fine-tuning not only improves the model's most likely output but also broadens its distribution to include more diverse correct solutions. This is counterintuitive—one might expect fine-tuning on a narrow distribution to reduce diversity—but the paper attributes it to the fact that Codex-S "prefers slightly higher temperatures for all k > 1, which possibly reflects the fact that Codex-S captures a narrower distribution than Codex" (Figure 10, Section 4.5). The higher temperatures compensate for the reduced diversity by injecting more randomness into sampling.

Sample selection with Codex-S. Figure 10 shows that the mean log-probability ranking heuristic provides consistent benefits for Codex-S, with an average advantage of 11.6 percentage points over random selection when ranking 1 to 100 samples—"over 2 percentage points higher than the corresponding benefit for Codex." This suggests that supervised fine-tuning makes the model's own confidence estimates more correlated with correctness, improving the reliability of log-probability-based ranking.


Docstring Generation Model (Codex-D)

The paper trains a complementary model, Codex-D, that generates docstrings from code bodies—the reverse of the primary code generation task. This model serves two purposes: providing a safety-relevant capability (describing the intent behind generated code, as motivated in Section 5) and enabling the back-translation sample selection heuristic.

Training data construction. The procedure is straightforward: for each training problem in the supervised fine-tuning dataset, "assemble a training example by concatenating the function signature, the reference solution, and then the docstring." This is the exact inverse of the code generation prompt—the model sees code first, then learns to generate the corresponding natural language description. Training uses the same negative log-likelihood objective, masking out loss on the prompt (signature + code) and training only on the docstring tokens.

Evaluation methodology for docstrings. Unlike code generation, there is no automated way to evaluate docstring correctness—a docstring can be semantically correct while using different wording, or it can be syntactically valid natural language that is factually wrong about the code's behavior. The paper therefore resorts to hand-grading: "we only grade 10 samples per problem, for a total of 1640 problems, from Codex-D-12B at temperature 0.8." A docstring is considered correct if it "uniquely and accurately specifies the code body."

Common failure modes. The paper identifies three types of errors in generated docstrings: (1) omission of important details (such as formatting or precision requirements), (2) over-conditioning on the function name and "inventing a problem unrelated to the function body," and (3) generation of meta-commentary like "I just found this function online" or "This test is not correctly written and it's not my solution." The latter failure mode is particularly interesting—it suggests the model has learned patterns from code comments that discuss code quality or provenance, and sometimes generates these patterns instead of functional descriptions.

Performance comparison. As shown in Table 3, Codex-D-12B achieves 20.3% pass@1 and 46.5% pass@10, compared to Codex-S-12B's 32.2% pass@1 and 59.5% pass@10 at the same temperature (0.8). Docstring generation is harder than code generation under these metrics, though the paper notes that comparisons are complicated by the different evaluation methodologies (hand-grading vs. unit tests). The authors "do not have a strong hypothesis for which direction should yield higher pass rates," noting that natural language syntax is less strict but docstrings in the training data "may be lower quality because developers tend to devote less time to writing docstrings."


BLEU Score vs. Functional Correctness

The paper provides direct evidence that BLEU score—the dominant metric in prior code generation work—is unreliable for measuring functional correctness. Figure 8 plots the probability densities of BLEU scores for correct (blue) and incorrect (green) solutions from Codex-12B, for four randomly selected HumanEval problems.

The visualization reveals "significant overlap" between the two distributions. For each problem, there exist incorrect solutions with higher BLEU scores than some correct solutions, and vice versa. The paper draws a strong conclusion:

"Since an incorrect solution is guaranteed to be functionally inequivalent to the reference solution, we conclude that improvements in BLEU score may not indicate improved rates of functional correctness in practice."

This is a methodological indictment of match-based evaluation. The guarantee of functional inequivalence comes from the definition of correctness: an incorrect solution fails at least one unit test, meaning there exists some input for which its output differs from the reference solution's output. If two programs produce different outputs on some input, they are by definition not functionally equivalent—regardless of how similar their source code looks textually. The fact that such programs can have high BLEU scores (sometimes higher than functionally correct programs) demonstrates that textual similarity and functional equivalence are weakly correlated at best.

The paper does not claim that BLEU score is completely uninformative—only that it is insufficient as a primary evaluation metric for code generation. A model that optimizes for BLEU score may be optimizing for the wrong thing, producing code that looks like the reference but behaves differently. This insight motivates the paper's entire evaluation framework built on functional correctness.


Summary of Design Choices and Their Justifications

  • GPT fine-tuning over training from scratch: leverages natural language representations for faster convergence, though not for better asymptotic performance at this data scale.
  • Whitespace tokens in tokenizer: recovers approximately 30% token efficiency for code, improving training and inference throughput by reducing the token count for indentation-heavy Python code.
  • Hand-written HumanEval dataset: avoids contamination from training data that would occur with benchmarks derived from public coding platforms, ensuring evaluation measures synthesis rather than memorization.
  • Unbiased pass@k estimator with n = 200 samples: provides a statistically principled metric that can be fairly compared across experiments with different total sample counts, avoiding the bias of the common 1(1p^)k1 - (1 - \hat{p})^k approximation.
  • Nucleus sampling with top p = 0.95: avoids the long tail of low-probability tokens while maintaining diversity; chosen as a standard value without code-specific tuning.
  • Temperature optimization per k: lower temperature for single-sample evaluation (maximizing correctness probability), higher temperature for multi-sample evaluation (maximizing diversity to increase the chance that at least one sample is correct).
  • gVisor sandbox with eBPF firewall: provides defense-in-depth for executing untrusted generated code, with kernel-level emulation for host protection and network-level filtering to prevent data exfiltration.
  • Supervised fine-tuning on curated standalone functions: explicitly matches training distribution to evaluation distribution (function synthesis from docstrings), improving pass@1 by 6.5 percentage points and pass@100 by 15.1 percentage points on average.
  • Codex-based filtering of training problems: uses the model's own capability to identify ill-posed or ambiguous training examples, improving training data quality without manual inspection.
  • Left-padding of prompts during supervised fine-tuning: aligns reference solution tokens at the same positions in context, improving attention patterns during training.

4. Key Insights and Innovations

Innovation 1: Functional Correctness as the Evaluation Gold Standard — and a Statistically Principled Way to Measure It

The paper's most consequential intervention is not a model architecture or a training recipe, but a redefinition of what it means to evaluate code generation. Before this work, the dominant practice was to treat generated code as text and measure its similarity to a reference solution using surface-form metrics like BLEU or exact match. This convention was inherited from natural language generation, where it was already known to be imperfect, but in code it is actively misleading: two programs can be functionally identical while sharing almost no tokens, and two programs can have high textual overlap while producing different outputs on the same inputs.

The paper makes this critique empirical rather than philosophical. Figure 8 shows that for four randomly selected HumanEval problems, the BLEU score distributions of correct and incorrect Codex-12B solutions overlap substantially. Since incorrect solutions are guaranteed to be functionally inequivalent to the reference (they fail at least one unit test), the overlap demonstrates that BLEU scores cannot separate working from non-working code. This is not an argument about BLEU being "noisy" or "imperfect"—it is evidence that optimizing for BLEU can steer models away from functional correctness entirely.

The intellectual move here is drawing a bright line: code has an objective correctness criterion (does it pass the tests?) that natural language lacks, and evaluation methodology should exploit this structural difference rather than ignore it. This reframes code generation from a text-matching problem to a program-synthesis problem with a verifiable success condition. The downstream consequence is that progress on code generation can be measured with the same kind of rigorous, automated benchmarking that the software engineering community uses for testing—a standard the NLP community had not previously adopted for generative code models.

The statistical contribution—the unbiased pass@k estimator (Equation 1, Figure 3)—is a refinement on the evaluation theme. Prior work (Kulal et al., 2019) had introduced pass@k conceptually, but the common estimator 1(1p^)k1 - (1 - \hat{p})^k is biased, as the paper proves in Appendix A. The bias is not a minor technical footnote: Figure 13 shows it persists even when n>5kn > 5k, meaning it can make models look better or worse depending on the number of samples drawn, undermining fair comparison. The paper's estimator—computing the exact hypergeometric probability of drawing k samples without replacement and finding at least one correct—is both unbiased regardless of n and k and numerically stable through the product formulation in Figure 3. This is a genuinely useful methodological contribution: it gives the field a metric that can be fairly compared across experiments with different sampling budgets, without the researcher needing to worry about estimator bias contaminating their conclusions.

This innovation is fundamental rather than incremental because it changes what the field optimizes for. A paper that uses BLEU score and a paper that uses unbiased pass@k are, in a meaningful sense, solving different problems—the former is solving a text-generation problem and the latter is solving a program-synthesis problem. The paper's release of HumanEval as a public benchmark cemented this shift, creating a common evaluation that subsequent work could adopt.


Innovation 2: Repeated Sampling as a Capability Amplifier — The Model Knows More Than It Shows on First Attempt

The paper's second major conceptual contribution is the demonstration that repeated sampling from the model surface correct solutions for many more problems than a single sample reveals, and that this gap widens with model scale. This is not simply "generate more outputs and you might get lucky"—it is evidence that the model's internal distribution over programs contains correct solutions for a majority of problems (77.5% for Codex-S-12B at pass@100) even when its most likely output is wrong for most of them (only 37.7% pass@1 for the same model).

This finding reframes the capability question. Before this work, a model's performance was typically characterized by its single-sample accuracy—what it produces when asked once. The paper shows that this is a pessimistic underestimate of the model's latent capability. The model "knows" how to solve many more problems than it "chooses" to on its first attempt, and the gap between pass@1 and pass@100 grows with model size (Figure 6), meaning larger models hide progressively more of their capability behind sampling variance. This is a diagnostic insight: it suggests that for code generation, the primary bottleneck is not capability acquisition (can the model represent a correct solution?) but capability expression (does the model assign high enough probability to that solution to sample it in one attempt?).

The practical importance of this finding is amplified by the sample selection heuristics. The paper shows that even without oracle access to unit tests, selecting the sample with the highest mean log-probability recovers a substantial fraction of the gap (44.5% pass@100 for Codex-12B with mean log-probability ranking vs. 72.3% with oracle selection, from Figure 1). This means the model's own confidence estimates carry genuine signal about correctness—the model "knows" not just how to solve more problems but which of its solutions are more likely to be right. The back-translation heuristic (using Codex-D to score samples by how well they explain themselves) provides a second, independent signal, though it underperforms log-probability ranking.

This innovation is incremental in mechanism but fundamental in implication. The idea of generating multiple samples and selecting the best is not new—it dates back to beam search in sequence models and best-of-N sampling in language modeling. What is novel is the quantification of the gap and the demonstration that it follows a scaling law: larger models benefit more from repeated sampling, suggesting this is not a temporary limitation that will be solved by better training but a persistent property of autoregressive models that will become more pronounced as capabilities improve. The paper does not claim to solve the capability expression problem—it diagnoses it and points to sample selection (mean log-probability, back-translation, and future heuristics) as the path forward.


Innovation 3: Distribution Matching as the Key Lever for Task-Specific Performance — Codex-S and the Narrowing of the Gap

The paper's third conceptual contribution is the demonstration that aligning the fine-tuning distribution with the evaluation distribution yields substantial gains that are not achievable by scaling alone, and that this distribution matching is orthogonal to and composable with model scaling. Codex-S—produced by supervised fine-tuning Codex on a curated dataset of approximately 50,000 correctly implemented standalone functions—improves pass@1 by an average of 6.5 percentage points and pass@100 by 15.1 percentage points across model sizes compared to the base Codex models (Figure 10, Section 4.5).

The significance of this finding lies in what it reveals about the nature of the capability gap between general code understanding and task-specific code generation. The base Codex models are trained on 159 GB of diverse GitHub Python code, which includes class implementations, scripts, configuration files, and data storage alongside standalone functions. This broad distribution gives the model strong general code understanding—it learns syntax, common patterns, library usage, and algorithmic idioms. But it does not specifically optimize for the narrow task of "given a function signature and docstring, produce a correct body." The supervised fine-tuning step bridges this gap by showing the model thousands of examples of exactly the task it will be evaluated on.

The intellectual move is to frame this not as "more training" but as distribution curation: the quality and relevance of training examples matter as much as their quantity, and deliberate effort to collect, verify, and filter task-aligned examples can yield efficiency gains equivalent to scaling model parameters by an order of magnitude or more. The paper's comparative analysis in Table 1 supports this: a 300M-parameter Codex (trained exclusively on code) achieves 13.2% pass@1, roughly equivalent to GPT-J-6B (20× larger, but trained on a general text corpus with only 8% code). Distribution matters more than scale for this particular capability.

The two data collection methods—competitive programming problems and CI tracing—represent complementary strategies for distribution curation. Competitive programming provides problems with well-specified algorithmic requirements and clean input-output behavior. CI tracing captures the messy reality of real-world software: functions that are building blocks of command-line tools, often dealing with file I/O, string manipulation, and library integration rather than algorithmic puzzles. By combining both, Codex-S is trained on a distribution that spans the space of standalone function synthesis, from interview-style algorithms to practical utility functions.

This innovation is incremental in method but conceptually important: supervised fine-tuning on task-aligned data is a well-established technique (the paper itself acknowledges it is "similar in spirit" to prior work like PyMT5), but the paper's contribution is quantifying the benefit, showing it composes with scale, and providing a reproducible recipe (with public dataset release for the evaluation) for others to build on. The finding that the benefit is larger for pass@100 than pass@1—15.1 vs. 6.5 percentage points—is particularly interesting because it suggests distribution matching not only improves the model's most likely output but also shapes its full distribution to include more diverse correct solutions, a non-obvious effect that would not be predicted from first principles.


Innovation 4: The Temperature-k Tradeoff as a Diagnostic for the Diversity-Correctness Tension

The paper's fourth conceptual contribution is the identification and systematic characterization of the temperature-k tradeoff: the optimal sampling temperature for pass@k depends on k, with lower temperatures better for small k and higher temperatures better for large k (Figure 5). This relationship is intuitive in retrospect—diversity helps when you can evaluate many samples, accuracy helps when you can evaluate only one—but the paper provides the first systematic evidence for it in code generation and demonstrates that it has practical consequences for deployment strategy.

The intellectual significance of this finding is that it reveals a fundamental tension in autoregressive generation that cannot be resolved by model improvements alone. A model with perfect single-sample accuracy would have no need for diversity, and would perform best at temperature 0. A model with perfect sampling diversity would generate a correct solution somewhere in its distribution for every problem, and would perform best at high temperature when combined with oracle selection. Real models lie between these extremes, and the optimal temperature-k curve traces out a Pareto frontier that characterizes the model's accuracy-diversity tradeoff at its current capability level. As models improve (higher pass@1), the frontier shifts—the optimal temperature for pass@1 moves toward 0 (as seen with Codex-S, which uses T* = 0 for k = 1 vs. T* = 0.2 for base Codex-679M), and the optimal temperature for pass@100 may increase or decrease depending on whether capability improvements come from better single-sample accuracy or broader solution distributions.

The practical translation of this insight is the temperature-as-hyperparameter-for-deployment framing: if you are building an autocomplete tool that shows one suggestion (k = 1), use low temperature. If you are building a batch code generation system that can evaluate many candidates against test cases (k = 100 or higher), use high temperature. If you are building something in between—showing a few suggestions and letting the user choose—the optimal temperature is somewhere in the middle and should be tuned for the specific k in your user interface. This is a deployment-relevant engineering insight that goes beyond the paper's core evaluation methodology.

This innovation is incremental but diagnostically valuable. Temperature tuning is a standard practice in language model deployment. What the paper adds is the formal relationship to k and the empirical characterization that the optimal temperature increases with k, which had not been systematically documented for code generation. The finding is robust across model sizes and between Codex and Codex-S (Figures 5, 9), suggesting it is a general property of autoregressive code models rather than a quirk of a particular training run.

5. Experimental Analysis

Evaluation Methodology

  • Dataset. The primary evaluation dataset is HumanEval, a collection of 164 hand-written Python programming problems created by the authors. Each problem includes a function signature, a docstring describing the intended behavior, a reference solution body, and an average of 7.7 unit tests implemented as assert statements. The problems are designed to assess language comprehension, reasoning, algorithms, and simple mathematics, with difficulty levels ranging from straightforward string manipulation to algorithmic problems comparable to simple software interview questions. The hand-written nature is deliberate: since Codex is trained on a large fraction of public GitHub repositories, any benchmark derived from existing public code would risk measuring memorization rather than genuine synthesis capability. The paper explicitly notes, "there are more than ten public repositories containing solutions to Codeforces problems, which make up part of the recently proposed APPS dataset" (Section 2.2), motivating the need for a clean, contamination-free evaluation set. The dataset is publicly released at https://www.github.com/openai/human-eval.

  • Base model(s). The experiments use the GPT model family (Brown et al., 2020) as the pretrained base, fine-tuned on code to produce Codex models spanning from 12M to 12B non-embedding parameters. The paper argues this model family is appropriate because its strong natural language representations provide a useful starting point for docstring-conditional code generation. From Codex, a supervised fine-tuned variant called Codex-S is produced by further training on a curated dataset of correctly implemented standalone functions. Additionally, a docstring generation model called Codex-D is trained by reversing the input-output order (code body → docstring). For external comparisons, the paper evaluates GPT-Neo (Black et al., 2021) at 125M, 1.3B, and 2.7B parameters; GPT-J (Wang & Komatsuzaki, 2021) at 6B parameters; and the largest free model from Tabnine, a commercial code autocomplete system. GPT-Neo and GPT-J are trained on The Pile (Gao et al., 2020), which contains 8% GitHub code among diverse text sources, making them useful baselines for quantifying the benefit of code-specialized training over general-domain training with incidental code exposure.

  • Metrics. The primary metric is pass@k: the probability that at least one of k generated samples per problem passes all unit tests. The paper uses an unbiased estimator (Equation 1) that computes this as 1(nck)(nk)1 - \frac{\binom{n-c}{k}}{\binom{n}{k}}, where n = 200 total samples are generated per problem, c is the number of those samples that pass all unit tests, and the expectation is taken across the 164 problems in HumanEval. The term (nck)(nk)\frac{\binom{n-c}{k}}{\binom{n}{k}} is the hypergeometric probability that k samples drawn without replacement from the pool of n samples are all incorrect; subtracting from 1 gives the probability that at least one correct sample appears in the draw. This estimator is unbiased regardless of n and k and avoids the bias of the common but incorrect approximation 1(1p^)k1 - (1 - \hat{p})^k, where p^\hat{p} is the empirical pass@1 rate. The paper proves this bias in Appendix A and provides a numerically stable numpy implementation (Figure 3) that computes the estimator as a product of probability terms, avoiding overflow from large binomial coefficients. A secondary metric is test loss (cross-entropy) measured on a held-out validation split of the Python GitHub code corpus, used to assess scaling behavior. For the APPS benchmark, the paper reports both raw pass@k and filtered pass@k (where generated solutions are first screened against the 3 public input/output examples included in each problem description), with a 3-second timeout per test case to handle algorithmically inefficient solutions. For the docstring generation task, where no automated correctness check exists, correctness is determined by hand-grading: a docstring is considered correct if "it uniquely and accurately specifies the code body" (Section 5), with 10 samples graded per problem for a total of 1,640 evaluations.

  • Baselines. The paper evaluates several external models for comparison on HumanEval:

    • GPT-Neo (Black et al., 2021) at 125M, 1.3B, and 2.7B parameters. GPT-Neo is trained on The Pile, which contains 8% GitHub code. Pass rates are obtained by taking the best result across temperatures 0.2, 0.4, and 0.8 for each k.
    • GPT-J-6B (Wang & Komatsuzaki, 2021), also trained on The Pile. Pass rates are obtained from temperatures 0.2 and 0.8.
    • Tabnine, the largest free model from a leading commercial code autocomplete system, evaluated at T = 0.4 for pass@1 and T = 0.8 for pass@100.
    • GPT-3 models (Brown et al., 2020) at various sizes, which achieve near 0% on both pass@1 and pass@100, establishing a floor that demonstrates the necessity of code-specific training.

    Within the Codex family, the baselines are Codex (fine-tuned on GitHub code only) and majority voting (for the sample selection experiments). For the APPS benchmark, the baseline is GPT-Neo-2.7B fine-tuned on the APPS training set, as reported by Hendrycks et al. (2021). The paper also compares against the theoretical oracle upper bound for sample selection: given k samples, always select the correct one when it exists, representing the maximum possible pass@k achievable by any selection heuristic.

  • Generation budget / compute accounting. Compute for generation is measured in terms of the number of samples generated per problem. For pass@k evaluation, the paper generates n = 200 samples per problem regardless of the value of k being reported (where k ≤ 100), ensuring the estimator has low variance. This means reporting pass@1 or pass@100 both require the same 200 samples per problem—the cost is in generating and executing the samples, not in the metric computation itself. For the APPS benchmark, up to 1,000 samples are generated per problem for pass@1000 evaluation. Training compute is reported qualitatively: the original GPT-3-12B training "consumed hundreds of petaflop/s-days of compute, while fine-tuning it to create Codex-12B consumed a similar amount of compute" (Section 7.6). The paper does not provide detailed FLOP counts or wall-clock training times for individual model sizes. For the sample selection experiments (Figure 7), the relevant budget is k, the number of samples from which one must be selected, with performance plotted as a function of k from 1 to 100.

  • Cross-validation / statistical protocol. The paper does not employ cross-validation for model selection or hyperparameter tuning in the traditional sense. Instead, it uses a fixed held-out validation split of the GitHub Python code corpus (size unspecified) for monitoring test loss during training and for fitting the power law in Figure 4. For the HumanEval evaluation, all 164 problems are used as a fixed test set—there is no train/validation/test split of the evaluation data itself because the models are not trained on HumanEval (it is hand-written and released specifically as a benchmark). Temperature optimization for pass@k is performed by sweeping temperatures (typically 0.2, 0.4, 0.6, 0.8, 1.0) and selecting the temperature that maximizes pass@k on the full test set; the paper reports these optimal temperatures explicitly (e.g., T* = 0.2 for pass@1, T* = 0.8 for pass@100 for Codex-679M). This means the reported pass@k numbers are technically tuned on the test set, though the tuning is limited to a single continuous hyperparameter (temperature) over a small number of values. For the APPS baseline (GPT-Neo fine-tuned on APPS), the paper uses the numbers reported by Hendrycks et al. (2021) without re-evaluation. The supervised fine-tuning of Codex-S uses early stopping based on validation loss plateau (less than 10B tokens of additional training). For the alignment evaluations (Appendix E), a subset of 30 HumanEval problems (the first 30 alphabetically by function name) is used to construct the prompts with correct or buggy solutions, while evaluation is performed on the remaining 128 problems—this constitutes a rudimentary held-out split for that specific experiment.

Main Quantitative Results

Codex Performance on HumanEval: Scaling and the Effect of Code-Specific Training

The central quantitative result for the base Codex models is the pass@k scaling with model size, shown in Table 1 and Figure 6. At the largest scale (12B parameters), Codex achieves 28.81% pass@1, 46.81% pass@10, and 72.31% pass@100 on HumanEval. These numbers are obtained at the optimal temperatures for each k: T = 0.2 for pass@1 and T = 0.8 for pass@100 (with pass@10 using an intermediate temperature not explicitly stated but implied by the upper hull in Figure 5).

The scaling behavior follows a sigmoid pattern in log-parameters (Figure 6). The smallest model, Codex-12M, achieves only 2.00% pass@1 and 8.58% pass@100. Performance improves smoothly with size: Codex-85M reaches 8.22% pass@1 and 22.4% pass@100; Codex-300M reaches 13.17% pass@1 and 36.27% pass@100; Codex-679M reaches 16.22% pass@1 and 40.95% pass@100; and Codex-2.5B reaches 21.36% pass@1 and 59.5% pass@100. The gap between pass@1 and pass@100 widens with model size: for the 12M model, pass@100 is approximately 4.3× pass@1; for the 12B model, pass@100 is approximately 2.5× pass@1. This indicates that larger models not only have higher single-sample accuracy but also concentrate more of their probability mass on correct solutions, making repeated sampling relatively less necessary (though still highly beneficial in absolute terms).

The test loss on the held-out code corpus follows a power law of the form (N/5.92×107)0.13(N / 5.92 \times 10^7)^{-0.13}, where N is the number of non-embedding parameters (Figure 4). The paper notes this demonstrates that "just as language model test loss follows a power law in model size, test loss after code fine-tuning follows a similar power law" (Section 3.3), extending the scaling laws framework to code.

The comparison against general-purpose language models (Table 1) quantifies the benefit of code-specialized training. GPT-Neo-2.7B achieves 6.41% pass@1 and 21.37% pass@100, which the paper notes is "roughly equivalent to Codex-85M (30× fewer parameters)." GPT-J-6B achieves 11.62% pass@1 and 27.74% pass@100, which is "roughly equivalent to Codex-300M (20× fewer parameters)." Tabnine achieves 2.58% pass@1 and 7.59% pass@100, "roughly equivalent to Codex-12M." All GPT models achieve near 0% on both metrics, confirming that natural language pretraining alone is insufficient for code generation at this scale.

Supervised Fine-Tuning: Codex-S Performance Gains

Codex-S, produced by supervised fine-tuning Codex on approximately 50,000 curated standalone function problems, yields consistent improvements across model sizes (Figure 10). The paper reports that "Codex-S outperforms the corresponding Codex by an average margin of 6.5 percentage points on pass@1 and by a larger average margin of 15.1 percentage points on pass@100 across model size" (Section 4.5). For Codex-S-12B specifically, pass@1 reaches 37.7% (at T* = 0, i.e., greedy decoding) and pass@100 reaches 77.5% (at T* = 1.0). These are the headline numbers from Figure 1.

The larger gain on pass@100 (15.1 percentage points average) compared to pass@1 (6.5 percentage points average) is notable. The paper attributes this to Codex-S "preferring slightly higher temperatures for all k > 1, which possibly reflects the fact that Codex-S captures a narrower distribution than Codex" (Section 4.5). In other words, supervised fine-tuning concentrates the model's probability mass on the task of function synthesis, making correct solutions more probable but also reducing diversity; higher temperatures compensate by injecting more randomness and recovering diverse samples.

The sample selection heuristics applied to Codex-S-12B (Figure 10, and cross-referenced with Figure 7 for Codex-12B) show that mean log-probability ranking provides an average benefit of 11.6 percentage points over random selection when ranking between 1 and 100 samples—"over 2 percentage points higher than the corresponding benefit for Codex" (Section 4.5). This suggests supervised fine-tuning makes the model's confidence estimates more reliable for correctness prediction.

Repeated Sampling and Sample Selection

The paper demonstrates a substantial gap between single-sample performance and oracle-selected multi-sample performance. For Codex-12B, pass@1 is 28.81% while pass@100 is 72.31%—a gap of 43.5 percentage points (Table 1). For Codex-S-12B, the gap is 39.8 percentage points (37.7% pass@1 vs. 77.5% pass@100, from Figure 1). This gap represents the headroom available to sample selection heuristics.

The mean log-probability ranking heuristic (Figure 7) partially bridges this gap. For Codex-12B at temperature 0.8, selecting the sample with the highest mean token log-probability from among k samples achieves approximately 44.5% accuracy at k = 100 (from Figure 1), compared to 72.31% for oracle selection and approximately 28.81% for random selection (which equals pass@1). This means mean log-probability ranking recovers roughly (44.5 - 28.81) / (72.31 - 28.81) ≈ 36% of the possible improvement over random selection.

The paper notes that sum log-probability performs worse than random selection in some regimes—"choosing the sample based on sum log probability can perform slightly worse than picking randomly" (Section 3.3). This is because sum log-probability penalizes longer sequences: a short, incorrect solution can have higher total log-probability than a longer, correct one simply because it has fewer tokens over which to accumulate negative log-probability. The mean normalization is essential for the heuristic to work.

The back-translation heuristic (using Codex-D to score samples by P(original docstringgenerated code)P(\text{original docstring} | \text{generated code})) "underperforms mean log-probability ranking, though it outperforms random ranking" and "appears to overfit quickly" (Section 5). The paper does not report the exact pass@100 for back-translation ranking in Figure 7, but the orange curve is visibly below the red (mean log-probability) curve for all k ≥ 2.

BLEU Score vs. Functional Correctness

Figure 8 directly demonstrates the inadequacy of BLEU score for evaluating code generation. For four randomly selected HumanEval problems, the paper plots the probability densities of BLEU scores for correct (blue) and incorrect (green) Codex-12B solutions. The distributions show "significant overlap" for all four problems. Since incorrect solutions are guaranteed to be functionally inequivalent to the reference (they fail at least one unit test), the overlap demonstrates that BLEU scores cannot reliably separate working from non-working code. The paper concludes that "improvements in BLEU score may not indicate improved rates of functional correctness in practice" (Section 3.3). This empirical finding underpins the paper's methodological argument for functional correctness as the appropriate evaluation metric.

APPS Benchmark Results

Table 2 reports Codex-12B performance on the APPS dataset, which tests full-program synthesis (reading from stdin, printing to stdout) rather than single-function synthesis. The results show a steep difficulty gradient across APPS's three tiers:

  • Introductory problems: 4.14% raw pass@1, 20.20% raw pass@100, 25.02% raw pass@1000. With filtering by the 3 public test cases, filtered pass@1 reaches 22.78% and filtered pass@5 reaches 24.52%.

  • Interview problems: 0.14% raw pass@1, 2.04% raw pass@100, 3.70% raw pass@1000. Filtered pass@1: 2.64%.

  • Competition problems: 0.02% raw pass@1, 1.05% raw pass@100, 3.23% raw pass@1000. Filtered pass@1: 3.04%.

The numbers in parentheses represent solutions that "do not fail on any unit test, but that do time-out on some of them" with a 3-second timeout. For introductory problems, these timeout-instead-of-fail solutions add roughly 0.2-2.8 percentage points to the pass rates depending on k.

Compared to GPT-Neo-2.7B fine-tuned on APPS (reported by Hendrycks et al., 2021), Codex-12B in the 1-shot setting achieves comparable performance on introductory problems (4.14% vs. 3.90% raw pass@1) but the comparison is complicated by the fact that Codex was not fine-tuned on APPS while the GPT-Neo baseline was. The paper notes this explicitly, positioning the APPS results as evidence of out-of-distribution generalization rather than as a head-to-head comparison.

The dramatic improvement from filtering (pass@1 jumping from 4.14% to 22.78% on introductory problems) demonstrates that even a small number of public test cases can substantially improve effective performance when many samples are generated and screened. However, this filtering approach also introduces a potential overfitting concern: solutions that pass the public tests but fail hidden tests are selected, and the paper does not analyze whether this filtering amplifies any bias in the public test cases.

Alignment and Misalignment Results

Appendix E provides quantitative evidence for alignment failures in Codex models. Figure 14 (and the related Figure 12 in the main text) shows that when the prompt includes subtly buggy code, Codex produces code with a higher frequency of bugs than when the prompt contains correct code—even though the model is capable of producing correct code (as demonstrated by its performance when prompted with correct examples). The gap between performance with correct-context prompts and buggy-context prompts increases with model size (Figure 12), suggesting this misalignment is likely to worsen rather than improve as capabilities scale.

The experimental setup uses 30 HumanEval problems to construct prompts that include either three examples of docstring + correct solution or three examples of docstring + solution with subtle bugs (e.g., off-by-one errors, single-character typographic errors), sampled i.i.d. from the 30 problems with the current task excluded. Evaluation is on the remaining 128 HumanEval problems at T = 0.2. The paper also tests an instruction condition where "# instruction: write correct code even if the previous code contains bugs" is inserted before the task docstring, finding that this helps "a little but does not fix the problem" (Figure 14 caption).

The paper operationalizes this as an alignment failure: the model "is capable of outputting code with a lower frequency of bugs" (demonstrated by its performance in the correct-context condition) and "capable of distinguishing between situations where the user does and does not want buggy code" (the model could easily be fine-tuned to detect the instruction), yet it "outputs code with a higher frequency of bugs when prompted with buggy code." This satisfies the paper's sufficient conditions for intent misalignment defined in Appendix E.

Synthetic Docstring Complexity Experiments

Figure 11 (Section 6) characterizes Codex-12B's performance degradation as a function of specification complexity using synthetically generated docstrings. The docstrings are constructed by chaining operations from a set of 13 basic string manipulation building blocks (listed in Appendix C), such as "convert the string to lowercase" or "remove every third character from the string." Each building block corresponds to a single line of code, so a docstring with N chained components requires the model to generate N lines of code in the correct order.

The results show that "as the number of chained building blocks in the docstring increases, model performance decreases exponentially" and that "with each additional component, pass rate drops by roughly a factor of 2-3" (Section 6). The paper contrasts this with human performance: "this behavior is uncharacteristic of a human programmer, who should be able to correctly implement a program for a chain of arbitrary length if they can do so for a chain of length two." This exponential degradation reveals a fundamental limitation in Codex's ability to compose multiple operations from a long specification, suggesting that the model does not truly "understand" each sub-operation as a composable unit but rather relies on pattern matching against training examples of similar length and complexity.

Insecure Code Generation

Figure 15 (Appendix G) quantifies Codex's tendency to generate insecure code when prompted with cryptographic function calls. Across model sizes from 12M to 12B parameters, approximately 20-50% of RSA key generation completions use key lengths shorter than 2048 bits (the minimum recommended by security standards), and a significant fraction of AES context completions use the ECB cipher mode, which is "rarely desired" due to known security weaknesses.

The paper notes that "we do not see a robust model size trend (over 1 order of magnitude of parameters) in this data," suggesting that insecure code generation is "an alignment issue" rather than a capability issue—larger models do not automatically become more secure. The experiments use 5 prompts across different cryptographic libraries (based on Sonar Source's Python vulnerability database), generating approximately 30,000 samples total across model sizes, with some samples removed based on expected runtime errors. The paper acknowledges that the evaluation captures only "clearly insecure" configurations and that "the produced samples that were not classified as clearly insecure are not necessarily secure"—the reported numbers are therefore lower bounds on the true rate of security issues.

Ablation Studies and Robustness Checks

Temperature optimization for pass@k (Figure 5, Figure 9): The paper sweeps temperatures from 0.2 to 1.0 and finds that the optimal temperature increases with k. For Codex-679M, T* = 0.2 for pass@1 and T* = 0.8 for pass@100 (Figure 5). For Codex-S-12B, T* = 0 for pass@1 and T* = 1.0 for pass@100 (Figure 9). This demonstrates that the temperature-k relationship is robust across model sizes and between base and supervised-fine-tuned models, though Codex-S requires higher temperatures for all k > 1, which the paper attributes to its narrower distribution. The optimal temperature for intermediate values of k is obtained by "taking the upper hull" of the pass@k vs. temperature curves (Figure 5, bottom panel).

Pass@k estimator bias (Figure 13, Appendix A): The paper compares the unbiased estimator (Equation 1) against the biased approximation 1(1p^)k1 - (1 - \hat{p})^k, where p^\hat{p} is the empirical pass@1 rate estimated from n samples. The biased estimator "underestimates the true value by a considerable margin," and the gap "doesn't fully close even when n > 5k." The unbiased estimator may have "slightly higher variance initially but allows for a fair comparison across different numbers of samples." This ablation justifies the paper's choice of estimator and warns against a common but incorrect practice in the literature.

Sample selection heuristics comparison (Figure 7): For Codex-12B, mean log-probability ranking (red curve) substantially outperforms random selection for all k ≥ 2. Back-translation ranking (orange curve) outperforms random but underperforms mean log-probability. The oracle upper bound (blue curve) shows the theoretical maximum. The sum log-probability heuristic performs "slightly worse than picking randomly" (stated in text, not plotted). This ablation demonstrates that (a) the model's own confidence estimates carry genuine signal about correctness, (b) length normalization is essential for this signal to be useful, and (c) back-translation provides a weaker but still positive signal.

Left-padding during supervised fine-tuning (Section 4.4): The paper describes left-padding shorter prompts "to the length of the longest prompt, so that the first tokens in the reference solutions line up in context" during Codex-S training. While not presented as a formal ablation with and without left-padding, the paper identifies this as an important design choice that affects training dynamics. No quantitative comparison of padding strategies is provided.

Problem filtering for supervised fine-tuning (Section 4.3): The paper uses Codex-12B to generate 100 samples per curated training problem and filters out problems where no sample passes the unit tests, considering such problems "either ambiguous or too difficult." This filtering was "reran several times to remove stateful or non-deterministic problems." The paper does not report how many problems were filtered out, what the performance of Codex-S would be without filtering, or whether filtering introduces any selection bias (e.g., removing problems that require capabilities Codex-12B specifically lacks).

1-shot formatting for APPS (Table 2): For APPS evaluation, the paper appends a single input/output example from the task description as a formatting hint. Without this, the model would likely generate function-style solutions incompatible with APPS's full-program format. While not presented as a formal ablation, the stark difference between Codex's in-distribution HumanEval performance (28.81% pass@1) and out-of-distribution APPS performance (4.14% pass@1 on introductory problems) demonstrates the sensitivity of the model to distribution matching—a finding that motivates the supervised fine-tuning approach.

Filtered vs. raw pass@k on APPS (Table 2): Filtering solutions by the 3 public test cases dramatically improves pass rates: filtered pass@1 is 22.78% vs. raw pass@1 of 4.14% on introductory problems. This ablation demonstrates both the value of even minimal test-case filtering and the fact that Codex generates many solutions that pass simple tests but fail more comprehensive hidden tests—a form of overfitting to the public test cases.

Critical Assessment

The experiments support the paper's central claims, but each claim requires careful boundary-drawing to understand what was actually demonstrated versus what was asserted.

Claim: Code-specialized training produces models that substantially outperform general-purpose language models on code generation. This claim is strongly supported by Table 1. The factor of 20-30× parameter efficiency advantage (Codex-300M matching GPT-J-6B) is a robust finding that holds across multiple model sizes and both pass@1 and pass@100 metrics. However, the claim is demonstrated only for Python function synthesis from docstrings on the HumanEval benchmark. The paper does not test whether this advantage generalizes to other programming languages (the training data is exclusively Python), other code generation tasks (class implementation, bug fixing, code translation), or other evaluation methodologies. The APPS results (Table 2) show that Codex's advantage narrows substantially on full-program synthesis tasks that differ from the training distribution—while Codex-12B achieves 4.14% raw pass@1 on introductory APPS problems, GPT-Neo-2.7B (fine-tuned on APPS) achieves 3.90%, and the paper notes this is "comparable" despite the 4.4× parameter difference. This suggests the 20-30× advantage is specific to in-distribution evaluation.

Claim: Repeated sampling is a surprisingly effective strategy for producing working solutions. This claim is strongly supported by the gap between pass@1 and pass@100 across all model sizes (Table 1, Figure 6). For Codex-S-12B, generating 100 samples and selecting via oracle unit tests solves 77.5% of problems vs. 37.7% for a single sample—a more than doubling of the solve rate. The effectiveness is not in question; what requires qualification is the "surprisingly" qualifier. The paper presents no baseline for how surprising this should be—it does not, for example, compare the scaling of pass@k with k against what would be expected under a model of independent samples with fixed per-sample success probability. If samples were independent and each had probability p of being correct, pass@k would be 1(1p)k1 - (1-p)^k, and the improvement from k=1 to k=100 would be fully determined by p. The paper does not analyze whether the observed pass@k curve follows this independence model or deviates from it (which would indicate correlation between samples that either helps or hurts diversity). The finding is empirically clear but its interpretation as "surprising" is not rigorously justified.

Claim: Mean log-probability ranking is an effective heuristic for sample selection without oracle access. This claim is supported by Figure 7, but with important scope limitations. The heuristic recovers roughly 36% of the possible improvement over random selection at k=100 for Codex-12B, which is practically useful but far from solving the selection problem. Moreover, the evaluation is on HumanEval problems where the model has a non-trivial pass@1 rate (28.81%). For problems where pass@1 is near zero, the heuristic is untested—if the model cannot generate any correct solutions, no ranking heuristic will help, but the paper does not analyze whether mean log-probability ranking degrades gracefully or fails catastrophically as per-sample success probability decreases. The paper also does not compare mean log-probability against other cheap heuristics like selecting the shortest solution, the solution with the fewest syntax errors (if parseable), or the solution that executes without runtime errors (ignoring correctness of output). These are practical baselines that would contextualize the 11.6 percentage point benefit over random selection.

Claim: BLEU score is unreliable for evaluating functional correctness. Figure 8 provides compelling visual evidence for four randomly selected problems. However, the paper does not report aggregate statistics—the correlation coefficient between BLEU score and functional correctness across all 164 problems, or the area under the ROC curve for using BLEU score to classify correct vs. incorrect solutions. The four examples are illustrative but cannot quantify the overall reliability (or unreliability) of BLEU score as a proxy metric. A reader looking to cite this paper for the claim that "BLEU score is uncorrelated with functional correctness" would be over-interpreting the presented evidence; the paper shows overlap but does not measure degree of correlation or lack thereof.

Claim: Supervised fine-tuning (Codex-S) provides consistent gains across model sizes. This claim is supported by Figure 10, which shows Codex-S outperforming Codex at every model size for both pass@1 and pass@100. However, the Codex-S training involves two confounded interventions: (1) training on a different data distribution (standalone functions vs. general GitHub code), and (2) training on a much smaller dataset (~50,000 examples vs. 159 GB). The paper does not include an ablation that controls for dataset size—e.g., fine-tuning on a random 50,000-example subset of the original GitHub code to isolate the effect of distribution from the effect of dataset scale. It is therefore unclear whether the gains come from the curated distribution (as the paper argues), the smaller dataset size (which might act as a form of regularization), or the combination.

Claim: Codex's performance scales as a sigmoid in log-parameters (Figure 6). The paper fits a power law to test loss (Figure 4) but describes pass@k scaling as "a sigmoid in log-parameters" (Section 3.3) without fitting a formal sigmoid function or reporting goodness-of-fit statistics. The visual evidence in Figure 6 is suggestive but the claim is qualitative. A more rigorous analysis would compare sigmoid, power-law, and exponential fits to the pass@k vs. log-parameters data and report which functional form best describes the scaling behavior.

Missing experiments that would strengthen the paper:

  • No evaluation of pass@k for k between 1 and 100 at fine granularity. Figure 5 shows pass@k vs. k for Codex-679M, but the main results (Table 1) report only pass@1, pass@10, and pass@100. The shape of the pass@k curve—whether it shows diminishing returns, linear improvement, or super-linear improvement with k—is important for understanding the cost-benefit tradeoff of repeated sampling in practice.

  • No evaluation of the sample selection heuristics on Codex-S. Figure 10 mentions that "log-prob sample ranking with Codex-S yields similar benefits over random sampling that Codex does" but does not show the full pass@k curve for Codex-S with mean log-probability ranking analogous to Figure 7 for Codex. Given that Codex-S is the best-performing model, understanding how well heuristics work on its outputs is practically important.

  • No comparison of beam search vs. nucleus sampling for code generation. The paper uses nucleus sampling exclusively but does not compare against beam search, which is a standard technique in sequence generation and was used in contemporaneous code generation work (e.g., RobustFill, Devlin et al., 2017). Beam search might produce higher-quality single samples (improving pass@1) at the cost of reduced diversity (potentially hurting pass@100), creating a tradeoff worth characterizing.

  • No breakdown of HumanEval performance by problem category. The paper states that HumanEval problems assess "language comprehension, reasoning, algorithms, and simple mathematics" but does not report performance separately by category. This makes it difficult to understand whether Codex's limitations are concentrated in specific types of problems (e.g., algorithmic reasoning vs. string manipulation) or uniformly distributed.

  • No analysis of whether repeated sampling helps more on easy or hard problems. Given that the paper analyzes difficulty for synthetic docstring chaining (Figure 11), it is surprising that there is no difficulty-stratified analysis of the gap between pass@1 and pass@100 on HumanEval. Problems where pass@1 is near zero may benefit more from repeated sampling (if the model occasionally generates correct solutions) or not at all (if it never does)—distinguishing these cases would inform deployment strategies.

  • Limited model sizes for the temperature-k analysis. Figure 5 shows the temperature-k relationship only for Codex-679M, and Figure 9 shows it for Codex-S-12B. The paper does not demonstrate that the relationship (higher temperature optimal for larger k) holds across the full range of model sizes, which would strengthen the claim that it is a general property rather than a quirk of specific model scales.

  • No confidence intervals on pass@k estimates. Despite the paper's careful attention to unbiased estimation, it does not report confidence intervals or standard errors on any pass@k numbers. With 164 test problems and n = 200 samples per problem, the pass@k estimate has some variance (especially for large k where the estimator is sensitive to the tail of the distribution of c across problems), and without error bars it is difficult to assess whether differences between models or temperatures are statistically significant. For example, the claim that Codex-S-12B achieves 37.7% pass@1 and Codex-12B achieves 28.81%—a gap of 8.9 percentage points—would be more convincing with a confidence interval showing this difference exceeds sampling noise.

Conditional nature of the claims:

The paper's findings are most robust under the following conditions, which should be understood as boundary conditions rather than universal statements:

  • The model is evaluated in-distribution. The claims about Codex's capabilities (28.81% pass@1, 72.31% pass@100) apply to function synthesis from docstrings, which matches the training distribution. The APPS results demonstrate that these numbers do not transfer to full-program synthesis, where performance is dramatically lower. Practitioners should not extrapolate HumanEval numbers to different code generation tasks.

  • Unit tests exist and are representative. The entire evaluation framework depends on the quality of the HumanEval unit tests. If the tests have blind spots (inputs not covered, edge cases untested), pass@k may overestimate functional correctness. The paper does not report test coverage metrics for HumanEval's unit tests.

  • The programming language is Python. All training data and evaluation are Python-specific. The paper makes no claims about other languages.

  • The model has non-trivial baseline capability. The repeated sampling strategy amplifies existing capability but does not create it. For problems where pass@1 is essentially zero (e.g., APPS competition problems at 0.02%), generating 100 or 1000 samples produces only marginal improvements (3.23% pass@1000). The sampling strategy is effective only when the model's distribution already contains some correct solutions.

  • The prompts are in English and follow the docstring convention. The evaluation uses English-language docstrings with a specific format (function signature + triple-quoted docstring). Performance on other natural languages, other commenting conventions, or informal specifications is untested.

Overall, the experimental analysis is thorough within its defined scope and provides clear evidence for the paper's main claims. The most significant gap is the lack of statistical rigor (no confidence intervals, limited formal model comparison for scaling laws) and the absence of experiments that would help practitioners decide when to apply the paper's methods (difficulty-stratified analysis of sampling benefits, head-to-head comparison of selection heuristics at different capability levels). The paper succeeds as a demonstration that code-specialized training at scale, evaluated through functional correctness, produces practically useful code generation capabilities. It is less successful as a guide to optimizing the deployment of these capabilities, leaving open questions about the cost-benefit tradeoffs of repeated sampling, the reliability of heuristic selection in low-capability regimes, and the generalizability of the findings beyond Python function synthesis.

6. Limitations and Trade-offs

Limitation 1: Capability Ceiling on Hard Problems — Repeated Sampling Cannot Compensate for Fundamental Incapability

The paper is candid about a hard boundary on test-time compute: generating more samples only helps when the model's distribution already contains correct solutions at some non-trivial rate. For problems where the base model's pass@1 is effectively zero, no amount of repeated sampling — whether 100, 1000, or more — produces meaningful improvements.

This limitation manifests most starkly in the APPS benchmark results (Table 2, Section 3.5). On competition-level problems, Codex-12B achieves only 0.02% raw pass@1, and generating 1000 samples per problem — a 1000× increase in inference compute — raises the solve rate to merely 3.23%. This is a genuine ceiling: the model simply does not have correct solutions for these problems anywhere in its output distribution. The same pattern appears on HumanEval's hardest problems. Figure 2 illustrates three problems where Codex-12B's single-sample solve probabilities are 0.9, 0.17, and 0.005 — and the paper's synthetic docstring-chaining experiments (Figure 11, Section 6) show that as specification complexity increases (more chained building blocks), "pass rate drops by roughly a factor of 2-3" per additional component, producing an exponential degradation that no amount of resampling can reverse because the base probability goes to zero.

The paper explicitly acknowledges this scope limitation in the context of the synthetic experiments, noting that "this behavior is uncharacteristic of a human programmer, who should be able to correctly implement a program for a chain of arbitrary length if they can do so for a chain of length two." In other words, the model fails in a qualitatively different way than a human would — it does not have the compositional generalization capability needed to extend its understanding to longer specifications. The repeated sampling strategy is an amplifier, not a generator: it surfaces solutions already present in the distribution but does not create capability that wasn't there.

The consequence is that the headline number — 77.5% of HumanEval problems solved with 100 samples from Codex-S-12B — is not a predictor of what would happen on genuinely harder problems. A practitioner facing a problem distribution that skews harder than HumanEval (e.g., competitive programming problems, complex multi-function system design, novel algorithmic challenges) should expect the sampling strategy to provide minimal benefit, because the base model's distribution won't contain correct solutions to amplify. The paper provides no method for determining, before generating samples, whether a given problem falls into the "amplifiable" regime or the "impossible" regime — the difficulty estimation problem is left entirely unaddressed.

Mitigation status: The paper does not attempt to solve this limitation. It presents the finding as a characterization of model capability rather than a problem to fix. The synthetic docstring experiments (Appendix C, Figure 11) quantify the degradation curve but do not propose architectural or training changes to improve compositional generalization. The paper's framing is diagnostic rather than prescriptive: it identifies that the model fails on long chains of operations and competition-level problems, but does not explore why or how to address it beyond suggesting this as an area where "significant room for improvement" exists (Section 9).


Limitation 2: Sample Selection Without Oracle Access Remains Largely Unsolved — The Heuristics Recover Only a Fraction of the Possible Gain

The paper's most practically important finding — that repeated sampling dramatically increases solve rates — depends on having a way to select the correct sample from the generated pool. The pass@k metric assumes oracle access to unit tests, which is unrealistic for most deployment scenarios. The paper investigates two heuristic selection methods — mean log-probability ranking and back-translation scoring — and finds that both fall far short of oracle performance, leaving a majority of the possible gain unrealized.

For Codex-12B, oracle selection at k=100 achieves 72.31% solve rate (Table 1), while mean log-probability ranking achieves approximately 44.5% (Figure 1). The gap is roughly 27.8 percentage points — meaning that of the possible improvement over random selection (which equals pass@1 at ~28.81%), the heuristic captures only about 36%. More than 60% of the headroom between random selection and oracle selection remains inaccessible. The back-translation heuristic performs even worse: the paper states it "underperforms mean log-probability ranking" and "appears to overfit quickly" (Section 5), with its curve in Figure 7 sitting visibly below mean log-probability for all k ≥ 2.

Furthermore, there is a self-defeating property lurking in the heuristic approach: as described in Section 4.5, supervised fine-tuning (Codex-S) achieves its largest gains on pass@100 (+15.1 percentage points over Codex on average) precisely because it concentrates probability mass onto task-aligned outputs, producing a narrower distribution. But the paper also notes that Codex-S "prefers slightly higher temperatures for all k > 1" specifically "to compensate for the fact that it models a narrower distribution" (Section 4.5). This creates a tension: the fine-tuning that improves the model's capability simultaneously makes heuristic selection harder because the model's confidence estimates may become less discriminative when the distribution is concentrated around plausible-looking but incorrect solutions. The paper doesn't quantify how much of the Codex-S pass@100 gain is recoverable via heuristics vs. only via oracle access — Figure 10 mentions the benefit of mean log-probability over random ranking for Codex-S but does not show the full oracle-vs-heuristic gap for the fine-tuned model, which is the metric that matters for deployment.

The sum log-probability heuristic performing "slightly worse than picking randomly" (Section 3.3) further underscores the fragility of confidence-based selection: a seemingly natural variant of the metric — total rather than mean probability — is actively harmful because it penalizes longer (and potentially more correct) solutions. This sensitivity to a seemingly minor normalization choice suggests that log-probability-based ranking is not a robust solution but rather a heuristic that works for reasons not fully understood and may fail under distribution shifts or for different model architectures.

Mitigation status: The paper acknowledges the gap implicitly by presenting both oracle and heuristic results, but it does not frame the heuristic weakness as a central limitation requiring further research. The discussion in Section 9 simply notes that "producing multiple samples from a model" improves performance without addressing the selection problem head-on. The back-translation approach (using Codex-D) is presented as a second heuristic but is not developed further — the observation that it "appears to overfit quickly" is noted without investigation into why or whether it could be improved. The paper identifies no path toward closing the ~64% gap between heuristic and oracle selection.


Limitation 3: Single-Language, Single-Task Evaluation — No Evidence of Generalization Beyond Python Function Synthesis

All of the paper's quantitative claims rest on a single evaluation dataset (HumanEval, 164 hand-written Python problems) testing a single task (generating standalone function bodies from docstrings). The training data is exclusively Python. The APPS evaluation (Section 3.5, Table 2) tests a different task — full-program synthesis with stdin/stdout I/O — and the results reveal a dramatic capability drop that the paper does not fully grapple with.

The comparison is stark: Codex-12B achieves 28.81% pass@1 on HumanEval but only 4.14% raw pass@1 on APPS introductory problems — a 7× reduction in solve rate — despite the APPS introductory tier being described as easier than HumanEval in some respects (the paper notes these problems test "language comprehension, algorithms, and simple mathematics," similar to HumanEval's scope). On APPS interview-level problems, pass@1 drops to 0.14%, and on competition-level problems to 0.02% (Table 2). This near-zero performance on out-of-distribution task formats suggests that Codex's capabilities are tightly coupled to the specific distribution it was trained on — standalone functions with clear docstrings and return values — and do not transfer robustly to even slightly different code generation formats.

The paper does not evaluate Codex on any of the following, all of which are relevant to real-world code generation deployment: other programming languages (despite GitHub containing massive amounts of Java, JavaScript, C++, etc.), code translation tasks, bug-fixing tasks (where the model must edit existing code rather than generate from scratch), class or module-level generation, or generation conditioned on informal natural language rather than structured docstrings. The introductory text mentions that "a distinct production version of Codex powers GitHub Copilot" (Abstract), but the production system's capabilities on these broader tasks are not evaluated or even described. A practitioner reading this paper cannot determine, from the evidence presented, whether Codex's code generation capability generalizes beyond Python function synthesis or whether entirely different training and evaluation would be needed for other languages and tasks.

The paper's own discussion implicitly acknowledges this limitation by noting, in Section 8 (Related Work), that "coding is a broad activity which involves much more than synthesizing code from docstrings" and citing work on unit test generation, bug-fixing, and code review. Yet the paper itself does not extend its evaluation to any of these activities, making its claims about "code-writing capabilities" (Abstract) somewhat broader than the evidence supports.

Mitigation status: The paper partially addresses this limitation by including the APPS evaluation and by being transparent about the scope of the training data (Python only, collected May 2020). The APPS results are presented as evidence of "out-of-distribution generalization" but the paper does not claim strong generalization — the numbers speak for themselves. The limitation is not presented as something to be solved in future work but rather as a scope boundary that readers should be aware of. No experiments test whether the supervised fine-tuning approach (Codex-S) would similarly benefit other languages or tasks if appropriate training data were collected.


Limitation 4: The Training Data Contamination Problem Is Acknowledged but Not Measured or Solved

The paper explicitly identifies a fundamental tension in evaluating models trained on public code: the training data contains solutions to problems from many public sources, making it impossible to guarantee that evaluation performance reflects genuine synthesis rather than memorization. The paper addresses this for HumanEval by hand-writing the problems to avoid direct duplication. However, this solution is incomplete, and the paper does not quantify the residual contamination risk.

The key passage is in Section 2.2:

"It is important for these tasks to be hand-written, since our models are trained on a large fraction of GitHub, which already contains solutions to problems from a variety of sources. For example, there are more than ten public repositories containing solutions to Codeforces problems, which make up part of the recently proposed APPS dataset."

The hand-written nature of HumanEval prevents exact memorization of problem-solution pairs — the specific docstring text and function signatures are novel. But it does not prevent functional near-duplication: HumanEval problems are designed to be representative of common programming tasks (string manipulation, prime checking, palindrome detection, etc.), and GitHub contains thousands of implementations of these canonical tasks with varying docstrings, variable names, and coding styles. A model trained on all of GitHub has almost certainly seen the core algorithmic pattern for "check if a number is prime" or "reverse the words in a string" many times, even if it hasn't seen the exact HumanEval docstring. The performance on these problems may therefore reflect pattern recognition (matching the docstring to a known algorithm) rather than genuine synthesis from the specification.

The paper's own analysis of memorization in Section 7.7 provides some evidence that exact copying is rare:

"Our preliminary research also finds that Codex models rarely generate code that is identical to the contents of training data. Such occurrences were < 0.1% in a study examining the frequency of code generations that appear to match code snippets in the training data."

But this 0.1% figure addresses only verbatim duplication. It says nothing about near-duplication, functionally equivalent solutions with different surface forms, or the model's ability to recognize that a novel docstring maps to a well-known algorithmic pattern it has seen implemented many times. The distinction between "memorization" and "genuine synthesis" is blurred when the model has seen functionally identical solutions in its training data, even if the variable names differ.

The consequence is that HumanEval pass@k numbers may overestimate the model's synthesis capability relative to what it would achieve on genuinely novel problems — that is, problems requiring algorithms or compositional patterns that do not appear in the training data. The synthetic docstring-chaining experiments (Figure 11) partially address this by creating novel compositions of known building blocks, but the building blocks themselves (converting to lowercase, removing characters, etc.) are individually common in the training data. The paper does not evaluate on problems designed to require genuinely novel algorithmic insights.

Mitigation status: The paper acknowledges the contamination concern explicitly and takes the reasonable step of hand-writing HumanEval problems to avoid direct duplication. The 0.1% memorization study provides some reassurance about exact copying. However, the paper does not attempt to measure or bound the effect of functional near-duplication, does not filter the training data against known benchmarks (beyond auto-generated file removal), and does not propose methods for creating evaluation sets that are robust to this more subtle form of contamination. The APPS results — where performance drops substantially despite more generous evaluation (filtered pass@k, 1-shot formatting) — could be interpreted either as evidence of genuine synthesis difficulty or as evidence that HumanEval benefits from in-distribution near-duplicates, but the paper does not explore this interpretation.


Limitation 5: Insecure and Misaligned Code Generation Is a Scaling-Proof Problem Not Addressed by the Proposed Methods

The paper presents evidence that two critical failure modes — generating insecure code and producing misaligned outputs (worse code when prompted with buggy examples) — do not improve with model scale and may, in the case of misalignment, actually worsen. Neither the base training procedure nor the supervised fine-tuning approach (Codex-S) addresses these failures, and the paper offers no mitigation that is demonstrated to work at scale.

On insecure code generation (Appendix G, Figure 15): when prompted to generate cryptographic functions, Codex models across all sizes (12M to 12B parameters) produce clearly insecure configurations in a substantial fraction of cases — RSA keys shorter than 2048 bits, AES in ECB mode. The paper explicitly notes "we do not see a robust model size trend (over 1 order of magnitude of parameters) in this data," and argues that "this suggests that insecure code production, at least in this case, is an alignment issue: it is unclear if the models are improving with scale." In other words, making the model larger and training it on more code — the core interventions studied in this paper — does not make it produce more secure cryptographic code. The model learns the distribution of GitHub code, and GitHub code contains insecure patterns; scaling amplifies both secure and insecure patterns without discriminating between them.

On misalignment (Appendix E, Figures 12 and 14): when the prompt includes subtly buggy code (off-by-one errors, single-character typos), Codex produces code with a higher bug frequency than when prompted with correct code, even though the model is capable of producing correct code (demonstrated by its performance on correct-context prompts) and can be instructed to write correct code (the instruction helps "a little but does not fix the problem"). Critically, the gap between correct-context and buggy-context performance increases with model size (Figure 12), meaning larger models are more prone to this misalignment, not less. The paper interprets this as evidence that the model "is better described as 'trying' to continue the prompt by either matching or generalizing the training distribution, than as 'trying' to be helpful to the user" (Appendix E.1).

The consequence for deployment is substantial: a code generation tool that becomes more likely to propagate bugs when the user's existing code is buggy, and more likely to suggest insecure configurations regardless of context, creates a dangerous feedback loop. Novice programmers — who are most likely to have buggy code and least likely to recognize insecure suggestions — are exactly the users most vulnerable to these failure modes. The student who writes a slightly buggy function and asks Codex to complete it may receive a completion that doubles down on the bug rather than fixing it, even though Codex "knows" the correct implementation.

Mitigation status: The paper discusses mitigations in general terms (Section 7.8 and Appendix E.4): curating training data to remove buggy/insecure code, conditioning the model on a "high quality" label at deployment time (Keskar et al., 2019), fine-tuning on high-quality code, and RL from human feedback (Stiennon et al., 2020). However, none of these mitigations are implemented or evaluated for Codex. The filtering of the supervised fine-tuning dataset (Section 4.3) — which removes problems where Codex-12B cannot generate any passing solution — might inadvertently remove examples of insecure code, but the paper does not analyze whether Codex-S produces more secure code than Codex. The alignment evaluations (Appendix E) were conducted only on base Codex models, not on Codex-S. The paper concludes that "more work is needed" and that "fully aligning models on tasks that are hard for human labelers... is a challenging open research problem" — an honest admission that the paper identifies the problem but does not solve it.


Limitation 6: The Practical Deployment Gap — Difficulty Estimation, Prompt Engineering Overhead, and Latency Are Unaccounted For

The paper's headline results assume ideal conditions that do not hold in real deployment: problems come pre-packaged with clean function signatures and docstrings, the appropriate number of samples k can be chosen without knowing problem difficulty in advance, and there is no latency constraint on generating and evaluating multiple samples. These assumptions collectively create a gap between the paper's reported performance and what a practitioner would experience when integrating Codex into a development workflow.

Prompt engineering overhead. HumanEval problems provide structured prompts with a specific format: a function signature, a well-written docstring (often including doctest-style examples), and an unambiguous specification of the desired behavior. Real-world programming scenarios rarely present this cleanly. A developer might have a vague intention ("sort this list of dictionaries by date and filter out entries before 2020"), a partially written function, or a comment in informal language. The paper provides no evidence about how Codex's performance degrades as prompt quality decreases — whether informal specifications, ambiguous requirements, or missing type hints reduce pass@1 by a small factor or render the model essentially useless. The synthetic docstring experiments (Figure 11) test complexity of specification but not quality — all synthetic docstrings are unambiguous and precisely specify the required operations.

No difficulty estimation or adaptive sampling strategy. The paper demonstrates that more samples help, but does not address the meta-problem: for a given problem, how many samples should you generate? Generating 100 samples for an easy problem that the model solves on the first try wastes 99× the inference compute. Generating only 1 sample for a hard problem that the model solves 1% of the time leaves a 99% chance of failure when 100 samples might have succeeded. The paper does not propose any method for estimating problem difficulty before or during generation — no confidence-based early stopping, no progressive sampling strategy, no classifier trained to predict whether a problem is likely to benefit from additional samples. The "oracle" in the pass@k metric is not just knowing which sample is correct but knowing how many samples to generate, and the paper provides no guidance on this practical question.

Latency vs. throughput tradeoff. The paper measures compute in "samples generated" but ignores wall-clock time. On appropriate hardware, 100 independent samples can be generated in parallel with minimal latency increase over a single sample — but only if sufficient compute resources are available. For a developer using an API or a local tool, generating and transmitting 100 full function bodies may take 100× longer than a single sample if resources are constrained, and the sample selection heuristic (mean log-probability) requires scoring all 100 samples, adding further computation. The paper does not discuss this latency-throughput tradeoff, does not report generation times, and does not evaluate whether smaller values of k (e.g., k = 5 or k = 10) with heuristic selection might provide a better latency-adjusted performance than k = 100.

The APPS filtering strategy as an implicit oracle. The APPS filtered pass@k results (Table 2) — which use the 3 public test cases provided in the problem statement to filter out obviously incorrect solutions before scoring — achieve dramatically higher pass rates than raw pass@k. But this filtering strategy itself depends on having access to test cases, which is exactly the oracle that pass@k assumes. In practice, a developer using Codex to solve a novel problem does not have pre-existing unit tests (if they did, they could use test-driven development and wouldn't need the model to generate the initial solution). The filtering results therefore share the same oracle-dependence problem as the main pass@k metric, and the paper does not discuss how to approximate this filtering in an oracle-free setting.

Mitigation status: The paper does not address any of these deployment-gap issues. The HumanEval dataset is released as a benchmark with a fixed format, not as a guide to prompt engineering. The temperature-k analysis (Figures 5, 9) implicitly assumes the practitioner knows k in advance and can tune temperature accordingly, but does not provide a method for choosing k adaptively. The discussion of sample selection heuristics (mean log-probability, back-translation) is the only nod toward oracle-free deployment, and as discussed in Limitation 2, these heuristics leave a large performance gap. The paper's explicit framing is as a capability demonstration and evaluation methodology contribution, not as a deployment guide — but the gap between the demonstrated capability (77.5% with oracle access) and what a practitioner can achieve without oracles, without clean prompts, and under latency constraints is substantial and unquantified.

7. Implications and Future Directions

How This Work Changes the Landscape

This paper does not introduce a new model architecture, training objective, or algorithmic innovation. It introduces something more foundational: a redefinition of what it means to evaluate code generation. Before this work, the field treated generated code as text — measuring its quality by how many n-grams it shared with a reference solution. This convention was inherited from machine translation and text summarization, where it was already known to be imperfect, but in code it crosses a line from imperfect to actively misleading. Two programs can be functionally identical while sharing almost no tokens (different variable names, different control flow, different library calls), and two programs can have high textual overlap while producing different outputs on the same inputs. A metric that cannot distinguish these cases is not merely noisy — it is measuring the wrong thing.

The paper makes this critique empirically irreversible. Figure 8's overlapping BLEU distributions for correct and incorrect Codex-12B solutions — on four randomly selected HumanEval problems — provides direct, visual evidence that surface-form matching cannot separate working from non-working code. Since incorrect solutions are guaranteed to be functionally inequivalent to the reference (they fail at least one unit test), the overlap demonstrates a structural mismatch between the metric space and the correctness space. A researcher optimizing for BLEU score on these problems could steer their model away from functional correctness without realizing it.

The practical consequence of this reframing is that the field now has a principled, reproducible, and automated evaluation standard in HumanEval and the unbiased pass@k estimator. The unbiased estimator (Equation 1) solved a specific statistical problem — the bias in the commonly used approximation 1(1p^)k1 - (1 - \hat{p})^k — and the numerically stable implementation in Figure 3 made it trivial for other researchers to adopt. The release of the dataset and evaluation framework at a public GitHub repository lowered the barrier to entry: any group training a code generation model could now benchmark against the same 164 hand-written problems with the same metric, producing numbers that could be directly compared across papers. This is a methodological contribution that compounds — each subsequent paper that adopts HumanEval and pass@k strengthens the common evaluation framework, making cross-paper comparisons more meaningful over time.

The paper's second major conceptual shift is the demonstration that a model's internal distribution contains correct solutions for many more problems than its single-sample output reveals, and that this gap widens with model scale. This reframes the capability question from "what can the model do on its first try?" to "what solutions exist in the model's distribution?" The implication is that capability expression — how to surface a correct solution from the distribution — is a problem of comparable importance to capability acquisition — how to get the correct solution into the distribution in the first place. The paper shows that larger models hide progressively more of their capability behind sampling variance (the pass@1-to-pass@100 gap grows with model size in Figure 6), meaning this expression problem becomes more acute, not less, as models improve.

This finding reconciles what might otherwise appear to be contradictory evidence about the usefulness of language models for code generation. A practitioner who evaluates a model by generating one sample per problem and checking correctness — the intuitive, default approach — would conclude that Codex-12B can solve about 29% of HumanEval problems. A practitioner who generates 100 samples and checks them all would conclude it can solve about 72%. Both numbers are correct under their respective evaluation protocols, but they measure different things: one measures the model's most-likely-output capability, the other measures the breadth of its solution distribution. The paper's contribution is not just reporting both numbers but providing the statistical machinery (the unbiased estimator) and the sampling strategy analysis (the temperature-k tradeoff in Figure 5) to understand why they differ and when each matters.

The temperature-k tradeoff itself (Figure 5) is a diagnostic contribution: the optimal sampling temperature depends on k, with lower temperatures better for small k (where single-sample accuracy dominates) and higher temperatures better for large k (where diversity matters more). This is intuitive in retrospect but had not been systematically characterized for code generation before this paper. It provides a practical knob for deployment: an autocomplete tool showing one suggestion should use low temperature; a batch code generation system that can evaluate many candidates should use high temperature. The fact that Codex-S requires higher temperatures for all k > 1 (Figure 9) — because supervised fine-tuning concentrates its distribution, reducing diversity — reinforces that this tradeoff is not a temporary quirk but a structural property of autoregressive generation that must be managed as models improve.

The supervised fine-tuning results (Codex-S, Section 4) demonstrate a complementary lever: distribution matching matters as much as scale. Codex-S improves pass@1 by 6.5 percentage points and pass@100 by 15.1 percentage points on average across model sizes, not by training on more data or a larger model but by training on different data — a curated set of ~50,000 correctly implemented standalone functions rather than 159 GB of general GitHub code. The fact that a 300M-parameter Codex matches GPT-J-6B (20× larger) on HumanEval (Table 1) quantifies the parameter efficiency gain from training on the right distribution. This is not a novel technique — supervised fine-tuning on task-aligned data is well-established — but the paper provides the first large-scale quantification of its benefit for code generation and shows it composes with model scaling (the gains are consistent across model sizes in Figure 10).

The comparative analysis against GPT-Neo, GPT-J, and Tabnine (Table 1) establishes a clear capability hierarchy that had been only anecdotal before HumanEval provided a common metric. The finding that GPT-Neo-2.7B (trained on The Pile with 8% GitHub code) is roughly equivalent to Codex-85M (30× smaller, trained exclusively on code) gives a concrete number to the intuition that code-specific training matters. The finding that all GPT models (trained on natural language only) score near 0% on HumanEval demonstrates that natural language pretraining alone does not transfer to code generation at this scale, contrary to what might have been hoped from GPT-3's early demonstrations of rudimentary code generation.

The paper also resolves a tension in how the research community should think about evaluation contamination. Prior work had noted that training on public code creates a risk of memorizing solutions to benchmark problems, but the response was ad hoc — some papers used held-out test sets from public sources, others hand-wrote problems, and there was no consensus on what constituted a clean evaluation. The paper's explicit identification of contamination as a methodological problem (citing "more than ten public repositories containing solutions to Codeforces problems" in the APPS dataset, Section 2.2) and its solution — hand-writing all 164 HumanEval problems to avoid exact duplication — established a standard that subsequent work could follow. The 0.1% memorization study (Section 7.7) provided some empirical reassurance about exact copying, though the paper acknowledges that functional near-duplication remains a concern that is not fully addressed.

Finally, the paper's alignment and security analyses (Appendices E and G) introduced a diagnostic framing that has outlasted the specific models studied. The finding that misalignment — the model producing worse code when prompted with buggy examples, despite being capable of better — increases with model size (Figure 12) is a concrete warning that scaling alone does not solve alignment problems and may exacerbate them. The finding that insecure code generation (Figure 15) shows no robust improvement with model size across an order of magnitude of parameters identifies a class of failures that are orthogonal to the capability improvements measured by pass@k. These analyses established evaluation practices — measuring not just what the model can do but what it chooses to do, and measuring not just correct behavior but safe behavior — that have become standard in subsequent work on code generation models.

Follow-Up Research This Work Enables or Suggests

1. Difficulty-adaptive sampling: how many samples should you generate for a given problem, and can you decide this before generating them? The paper demonstrates that repeated sampling amplifies capability but provides no mechanism for deciding when to use it. A problem that the model solves with 90% probability on the first attempt gains almost nothing from 100 samples; a problem solved with 1% probability gains enormously. The obvious follow-up is a difficulty estimator that predicts, from the prompt alone (or from a small number of initial samples), how many samples are needed to achieve a target pass probability. A strong experiment would train a lightweight classifier on the HumanEval training distribution — using prompt features (docstring length, presence of algorithmic keywords, number of input-output examples) or early-sample features (mean log-probability of the first few samples, diversity of generated outputs) — to predict the empirical pass@1 rate or the shape of the pass@k curve. The metric would be whether adaptive sampling (allocating more samples to hard problems, fewer to easy ones) achieves a higher aggregate solve rate than uniform sampling at the same total generation budget. The paper's HumanEval dataset, with its 164 hand-written problems of varying difficulty, provides a natural testbed for this experiment. A negative result — finding that early samples carry little signal about whether more samples would help — would be equally valuable, as it would indicate that difficulty estimation requires fundamentally different approaches than surface-level prompt analysis.

2. Combining sample selection heuristics: can mean log-probability, back-translation, and execution-based filtering be combined to close the gap with oracle selection? The paper evaluates selection heuristics in isolation — mean log-probability ranking recovers ~36% of the possible gain over random selection, back-translation recovers less — but does not investigate whether combining them multiplicatively or through a learned weighting would perform better. A natural experiment is to train a binary classifier (correct vs. incorrect) on features including mean log-probability, back-translation score, and additional signals the paper does not explore: syntactic validity (does the code parse?), runtime behavior (does it execute without errors on the example inputs provided in the docstring?), code length, and agreement with other samples (majority voting on the output for a few canonical inputs). The training data would be the n = 200 samples per HumanEval problem, labeled by unit test outcomes. The evaluation would measure how close the combined classifier gets to oracle pass@k. Because the paper's HumanEval framework already generates and labels 200 samples per problem, this experiment requires no new model inference — only feature extraction and classifier training on existing data. A key question is whether the benefit of combining heuristics is additive (each contributes independent signal) or redundant (all heuristics capture the same underlying confidence dimension). The paper's finding that back-translation "appears to overfit quickly" (Section 5) suggests it may capture a different signal than log-probability, making combination potentially fruitful.

3. BLEU score as a diagnostic for when functional correctness evaluation is most needed. The paper shows that BLEU distributions for correct and incorrect solutions overlap (Figure 8), establishing that BLEU is unreliable as a primary metric. But the paper does not quantify how unreliable — the correlation between BLEU and functional correctness across all 164 problems, the AUC for using BLEU to classify correct vs. incorrect solutions, or whether BLEU is more reliable for some problem types than others. A follow-up analysis using the existing 200 samples per problem for Codex-12B (already generated and labeled with unit test outcomes) would compute these aggregate statistics. The practical question is: are there regimes where BLEU is so unreliable that functional correctness evaluation is essential, and other regimes where BLEU is a reasonable proxy? For example, problems requiring exact string manipulation (where the reference solution is one of few possible implementations) might show higher BLEU-correctness correlation than problems with diverse algorithmic solutions. This analysis would help the community decide when the overhead of unit-test-based evaluation (writing tests, setting up a sandbox) is worth the improved metric quality versus when surface-form metrics are an acceptable approximation. It would also identify problem categories where new, specialized evaluation approaches are most needed.

4. The effect of supervised fine-tuning dataset composition on capability breadth. Codex-S is trained on two complementary data sources — ~10,000 competitive programming problems (algorithmic reasoning) and ~40,000 CI-traced functions (practical utility functions) — but the paper does not ablate their individual contributions. A follow-up would train Codex-S variants on each source independently and on both combined, then evaluate not just on aggregate HumanEval pass@k but on HumanEval problems stratified by type (string manipulation vs. algorithmic reasoning vs. mathematical computation, to the extent HumanEval problems can be categorized). The hypothesis is that competitive programming data drives improvements on algorithmic problems while CI-traced data drives improvements on practical function synthesis, and that the full Codex-S benefit comes from covering both. If the benefits are additive, this provides a recipe for targeted data collection: to improve on a specific code generation sub-task, collect supervised fine-tuning data from the corresponding distribution. If the benefits are synergistic (the combined model outperforms the sum of individual improvements), this suggests that exposure to diverse function synthesis problems transfers across sub-tasks, and the key design choice is breadth of the fine-tuning distribution rather than precise matching to the evaluation set. A negative result — finding that one data source dominates and the other contributes negligibly — would simplify future data collection efforts by identifying which source of training problems is worth the curation effort.

5. Stress-testing the pass@k estimator: what happens when samples are not independent? The unbiased estimator in Equation 1 assumes that when drawing k samples without replacement from a pool of n, the correctness of each sample is independent of the others (beyond the without-replacement constraint). But samples from a language model at a given temperature are not independent — they are generated from the same model with the same parameters, and the model's probability distribution induces correlations between samples. If the model generates the same incorrect solution repeatedly (low diversity), the effective number of independent samples is less than k, and pass@k computed from the estimator may overestimate the true probability of finding a correct solution in k independent attempts from the model's distribution (as opposed to k draws from a fixed pool of n samples). A diagnostic experiment would compare the pass@k estimator computed from n = 200 samples against pass@k computed by repeatedly drawing k independent samples from the model (i.e., generating batches of k samples independently, checking each batch for at least one correct answer, and averaging). If the two estimates diverge — particularly at low temperatures where diversity is low — this would reveal a limitation of the estimator when applied to low-diversity sampling regimes. The fix, if needed, would be to increase the total sample count n until the pool adequately represents the model's distribution, or to develop an estimator that accounts for sample correlation. This is a methodological follow-up that directly stress-tests one of the paper's core contributions.

6. Does supervised fine-tuning (Codex-S) reduce or exacerbate insecure code generation and misalignment? The paper's security analysis (Appendix G) and alignment analysis (Appendix E) are conducted on base Codex models only. It is unknown whether the supervised fine-tuning procedure — which filters training problems where Codex-12B cannot generate any passing solution (Section 4.3) — incidentally removes insecure code patterns or exacerbates them. A direct follow-up would replicate the cryptographic security evaluation (Figure 15) and the buggy-context misalignment evaluation (Figure 12) on Codex-S models across the same size range. If Codex-S shows lower rates of insecure code generation or smaller misalignment gaps, this would suggest that curating the fine-tuning distribution for functional correctness also improves security and alignment as a side effect — a practically important finding that would make supervised fine-tuning more attractive. If Codex-S shows worse security or alignment (because the narrower training distribution overfits to task-specific patterns and loses the broader code-quality signal from the diverse GitHub corpus), this would indicate that functional correctness and safe behavior are independent objectives that must be optimized separately — an equally important negative result that would motivate research into multi-objective fine-tuning approaches.

Practical Applications and Downstream Use Cases

1. Automated code generation with human-in-the-loop verification. The paper's most directly actionable finding for deployment is the combination of repeated sampling with mean log-probability ranking. In a setting where a developer writes a function signature and docstring, the system generates k = 10 or k = 20 candidate implementations, ranks them by mean log-probability, and presents the top-ranked candidates to the developer for review and selection. For Codex-12B, this yields approximately 44.5% solve rate at k = 100 (Figure 1); at smaller k the solve rate is lower but the review burden on the developer is proportionally smaller. The key deployment insight is that the developer does not need to write unit tests — the model's own confidence estimates provide a useful ranking signal, and the developer's judgment serves as the final correctness check. This workflow is directly analogous to how GitHub Copilot (the production descendant of Codex) operates: generate suggestions, rank by internal confidence, present the top suggestions to the user. The paper provides the empirical justification for this design — mean log-probability ranking outperforms random selection by 11.6 percentage points for Codex-S-12B (Section 4.5) — and quantifies the tradeoff between k (number of suggestions generated) and solve rate, enabling product decisions about how many candidates to surface to the user.

2. Test-driven code synthesis for batch evaluation pipelines. In settings where unit tests are available — for example, in educational contexts where instructors write problems with test suites, in competitive programming platforms that already have hidden test cases, or in organizations that practice test-driven development — the full pass@k strategy can be deployed. The paper's results suggest a concrete batch pipeline: for each problem, generate n = 200 samples at high temperature (T = 0.8 for Codex, T = 1.0 for Codex-S) to maximize diversity, execute all samples against the unit tests in the sandbox, and report the first passing solution (or all passing solutions). The 77.5% solve rate for Codex-S-12B at pass@100 (Figure 1) means that roughly three-quarters of HumanEval-difficulty problems can be solved automatically with this approach, requiring only that someone has written the tests. For an organization with a repository of test-driven specifications (e.g., a software engineering curriculum with autograded assignments), this pipeline could automate solution generation for problems that fall within the model's capability range, flagging the remaining ~22.5% for human attention. The sandbox design described in Section 2.3 (gVisor container runtime, eBPF firewall rules) provides a reference architecture for the execution environment, addressing the security concerns that would otherwise make automated execution of model-generated code prohibitively risky.

3. Training data generation for supervised fine-tuning of future code models. The paper's supervised fine-tuning pipeline (Section 4) — collect problems from competitive programming and CI tracing, filter using the model's own capability, train on the curated distribution — is a recipe that subsequent work can replicate and extend. The key finding that Codex-S improves pass@100 by 15.1 percentage points on average (Section 4.5) means that the investment in data curation pays off substantially, and the paper provides a cost estimate for that curation: ~50,000 problems collected through a combination of automated tracing and competitive programming scraping, filtered by generating 100 samples per problem and keeping only those where Codex-12B finds at least one correct solution. An organization training a code model for a specific domain (e.g., data science, web development, systems programming) could follow the same pipeline: collect domain-specific code with associated documentation, automatically extract function-level input-output pairs through profiling, filter with an existing code model, and fine-tune. The paper demonstrates that this approach works for general Python function synthesis; the extension to domain-specific synthesis is a straightforward application of the same methodology with different data sources. The CI tracing methodology using sys.setprofile is particularly replicable — it requires only that the target codebase have integration tests that exercise the functions of interest, which is true of most well-maintained open-source projects.

4. Docstring generation as a code understanding and documentation tool. The paper's Codex-D model (Section 5) achieves 20.3% pass@1 and 46.5% pass@10 on docstring generation at temperature 0.8, as judged by human evaluation. While lower than Codex-S's code generation pass rates (32.2% pass@1, 59.5% pass@10), these numbers represent a non-trivial capability to automatically document code. In a deployment setting, a docstring generation tool could be integrated into a code editor or code review workflow: when a developer writes a function without documentation, the tool generates a candidate docstring for review. The paper's finding that Codex-D sometimes generates meta-commentary ("I just found this function online") rather than functional descriptions identifies a failure mode that would need to be filtered or flagged in production, but the 46.5% pass@10 indicates that for nearly half of functions, at least one of 10 generated docstrings is correct and specific. This is sufficient to provide value as a documentation assistant, especially if combined with a ranking heuristic (analogous to mean log-probability for code) to present the most likely correct docstring first. The paper's back-translation experiments (Section 5) — using Codex-D to score code samples — also suggest a dual-use deployment where the docstring model serves both as a documentation tool and as a component of a code ranking system, though the paper's finding that back-translation underperforms log-probability ranking tempers expectations for the latter application.