A fast and efficient human-computer collaborative program translation method

By introducing prefix-based human-computer interactive program translation and attention caching mechanisms, the program translation process is optimized, and the problems of high cost, low efficiency and response delay in the existing technology are solved, and efficient and accurate human-computer collaborative translation is achieved.

CN115421734BActive Publication Date: 2025-08-19NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211077086.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-05
Publication Date
2025-08-19
Estimated Expiration
2042-09-05

AI Technical Summary

Technical Problem

In the prior art, program translation methods have problems such as high cost, low efficiency and prone to errors, especially when the program length is long, the response delay in the human-computer collaboration process is severe, affecting the user experience.

Method used

Prefix-based human-computer interactive program translation method (PHM) and attention caching mechanism are used to avoid repeated calculations by caching attention information, aborting invalid reasoning in advance, and splicing existing code suffixes are optimized, combining the feedback from software engineers.

Benefits of technology

It significantly reduces the workload and response time of software engineers, improves the accuracy and user experience of program translation, and reduces the response delay caused by excessive program length.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115421734B_ABST
    Figure CN115421734B_ABST
Patent Text Reader

Abstract

The present invention relates to a fast and efficient human-computer collaborative program translation method, comprising: 1. When a program translation model translates a source program, a software engineer corrects the output code and feeds back the editing results to the program translation model in the form of a prefix; 2. The subsequent retranslation process is divided into two parts: 1). For the generation of prefixes, the cached attention information is used to remove repeated prefixes in the next round. 2). For the remaining generation parts, at each time step, a two-stage method is proposed to determine whether the position can be spliced by a known suffix. If so, the reasoning is terminated in advance. This interaction will be repeated until the software engineer is satisfied with the result. Through the above method, human intelligence and machine intelligence are effectively combined, the accuracy of the final result of program translation is improved, the workload of software engineers is reduced, and the response delay in the collaborative process caused by the excessive length of the program is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of program code translation based on deep learning, and relates to a fast and efficient human-computer collaborative program translation method, and in particular to a program code translation method based on an intelligent model and a human-computer collaborative mode. Background Art

[0002] In the IT field, programming languages are evolving much faster than natural languages. For example, over 2,500 high-level programming languages have emerged in the world in recent decades. Therefore, program translation has become a significant need. Program translation involves rewriting existing code from one programming language into another, such as from Python to Java. Effective program translation methods can help companies improve efficiency in many practical development scenarios, such as: 1) Application modernization. For example, the Commonwealth Bank of Australia spent five years and $750 million converting its platform from COBOL to Java. Furthermore, some regions in the United States have massive access to unemployment benefit systems, all of which are written in ancient languages. 2) Multiple language versions of applications on different platforms. For example, when a company plans to bring a Windows-based desktop program to the Android platform, they may need to rewrite the related C++ program in Java.

[0003] Traditional program translation methods rely on purely manual coding to translate from the source language to the target language. This is both expensive and inefficient, requiring experts with complex bilingual knowledge and knowledge of compiler theory. In recent years, the explosive growth of programs on code hosting platforms like GitHub has spurred research into machine learning-based program translation. While this type of machine learning-based program translation offers low cost and high efficiency, it also introduces a significant risk of program errors. This is because overlooked errors in natural language translation can affect the overall operation of a program. For example, the TransCoder-DOBF model released by Facebook in 2021 only achieves a computational accuracy of 50% for Python and Java translations, making it clearly unsuitable for direct enterprise development. For program translation tasks, some simple human-machine collaborative approaches have been proposed, such as confidence highlighting and candidate translations. However, these approaches essentially require software engineers to post-edit the output code without considering how to feed user modifications back to the model.

[0004] To address this thorny issue, a Human–Machine Computing (HMC) framework is proposed for program translation. The core idea of HMC is to leverage the strengths of both humans and machines, thereby improving overall quality, namely accuracy and efficiency, through continuous iterative updates. However, this also presents two challenges. First, post-editing on the output code by software engineers only statically modifies the code, thus requiring a large workload (i.e., the number of modifications). To effectively reduce the workload, how should software engineers iteratively collaborate with program translation models? Second, compared with natural language translation tasks, program translation has longer text (for example, the longest program in the TransCoder test dataset has 548 tokens), and current program translation models are almost all based on Transformer models, which are large deep neural networks. This will inevitably lead to high response latency, severely impacting the user's collaborative experience. Summary of the Invention

[0005] Technical problems to be solved

