Program Synthesis with Large Language Models
Jacob AustinAugustus OdenaMaxwell NyeMaarten BosmaHenryk MichalewskiDavid DohanEllen JiangCarrie CaiMichael TerryQuoc Le
Introduces the MBPP benchmark for Python code synthesis, demonstrating that large language model performance scales log-linearly with model size and that conversational human feedback cuts error rates in half.
The growing capability of large language models offers promising avenues for automating software engineering workflows. Historically, automated program synthesis has been largely confined to narrow, domain-specific languages due to the difficulty of producing correct, executable code in general-purpose languages. Developing models that can generate functional Python code directly from human descriptions has major real-world significance, as it could substantially boost developer productivity and make software development more accessible to non-experts.
The article evaluates the extent to which dense, decoder-only Transformer language models can synthesize short, functional Python programs from natural language prompts and input-output assertions. It also examines the models' capacity to refine code interactively with human feedback and their ability to execute and predict the runtime output of existing programs.
The evaluation used language models ranging from 244 million to 137 billion parameters, pre-trained on a broad web and dialog corpus without specialized code pre-training. Researchers created two primary benchmarks: Mostly Basic Programming Problems (MBPP), comprising 974 entry-level Python programming tasks with functional unit tests, and MathQA-Python, containing 23,914 mathematical word problems translated into Python. The evaluation assessed both few-shot prompting and fine-tuned models, testing functional correctness by executing the generated solutions against rigorous test suites using multiple sampling temperatures.
Synthesis performance scales predictably and log-linearly with model size across both datasets. On MBPP, the largest 137B model solved 59.6% of tasks using few-shot prompting, and fine-tuning improved accuracy by approximately 10 percentage points across most model scales. On MathQA-Python, the fine-tuned 137B model attained 83.8% accuracy. Crucially, human-in-the-loop interaction proved highly effective: allowing humans to provide up to four short conversational hints more than doubled few-shot success on a subset of MBPP problems from 30% to 65%, cutting the overall error rate in half. In contrast, the models demonstrated severe deficits in program execution, failing to accurately predict the output of given programs and rarely exceeding 29% execution accuracy even when fine-tuned.
These findings indicate that large language models are powerful code-generation assistants when coupled with automated testing and human oversight, but they lack deep semantic understanding of program execution. Because a single natural language hint provided more performance gain than a five-fold increase in automated sample generations, the most effective practical application is collaborative pairing rather than fully autonomous programming. Furthermore, the risk of memorization is minimal, as training data overlap with the benchmark tasks was exceedingly low, but models remain prone to subtle logical errors on multi-step problems.
Organizations considering generative code tools should integrate these models as interactive developer assistants with automated test harnesses rather than autonomous systems. Leaders should establish testing pipelines that automatically validate generated code and design workflows enabling rapid human feedback. Before deploying such models into production engineering pipelines, teams must conduct additional analyses on code security, bias, and vulnerability risks.
Confidence in these findings is high for short, standalone programming functions under clear test conditions. However, caution is advised when extrapolating to complex software architectures. The benchmarks evaluated short, isolated Python scripts, and the models' inability to accurately trace program execution highlights fundamental limitations in their grasp of software semantics.
- Paper: Evaluating Large Language Models Trained on Code, Mark Chen et al. (2021). Evaluating Large Language Models Trained on Code established the Codex methodology and HumanEval benchmark that directly informed the code-synthesis evaluations and datasets analyzed in the source paper.
- Paper: Textbooks Are All You Need, Suriya Gunasekar et al. (2023). Textbooks Are All You Need builds directly on the code-synthesis findings of the source paper by demonstrating that high-quality, targeted training data enables much smaller models to excel at Python generation.
