Generating computer code from task descriptions using neural networks

Generating computer programs through multiple generative neural network sets and Transformer models, combined with metadata conditionalization and parallel processing, solves the problem of generating complete computer programs in natural language descriptions, achieving efficient and accurate program generation and parallel processing efficiency.

CN118696295APending Publication Date: 2024-09-24GDM HOLDING LLC
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202380019612.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-02-02
Filing Date
2023-02-02
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

It is difficult for existing technologies to efficiently and accurately generate complete computer programs from natural language descriptions, especially when the structured space is huge and the diversity and quality of solutions are difficult to guarantee.

Method used

Multiple generative neural network sets are used, the Transformer model is used to generate a large program sample set, and a synthetic computer program candidate set is obtained through filtering and clustering, combined with metadata conditionalization and parallel processing hardware to improve efficiency and quality.

Benefits of technology

In the case where the structured space is huge and the solution diversity and quality are difficult to guarantee, it is possible to efficiently and accurately generate synthetic computer programs, ensuring that the generated programs can be effectively executed in specific tasks and show high efficiency on parallel processing hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118696295A
    Figure CN118696295A
Patent Text Reader

Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, 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 a 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 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 one or more computer programs from the candidate computer programs as synthetic computer programs for performing the computer programming task based at least in part on outputs generated by executing the candidate computer programs in the subset on inputs in the first set of inputs.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0001] This specification relates to generating computer code using a neural network.

[0002] A neural network is a machine learning model that uses one or more layers of nonlinear units to predict outputs from received inputs. In addition to an output layer, some neural networks include one or more hidden layers. The output of each hidden layer is used as input to the next layer in the network, such as the next hidden layer or the output layer. Each layer of the network generates an output from the received input based on the current values ​​of the corresponding set of parameters. Summary of the invention

[0003] This specification describes a system implemented as a computer program on one or more computers in one or more locations that generates computer program code using a neural network. In particular, the system receives input including description data describing a computer programming task, and generates one or more computer programs as output that, when executed, perform the computer programming task described in the description data.

[0004] The subject matter described in this specification can be implemented in specific embodiments to realize one or more of the following advantages.

[0005] Generating code that solves a specified task requires searching through a huge structured space of possible computer programs with a very sparse reward signal. For example, even if single character edits do not cause a crash, they can completely change program behavior, solutions can look significantly different even for the same problem, and judging whether an incomplete or incorrect program is useful is a difficult challenge. Therefore, generating entire programs in general-purpose programming languages ​​such as C++ or Python starting from a natural language task description has been an open problem.

[0006] This specification describes techniques for efficiently using a collection of one or more generative neural networks to accurately generate computer programs conditioned on natural language descriptions. In particular, the described techniques address the problem of searching a large structured space by using a generative neural network, such as a Transformer model, to generate a large set of program samples, and then filtering, clustering, or both the results using corresponding inputs to obtain a small set of candidates to be proposed as synthetic computer programs. In some cases, to improve the diversity of the generated samples, the techniques utilize "metadata conditioning."

[0007] Furthermore, the described system can pre-train a generative neural network on code sequences and then fine-tune it on a collection of task-specific data to ensure that the generative neural network can generate high-quality candidates even when the amount of task-specific training data is limited.

[0008] In addition, the described method is designed to be particularly efficient when implemented on parallel processing hardware. In particular, the system can perform the generation of candidates and the sampling of output sequences in parallel. For example, the system can use multiple parallel processing devices, such as CPUs, GPUs, TPUs or other ASICs, FPGAs, etc., to perform generation and sampling in parallel. As a specific example, the system can deploy multiple instances of each of one or more generative neural networks across devices. For example, the system can use model parallelism techniques to deploy each instance on a different device or deploy instances across multiple devices. Then, for each instance, the system can use the instance in parallel with each other instance to sample the candidates as described above. The system can also parallelize the code generation process by evaluating the candidates in parallel on the same device on which the candidates were generated.

[0009] An example method described herein is performed by one or more computers and includes receiving description data describing a computer programming task, the description data including 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 configured to receive an input sequence including the plurality of text tokens in the description data, and process the input sequence to generate an output sequence including a plurality of computer code tokens, the plurality of computer code tokens specifying candidate computer programs 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 to generate an output; and selecting one or more computer programs from the candidate computer programs as a synthetic computer program for performing the computer programming task based at least in part on the output generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs.

[0010] The method may include receiving a new input for a computer programming task; and executing one or more synthetic computer programs in the synthetic computer program on the new input to generate an output for the computer programming task for the new input. The method may also include: for each input in the first set, receiving a corresponding expected output generated by executing the computer programming task on the input. The selection may include: 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 corresponding expected output of the input; selecting only the following candidate computer programs as the initial set of computer programs: the candidate computer program generates an output that matches the corresponding expected output of the input when executed on the input for each input in the first set; selecting one or more corresponding computer programs from the initial set of computer programs as the synthetic computer program. The subset of candidate computer programs may include all of the multiple candidate computer programs.

[0011] The selecting may include: clustering the candidate computer programs in the subset into a plurality of clusters based on outputs generated by executing the candidate computer programs on the inputs in the first set; and selecting one or more corresponding candidate computer programs from each of one or more of the clusters as synthetic computer programs. Selecting one or more corresponding computer programs from each of the one or more clusters as at least one of the synthetic computer programs may include: selecting one or more corresponding computer programs from each of a predetermined number of maximum clusters in the plurality of clusters as at least one of the synthetic computer programs. Obtaining the first set of inputs for the computer programming task may include: processing one or more description sequences each including a plurality of text tokens from the description data using a test input generating neural network, the test input generating neural network being configured to process each description sequence to generate one or more test inputs for the computer programming task described by the description sequence as outputs. In an example, the subset of candidate computer programs may include only candidate computer programs that are not filtered out from the plurality of candidate computer programs based on whether, for each candidate computer program and for each input in the second set of inputs, the output generated by executing the candidate computer program on the input matches the corresponding expected output of the input.

[0012] The set of one or more generative neural networks may include only a single generative neural network. Alternatively, the set of one or more generative neural networks may include multiple generative neural networks. Each generative neural network in the set may have a different combination of values ​​of the set of one or more attributes compared to each other neural network in the set. The attributes may include one or more of the following: (i) training data for training the generative neural network, (ii) multiple parameters of the generative neural network, or (iii) a sampling temperature for sampling an output sequence from the generative neural network. One or more of the generative neural networks in the set may include: an encoder neural network configured to process an input sequence to generate an encoded representation of the input sequence; and a decoder neural network configured to process the encoded representation to generate an output sequence. The encoder neural network in the set may be a Transformer encoder that applies self-attention to the input sequence. The decoder neural network in the set may be an autoregressive Transformer decoder that applies cross-attention to the encoded representation.