[0006] In order to avoid the deficiencies of the prior art, the present invention provides a fast and efficient human-computer collaborative program translation method.

[0007] Technical Solution

[0008] A fast and efficient human-computer collaborative program translation method is characterized by the following steps:

[0009] Step 1: Prefix-based Human-Computer Interactive Program Translation (PHM): Considering that for structured texts like program code, changes in some characters can have a huge impact on subsequent program fragments, we consider introducing a prefix-based protocol in natural language translation to complete the program translation task; in this protocol, software engineers need to check the target program. And correct the first wrong token This indirectly means that software engineers accept the original prefix and produces a valid prefix The basic equation for this process is as follows:

[0010]

[0011]

[0012] is the translation result of this round; is the source program of this round; Pr is the abbreviation of Probability, which means probability; argmax is a function. For the function y = f(x), x0 = argmax(f(x)) means that the parameter x0 satisfies that f(x0) is the maximum value of f(x);

[0013] Specifically, the program translation process of the next round is divided into two parts:

[0014]

[0015] where δ is the Kronecker delta symbol, A t is the output of the decoder of the Transformer model at time step t, is the weight matrix of the linear layer, v is the size of the vocabulary, d is the hidden layer dimension, softmax(VA t ) is the output of the Transformer-based program translation model, is the one-hot encoding of the word y t ;

[0016] Step 2: Attention Cache: When t ∈ [0, x - 1], the token corresponding to the maximum value of the generated output probability distribution meets the user's requirements; although its probability distribution does not strictly conform to the first case, from the perspective of the impact on subsequent inferences, these two probability distributions are equivalent; and when t = i, the user corrects a token; in this case, the token corresponding to the maximum value of the output probability distribution generated by the model does not meet the user's requirements, so the output probability distribution must be forcibly changed;

[0017] It is recommended to re-divide the decoding process into two stages, and the token outputs of these two stages are exactly the same as before:

[0018]

[0019] When the time step t < i, the sub-process repeats the exact same sub-process as the previous round. Therefore, the above formula can

[0020] be rewritten as:

[0021]

[0022] where, is the output of the decoder of the program translation model at time step t in the previous round of translation;

[0023] It is recommended to directly skip the sub-process with time step t ∈ [0, i - 1] to avoid repeated calculations. In this case, the overall translation process is rewritten as:

[0024]

[0025] It is proposed to directly use the cached state information to replace the first stage to minimize the repeated calculations with the previous round;

[0026] Therefore, the user's feedback f' should be defined as:

[0027]

[0028] in

[0029] S 0a ={K 0lja ,V 0lja |l∈[1,L],j∈[1,h]}

[0030]

[0031] Among them, S 0a It is the state information of the encoder-decoder attention sublayer in the decoder during the first round of interaction; it mainly includes the key matrix and value matrix of the encoder-decoder attention sublayer of each h head in the L layer; represents the key matrix of the encoder-decoder attention sub-layer of the jth head of the lth layer after the first inference of the decoder, and so on; It is the state information of the self-attention sublayer in the decoder of the most recent inference, mainly including the key matrix and value matrix of the self-attention sublayer of each h head in the L layer after slicing; Represents the slice submatrix of the key matrix of the self-attention sublayer of the jth layer of the decoder after the most recent inference, and so on;

[0032] Step 3: Suffix Splicing: To avoid the generation of invalid suffixes, it is recommended to terminate the reasoning process in advance when appropriate; to ensure that a complete target program is presented to the user, another program suffix should be spliced at the termination point; and this suffix can be obtained from the first round. Therefore, the whole process can be rewritten as:

[0033]

[0034] Where e represents the position to be terminated, and e0 represents the first round The position in the output code corresponding to the termination point;

[0035] The best stopping point should be the place where the user will correct the problem next time. It is recommended to divide this work into two stages. When the generated position is t, first, determine the generated program fragment. Whether it has contained a potential error token; then, evaluate Is it possible to output a suffix of the first round of code? splicing; if these two conditions are met, suffix splicing will be performed at position t;

[0036] To judge Is a potential error token already included? It is recommended to use Is there a maximum output probability P in j The tokens below a certain threshold are used to evaluate the quality; the expression is:

[0037]

[0038] if will be identified as containing potential errors, and β is a user-defined parameter;

[0039] As for judging the generated fragment There are two conditions for being able to splice a suffix of the first round output code: 1. and predicted 2. Considering that similar sequence outputs are more likely to have similar subsequent decoder outputs, it is assumed that the cosine similarity between the sequence output of e0 and the sequence output of the current position is large enough;

