NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Program Synthesis with Large Language Models

Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie J. Cai, Michael Terry, Quoc V. Le, Charles SuttonarXiv 2021

Abstract

This paper explores the limits of the current generation of large language models for program synthesis in general purpose programming languages. We evaluate a collection of such models (with between 244M and 137B parameters) on two new benchmarks, MBPP and MathQA-Python, in both the few-shot and fine-tuning regimes. Our benchmarks are designed to measure the ability of these models to synthesize short Python programs from natural language descriptions. The Mostly Basic Programming Problems (MBPP) dataset contains 974 programming tasks, designed to be solvable by entry-level programmers. The MathQA-Python dataset, a Python version of the MathQA benchmark, contains 23914 problems that evaluate the ability of the models to synthesize code from more complex text. On both datasets, we find that synthesis performance scales log-linearly with model size. Our largest models, even without finetuning on a code dataset, can synthesize solutions to 59.6 percent of the problems from MBPP using few-shot learning with a well-designed prompt. Fine-tuning on a held-out portion of the dataset improves performance by about 10 percentage points across most model sizes. On the MathQA-Python dataset, the largest fine-tuned model achieves 83.8 percent accuracy. Going further, we study the model's ability to engage in dialog about code, incorporating human feedback to improve its solutions. We find that natural language feedback from a human halves the error rate compared to the model's initial prediction. Additionally, we conduct an error analysis to shed light on where these models fall short and what types of programs are most difficult to generate. Finally, we explore the semantic grounding of these models by fine-tuning them to predict the results of program execution. We find that even our best models are generally unable to predict the output of a program given a specific input.

Introduction: The Challenge of General-Purpose Program Synthesis

Program synthesis—the task of automatically generating executable code from natural language descriptions—has long been a "holy grail" of AI. Historically, researchers focused on restricted Domain-Specific Languages (DSLs) or symbolic methods. However, these don't translate well to the messy, "full-featured" world of general-purpose languages like Python.

This research investigates whether massive Transformer-based models, originally designed for natural language, can bridge this gap. The study specifically examines three core questions:

  1. Scaling: Does adding more parameters consistently make models better at coding?
  2. Generalization: Can these models solve "entry-level" programming tasks they haven't seen before?
  3. Understanding: Do these models actually "understand" the semantics of code, or are they just sophisticated pattern matchers?

Methodology and Datasets

The researchers evaluated a suite of dense, decoder-only Transformer models ranging from 244 million to 137 billion parameters. These models were pre-trained on a massive 2.81 trillion token dataset of web documents (including code-heavy sites like StackOverflow) and Wikipedia.

Testing occurred under two main regimes:

  • Few-shot Prompting: Providing the model with a few examples of (Description $\rightarrow$ Code) pairs and asking it to complete a new one.
  • Fine-tuning: Training the model further on a small, task-specific dataset to specialize it for Python synthesis.

To evaluate these models, the paper introduces two significant new benchmarks:

  1. MBPP (Mostly Basic Programming Problems): 974 short Python functions designed for entry-level programmers. Each includes a description, the code, and three automated test cases.
  2. MathQA-Python: A Python-translated version of the MathQA benchmark, containing ~24,000 problems involving complex natural language descriptions of mathematical word problems.
Examples of programming tasks from the MBPP dataset and the corresponding code generated by the model.

Beyond simple generation, the authors pioneered Human-Model Collaboration experiments, where a human provides natural language feedback to help the model repair its own buggy code.

Key Results and Insights

The most significant finding is the Log-Linear Scaling Law. Coding ability isn't a "binary" skill that emerges suddenly; it improves predictably as models get larger. The slope of this improvement shows no signs of flattening, suggesting even larger models will be even better coders.

The percentage of tasks solved scales log-linearly with model size for both few-shot and fine-tuned models.

Performance Benchmarks

  • MBPP Performance: The largest 137B model solved 59.6% of problems in a few-shot setting. Fine-tuning on a tiny set of 374 examples boosted this by roughly 10 percentage points.
  • MathQA-Python: The fine-tuned 137B model achieved a high accuracy of 83.8%.
  • Human-in-the-loop: Through four turns of natural language dialog, the model's success rate on a difficult subset of problems jumped from 30% to 65%, effectively halving the error rate. This points toward a future where AI acts as a collaborative "pair programmer."

The "Understanding" Gap

Despite their generative prowess, the models exhibit a striking "understanding" gap. They are much better at writing code than executing it in their "heads." Even the best models were generally unable to predict the output of a program given a specific input, with accuracy never exceeding 29%. This suggests they lack a robust internal model of program semantics.

Additionally, the models showed high Prompt Sensitivity. The specific examples chosen for a few-shot prompt matter immensely. One set of examples might lead to a 60% success rate, while another might result in less than 30%, highlighting the "brittleness" of current prompting techniques.

Limitations and Future Outlook

The authors acknowledge that their benchmarks focus on "short and simple" programs—mostly single functions. They haven't yet captured the complexity of large-scale software engineering involving multiple files or complex library dependencies. Furthermore, the models are still unreliable; they might require many samples to produce one correct solution.

Future work should focus on improving the semantic grounding of models so they can reason about code execution, developing better collaborative tools, and exploring multi-modal approaches.

Summary updated

BibTeX
@misc{austin2021program,
  author = {Jacob Austin and Augustus Odena and Maxwell Nye and Maarten Bosma and Henryk Michalewski and David Dohan and Ellen Jiang and Carrie J. Cai and Michael Terry and Quoc V. Le and Charles Sutton},
  title = {{Program Synthesis with Large Language Models}},
  year = {2021},
  eprint = {2108.07732},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.07732},
}
Figure