[0013] Generating a plurality of candidate computer programs by sampling a plurality of output sequences from a set of one or more generative neural networks may include repeatedly performing operations including: generating a current input sequence from the description data; and sampling the one or more output sequences by processing the current input sequence using one of the generative neural networks in the set. The operations may be performed in parallel across a plurality of hardware devices. Each input sequence may include a plurality of text tokens from the description data and one or more tokens identifying a programming language. Generating the current input sequence from the description data may include: 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.

[0014] Each input sequence may include a plurality of text tokens from the description data and one or more tokens indicating whether an output sequence generated by the generative neural network should specify a correct solution or an incorrect solution to the computer programming task. Generating the current input sequence from the description data may include including one or more tokens indicating that an output sequence generated by the generative neural network should specify a correct solution to the computer programming task.

[0015] Each input sequence may include a plurality of text tokens from the description data and zero or more tags, each tag including one or more tokens and identifying an algorithm that should be implemented by the generative neural network to generate an output sequence. Generating the current input sequence from the description data may include: sampling one or more tags from a distribution over a set of tags; and including the sampled tags in the current output sequence.

[0016] Each input sequence may include a plurality of text tokens from the description data and one or more tokens specifying a difficulty rating for a computer programming task. Generating a current input sequence from the description data may include: selecting a difficulty rating for the computer programming task; and including one or more tokens specifying the selected difficulty rating in a current output sequence. Selecting a difficulty rating for the computer programming task may include selecting a fixed difficulty rating that is the same for all computer programming tasks after training the generative neural network. Selecting a difficulty rating for the computer programming task may include sampling a difficulty rating from a distribution over a set of difficulty ratings.

[0017] Each generative neural network may have been pre-trained on a first set of training data for a language modeling objective and fine-tuned on a second set of training data for a code generation objective, the second set of training data comprising a plurality of training examples, each training example comprising (i) a training input sequence representing a computer programming task and (ii) a training output sequence representing a computer program. The first set of training data may comprise a set of sequences each representing a computer code segment. The plurality of training examples may comprise a first subset of training examples and a second set of training examples, the training output sequences in the training examples being correct solutions to the computer programming tasks represented by the training input sequences in the training examples, the training output sequences in the training examples not being correct solutions to the computer programming tasks represented by the training input sequences in the training examples. The code generation objective may be GOLD with tempering.

[0018] Text tokens and computer code tokens may be selected from the same token vocabulary.

[0019] The example systems described herein include 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 the operations of any of the methods described herein.

[0020] In another example described herein, one or more computer storage media store instructions that, when executed by one or more computers, cause the one or more computers to perform the operations of any of the methods described herein.

[0021] The details of one or more embodiments of the subject matter of this specification are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a diagram of the example code generation system.

[0023] Figure 2A The operation of the code generation system is shown.

[0024] Figure 2B An example of a computer program that has been generated by the system is shown.

[0025] Figure 3 is a flow chart of an example process for generating computer code.

[0026] Figure 4 is a flowchart of an example process for training a generative neural network.

[0027] Like reference numerals and reference characters in the various drawings represent like elements. DETAILED DESCRIPTION

[0028] Figure 1 is a diagram of an example code generation system 100. Code generation system 100 is an example of a system implemented as a computer program on one or more computers in one or more locations in which the systems, components, and techniques described below may be implemented.

[0029] System 100 generates computer program code in response to received requests using neural network 110. In particular, in response to a given request, system 100 generates one or more synthetic computer programs 150 that, when executed, perform the computer programming tasks specified in the request.

[0030] In particular, the system 100 receives description data 102 that describes a computer programming task, ie, describes the type of output that should be generated by executing a computer program on an input of the task.

[0031] Typically, description data 102 includes natural language text that describes the intended functionality of a computer program to be generated by system 100. For example, system 100 may receive natural language text as input from a user and generate description data 102 from the natural language text.

[0032] Natural language text may be represented as a sequence of text tokens, for example, tokens representing one or more of the following: characters, bytes, word pieces, words, punctuation marks, and the like.

[0033] For example, the system 100 may generate sequences from natural language input by applying a lemma analyzer—eg, the SentencePiece lemma analyzer or another lemma analyzer—to divide the natural language input into lemmas in a vocabulary.

[0034] For example, the system 100 may train a token analyzer on data comprising a mixture of natural language text sequences and computer code snippets in various programming languages, such as Python, C++, C#, Java, Ruby, PHP, etc., to ensure that the token analyzer can effectively tokenize programs from a range of programming languages, as well as natural language descriptions of tasks received as input by the system 100.

[0035] The system 100 also obtains one or more sets of inputs 104 for a computer programming task. Each set of inputs 104 satisfies the requirements for the inputs of the computer programming task, for example, including a corresponding value for each input variable required to perform the task. As a simplified example, when the task described by the description 102 requires sorting a set of input numbers, each input will include a set of numbers to be sorted.

[0036] In particular, system 100 may obtain (i) a set of filtered inputs 106 , (ii) a set of clustered inputs 108 , or (iii) both.

[0037] The set of filter inputs 106 includes a set of inputs and, for each input, a corresponding expected output generated by performing a computer programming task on the input.Filter input-expected output pairs may be received as input by the system 100, for example, from a user along with description data.

[0038] The set of clustered inputs 108 comprises a set of inputs for a computer programming task, but does not require that there be any expected outputs for the inputs.

[0039] As described in more detail below, in some implementations, system 100 generates some or all of clustering inputs 108 from description data 102 using a test input generation neural network.

[0040] System 100 then uses description data 102 to generate a plurality of candidate computer programs.

[0041] In particular, the system 100 may generate a candidate output program by sampling a plurality of output sequences from a collection of one or more generative neural networks 110 .

[0042] Each generative neural network 110 in the set is configured to receive an input sequence comprising a plurality of text tokens in the description data 102, and to process the input sequence to generate an output sequence comprising a plurality of computer code tokens specifying a candidate computer program for performing the computer programming task described by the description data.