[0040] When the generated program fragment When a suffix can be spliced, the result of the splicing It will be returned directly. It is recommended to distinguish two situations: whether the user's correction position of this result is within the decoding range to determine the effective attention cache;

[0041] In the next round of interaction, when the user’s correction position i falls within the decoding range, i∈[i p +1,e p +1], the model’s attention cache includes the valid range; when the result position i corrected by the user exceeds the decoding range, i∈[e p +2,I p ], the effective attention cache range is only up to e p , the remaining attention results are in [e p +1,i] needs to be calculated in the next round; therefore, it is recommended to redefine the state information f' fed back to the next reasoning as:

[0042]

[0043] in,

[0044]

[0045] The total number of time steps required for the next round of reasoning is e-min(i-1,e p ), the probability of the token at each position is:

[0046]

[0047] A computer system, characterized in that it includes: one or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned method.

[0048] A computer-readable storage medium is characterized by storing computer-executable instructions, which are used to implement the above method when executed.

[0049] Beneficial effects

[0050] This invention provides a fast and efficient method for human-machine collaborative program translation, effectively combining human and machine intelligence. This method improves the accuracy of the final program translation results, reduces the workload of software engineers, and significantly reduces response delays during the collaborative process caused by excessive program length. Results show that compared to manual post-editing methods, this method reduces workload at the token level by up to 73.5%. The proposed optimization method for prefix and suffix generation reduces response time by up to approximately 76.1%, providing users with flexible choices in terms of workload and response time.

[0051] This invention provides a fast and efficient method for human-machine collaborative program translation. It effectively combines machine intelligence with human intelligence, significantly reducing user workload and improving task completion efficiency. Furthermore, by significantly reducing response latency, it reduces costs while ensuring the reliability of interactive tasks and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The accompanying drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like parts throughout the drawings.

[0053] Figure 1 A scene diagram of the program translation method HMPT based on human-computer collaboration in an example of the present invention;

[0054] Figure 2This is the framework diagram of HMPT;

[0055] Figure 3 、 4 ,5 respectively show the effects of the program translation method using human-computer collaboration in reducing user workload (WSR, KSMR) and average response delay. DETAILED DESCRIPTION

[0056] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only intended to illustrate the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.

[0057] The present invention utilizes the following principles: First, it is recommended to input the editing information of the software engineer on the current output code into the model again, and complete this task through interactive collaboration. Specifically, the prefix-based interactive protocol in the field of natural language interactive translation is introduced to the program translation task. This protocol significantly reduces the workload, but also introduces a large response delay. Secondly, in order to reduce the response time, invalid calculations during human-computer interaction are avoided as much as possible. Specifically, in the process of re-translation, this goal is achieved in two aspects: using the attention information cached in the previous round of translation to avoid repeated prefix generation. And by terminating in advance at the appropriate time step and splicing the suffix of the first round of output code, the generation of invalid suffixes (i.e., non-prefix parts) is reduced.

[0058] The present invention establishes a human-machine collaborative program translation method, namely HMPT (Human-Machine Program Translation). The process of each round of collaboration is as follows: First, when the program translation model translates the source program, the software engineer corrects the output code and feeds back the editing results to the program translation model in the form of prefixes. On this basis, the effective cached attention information is determined. Second, the subsequent retranslation process will be divided into two main parts: 1). For the generation of prefixes, the cached attention information is used to remove the repeated prefixes in the next round. 2). For the remaining generation parts, it is observed that most of the generated suffixes are invalid. Therefore, at each time step, the present invention proposes a two-stage method to determine whether the position can be spliced by a known suffix. If so, the reasoning is terminated in advance. This interaction will be repeated until the software engineer is satisfied with the result.

[0059] There are 5 drawings in this invention, please refer to Figure 2 As shown, the specific steps of the present invention are as follows:

[0060] Step 1: Prefix-based Human-Computer Interactive Program Translation (PHM): Considering structured texts like program codes, the change of some characters will have a huge impact on the subsequent program fragments, especially the change of keywords, such as for to while, switch to if, etc. Therefore, the present invention considers introducing a prefix-based protocol in natural language translation to complete the program translation task. In this protocol, software engineers need to check the target program. And correct the first wrong token This indirectly means that software engineers accept the original prefix and produces a valid prefix Program translation model for feedback To constrain the conditions, we search in a more limited space to generate a better target program in the next round. The basic equation of this process is as follows:

[0061]

