# US 2022/0035605 A1 · Dual bayesian encoding-decoding technique for text to code transformations

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0035605 A1
- Document ID: US20220035605A1
- Status: Published application
- Kind: A1
- Application number: 17/499,749
- Filed: 2021-10-12
- Published: 2022-02-03
- Earliest claimed: 2021-10-12
- Assignees: Intel Corporation
- Applicants: Intel Corporation
- Inventors: Alejandro IBARRA VON BORSTEL; Fernando AMBRIZ MEZA; David Israel GONZALEZ AGUIRRE; Walter Alejandro MAYORGA MACIAS; Rocio HERNANDEZ FABIAN
- Web page: https://patentgrep.com/patent/US20220035605A1

## CPC

- G06F 8/35: model driven
- G06F 8/425: {Lexical analysis}
- G06F 8/30: Creation or generation of source code
- G06F 8/427: {Parsing}
- G06N 3/044: Recurrent networks, e.g. Hopfield networks
- G06N 3/0442: characterised by memory or gating, e.g. long short-term memory [LSTM] or gated recurrent units [GRU]
- G06N 3/045: Combinations of networks
- G06N 3/0455: Auto-encoder networks; Encoder-decoder networks
- G06N 3/047: Probabilistic or stochastic networks
- G06N 3/09: Supervised learning
- G06N 7/01: Probabilistic graphical models, e.g. probabilistic networks
- G06N 20/00: Machine learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Methods, apparatus, and software for implementing dual Bayesian encoding-decoding for text-to-code transformations. In one aspect, a multi-model probabilistic source code model employing dual Bayesian encoder-decoder models is used to convert natural language (NL) inputs (aka requests) into source code. An NL input is processed to generate a Probabilistic Distribution (PD) of Source code (SC) tokens in an SC token sequence and a PD of Abstract Syntax Tree (AST) tokens in an AST token sequence, wherein each SC token is associated with a respective AST token, and each of the SC and AST tokens have a respective PD. One or more fixing rules are applied to one or more tokens SC tokens that are identified as needing fixing, wherein the fixing rule are selected in consideration of the PDs of the SC tokens and the PDs of their associated AST tokens.

## Claims

### Claim 1

A method for generating source code from a Natural Language (NL) input, comprising:
processing the NL input to generate a Probabilistic Distribution (PD) of Source code (SC) tokens in an SC token sequence;
processing the NL input to generate a PD of Abstract Syntax Tree (AST) tokens in an AST token sequence;
identifying one or more SC tokens to be fixed; and
applying one or more fixing rules to the one or more SC tokens that are identified, wherein the fixing rule for a given SC token is selected based on at least one of the PD of the SC token and the PD of an AST token associated with the SC token.

### Claim 2 (depends on 1)

The method of claim 1, wherein identifying an SC token to be fixed comprises:
at least one of compiling an SC token sequence with a compiler and interpreting an SC token sequence with an interpreter; and
detecting an SC token that causes the compiler or interpreter to throw a syntax error.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
determining an SC token has a low confidence level and the associated AST token has a high confidence level; and
using a deterministic grammar dictionary to replace the SC token.

### Claim 4 (depends on 1)

The method of claim 1, further comprising:
determining an AST token associated with an SC token has a low confidence level and is a variable (var); and
replacing the SC token with an entry in a source code vocabulary list.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
determining an AST token associated with an SC token has a low confidence level and is not a variable (var); and
employing a genetic programming process to replace the SC token.

### Claim 6 (depends on 1)

The method of claim 1, wherein the PD of the SC tokens is generated by a Text-to-source code (Text2Code) machine learning (ML) model.

### Claim 7 (depends on 6)

The method of claim 6, wherein the Text2Code ML model comprises a Long Short-Term Memory (LSTM) encoder and a Source Code Bayesian LSTM decoder that outputs a sequence of decoded SC tokens.

### Claim 8 (depends on 1)

The method of claim 1, wherein the PD of the AST tokens is generated by a Text-to-AST (Text2AST) machine learning (ML) model.

### Claim 9 (depends on 8)

The method of claim 8, wherein the Text2AST ML model comprises a Long Short-Term Memory (LSTM) encoder and an AST Bayesian LSTM decoder that outputs a sequence of decoded AST tokens.

### Claim 10 (depends on 1)

The method of claim 1, wherein a PD for an SC token comprises a mean associated with a level of certainty to whether the SC token is a match and a standard deviation associated with a level of uncertainty to whether the SC token is a match, wherein a PD for an AST token comprises a mean associated with a level of certainty to whether the AST token is a match and a standard deviation associated with a level of uncertainty to whether the AST token is a match, and wherein selection of the fixing rule employs at least one of the level of certainty and the level of uncertainty for at least one of an SC token and its associated AST token.