[0043] Each computer code token is selected from a vocabulary of tokens representing code symbols in one or more computer programming languages, such as Python, C++, C#, Java, Ruby, PHP, etc. For example, the vocabulary of the token may be the same as the input vocabulary of the above-mentioned token, for example, the same as the vocabulary adopted by the above-mentioned token analyzer.

[0044] The neural network 110 may have any suitable neural network architecture that allows the model to map an input sequence of word-grams from a vocabulary to an output sequence of word-grams from a vocabulary.

[0045] For example, each neural network 110 can have an encoder-decoder architecture, such as an architecture having a Transformer encoder that applies self-attention to an input sequence to generate an encoded representation of the input sequence and a Transformer decoder that applies cross-attention to the output of the Transformer.

[0046] In particular, each neural network 110 may be an autoregressive neural network that autoregressively generates an output sequence of word-grams by generating each particular word-gram in the output sequence conditioned on a current input sequence comprising (i) the input sequence followed by (ii) any text word-grams preceding the particular text word-gram in the output sequence.

[0047] More specifically, to generate a particular word-gram, neural network 110 may process the current input sequence to generate a score distribution, such as a probability distribution, that assigns a corresponding score, such as a corresponding probability, to each word-gram in the vocabulary of text words. For example, the penultimate layer of neural network 110 may generate a score ("logit") for each word-gram in the vocabulary, and the final layer of neural network 110 may be a softmax layer that maps the scores of the word-grams to the probability distribution.

[0048] The neural network 110 may then use the score distribution to select a text token from the vocabulary as the particular text token. For example, the neural network 110 may greedily select the token with the highest score, or may sample tokens from the distribution, for example, using top-k sampling, kernel sampling, or other sampling techniques.

[0049] In general, because the neural network 110 is autoregressive, the system 100 can generate multiple different candidate output sequences in response to the same input using the same neural network 110 by sampling from the distribution at each time step. That is, by sampling tokens instead of just selecting the highest-scoring tokens, the system 100 introduces randomness into the generation process and can generate different sequences by processing the same input multiple times in parallel or sequentially.

[0050] Examples of autoregressive Transformer architectures that can be used for neural network 110 include those described in: Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang,Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019; Daniel Adiwardana, Minh-Thang Luong, David R. So, Jamie Hall, Noah Fiedel, Romal Thoppilan, Zi Yang, Apoorv Kulshreshtha, Gaurav Nemade, Yifeng Lu, and Quoc V. Le. Towards a human-like open-domain chatbot. CoRR, abs / 2001.09977, 2020; and Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin Attention Is All You Need arXiv preprint arXiv: 1706.03762, 2017.

[0051] In some embodiments, the architecture of the generative neural network 110 can be modified relative to those described above to facilitate efficient sampling. For example, the generative neural network 110 can employ multi-query attention instead of multi-head attention. In multi-query attention, each attention head within the encoder, decoder, or both has a different query, but shares keys and values. Because the keys and values ​​are shared, sampling efficiency is improved and the number of parameters of the neural network 110 is reduced. In particular, memory usage and the cost of cache updates, each of which represents a potential bottleneck during sampling, can be reduced by using multi-query attention.

[0052] Table 1 shows some example hyperparameters of an encoder-decoder Transformer with multi-query attention or with multi-head attention that may be used for the neural network 110.

[0053] This table lists the total number of parameters in the model , the hidden dimension of the Transformer block , the number of query and key-value (KV) heads, the number of Transformer blocks in the encoder (enc) and decoder (dec), the training batch size, the number of gradient update steps, and the number of total training tokens. All of these example configurations share a head size of 128 and a feedforward fan-out ratio of 6.

[0054] When there are multiple neural networks 110 in the set of generative neural networks 110, each generative neural network 110 has a different combination of values ​​of the set of one or more properties compared to each other neural network 110 in the set. For example, the properties may include one or more of the following: (i) training data used to train the generative neural network 110, (ii) initialization values ​​of parameters of the generative neural network 110 before training the generative neural network 110, (ii) multiple parameters of the generative neural network 110, or (iii) a sampling temperature used to sample the output sequence from the generative neural network 110. The sampling temperature will be described in more detail below.

[0055] By ensuring that each neural network 110 in the set has a different combination of values ​​for the set of properties, the system 100 can ensure that the neural networks 110 can be used to generate a diverse set of outputs for a given input.

[0056] For each candidate computer program in the subset of candidate computer programs generated using neural network 110 , and for each input in one or more sets of inputs 104 , system 100 executes the candidate computer program on the input to generate an output.

[0057] System 100 may execute computer programs in any of a variety of ways.

[0058] For example, system 100 may use an appropriate compiler to compile a given candidate computer program into an executable file and then cause the computer to execute the machine instructions in the executable file.

[0059] As another example, the system 100 may execute a given candidate computer program using an appropriate interpreter that translates and executes code in the computer program.

[0060] If a candidate program fails to compile or cannot be interpreted by the interpreter, the system 100 can remove the candidate program from consideration.

[0061] System 100 then selects one or more computer programs from the candidate computer programs as composite computer programs 150 for performing the computer programming task based at least in part on output generated by executing the candidate computer programs in the subset on inputs in one or more sets of inputs 104 .

[0062] That is, the system uses one or more sets of inputs 104 to “filter” a set of candidate computer programs to produce one or more synthetic computer programs 150 .

[0063] The following will refer to Figure 2A This filtering is described in more detail.

[0064] Once system 100 has selected one or more computer programs 150, system 100 may use the selected programs for any of a variety of tasks.

[0065] For example, system 100 may provide source code for each selected computer program 150 for presentation to the user in a user interface, e.g., to allow the user to select one of the selected computer programs for inclusion in a larger computer program that the user is programming, or to select one of the selected computer programs for modification before being used to perform a task.

[0066] As another example, the system 100 can directly use the selected computer program to perform the task. For example, the system 100 can receive a new input for a computer programming task, such as submitted by a user through a user interface, provided by another computer program running on the same computer or a remote computer, or received through an application programming interface (API) provided by the system 100, and execute one or more synthetic computer programs 150 on the new input to generate the output of the computer programming task for the new input. The system 100 can then provide one or more generated outputs as the output of the task. For example, when there is only a single selected computer program 150 or when each computer program 150 generates the same output, the system 100 can provide a single output as the output of the task. When multiple computer programs are selected and the programs generate different outputs, the system 100 can provide the output generated by the maximum number of programs as the output of the task.