[0062] Since almost all current program translation models are based on variants of the Transformer architecture, inspired by research on prefix-based interaction protocols for Transformer models in natural language translation, this paper considers introducing this method into the task of program translation.

[0063] Specifically, the next round of program translation is divided into two parts. When the time step does not exceed i, the decoder's output probability distribution over the vocabulary is restricted. When the time step exceeds i, the decoder will freely predict the next token until the terminal symbol is predicted. In this method, only feedback needs to be provided to the model in the next iteration. Accordingly, the probability of each word at each time step t is:

[0064]

[0065] Where δ is the Kronecker delta symbol. t is the output of the decoder of the Transformer model at time step t (i.e., sequence output), is the weight matrix of the linear layer, v is the size of the vocabulary, d is the hidden layer dimension, and softmax (VA t ) is the output of the Transformer-based program translation model, It is word y t One-hot encoding of .

[0066] Step 2: Attention Cache: In the PHM method, when the time step is less than or equal to the user-edited position i, the output probability distribution is forcibly changed. In fact, when the time step is strictly less than i (i.e., the edit position has not been reached), its purpose is to reproduce the state context information of the time step i in the previous round of translation. Due to the effect of the attention mechanism, this will have an impact on the inference in subsequent time steps.

[0067] We note that when t ∈ [0, x - 1], the token corresponding to the maximum value of the generated output probability distribution meets the user's requirements. Although its probability distribution does not strictly conform to the first case of formula (3-3), from the perspective of the impact on subsequent inference, these two probability distributions are equivalent (because in both cases, the token input to the decoder at the next time step is the same). When t = i, the user corrects a token. In this case, the token corresponding to the maximum value of the output probability distribution generated by the model does not meet the user's requirements, so the output probability distribution must be forcibly changed.

[0068] Therefore, it is recommended to re-divide formula (3) into two stages, and the token outputs of these two stages are exactly the same as those of formula (3) (note that it is not the same output of the probability distribution. However, this is exactly the same translation result for software engineers):

[0069]

[0070] We note that when the time step t < i, the sub-process repeats exactly the same sub-process as the previous round. Therefore, formula (4) can be rewritten as:

[0071]

[0072] where is the output of the decoder of the program translation model at time step t in the previous round of translation.

[0073] It is recommended to directly skip the sub-process with time step t ∈ [0, i - 1] to avoid repeated calculations. In this case, equation (1) is rewritten as:

[0074]

[0075] where f' should contain, in addition to the prefix verified by the user, the relevant state information that affects subsequent decoding in the previous round of translation at time step i, so as to avoid repeated calculations to the greatest extent.

[0076] We note that in order to avoid repeated operations at each time step during inference, most frameworks introduce a cache mechanism during inference. This mechanism can be considered as an acceleration technique during a certain round of inference.

[0077] Inspired by this mechanism, the present invention proposes to directly use the cached state information to replace the first stage of formula (5) to avoid repeated calculations with the previous round to the greatest extent.

[0078] Specifically, we propose to divide the state information into two parts based on whether it is related to the editing position. The key matrix and value matrix of all encoder-decoder attention sub-layers will remain unchanged after the first round of interaction. In the decoder self-attention sub-layer, each position needs to calculate the attention from the beginning to the current position, and the key matrix and value matrix are both related to the time step. Therefore, the next round of translation requires the state information of the decoder self-attention sub-layer up to position i (note that this does not include position i).

[0079] Therefore, f' in formula (6) should be defined as:

[0080]

[0081] in

[0082]

[0083] in, It is the state information of the encoder-decoder attention sublayer in the decoder during the first round of interaction. It mainly includes the key matrix and value matrix of the encoder-decoder attention sublayer of each h head in the L layer. Represents the key matrix of the encoder-decoder attention sub-layer of the jth head of the lth layer after the first inference of the decoder, and so on. It is the state information of the self-attention sublayer in the decoder of the most recent inference, mainly including the key matrix and value matrix of the self-attention sublayer of each h head in the L layer after slicing. Represents the sliced submatrix of the key matrix of the self-attention sublayer of the jth layer of the decoder after the most recent inference, and so on.

[0084] Step 3: Suffix Splicing: We found that in most cases, there was more than one interaction, which means that part of the inference process is actually useless to the user, thus wasting some decoding computation time.

[0085] Therefore, it is recommended to terminate the reasoning process in advance when appropriate. In order to ensure that a complete target program is presented to the user, another program suffix should be spliced at the termination point. This suffix can be obtained from the first round. Therefore, formula (6) should be rewritten as:

