Next AST branch prediction and next token prediction joint pre-training task for code generative models
Abstract
During pretraining, a computer generates three trainable and untrained machine learning models that are a token sequence encoder, a token predictor, and a path predictor. A sequence of lexical tokens is generated that represents a lexical text in a training corpus. A graph is generated that represents the lexical text. In the graph, a next traversal path is selected that corresponds to a next lexical token that is adjacent to a sliding subsequence of the sequence of lexical tokens. From the subsequence, the token sequence encoder infers an encoded sequence that represents the subsequence. The path predictor and token predictor accept the encoded sequence as input for respective inferencing for which respective training losses are measured. Both training losses are combined into a combined loss that is used to increase the accuracy of the three machine learning models by, for example, backpropagation of the combined loss.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 16 · Forward citations: 0.
Claims (20 — 2 Independent, 18 Dependent)
- Claim 1Independent Claim
A method comprising: generating a token sequence encoder that is trainable and untrained; generating a sequence of lexical tokens that represents a lexical text; generating a graph that represents the lexical text; inferring from a subsequence of the sequence of lexical tokens, by the token sequence encoder, an encoded sequence that represents the subsequence of the sequence of lexical tokens; predicting, from the encoded sequence that represents the subsequence of the sequence of lexical tokens, a predicted traversal path that represents a next lexical token that occurs next in the sequence of lexical tokens adjacent to the subsequence of the sequence of lexical tokens; and adjusting the token sequence encoder based on the predicted traversal path that represents the next lexical token.
- Claim 2Depends on #1
The method of claim 1 further comprising self-supervised training: a first machine learning model that accepts as input the encoded sequence that represents the subsequence of the sequence of lexical tokens, and a second machine learning model that accepts as input the encoded sequence that represents the subsequence of the sequence of lexical tokens.
- Claim 3Depends on #2
The method of claim 2 further comprising: measuring, for the first machine learning model, a first training loss that is based on the predicted traversal path that represents the next lexical token; measuring, for the second machine learning model, a second training loss that is not based on the predicted traversal path that represents the next lexical token.
- Claim 4Depends on #2
The method of claim 2 further comprising predicting, by the second machine learning model, a lexical token that occurs next in the sequence of lexical tokens adjacent to the subsequence of the sequence of lexical tokens.
- Claim 5Depends on #4
The method of claim 4 further comprising: deploying into a production environment, without the first machine learning model, the token sequence encoder and the second machine learning model; predicting, by the second machine learning model, a lexical token that occurs next in a new sequence of lexical tokens that represents a new lexical text that is syntactically invalid.
- Claim 6Depends on #1
The method of claim 1 further comprising counting occurrences of a particular sub-path in a traversal path that represents said next lexical token.
- Claim 7Depends on #1
The method of claim 1 wherein the predicted traversal path comprises at least one selected from a group consisting of: a multilabel frequency distribution, an indication that a particular sub-path does not occur, and an indication that a first sub-path is more frequent than a second sub-path that has a same length as the first sub-path.
- Claim 8Depends on #1
The method of claim 1 further comprising selecting the subsequence of the sequence of lexical tokens by sliding a fixed-length window over the sequence of lexical tokens that represents the lexical text.
- Claim 9Depends on #1
The method of claim 1 wherein: the method further comprises multitask learning by the token sequence encoder; said inferring the encoded sequence that represents the subsequence of the sequence of lexical tokens and said adjusting the token sequence encoder occur during said multitask learning by the token sequence encoder.
- Claim 10Depends on #1
The method of claim 1 wherein the graph is at least one selected from a group consisting of a directed acyclic graph (DAG), a dataflow graph, an abstract syntax tree (AST), and an imbalanced tree.
- Claim 11Independent Claim
One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause: generating a token sequence encoder that is trainable and untrained; generating a sequence of lexical tokens that represents a lexical text; generating a graph that represents the lexical text; inferring from a subsequence of the sequence of lexical tokens, by the token sequence encoder, an encoded sequence that represents the subsequence of the sequence of lexical tokens; predicting, from the encoded sequence that represents the subsequence of the sequence of lexical tokens, a predicted traversal path that represents a next lexical token that occurs next in the sequence of lexical tokens adjacent to the subsequence of the sequence of lexical tokens; and adjusting the token sequence encoder based on the predicted traversal path that represents the next lexical token.
- Claim 12Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein the instructions further cause self-supervised training: a first machine learning model that accepts as input the encoded sequence that represents the subsequence of the sequence of lexical tokens, and a second machine learning model that accepts as input the encoded sequence that represents the subsequence of the sequence of lexical tokens.
- Claim 13Depends on #12
The one or more non-transitory computer-readable media of claim 12 wherein the instructions further cause: measuring, for the first machine learning model, a first training loss that is based on the predicted traversal path that represents the next lexical token; measuring, for the second machine learning model, a second training loss that is not based on the predicted traversal path that represents the next lexical token.
- Claim 14Depends on #12
The one or more non-transitory computer-readable media of claim 12 wherein the instructions further cause predicting, by the second machine learning model, a lexical token that occurs next in the sequence of lexical tokens adjacent to the subsequence of the sequence of lexical tokens.
- Claim 15Depends on #14
The one or more non-transitory computer-readable media of claim 14 wherein the instructions further cause: deploying into a production environment, without the first machine learning model, the token sequence encoder and the second machine learning model; predicting, by the second machine learning model, a lexical token that occurs next in a new sequence of lexical tokens that represents a new lexical text that is syntactically invalid.
- Claim 16Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein the instructions further cause counting occurrences of a particular sub-path in a traversal path that represents said next lexical token.
- Claim 17Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein the predicted traversal path comprises at least one selected from a group consisting of: a multilabel frequency distribution, an indication that a particular sub-path does not occur, and an indication that a first sub-path is more frequent than a second sub-path that has a same length as the first sub-path.
- Claim 18Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein the instructions further cause selecting the subsequence of the sequence of lexical tokens by sliding a fixed-length window over the sequence of lexical tokens that represents the lexical text.
- Claim 19Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein: the instructions further cause multitask learning by the token sequence encoder; said inferring the encoded sequence that represents the subsequence of the sequence of lexical tokens and said adjusting the token sequence encoder occur during said multitask learning by the token sequence encoder.
- Claim 20Depends on #11
The one or more non-transitory computer-readable media of claim 11 wherein the graph is at least one selected from a group consisting of a directed acyclic graph (DAG), a dataflow graph, an abstract syntax tree (AST), and an imbalanced tree.
Technical Overview & Description
FIELD OF THE INVENTION The present invention relates to natural language processing (NLP). Herein is machine learning pretraining to predict a graph traversal path that corresponds to a next lexical token in a sequence of lexical tokens that represents a lexical text. BACKGROUND For state of the art source code generation, training is bilingual and biphasic as follows. A large language model is pretrained with a natural language training corpus and then finetuned with a corpus of a particular programing language, and the programing language is treated no differently than natural language. A programming language has rules and internal grammar much stricter than a natural language, and naively applying a natural language model to a programming language task neglects the inherent structure present in code, potentially leading to suboptimal generated code. Accuracy of bilingual training is suboptimal because source code syntax is unused. Decreased accuracy of bilingual training may also increase a finetuning duration needed to achieve a desired final accuracy. Thus, bilingual biphasic training may be both slow and inaccurate. Alternative approaches that inspect program structure cannot handle syntactically invalid source code, even though an application such as source code completion usually begins with invalid logic. For example, an approach may tokenize source code into an original token sequence and insert synthetic tokens that represent syntactic structure into the original token sequence to generate an enhanced token sequence. However, synthetic tokens are unavailable for insertion if source logic is syntactically invalid and, for example in production, missing synthetic tokens may somewhat or entirely interfere with inferencing. BRIEF DESCRIPTION OF THE DRAWINGS In the drawings: FIG. 1 is a block diagram that depicts an example computer that pretrains a path predictor to predict, based on natural language processing (NLP), a traversal path that corresponds to a ne
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 (16)
Non-Patent Literature (10)
- Zugner, Daniel, et al.,
- “
- Language-Agnostic Representation Learning of Source Code from Structure and Context
- ”
- , ICLR 2021, https://arxiv.org/abs/2103.11318, Mar. 21, 2021, 22pgs.
- Zhang, Jian, et al.,
- “
- A Novel Neural Source Code Representation Based on Abstract Syntax Tree
- ”
- , 2019 IEEE/ACM 41st ICSE, doi: 10.1109/ICSE.2019.00086, pp. 783-794, May 25, 2019, 12pgs.