[0067] Before using neural network 110 to generate a synthetic computer program, system 100 or another training system trains neural network 110 on training data. In some cases, as will be described in more detail below, the training system first pre-trains neural network 110 on computer code sequences and then fine-tunes neural network 110 with respect to the code generation goal required to generate code from a task description.

[0068] Figure 2A Operations performed by system 100 to generate one or more composite computer programs 250 are shown.

[0069] The system 100 receives the task description data 102 and then performs large-scale sampling 210 on the task description data 202 using the generative neural network 110 to generate a large set of candidate computer programs 212. For example, the system 100 may continue sampling 210 until a computational budget allocated for sampling is exhausted or until a threshold number of samples have been generated.

[0070] In other words, the system 100 uses the task description data and the generative neural network 110 to generate a large set of different candidate computer programs 212 .

[0071] That is, the system 100 generates one or more input sequences, each input sequence comprising text tokens in the description data 102, and for each generated input sequence, samples a set of corresponding output sequences of each generative neural network from one or more generative neural networks 110 when the generative neural network is conditioned on the generated input sequence.

[0072] The system 100 may use any suitable technique to sample from the autoregressive model samples from a given generative neural network 110 when the neural network 110 is conditioned on the descriptive data, such as kernel sampling, reduced temperature sampling, greedy sampling, etc.

[0073] In some embodiments, each input sequence includes only text tokens in the description data 102, and the system 100 generates diverse candidates relying on the stochastic nature of sampling from a given neural network 110, the different outputs generated by different neural networks 110, or both.

[0074] In some other embodiments, each input sequence also includes "metadata" tokens that characterize the desired attributes of the output sequence. For example, these metadata tokens can be inserted before or after the description data 102 in the input sequence and can be formatted according to a specified format.

[0075] Metadata tokens may include tokens that specify any of a variety of properties of a computer program.

[0076] As an example, the metadata tokens may include one or more tokens that identify the programming language that the computer program is to be written in. For example, these tokens may be formatted as the token "LANGUAGE IS" followed by the name of the programming language, such as "Python" or "C++".

[0077] As another example, the metadata tokens may include one or more tokens indicating whether an output sequence generated by the generative neural network should specify a correct or incorrect solution to a computer programming task. For example, when a correct solution is expected, the tokens may be formatted as "CORRECT SOLUTION", and when an incorrect solution is expected, the tokens may be formatted as "INCORRECT SOLUTION".

[0078] As another example, a metadata token may include one or more tags, each tag identifying an algorithm that should be implemented by the output sequence generated by the generative neural network, such as "divide and conquer", "dynamic programming", and "data structures". For example, these tokens may be formatted as "TAGS:" followed by an identifier of any algorithm that should be implemented. For some inputs, the input sequence may include a zero label, e.g., when no algorithm is well suited for the task at hand.

[0079] As another example, the metadata tokens may include one or more tokens identifying a difficulty rating of the task, e.g., as a numeric rating between the predefined rating scales "divide and conquer," "dynamic programming," and "data structures." For example, these tokens may be formatted as "RATING:" followed by a numeric value.

[0080] During training, when input sequences are generated, the system 100 generates these metadata tokens to match the actual properties of the output sequence provided as the target for the current input sequence. That is, the system includes metadata indicating whether the program in the training example is a correct solution to the description represented by the input sequence in the training example, the actual difficulty rating of the task described by the input sequence, the actual computer language in which the program in the training example is written, the actual algorithm implemented within the program in the training example or that has otherwise been determined to be useful for the task described in the input sequence, etc.

[0081] However, at sample time, ie, after neural network 110 has been trained, system 100 may use “metadata conditioning” to improve the diversity and accuracy of candidate programs 122 .

[0082] That is, at the time of sampling, because the final computer program has not yet been generated, the system 100 cannot obtain the final computer program that has been generated, and therefore cannot obtain the actual properties of the final computer program.

[0083] Instead, system 100 uses “metadata conditioning” to select, for each input sequence generated, values ​​for attributes that will produce metadata that generates high-quality and diverse candidate programs 122 .

[0084] As an example, when the metadata tokens include one or more tokens identifying a programming language to be used to write a computer program, the system 100 may sample a programming language from a distribution over a set of programming languages ​​each time a current input sequence is generated and include the one or more tokens identifying the programming language in the current input sequence.

[0085] As another example, when the metadata tokens include an indication of whether an output sequence generated by the generative neural network should specify a correct or incorrect solution to a computer programming task, the system 100 may include one or more tokens in the current input sequence each time the current input sequence is generated that indicate that the output sequence generated by the generative neural network should specify a correct solution to the computer programming task, i.e., because a candidate program 122 that is not a correct solution is not useful at the sampling time.

[0086] As another example, when the metadata tokens include one or more tags—each tag includes one or more tokens identifying an algorithm that should be implemented by the generative neural network to generate an output sequence, the system 100 can sample one or more tags from a distribution over a set of tags each time a current input sequence is generated, and include the sampled tags in the current output sequence.

[0087] As another example, when the metadata tokens include one or more tokens identifying a difficulty rating for a task, the system 100 may select the difficulty rating for the computer programming task and include one or more tokens specifying the selected difficulty rating in the current output sequence.

[0088] For example, system 100 may select a fixed difficulty rating that is the same for all computer programming tasks after training generative neural network 110, or sample a difficulty rating from a distribution over a set of difficulty ratings and use the sampled difficulty rating as the selected difficulty rating.

[0089] Therefore, to generate candidate program 122, i.e., to sample a plurality of output sequences representing candidate program 122, system 100 repeatedly performs the following operations: (i) generating a current input sequence from description data 102, and (ii) sampling one or more output sequences by processing the current input sequence using one of the generative neural networks 110 in the set. When "metadata conditioning" is employed, system 100 performs "metadata conditioning" as part of generating the current input sequence.

[0090] In some embodiments, the system 100 repeatedly performs multiple instances of candidate generation and sampling of output sequences in parallel. For example, the system can use multiple parallel processing devices, such as CPUs, GPUs, TPUs or other ASICs, FPGAs, etc., to perform generation and sampling in parallel. As a specific example, the system 100 can deploy multiple instances of each of the one or more generative neural networks 110 across devices. For example, the system 100 can use model parallelism techniques to deploy each instance on a different device or deploy instances across multiple devices. Then, for each instance, the system 100 can sample the candidate samples as described above using an instance in parallel with each other instance.

[0091] In some of these embodiments, system 100 may also perform execution of candidate programs 122 across multiple devices in parallel, for example, by executing each candidate generated by a given instance on the device on which the instance is deployed.