[0086]

[0087] Where e represents the position to be terminated (i.e., the termination point), and e0 represents the first round The position in the output code that corresponds to the interruption point.

[0088] The best stopping point should be the place where the user will correct the next time. In addition, even if this position can be found, it may not be suitable for splicing a suffix of the first round of output code. Therefore, the present invention proposes to divide this work into two stages. When the generated position is t (note that the time step of this position in this round should be ti), first, determine the generated program fragment Whether it has contained a potential error token. Then, evaluate Is it possible to output a suffix of the first round of code? If these two conditions are met, suffix splicing will be performed at position t.

[0089] To judge Has a potential error token been included? This invention recommends using Is there a maximum output probability P in j The quality of tokens below a certain threshold is evaluated. The expression is:

[0090]

[0091] if will be identified as containing potential errors. While β is a user-defined parameter, we will show the impact of different β values in the experimental results.

[0092] As for judging the generated fragment There are two main conditions for being able to splice a suffix of the first round output code: 1. and predicted 2. Considering that similar sequence outputs are more likely to have similar subsequent decoder outputs, it is assumed that the cosine similarity between the sequence output of e0 and the sequence output of the current position is large enough. Algorithm 1 describes the entire process in detail.

[0093] Algorithm 1 determines whether the generated program fragment can be spliced with a certain translation suffix

[0094] Input: Sequence output of the current position, At;

[0095] The token of the current location prediction,

[0096] The sequence output dictionary At_dictionary of all time steps in the first round;

[0097] The token list of all time steps in the first round, token_list;

[0098] Output: If splicing can be performed at the current position, return the suffix If the condition is not met, return None

[0099]

[0100]

[0101] At_dictionary is a hash table created during the first round of translation. Its key is The value is a two-tuple A list consisting of t, representing the position of a token in the first round of output code i and the decoder output at that position

[0102] When the generated program fragment When a suffix can be spliced, the result of the splicing Will return directly.

[0103] The present invention proposes to distinguish two cases: whether the user's correction position of this result is within the decoding range to determine the effective attention cache.

[0104] In the next round of interaction, when the user’s correction position i falls within the decoding range, i∈[i p +1,e p +1], the model’s attention buffer includes the valid range, so the method of formula (6) is applicable.

[0105] When the position i of the result corrected by the user exceeds the decoding range, i∈[e p +2,I p ], the effective attention cache range is only up to e p , the remaining attention results are in [e p +1,i] need to be calculated in the next round. Therefore, the present invention proposes to redefine the state information f' fed back to the next reasoning as:

[0106]

[0107] in,

[0108]

[0109] The total number of time steps required for the next round of reasoning is e-min(i-1,e p ), the probability of the token at each position is:

[0110]

[0111] Algorithm 2 details the process of the HMPT method.

[0112] Algorithm 2 Overall reasoning process of the HMPT method

[0113] Input: source program input,

[0114] A valid user-provided prefix,

[0115] The attention cache of the previous round, Output: Returns the predicted target program, The attention cache of this round,

[0116]

[0117] The present invention is a fast and efficient human-computer collaborative program translation method, which introduces the prefix-based interactive translation protocol in natural language translation into the program translation scenario and proposes PHM. It can greatly reduce the workload of software engineers in program translation tasks. However, due to the problem of excessive program length, PHM brings considerable response delay, so the present invention proposes HMPT. First, in order to avoid repeated prefix generation processes, cache attention is proposed, and it is passed to the next round of reasoning process according to the position of the prefix. In order to avoid the generation of invalid suffixes, suffix splicing is proposed to terminate invalid reasoning processes in advance. This method effectively combines machine intelligence and human intelligence, greatly reduces the user's workload, and improves task completion efficiency. At the same time, due to the significant reduction in response delay, while ensuring the reliability of interactive tasks, it reduces enterprise development costs and improves the user's interactive experience.

[0118] The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with this technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present invention, and these modifications or replacements should all be included in the scope of protection of the present invention.

Claims