### Claim 11

A non-transitory machine-readable medium having instructions stored thereon configured to be executed on one or more processors on a computing system to generate source code from a Natural Language (NL) input, wherein execution of the instructions causes the computing system to:
process the NL input to generate a Probabilistic Distribution (PD) of Source code (SC) tokens in an SC token sequence;
process the NL input to generate a PD of Abstract Syntax Tree (AST) tokens in an AST token sequence;
identify one or more SC tokens to be fixed; and
apply one or more fixing rules to the one or more SC tokens that are identified, wherein the fixing rule for a given SC token is selected based on at least one of the PD of the SC token and the PD of an AST token associated with the SC token.

### Claim 12 (depends on 11)

The non-transitory machine-readable medium of claim 11, wherein a portion of the instructions comprise a Text-to-AST (Text2AST) machine learning (ML) model comprising a Long Short-Term Memory (LSTM) encoder and an AST Bayesian LSTM decoder that outputs a sequence of decoded AST tokens.

### Claim 13 (depends on 11)

The non-transitory machine-readable medium of claim 11, wherein a portion of the instructions comprise a Text-to-source code (Text2Code) machine learning (ML) model comprising a Long Short-Term Memory (LSTM) encoder and an AST Bayesian LSTM decoder that outputs a sequence of decoded source code tokens.

### Claim 14 (depends on 11)

The non-transitory machine-readable medium of claim 11, wherein a PD for an SC token comprises a mean associated with a level of certainty to whether the SC token is a match and a standard deviation associated with a level of uncertainty to whether the SC token is a match, wherein a PD for an AST token comprises a mean associated with a level of certainty to whether the AST token is a match and a standard deviation associated with a level of uncertainty to whether the AST token is a match, and wherein selection of the fixing rule employs at least one of the level of certainty and the level of uncertainty for at least one of an SC token and its associated AST token.

### Claim 15 (depends on 11)

The non-transitory machine-readable medium of claim 11, wherein execution of the instructions further causes the computing system to:
determine an SC token has a low confidence level and its associated AST token has a high confidence level; and
use a deterministic grammar dictionary to replace the SC token.

### Claim 16 (depends on 11)

The non-transitory machine-readable medium of claim 11, wherein execution of the instructions further causes the computing system to:
determine an AST token associated with an SC token has a low confidence level and is a variable (var); and
replace the SC token with an entry in a source code vocabulary list.

### Claim 17

A computing system comprising:
one or more processors,
memory, coupled to the one or more processors, having instructions stored therein configured to be executed on at least one of the one or more processors to enable the system to:
process a natural language (NL) input to generate a Probabilistic Distribution (PD) of Source code (SC) tokens in an SC token sequence;
process the NL input to generate a PD of Abstract Syntax Tree (AST) tokens in an AST token sequence;
identify one or more SC tokens to be fixed; and
apply one or more fixing rules to the one or more SC tokens that are identified, wherein the fixing rule for a given SC token is selected, at least in part, based on at least one of the PD of the SC token and the PD of an AST token associated with the SC token.

### Claim 18 (depends on 17)

The computing system of claim 17, wherein a first portion of the instructions comprise a Text-to-AST (Text2AST) machine learning (ML) model comprising a Long Short-Term Memory (LSTM) encoder and an AST Bayesian LSTM decoder that outputs a sequence of decoded AST tokens, and wherein a second of the instructions comprise a Text-to-source code (Text2Code) machine learning (ML) model comprising a Long Short-Term Memory (LSTM) encoder and an AST Bayesian LSTM decoder that outputs a sequence of decoded source code tokens.

### Claim 19 (depends on 17)

The computing system of claim 17, wherein a PD for an SC token comprises a mean associated with a level of certainty to whether the SC token is a likely match and a standard deviation associated with a level of uncertainty to whether the SC token is a match, wherein a PD for an AST token comprises a mean associated with a level of certainty to whether the AST token is a likely match and a standard deviation associated with a level of uncertainty to whether the AST token is a match, and wherein selection of the fixing rule employs at least one of the level of certainty and the level of uncertainty for at least one of an SC token and its associated AST token.

### Claim 20 (depends on 17)

The computing system of claim 17, wherein execution of the instructions enables the system to:
receive one or more NL input requests; and
automatically generate source code snippets corresponding to the one or more NL input requests.