[0092] exist Figure 2A In the example of , system 100 receives a set of inputs including filter input 106 and cluster input 108 .

[0093] The system then performs filtering and clustering 220 on the set of candidate computer programs 212 to select one or more synthetic computer programs 250 .

[0094] Typically, as part of performing filtering and clustering 220, for each candidate computer program in the subset of candidate computer programs 122 and for each input in one or more sets of inputs 104, system 100 executes the candidate computer program on the input to generate an output. As described above, if a given candidate fails to compile or cannot be interpreted, system 100 removes the candidate from consideration.

[0095] Alternatively, system 100 may maintain data specifying criteria for latency or resource consumption or both. If the execution of any given candidate fails any of the criteria, system 100 removes the candidate from consideration. Thus, system 100 may ensure that synthesis program 250 remains resource efficient.

[0096] The system 100 then selects one or more computer programs from the candidate computer programs 122 as a composite computer program 250 for performing the computer programming task based at least in part on output generated by executing the candidate computer programs in the subset on the input.

[0097] In particular, when one or more sets include filter input 106 , the subset (of candidate computer programs 122 executed on the input) is typically not a true subset. That is, the subset includes all of the plurality of candidate computer programs 122 .

[0098] Then, for each candidate computer program and each filter input 106 , the system may determine whether an output generated by executing the candidate computer program on the filter input 106 matches a corresponding expected output of the filter input 106 .

[0099] The system 100 may then select as an initial set of computer programs only those candidate computer programs that, for each filtered input 106 , when executed on the filtered input 106 , generate an output that matches the corresponding expected output of the filtered input 106 .

[0100] When one or more sets also include clustering input 108, system 100 can then cluster the candidate computer programs in the initial set into a plurality of clusters based on outputs generated by executing the candidate computer programs on the clustering input. The system can use any suitable clustering technique to cluster the candidate computer programs based on outputs generated by the clustering input. For example, system 100 can group two candidates into the same cluster only if the two candidates generate matching outputs for at least a threshold proportion of the clustering input.

[0101] The system 100 may then select one or more corresponding candidate computer programs from each of the one or more clusters as the synthetic computer program 250 .

[0102] As a specific example, the system 100 may select one or more corresponding computer programs from each of a predetermined number of largest clusters in a plurality of clusters as the composite computer program 250, wherein the size of the cluster is determined based on the number of candidates in the cluster. Selecting the composite computer program 250 in this manner takes advantage of the fact that, while there are many ways a solution may be incorrect, correct solutions tend to behave the same and are therefore grouped into larger clusters.

[0103] In other examples, system 100 receives only filter input 106. In these cases, system 100 may select one or more synthesized programs 250 from the initial set, for example by selecting a fixed number randomly or based on one or more heuristics such as program length.

[0104] In other examples, system 100 receives only clustering input 108. In these cases, system 100 can cluster all candidate programs as described above, rather than clustering only those programs in the initial set.

[0105] In some implementations, the system 100 receives all clustering inputs 108 as input from a user. In some other implementations, the system 100 may generate one or more “synthetic” clustering inputs 108 instead of or in addition to receiving clustering inputs 108 as input.

[0106] In particular, the system 100 can process one or more description sequences each including a plurality of text tokens from the description data 102 using a test input generation neural network 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. Although these synthetic inputs are not guaranteed to be valid, especially when the task has complex constraints, imperfect or even invalid test inputs are still useful for grouping candidate programs.

[0107] Reference below Figure 4 Describes training a neural network to generate test inputs.

[0108] Figure 2B An example of a computer program 290 that has been generated by the system is shown.

[0109] like Figure 2B As shown, the user provides description data 252 that describes the problem, ie, the task in natural language. The user also provides a set of filter inputs 254 and the expected output for each filter input.

[0110] exist Figure 2B In the example of , each filter input 254 is a pair of strings, and the expected output 256 for the pair of strings indicates whether one string can be obtained from the other string by pressing "backspace" instead of typing one or more characters in the first string. System 100 uses neural network 110 to process an input sequence including description data 252, optionally including filter input 254 and notes 256 about the filter input, to generate candidate programs, and then uses at least filter input 254 to filter the candidates to obtain synthetic computer program 290. That is, in some cases, in addition to being used to filter candidate programs, filter input 254 is also considered to be part of description data 252. From Figure 2B It can be seen that the composite computer program 290 accurately performs the tasks described in the description data 252 .