1. A fast and efficient human-computer collaborative program translation method, characterized by Here are the steps: Step 1: Prefix-based Human-Computer Interactive Program Translation (PHM): Considering that for structured texts like program code, changes in some characters can have a huge impact on subsequent program fragments, we consider introducing a prefix-based protocol in natural language translation to complete the program translation task; in this protocol, software engineers need to check the target program. And correct the first wrong token This indirectly means that software engineers accept the original prefix and produces a valid prefix The basic equation for this process is as follows: is the translation result of this round; It is the source program of this round; Pr is the abbreviation of Probability, which means probability; argmax is a function. For the function y = f(x), x0 = argmax(f(x)) means that the parameter x0 satisfies f(x0) to be the maximum value of f(x); Specifically, the next round of program translation process is divided into two parts: where δ is the Kronecker delta symbol, A t is the output of the Transformer model’s decoder at time step t, is the weight matrix of the linear layer, v is the size of the vocabulary, d is the hidden layer dimension, and softmax (VA t ) is the output of the Transformer-based program translation model, It is word y t One-hot encoding of ; Step 2: Attention Cache: When t∈[0,x-1], the token corresponding to the maximum value of the generated output probability distribution meets the user's requirements. Although its probability distribution does not strictly conform to the first case, the two probability distributions are equivalent in terms of their impact on subsequent reasoning. When t=i, the user corrects a token. In this case, the token corresponding to the maximum value of the output probability distribution generated by the model does not meet the user's requirements, so the output probability distribution must be forcibly changed. It is recommended to re-divide the decoding process into two stages, and the token output of these two stages is exactly the same as before: When the time step t < i, the sub-process will repeat the same sub-process as the previous round. Therefore, the above formula can be rewritten as: in, is the output of the decoder of the program translation model at time step t in the previous round of translation; It is recommended to skip the sub-process with time step t∈[0,i-1] directly to avoid repeated calculations. In this case, the overall translation process is rewritten as: It is proposed to directly use the cached state information to replace the first stage to minimize repeated calculations with the previous round; therefore, the user feedback f′ should be defined as: in S 0a ={K 0lja ,V 0lja ∣l∈[1,L],j∈[1,h]} Among them, S 0a It is the state information of the encoder-decoder attention sublayer in the decoder during the first round of interaction; it mainly includes the key matrix and value matrix of the encoder-decoder attention sublayer of each h head in the L layer; represents the key matrix of the encoder-decoder attention sub-layer of the jth head of the lth layer after the first inference of the decoder, and so on; It is the state information of the self-attention sublayer in the decoder of the most recent inference, mainly including the key matrix and value matrix of the self-attention sublayer of each h head in the L layer after slicing; Represents the slice submatrix of the key matrix of the self-attention sublayer of the jth layer of the decoder after the most recent inference, and so on; Step 3: Suffix Splicing: To avoid the generation of invalid suffixes, it is recommended to terminate the reasoning process in advance when appropriate; to ensure that a complete target program is presented to the user, another program suffix should be spliced at the termination point; and this suffix can be obtained from the first round. Therefore, the whole process can be rewritten as: Where e represents the position to be terminated, and e0 represents the first round The position in the output code corresponding to the termination point; The best stopping point should be the place where the user will correct the problem next time. It is recommended to divide this work into two stages. When the generated position is t, first, determine the generated program fragment. Whether it has contained a potential error token; then, evaluate Is it possible to output a suffix of the first round of code? splicing; if these two conditions are met, suffix splicing will be performed at position t; To judge Is a potential error token already included? It is recommended to use Is there a maximum output probability P in j The tokens below a certain threshold are used to evaluate the quality; the expression is: if will be identified as containing potential errors, and β is a user-defined parameter; As for judging the generated fragment There are two conditions for being able to splice a suffix of the first round output code:

1. and predicted 2. Considering that similar sequence outputs are more likely to have similar subsequent decoder outputs, it is assumed that the cosine similarity between the sequence output of e0 and the sequence output of the current position is large enough; When the generated program fragment When a suffix can be spliced, the result of the splicing It will be returned directly. It is recommended to distinguish two situations: whether the user's correction position of this result is within the decoding range to determine the effective attention cache; In the next round of interaction, when the user’s correction position i falls within the decoding range, i∈[i p +1,e p +1], the model’s attention cache includes the valid range; when the result position i corrected by the user exceeds the decoding range, i∈[e p +2,l p ], the effective attention cache range is only up to e p , the remaining attention results are in [e p +1,i] needs to be calculated in the next round; therefore, it is recommended to redefine the state information f′ fed back to the next reasoning as: in, The total number of time steps required for the next round of reasoning is e-min(i-1,e p ), the probability of the token at each position is:

2. A computer system, characterized in that include: One or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method of claim 1.

3. A computer-readable storage medium, characterized in that Computer-executable instructions are stored, and when the instructions are executed, they are used to implement the method of claim 1.