Computer code generation from task descriptions using neural networks
Abstract
Methods, systems, and apparatus, including computer programs encoded on computer storage media, for generating computer code using neural networks. One of the methods includes receiving description data describing a computer programming task; receiving a first set of inputs for the computer programming task; generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks; for each candidate computer program in a subset of the candidate computer programs and for each input in the first set: executing the candidate computer program on the input to generate an output; and selecting, from the candidate computer programs, one or more computer programs as synthesized computer programs for performing the computer programming task based at least in part on the outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 20 · Forward citations: 0.
Claims (25 — 3 Independent, 22 Dependent)
- Claim 1Independent Claim
A method performed by one or more computers, the method comprising: receiving description data describing a computer programming task, the description data comprising a plurality of text tokens; receiving a first set of inputs for the computer programming task; generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks, wherein each generative neural network in the set is deployed as a plurality of instances on a respective set of one or more devices, and wherein each instance of each generative neural network in the set is configured to, in parallel with each other instance of each generative neural network, receive an input sequence that includes the plurality of text tokens in the description data and to process the input sequence to generate an output sequence comprising a plurality of computer code tokens that specifies a candidate computer program for performing the computer programming task described by the description data; for each candidate computer program in a subset of the candidate computer programs and for each input in the first set: executing the candidate computer program on the input on the respective set of one or more devices on which the instance that generated the candidate computer program is deployed to generate an output; and selecting, from the candidate computer programs, one or more computer programs as synthesized computer programs for performing the computer programming task based at least in part on the outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs, comprising: clustering the candidate computer programs in the subset into a plurality of clusters based on the outputs generated by executing the candidate computer programs on the inputs in the first set; and selecting, as a synthesized computer program, one or more respective candidate computer programs from each of one or more of the clusters.
- Claim 2Depends on #1
The method of claim 1, further comprising: receiving a new input for the computer programming task; and executing one or more of the synthesized computer programs on the new input to generate an output for the computer programming task for the new input.
- Claim 3Depends on #1
The method of claim 1, further comprising: receiving, for each input in the first set, a respective expected output generated by performing the computer programming task on the input, wherein the selecting comprises: for each candidate computer program in the subset and for each input in the first set: determining whether the output generated by executing the candidate computer program on the input matches the respective expected output for the input; and selecting, as an initial set of computer programs, only candidate computer programs that, for each input in the first set, generated an output that matched the respective expected output for the input when executed on the input; wherein selecting, from the candidate computer programs, one or more computer programs as synthesized computer programs for performing the computer programming task based at least in part on the outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs comprises selecting, as a synthesized computer program, one or more respective computer programs from the initial set of computer programs.
- Claim 4Depends on #1
The method of claim 1, wherein the subset of candidate computer programs includes all of the plurality of candidate computer programs.
- Claim 5Depends on #1
The method of claim 1, wherein selecting, as a synthesized computer program, one or more respective computer programs from each of one or more of the clusters comprises: selecting, as a synthesized computer program, one or more respective computer programs from each of a predetermined number of largest clusters of the plurality of clusters.
- Claim 6Depends on #1
The method of claim 1, wherein obtaining the first set of inputs for the computer programming task comprises: processing one or more description sequences that each include the plurality of text tokens from the description data using a test input generation neural network that is configured to process each description sequence to generate as output one or more test inputs for the computer programming task described by the description sequence.
- Claim 7Depends on #1
The method of claim 1, wherein the subset of candidate computer programs includes only candidate computer programs that were not filtered out from the plurality of candidate computer programs based on, for each candidate computer program and for each input in a second set of inputs, whether the output generated by executing the candidate computer program on the input matched a respective expected output for the input.
- Claim 8Depends on #1
The method of claim 1, wherein the set of one or more generative neural networks includes only a single generative neural network.
- Claim 9Depends on #1
The method of claim 1, wherein the set of one or more generative neural networks includes a plurality of generative neural networks, wherein each generative neural network in the set has a different combination of values for a set of one or more properties than each other neural network in the set, and wherein the properties include one or more of (i) training data used to train the generative neural network, (ii) a number of parameters of the generative neural network, or (iii) a sampling temperature for sampling output sequences from the generative neural network.
- Claim 10Depends on #1
The method of claim 1, wherein one or more of the generative neural networks in the set include: an encoder neural network configured to process the input sequence to generate an encoded representation of the input sequence; and a decoder neural network configured to process the encoded representation to generate the output sequence.
- Claim 11Depends on #10
The method of claim 10, wherein the encoder neural network is a Transformer encoder that applies self-attention over the input sequence and the decoder neural network is an auto-regressive Transformer decoder that applies cross-attention into the encoded representation.
- Claim 12Depends on #1
The method of claim 1, wherein generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks comprises repeatedly performing operations comprising: generating a current input sequence from the description data; and sampling one or more output sequences by processing the current input sequence using one of the generative neural networks in the set.
- Claim 13Depends on #12
The method of claim 12, wherein each input sequence comprises the plurality of text tokens from the description data and one or more tokens identifying a programming language, and wherein generating a current input sequence from the description data comprises: sampling a programming language from a distribution over a set of programming languages; and including one or more tokens identifying the programming language in the current input sequence.
- Claim 14Depends on #12
The method of claim 12, wherein each input sequence comprises the plurality of text tokens from the description data and one or more tokens indicating whether the output sequence generated by the generative neural network should specify a correct or incorrect solution for the computer programming task, and wherein generating a current input sequence from the description data comprises: including one or more tokens indicating that the output sequence generated by the generative neural network should specify a correct solution for the computer programming task.
- Claim 15Depends on #12
The method of claim 12, wherein each input sequence comprises the plurality of text tokens from the description data and zero or more tags that each comprise one or more tokens and that identify an algorithm that should be implemented by the output sequence generated by the generative neural network, and wherein generating a current input sequence from the description data comprises: sampling one or more tags from a distribution over a set of tags; and including the sampled tags in the current output sequence.
- Claim 16Depends on #12
The method of claim 12, wherein each input sequence comprises the plurality of text tokens from the description data and one or more tokens that specify a difficulty rating for the computer programming task, and wherein generating a current input sequence from the description data comprises: selecting a difficulty rating for the computer programming task; and including one or more tokens specifying the selected difficulty rating in the current output sequence.
- Claim 17Depends on #16
The method of claim 16, wherein selecting a difficulty rating for the computer programming task comprises: selecting a fixed difficulty rating that is the same for all computer programming tasks after training of the generative neural networks.
- Claim 18Depends on #16
The method of claim 16, wherein selecting a difficulty rating for the computer programming task comprises: sampling a difficulty rating from a distribution over a set of difficulty ratings.
- Claim 19Depends on #1
The method of claim 1, wherein each generative neural network has been pre-trained on a language modeling objective on a first set of training data and fine-tuned on a code generation objective on a second set of training data that includes a plurality of training examples that each include (i) a training input sequence representing a computer programming task and (ii) a training output sequence that represents a computer program.
- Claim 20Depends on #19
The method of claim 19, wherein the first set of training data comprises a set of sequences that each represent a segment of computer code.
- Claim 21Depends on #19
The method of claim 19, wherein the plurality of training examples includes a first subset of training examples for which the training output sequence in the training example is a correct solution to the computer programming task represented by the training input sequence in the training example and a second set of training examples for which the training output sequence in the training example is not a correct solution to the computer programming task represented by the training input sequence in the training example.
- Claim 22Depends on #19
The method of claim 19, wherein the code generation objective is GOLD with tempering.
- Claim 23Depends on #1
The method of claim 1, wherein the text tokens and the computer code tokens are selected from a same vocabulary of tokens.
- Claim 24Independent Claim
A system comprising one or more computers and one or more storage devices storing instructions that when executed by the one or more computers cause the one or more computers to perform operations comprising: receiving description data describing a computer programming task, the description data comprising a plurality of text tokens; receiving a first set of inputs for the computer programming task; generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks, wherein each generative neural network in the set is deployed as a plurality of instances on a respective set of one or more devices, and wherein each instance of each generative neural network in the set is configured to, in parallel with each other instance of each generative neural network, receive an input sequence that includes the plurality of text tokens in the description data and to process the input sequence to generate an output sequence comprising a plurality of computer code tokens that specifies a candidate computer program for performing the computer programming task described by the description data; for each candidate computer program in a subset of the candidate computer programs and for each input in the first set: executing the candidate computer program on the input on the respective set of one or more devices on which the instance that generated the candidate computer program is deployed to generate an output; and selecting, from the candidate computer programs, one or more computer programs as synthesized computer programs for performing the computer programming task based at least in part on the outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs, comprising: clustering the candidate computer programs in the subset into a plurality of clusters based on the outputs generated by executing the candidate computer programs on the inputs in the first set; and selecting, as a synthesized computer program, one or more respective candidate computer programs from each of one or more of the clusters.
- Claim 25Independent Claim
One or more non-transitory computer-readable storage media storing instructions that when executed by one or more computers cause the one or more computers to perform operations comprising: receiving description data describing a computer programming task, the description data comprising a plurality of text tokens; receiving a first set of inputs for the computer programming task; generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks, wherein each generative neural network in the set is deployed as a plurality of instances on a respective set of one or more devices, and wherein each instance of each generative neural network in the set is configured to, in parallel with each other instance of each generative neural network, receive an input sequence that includes the plurality of text tokens in the description data and to process the input sequence to generate an output sequence comprising a plurality of computer code tokens that specifies a candidate computer program for performing the computer programming task described by the description data; for each candidate computer program in a subset of the candidate computer programs and for each input in the first set: executing the candidate computer program on the input on the respective set of one or more devices on which the instance that generated the candidate computer program is deployed to generate an output; and selecting, from the candidate computer programs, one or more computer programs as synthesized computer programs for performing the computer programming task based at least in part on the outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs, comprising: clustering the candidate computer programs in the subset into a plurality of clusters based on the outputs generated by executing the candidate computer programs on the inputs in the first set; and selecting, as a synthesized computer program, one or more respective candidate computer programs from each of one or more of the clusters.
Technical Overview & Description
CROSS-REFERENCE TO RELATED APPLICATION This application claims priority to U.S. Provisional Application No. 63/306,043, filed on Feb. 2, 2022. The disclosure of the prior application is considered part of and is incorporated by reference in the disclosure of this application. BACKGROUND This specification relates to generating computer code using neural networks. Neural networks are machine learning models that employ one or more layers of nonlinear units to predict an output for a received input. Some neural networks include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as input to the next layer in the network, e.g., the next hidden layer or the output layer. Each layer of the network generates an output from a received input in accordance with current values of a respective set of parameters. SUMMARY This specification describes a system implemented as computer programs on one or more computers in one or more locations that that generates computer program code using a neural network. In particular, the system receives an input that includes description data describing a computer programming task and generates as output one or more computer programs that, when executed, carry out the computer programming task described in the description data. The subject matter described in this specification can be implemented in particular embodiments so as to realize one or more of the following advantages. Generating code that solves a specified task requires searching in a huge structured space of possible computer programs, with a very sparse reward signal. For example, single character edits can completely change program behaviour even if they don't cause crashes, solutions can look dramatically different even for the same problem, and judging if a partial or incorrect program is useful is a difficult challenge. Thus, generating an entire program in a general-purpose programming language such as C++ or Python starting fro
Cited By — Indexed Forward Citations (0 of 0 total)
No indexed citing patents in this generation yet. Ingest USPTO/PatentsView bulk citation tables via patents-ingest to expand the local forward citation graph.
References Cited — Backward Prior Art (20)
Non-Patent Literature (10)
- International Preliminary Report on Patentability in International Appln. No. PCT/EP2023/052595, dated Aug. 15, 2024, 13 pages.
- Adiwardana et al.,
- “
- Towards a human-like open-domain chatbot,
- ”
- CoRR, Jan. 27, 2020, 38 pages.
- Bonthu et al.,
- “
- Text2PyCode: Machine Translation of Natural Language Intent to Python Source Code,
- ”