[0111] Figure 3 is a flow chart of an example process 300 for generating one or more synthetic computer programs for performing a task. For convenience, process 300 will be described as being performed by a system of one or more computers located in one or more locations. For example, a code generation system (e.g., Figure 1 The code generation system 100 depicted in FIG. 1 may perform process 300 .

[0112] The system receives description data describing a computer programming task (step 302). As described above, the description data includes a plurality of text words describing the task.

[0113] The system receives a first set of inputs for a computer programming task (step 304 ).

[0114] The system generates a plurality of candidate computer programs by sampling a plurality of output sequences from a collection of one or more generative neural networks (step 306). As described above, each generative neural network in the collection is configured to receive an input sequence comprising a 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 specify a candidate computer program for performing the computer programming task described by the description data.

[0115] For each candidate computer program in the subset of candidate computer programs and for each input in the first set, the system executes the candidate computer program on the input to generate an output (step 308 ).

[0116] The system selects one or more computer programs from the candidate computer programs as synthetic computer programs for performing the computer programming task based at least in part on outputs generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs (step 310). That is, the system uses the first set of inputs to "filter" the candidate computer programs to select one or more synthetic computer programs.

[0117] As described above, the system or a different training system trains the generative neural network before using the generative neural network to generate computer code.

[0118] For example, the system can pre-train each generative neural network on a language modeling objective on a first set of training data, and then fine-tune the generative neural network on a code generation objective on a second set of training data. This is described below with reference to Figure 4 Describe in more detail.

[0119] Figure 4is a flow chart of an example process 400 for training a neural network. For convenience, process 400 will be described as being performed by a system of one or more computers located in one or more locations. For example, a code generation system appropriately programmed according to the present specification, such as, Figure 1 The code generation system 100 depicted in FIG. 1 may perform process 400 .

[0120] The system obtains a first set of training data (step 402 ).

[0121] The first set of training data comprises a set of sequences that each represent a segment of computer code.

[0122] For example, the system can obtain a repository of computer code segments, such as computer code files or portions of computer code files, which include computer code segments written in multiple computer programming languages. The system can then generate a first set of training data by "flattening" each computer code segment into a sequence, for example, by removing whitespace or by replacing whitespace with a specified token.

[0123] Thus, the first set of training data includes sequences representing computer code, but does not include any task descriptions describing the task completed by a given computer code segment (other than any task information that would be embedded in annotations within the computer code segment).

[0124] The system pre-trains a neural network on a first set of training data (step 404 ).

[0125] In particular, the system trains a generative neural network on a first set of training data with respect to a language modeling objective that requires the generative neural network to predict a word-gram following a given subsequence of word-grams within a given sequence given a subsequence of word-grams from the first set of training data.

[0126] For example, when the neural network has an encoder-decoder architecture as described above, the system can sample the pivot point within each sequence. The system can then generate training examples that include the word-gram before the pivot point in the sequence as input and the word-gram after the pivot point in the sequence as target output.

[0127] The language modeling objective can then ask the neural network to predict the target output in each training example by processing the input sequence in the training examples.

[0128] For example, given the encoded representation of the input sequence in the training examples generated by the encoder, the language modeling objective can be the cross-entropy next-term prediction loss of the decoder.

[0129] Optionally, the system can include one or more auxiliary losses as part of pre-training.

[0130] For example, the system can incorporate a masked language modeling loss on the encoder's predictions during pre-training. The masked language modeling loss is described in more detail in J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805,2018. Although the pre-training dataset does not include the task description and thus does not directly train the generative neural network to perform the code generation task, the pre-training phase can help the generative neural network learn a good representation of the code and generate code fluently. As a result, the model can reasonably represent the space of human coding, which greatly reduces the problem search space.

[0131] The system obtains a second set of training data for fine-tuning the generative neural network (step 406 ).

[0132] The second training data set includes a plurality of training examples, each training example including (i) a training input sequence representing a computer programming task and (ii) a training output sequence representing a computer program.

[0133] As described above, in some embodiments, after training, the input to the generated neural network includes "metadata" tokens, each of which specifies an attribute of an output sequence to be generated by the neural network.

[0134] In these embodiments, the system also augments each training input sequence with metadata tokens that specify corresponding actual properties of the computer program represented by the output sequence in the training examples.

[0135] In some of these embodiments, the system can utilize this metadata to allow the system to incorporate incorrect computer programs into training.

[0136] In particular, the training examples may include a) a first subset of training examples for which the training output sequences in the training examples are correct solutions to the computer programming tasks represented by the training input sequences in the training examples, and b) a second set of training examples for which the training output sequences in the training examples are not correct solutions to the computer programming tasks represented by the training input sequences in the training examples. For each training example in a), the system includes a metadata token indicating a correct solution, and for each training example in b), the system includes a metadata token indicating an incorrect solution. This provides additional training signals and allows the use of data that might otherwise mislead the model.

[0137] The system trains the generative neural network on the code-generating neural network (step 408 ).

[0138] That is, the system trains the generative neural network with respect to a goal that encourages the generative neural network to generate a computer program that accurately performs the task specified by the input sequence in each training example.

[0139] In some embodiments, the system employs "tempering" during training. Tempering is a regularization technique that makes the token probability distribution generated by the generative neural network artificially smoother or sharper during training by dividing the output logit of the neural network - that is, the score generated by the second-to-last layer of the neural network - by a scalar temperature T before the softmax layer. When tempering is employed, the system uses a temperature T between zero and one - not including zero and one. Using temperatures in this range can avoid overfitting the fine-tuning data set by making the training distribution sharper and therefore the inference distribution smoother. For example, the system can set T equal to .1, .2, or .4

[0140] In these embodiments, at the sampling time, the system divides the logit by another temperature between zero and one, exclusive of zero and one. For example, the system can determine T' by adjusting the value on the validation set after training.

[0141] In some implementations, the system uses maximum likelihood as the code generation objective.

[0142] In some other embodiments, the system uses the GOLD objective as the code generation objective. GOLD is an offline RL algorithm that adds off-policy importance weights to the standard maximum likelihood objective gradient. The use of the GOLD objective can take into account the fact that code generation based on task description is inherently one of many tasks: each task problem allows many different solutions depending on algorithm selection, implementation, etc. The standard maximum likelihood objective minimizes the loss (such as recall) by applying a certain weight to each solution in the training set, while the system's goal is a single correct solution (such as precision) within the budget budget. GOLD can solve this problem by adding off-policy importance weights, which allows the model to learn from both the tokens to which it has assigned high likelihood and ignore the tokens that are not in its distribution. In this way, the model can focus on precision rather than recall and increase its chances of obtaining at least one correct sample. More specifically, the gradient of the GOLD objective satisfies: , in are the parameters of the generative neural network, the solution token is the token in the output sequence of the training example, and is the probability assigned to the word s by the generative neural network.

[0143] In some cases, to mitigate instabilities during training, the system uses Replace the importance weights above ,in =12 and =0.05.

[0144] In some of these embodiments, the target is GOLD with tempering. In these embodiments, the system can first divide the logarithm by the temperature before calculating the loss, so both the log loss term and the importance weight use the tempered distribution.

[0145] Optionally, the system may include one or more auxiliary losses as part of fine tuning.

[0146] For example, the system can incorporate a masked language modeling loss on the encoder's predictions during fine-tuning. The masked language modeling loss is described in more detail in J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805,2018. As another example, the system can incorporate a value prediction auxiliary task into the training of the decoder. In this example, the last layer of word-meta representations before projection to logit is also used in, for example, the prediction head of a small Transformer to classify whether the generated computer program is correct or incorrect.

[0147] When using the test input generating neural network at inference time, the test input generating neural network may also have an encoder-decoder architecture like the generating neural network. In particular, the system may train the test input generating neural network starting from the pre-trained generating neural network after step 404, but may use a different fine-tuning objective. In particular, the fine-tuning objective may be to predict the test input from the problem description using the known test input as the target output. For example, the objective may be a maximum log-likelihood objective.

[0148] As described above, the system can make any of several adjustments to the training and sampling process in order to improve the performance of the system. Table 2 shows the effect of some of these adjustments on the performance of the system on a task that requires submitting 10 synthetic programs for each natural language description and is determined to be successfully executed when one or more of the 10 programs successfully execute the task.

[0149] Each row of Table 2 shows the solution rate of the system using the adjustment given in that row and all the adjustments given in any row above that row, where the number in parentheses is the 95% confidence interval of the solution rate. "Solve rate" is the percentage of inputs to the above tasks for which the system generates successful programs. Row 2, "No Enhancement", corresponds to using a neural network fine-tuned with the standard next-term prediction loss (no GOLD or tempering during training, and no masked language modeling or value prediction auxiliary losses, and no clustering during sampling). On the other hand, the last row corresponds to using the "No Enhancement" system, but with masked language modeling, tempering, random labels and ratings (using "metadata conditioning" with randomly selected labels and ratings as described above), value prediction, GOLD, and clustering during sampling. As can be seen from Table 2, each adjustment improves the performance of the system relative to the system that does not include the adjustment.

[0150] This specification uses the term "configuration" in conjunction with system and computer program components. For a system of one or more computers to be configured to perform a particular operation or action, it is meant that the system has installed thereon software, firmware, hardware, or a combination thereof, which, in operation, causes the system to perform the operation or action. For one or more computer programs to be configured to perform a particular operation or action, it is meant that the one or more programs include instructions that, when executed by a data processing device, cause the device to perform the operation or action.

[0151] Embodiments of the subject matter and functional operations described in this specification may be implemented in digital electronic circuits, tangibly embodied computer software or firmware, computer hardware, including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. Embodiments of the subject matter described in this specification may be implemented as one or more computer programs, for example, one or more modules of computer program instructions encoded on a tangible non-transitory storage medium, for execution by a data processing device or for controlling the operation of a data processing device. A computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them. Alternatively or additionally, program instructions may be encoded on an artificially generated propagation signal, such as a machine-generated electrical, optical, or electromagnetic signal, which is generated to encode information for transmission to a suitable receiver device for execution by a data processing device.

[0152] The term "data processing apparatus" refers to data processing hardware and covers all kinds of apparatus, devices and machines for processing data, including, for example, a programmable processor, a computer or multiple processors or computers. The apparatus may also be or further include special-purpose logic circuits, such as an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit). In addition to hardware, the apparatus may optionally include code that creates an execution environment for a computer program, for example, code constituting processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.

[0153] A computer program, which may also be referred to or described as a program, software, software application, app, module, software module, script or code, may be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages; and it may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment. A program may, but need not, correspond to a file in a file system. A program may be stored in a portion of a file that holds other programs or data, such as one or more scripts stored in a meta-language document, in a single file dedicated to the program in question, or in multiple coordinated files, such as files that store one or more modules, subroutines or code portions. A computer program may be deployed to be executed on one computer located at one site or on multiple computers distributed across multiple sites and interconnected by a data communications network.

[0154] In this specification, the term "database" is used broadly to refer to any collection of data: the data need not be structured in any particular way, or at all, and it may be stored on storage devices in one or more locations. Thus, for example, an index database may include multiple data collections, each of which may be organized and accessed differently.

[0155] Similarly, in this specification, the term "engine" is used broadly to refer to a software-based system, subsystem, or process that is programmed to perform one or more specific functions. Typically, an engine will be implemented as one or more software modules or components installed on one or more computers in one or more locations. In some cases, one or more computers will be dedicated to a specific engine; in other cases, multiple engines can be installed and run on the same computer or multiple computers.

[0156] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform functions by operating on input data and generating output. The processes and logic flows can also be performed by a dedicated logic circuit such as an FPGA or ASIC, or by a combination of a dedicated logic circuit and one or more programmed computers.

[0157] Computers suitable for executing computer programs can be based on general or special purpose microprocessors or both, or any other kind of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory or a random access memory or both. The basic elements of a computer are a central processing unit for executing or implementing instructions and one or more memory devices for storing instructions and data. The central processing unit and the memory can be supplemented by or incorporated into a special purpose logic circuit. Typically, the computer will also include one or more mass storage devices for storing data, such as magnetic disks, magneto-optical disks or optical disks, or operably coupled to receive data from or transmit data to, or both. However, the computer does not need to have such a device. In addition, the computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device, such as a universal serial bus (USB) flash drive, to name a few.

[0158] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, including, for example, semiconductor memory devices, such as EPROM, EEPROM, and flash memory devices; magnetic disks, such as internal hard disks or removable disks; magneto-optical disks; and CD ROM and DVD-ROM disks.

[0159] To provide interaction with a user, embodiments of the subject matter described in this specification may be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user, as well as a keyboard and a pointing device such as a mouse or trackball through which the user can provide input to the computer. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback, such as visual feedback, auditory feedback, or tactile feedback; and input from the user may be received in any form, including acoustic, voice, or tactile input. In addition, the computer may interact with the user by sending documents to and receiving documents from a device used by the user; for example, by sending a web page to a web browser on a user's device in response to a request received from the web browser. In addition, the computer may interact with the user by sending a text message or other form of message to a personal device, such as a smart phone running a messaging application, and receiving a response message from the user in return.

[0160] The data processing apparatus for implementing the machine learning model may also include, for example, dedicated hardware accelerator units for processing common and computationally intensive parts of machine learning training or production, such as inference, workloads.

[0161] Machine learning models can be implemented and deployed using a machine learning framework such as the TensorFlow framework.

[0162] Embodiments of the subject matter described in this specification can be implemented in a computing system that includes a back-end component, for example, as a data server, or includes a middleware component, for example, an application server, or includes a front-end component, for example, a client computer with a graphical user interface, a web browser, or an application through which a user can interact with an implementation of the subject matter described in this specification, or any combination of one or more such back-end, middleware, or front-end components. The components of the system can be interconnected by digital data communication of any form or medium, such as a communication network. Examples of communication networks include local area networks (LANs) and wide area networks (WANs), such as the Internet.

[0163] A computing system may include a client and a server. The client and the server are usually remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on respective computers and having a client-server relationship with each other. In some embodiments, the server transmits data such as HTML pages to a user device, for example, for displaying data to a user interacting with a device acting as a client and receiving user input from the user. Data generated at the user device, such as the result of a user interaction, can be received from the device at the server.

[0164] Although this specification contains many specific implementation details, these should not be interpreted as limitations on the scope of any invention or the scope that may be claimed, but rather as descriptions of features that may be specific to a particular embodiment of a particular invention. Certain features described in this specification in the context of a separate embodiment may also be implemented in combination in a single embodiment. On the contrary, the various features described in the context of a single embodiment may also be implemented in multiple embodiments individually or in any suitable sub-combination. In addition, although features may be described above as working in certain combinations and even initially claimed as such, in some cases, one or more features from the claimed combination may be deleted from the combination, and the claimed combination may be directed to a sub-combination or a variation of the sub-combination.

[0165] Similarly, although operations are depicted in the drawings and recited in the claims in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in a sequential order, or that all of the illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

[0166] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve the desired results. As an example, the processes depicted in the accompanying drawings do not necessarily require the particular order shown or sequential order to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous.

Claims

1. A method executed by one or more computers, the method include: receiving description data describing a computer programming task, the description data comprising a plurality of text words; 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 configured to receive an input sequence comprising 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, the output sequence specifying a candidate computer program for performing the computer programming task described by the description data; For each candidate computer program in the subset of candidate computer programs and for each input in the first set: executing the candidate computer program on the input to generate an output; and One or more computer programs are selected from the candidate computer programs as composite 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 inputs in the first set of inputs.

2. The method according to claim 1, further comprising: include: receiving new input for said computer programming task; as well as One or more of the synthesized computer programs are executed on the new input to generate an output for the computer programming task for the new input.

3. A method according to any preceding claim, further comprising: include: For each input in the first set, receiving a corresponding 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 an output generated by executing the candidate computer program on the input matches a corresponding expected output for the input; and selecting as the initial set of computer programs only those candidate computer programs that, for each input in the first set, when executed on the input, generate an output that matches a corresponding expected output for the input; Wherein, based at least in part on the output generated by executing the candidate computer programs in the subset on the inputs in the first set of inputs, selecting one or more computer programs from the candidate computer programs as synthetic computer programs for performing the computer programming task comprises selecting one or more corresponding computer programs from the initial set of computer programs as synthetic computer programs.

4. A method according to any preceding claim, in, The subset of the candidate computer programs includes all of the plurality of candidate computer programs.

5. The method according to any one of claims 1 or 2, in, The options include: 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 inputs in the first set; and One or more corresponding candidate computer programs are selected from each of one or more of the clusters as synthetic computer programs.

6. The method according to claim 5, in, Selecting one or more corresponding computer programs from each of one or more of the clusters as a composite computer program comprises: One or more corresponding computer programs are selected from each of a predetermined number of largest clusters of the plurality of clusters as a synthesized computer program.

7. The method according to any one of claims 5 or 6, in, Obtaining the first set of inputs for the computer programming task comprises: One or more description sequences each comprising the plurality of text tokens from the description data are processed using a test input generating neural network, the test input generating neural network being 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.

8. The method according to any one of claims 5 to 7, in, 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 whether, for each candidate computer program and for each input in the second set of inputs, an output generated by executing the candidate computer program on the input matches a corresponding expected output for the input.

9. A method according to any preceding claim, in, The set of one or more generative neural networks includes only a single generative neural network.

10. The method according to any one of claims 1 to 8, in, 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 compared to 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 used to sample an output sequence from the generative neural network.

11. A method according to any preceding claim, in, One or more of the generative neural networks in the set of generative neural networks 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 is configured to process the encoded representation to generate the output sequence.

12. The method according to claim 11, in, The encoder neural network is a Transformer encoder that applies self-attention to the input sequence, and the decoder neural network is an autoregressive Transformer decoder that applies criss-cross attention to the encoded representation.

13. A method according to any preceding claim, in, Generating a plurality of candidate computer programs by sampling a plurality of output sequences from a collection of one or more generative neural networks comprises repeatedly performing operations comprising: generating a current input sequence from the description data; and One or more output sequences are sampled by processing the current input sequence using one of the generative neural networks in the set.

14. The method according to claim 13, in, The operations are performed in parallel across multiple hardware devices.

15. The method according to claim 13 or 14, in, 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 programming languages ​​from a distribution over a set of programming languages; and One or more tokens identifying the programming language are included in the current input sequence.

16. The method according to any one of claims 13 to 15, in, Each input sequence comprises the plurality of text tokens from the description data and one or more tokens indicating whether an output sequence generated by the generative neural network should specify a correct solution or an incorrect solution to the computer programming task, and wherein generating a current input sequence from the description data comprises: One or more word-grams are included that indicate that an output sequence generated by the generative neural network should specify a correct solution to the computer programming task.

17. The method according to any one of claims 13 to 16, in, Each input sequence comprises a plurality of text tokens from the description data and zero or more tags, the zero or more tags each comprising one or more tokens and identifying an algorithm that should be implemented by an output sequence generated by the generative neural network, and wherein generating the current input sequence from the description data comprises: sampling one or more labels from a distribution over a set of labels; and The sampled labels are included in the current output sequence.

18. The method according to any one of claims 13 to 17, in, Each input sequence includes the plurality of text tokens from the description data and one or more tokens specifying a difficulty rating of the computer programming task, and wherein generating a current input sequence from the description data includes: selecting a difficulty rating for the computer programming task; and One or more word-grams specifying a selected difficulty rating are included in the current output sequence.

19. The method according to claim 18, in, The difficulty ratings for the computer programming tasks were selected to include: After training the generative neural network, a fixed difficulty rating is selected that is the same for all computer programming tasks.

20. The method according to claim 18, in, The difficulty ratings for the computer programming tasks were selected to include: Sample a difficulty rating from a distribution over the set of difficulty ratings.

21. A method according to any preceding claim, in, Each generative neural network has been pre-trained on a first set of training data for a language modeling objective and fine-tuned on a second set of training data for a code generation objective, the second set of training data comprising a plurality of training examples, the plurality of training examples each comprising (i) a training input sequence representing a computer programming task and (ii) a training output sequence representing a computer program.

22. The method according to claim 21, in, The first set of training data comprises a set of sequences each representing a segment of computer code.

23. The method according to claim 21 or 22, in, The multiple training examples include a first subset of training examples and a second set of training examples. For the first subset of training examples, the training output sequences in the training examples are correct solutions to the computer programming tasks represented by the training input sequences in the training examples. For the second set of training examples, the training output sequences of the training examples are not correct solutions to the computer programming tasks represented by the training input sequences in the training examples.

24. The method according to any one of claims 21 to 23, in, The code generation target is GOLD with tempering.

25. A method according to any preceding claim, in, The text words and the computer code words are selected from the same word word vocabulary.

26. A system comprising one or more computers and one or more storage devices storing instructions which, when executed by the one or more computers, cause the one or more computers to perform the operations of the respective methods of any one of claims 1 to 25.

27. One or more computer storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform the operations of the respective methods of any one of claims 1 to 25.

Citation Information

Cited By

  • Computer code generator

    US12353854B2