Minimized Modification Program Repair Method, Device, System and Storage Medium Based on Large Language Model

Through iterative incremental and code equivalence comparison mechanisms, the consistency and minimize modification problems of large language models in program repair are solved, and the repair accuracy and efficiency are improved, and are suitable for software development and education scenarios.

CN119415074BActive Publication Date: 2025-08-01YANSHAN UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411515816.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-08-01
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

The existing large language models have problems such as poor consistency, high randomness and excessive modification in program repair. Especially in educational scenarios, it is easy to mislead students and it is difficult to achieve minimal modification.

Method used

The iterative increment minimization modification strategy and code equivalence comparison mechanism are adopted, and the correctness of repair results is ensured by gradually increasing the number of modifications and the use of abstract syntax tree analysis, and the correctness of repair results is verified in combination with test cases.

Benefits of technology

Improves the accuracy and consistency of program repairs, reduces computing costs, is suitable for software development and programming education scenarios, reduces interference to the original code, and improves the availability of repair tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415074B_ABST
    Figure CN119415074B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, system, and storage medium for minimizing modified program repair based on a large language model. The method includes: obtaining a program to be repaired and a problem description; initializing the limit of the number of modified lines to 1 and setting the temperature of the large language model to 0; determining all information of the current defective code; using the large language model to perform inference to generate a repair result based on the set maximum number of modified lines; using test cases to verify the correctness of the repair result; in the case where the repair result is correct, saving the correct repair result to the database, and in the case where the repair result is incorrect, incrementing the number of modified lines by 1, the large language model re-performing inference based on all information of the current defective code, updating the repair result, and using test cases to verify the correctness of the updated repair result; if the current number of modified lines is greater than the set maximum number of modified lines, directly ending the repair process. The method of the present invention can effectively improve the correctness of program repair.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence and software engineering technology, and in particular to a method, device, system and storage medium for minimizing program modification based on a large language model. Background Art

[0002] A large language model (LLM) is a natural language processing model based on deep learning. Its core structure is usually based on the Transformer architecture. The Transformer is a neural network structure based on the self-attention mechanism, mainly composed of multiple layers of encoders and decoders.

[0003] Currently, the application methods of large language models in the field of program repair can be divided into the following two categories:

[0004] The first category is direct code generation, such as OpenAI's ChatGPT, which can generate complete programs directly from natural language descriptions or partial code. While this approach is powerful, it can over-modify the original code when fixing specific bugs.

[0005] The second category is multi-round interactive repair: some studies propose to interact with LLM through multi-round dialogue to gradually refine the repair plan.

[0006] Although these methods have made significant progress in the field of program repair, the following key issues still exist:

[0007] a) Poor consistency: For similar code, LLM may generate different repair solutions, resulting in inconsistent repair results. Furthermore, due to the randomness of large language models, even for the same input, LLM may produce different outputs at different runs, which can easily mislead students in educational scenarios.

[0008] b) Excessive modification: LLM tends to generate complete code snippets, which may introduce unnecessary changes. This prevents the source code author from accurately identifying the specific location of defects in the source code and how to modify them. In educational scenarios, this can have a significant negative impact on students and may even affect other functional logic of the original program, making it difficult to achieve gradual and minimal code modifications.

[0009] These issues limit the application of LLM-based program repair technology in actual software development and maintenance, especially in scenarios that require high consistency, controllability, and efficiency. Therefore, how to improve the consistency of repairs, reduce randomness, and minimize modifications has become a key issue that needs to be addressed in this field. Summary of the Invention

[0010] To solve the above problems, the present invention provides a method, apparatus, system, and storage medium for minimizing modified program repair based on a large language model, aiming to achieve at least one of the following purposes:

[0011] 1) Improve the consistency of repair results and provide consistent repair solutions for similar errors.

[0012] 2) Reduce the randomness of the repair process, improve repeatability, and especially avoid misleading students in educational scenarios.

[0013] 3) Achieve minimal code modification to help developers or students accurately locate and understand defects in the code.

[0014] 4) Maintain the original code structure and functional logic to avoid introducing unnecessary changes.

[0015] 5) Improve repair efficiency and reduce resource consumption.

[0016] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0017] According to the first aspect of the present invention, there is provided a method for minimizing modified program repair based on a large language model, the method comprising:

[0018] Obtain the program to be repaired and a problem description;

[0019] Initialize the modified line number limit to 1 and set the temperature of the large language model to 0;

[0020] Determine all information of the current defective code according to the program to be repaired and the problem description; wherein, all information of the current defective code includes defective code information in the program to be repaired and the error repair results of previous rounds;

[0021] Based on the set maximum number of modified lines, the large language model generates a repair result in response to all information of the input current defective code through reasoning;

[0022] Verify the correctness of the repair result using test cases; in the case where the repair result is correct, save the correct repair result to the database, and in the case where the repair result is incorrect, increment the modified line number by 1, and the large language model re-reasons based on all information of the current defective code to update the repair result, and verify the correctness of the updated repair result using test cases;

[0023] If the current modified line number is greater than the set maximum number of modified lines, directly end the repair process.

[0024] Further, before determining all information of the current defective code according to the program to be repaired and the problem description, the method includes:

[0025] Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records.

[0026] Convert the program to be repaired into an abstract syntax tree and compare it with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree in all historical repair records that is exactly the same as the current abstract syntax tree, then directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired, and end the repair process.

[0027] Furthermore, the maximum number of lines of large modifications is set by the following method:

[0028] Based on the prompting words, determine the maximum number of lines of modification for the results generated by the large language model according to the current setting requirements.

[0029] Furthermore, the problem description is:

[0030] Given a matrix of data, find a non-empty submatrix in the matrix such that the sum of the elements in the non-empty submatrix is the largest.

[0031] Furthermore, the large language model includes:

[0032] An input processing layer, configured to convert the input text data into a sequence of tokens; wherein, the input text data is the program to be repaired, the problem description, and the set maximum number of lines of modification.

[0033] An embedding layer, configured to convert the sequence of tokens into a vector representation.

[0034] A self-attention mechanism layer, in response to the input of the embedding layer, calculates the relationships between various elements in the input sequence through a multi-head attention mechanism.

[0035] A feed-forward neural network, configured to process the output of the self-attention mechanism layer.

[0036] A layer normalization and residual connection layer, used to stabilize the training process and alleviate the problem of gradient disappearance.

[0037] A multi-layer stacking layer, including multiple stacked Transformer layers.

[0038] An output layer, which generates the probability distribution of the next word through a softmax function.

[0039] According to the second technical solution of the present invention, there is provided a device for repairing a program with minimal modification based on a large language model, and the device includes:

[0040] A text acquisition module, configured to acquire the program to be repaired and the problem description.

[0041] An initialization module, configured to initialize the modified line number limit to 1 and set the temperature of the large language model to 0;

[0042] An information determination module, configured to determine all information of the current defective code according to the program to be repaired and the problem description; wherein, all information of the current defective code includes defective code information in the program to be repaired and error repair results of previous rounds;

[0043] An inference repair module, configured to generate a repair result by inference based on the set maximum number of modified lines and using the large language model in response to all information of the current defective code input;

[0044] An iterative repair module, configured to verify the correctness of the repair result using test cases; in the case where the repair result is correct, save the correct repair result to the database, and in the case where the repair result is incorrect, increment the number of modified lines by 1, and the large language model re-infers based on all information of the current defective code, updates the repair result, and verifies the correctness of the updated repair result using test cases;

[0045] An iterative termination module, configured to directly end the repair process if the current number of modified lines is greater than the set maximum number of modified lines.

[0046] Further, the device further includes an equivalence comparison module, and the equivalence comparison module is configured to:

[0047] Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records;

[0048] Compare the abstract syntax tree obtained by converting the program to be repaired with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree in all historical repair records that is exactly the same as the current abstract syntax tree, directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired and end the repair process.

[0049] Further, the problem description is: Given a matrix of data, find a non-empty sub-matrix in the matrix such that the sum of the elements in the non-empty sub-matrix is the largest.

[0050] According to the third technical solution of the present invention, there is provided a minimized modified program repair system based on a large language model, the system includes: a memory for storing a computer program; a processor for executing the computer program to implement the method as described above.

[0051] According to the fourth technical solution of the present invention, there is provided a non-transitory computer-readable storage medium storing instructions, which, when executed by a processor, execute the method as described above.

[0052] The present invention has at least the following beneficial effects:

[0053] The present invention designs a minimization modification strategy based on iterative increment and a code equivalence comparison mechanism. Among them, the minimization modification strategy based on iterative increment realizes the minimization modification of the program by gradually increasing the number of lines of code allowed to be modified, ensuring the accuracy and comprehensibility of the repair. The code equivalence comparison mechanism uses abstract syntax tree (AST) analysis to compare the code to be repaired with historical repair records, improving the repair consistency and efficiency. These two core technical key points cooperate with each other to jointly constitute an innovative and efficient minimization program repair method. This method can not only improve the accuracy and consistency of the repair, but also reduce the inference calculation cost of the large model, and is particularly suitable for software development and programming education scenarios, improving the usability of the program repair tool and reducing the application cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 FIG. shows a flowchart of a minimization modification program repair method based on a large language model according to an embodiment of the present invention.

[0055] Figure 2 FIG. shows a flowchart of a code equivalence comparison mechanism according to an embodiment of the present invention.

[0056] Figure 3 FIG. shows a schematic diagram of defective code according to an embodiment of the present invention.

[0057] Figure 4 FIG. shows a structure diagram of a prompt word according to an embodiment of the present invention.

[0058] Figure 5 FIG. shows a test result diagram of a minimization modification program repair method based on a large language model according to an embodiment of the present invention.

[0059] Figure 6 FIG. shows a structure diagram of a minimization modification program repair device based on a large language model according to an embodiment of the invention.

[0060] Figure 7 FIG. shows another structure diagram of a minimization modification program repair device based on a large language model according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0061] The following uses specific examples to illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through different specific implementation manners. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.

[0062] The following combines the drawings and embodiments to further describe the specific implementation of the present invention in detail.

[0063] The embodiment of the present invention provides a method for repairing a minimized modified program based on a large language model. Please refer to Figure 1 , which is a flowchart of a method for repairing a minimized modified program based on a large language model. The method for repairing a minimized modified program based on a large language model includes the following steps:

[0064] S100. Obtain the program to be repaired and the problem description.

[0065] In this embodiment, the program to be repaired can be a defective part in a program. The code corresponding to the defective part is used as the program to be repaired, and the function and purpose to be achieved by the defective part are reflected by the problem description.

[0066] In some embodiments, the problem description can be: Given a matrix of data, find a non-empty submatrix in the matrix such that the sum of the elements in the non-empty submatrix is the largest.

[0067] Exemplarily, the problem description includes a description of the problem and also includes limitations on the input format and output format.

[0068] S200. Initialize the modification line number limit to 1 and set the temperature of the large language model to 0;

[0069] In this embodiment, step S200 is an initialization step for the large language model. Among them, setting the temperature of the large language model to 0 effectively reduces the randomness of the repair process, improves the predictability and repeatability of the results, and avoids misleading students. And the modification line number is initialized to 1 so that in the process of repairing the program, starting from minimizing the modification, the original code structure and functional logic are maintained as much as possible, avoiding potential problems caused by excessive modification.

[0070] When using a large language model for code repair, the temperature is a key parameter for controlling the certainty of the repair result. This key parameter adjusts the output probability distribution of the model through the following formula:

[0071] P'(x) = exp(log(P(x)) / T)

[0072] Where T is the temperature value, P(x) is the original probability distribution, P'(x) is the adjusted probability distribution, and exp is the empirical function.

[0073] Lower temperature values (such as 0.1 - 0.3) will make the model more inclined to select high-probability outputs, resulting in more certain and conservative code repair results. In particular, when the temperature T is set to 0, the model will always select the output with the highest probability, that is, adopt a completely deterministic greedy decoding strategy. This feature is especially important in the code repair scenario, which not only keeps the code repair highly accurate and consistent but also avoids potential errors caused by introducing unnecessary creative changes.

[0074] Therefore, in the present invention, the selection of the temperature parameter focuses on ensuring the reliability and certainty of the code repair output.

[0075] In some embodiments, the large language model includes the following seven structural layers, namely:

[0076] An input processing layer for converting the input text into a sequence of tokens (token).

[0077] An embedding layer for converting tokens into vector representations.

[0078] A self-attention mechanism layer for the model to calculate the relationships between various elements in the input sequence through the multi-head attention mechanism.

[0079] A feed-forward neural network for further processing the output of the attention mechanism.

[0080] A layer normalization and residual connection layer for stabilizing the training process and alleviating the problem of gradient vanishing.

[0081] A multi-layer stacking layer for the model to learn more complex language representations by stacking multiple Transformer layers.

[0082] An output layer that, as the final layer, generates the probability distribution of the next word through the softmax function.

[0083] The large language model learns rich language knowledge and patterns through pre-training on a large-scale text corpus. After fine-tuning on specific tasks, these models can perform various natural language processing tasks, including text generation, question answering, summarization, etc. In the field of program repair, the large language model can utilize its powerful language understanding and generation capabilities to analyze code containing errors, understand the problem description, and generate corresponding repair solutions.

[0084] S300. Determine all information of the current defect code according to the program to be repaired and the problem description; wherein, all information of the current defect code includes defect code information in the program to be repaired and the error repair results of previous rounds.

[0085] In this embodiment, all information of the current defect code includes the defect code. Part or all of the program to be repaired can be used as the defect code. The error repair results of previous rounds are the repair results previously repaired by the large language model based on the program to be repaired and the problem description. Since this repair result did not pass the correctness verification, it is used as an error repair result. Collecting the error repair results of previous rounds can prevent the large language model from repairing the program to be repaired in the previous repair manner.

[0086] In some embodiments, as Figure 2 shown, before determining all information of the current defect code according to the program to be repaired and the problem description, the method includes:

[0087] S201. Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records.

[0088] S202. Compare the abstract syntax tree obtained by converting the program to be repaired with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree in all historical repair records that is exactly the same as the current abstract syntax tree, then directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired, and end the repair process.

[0089] In this embodiment, a code equivalence comparison mechanism is provided. By using historical repair records, duplicate calculations are reduced, the repair efficiency is significantly improved, and resource consumption is reduced. And through code equivalence comparison and abstract syntax tree (AST) analysis, the consistency of repair is significantly improved. For logically equivalent errors, a consistent repair solution can be provided, which is especially suitable for educational scenarios.

[0090] S400. Based on the set maximum number of modified lines, the large language model generates a repair result in response to all information of the current defect code input.

[0091] In this embodiment, the maximum number of modified lines is the maximum number of program lines that can be repaired during a program repair process. For example, if the maximum number of modified lines is set to 5, then the maximum number of program lines that can be repaired is 5. During the program repair process, when initially repairing the program, the number of modified lines is 1. During the continuous iteration process, the number of modified lines will increase as the program repair deepens, and the increased number of modified lines shall not be greater than the set maximum number of modified lines to avoid excessive modification of the original program.

[0092] In some embodiments, the maximum number of lines for large modifications is set by the following method: Based on the promotion words, it is the maximum number of lines for the large language model to generate results according to the current setting requirements in the prompt words.

[0093] S500. Verify the correctness of the repair result using test cases; if the repair result is correct, save the correct repair result to the database. If the repair result is incorrect, increment the number of modified lines by 1, and the large language model re-infers based on all the information of the current defective code, updates the repair result, and uses test cases to verify the correctness of the updated repair result. If the current number of modified lines is greater than the set maximum number of lines, directly end the repair process.

[0094] In this embodiment, step S500 is an iterative verification process, that is, using test cases to verify the repair result. If the repair result is correct, the repair program ends and outputs the correct repair result. If the repair result is incorrect, increment the number of modified lines and re-execute step S400 to update the repair result until the number of modified lines reaches the set maximum number of lines.

[0095] Therefore, the present invention adopts an iterative incremental approach and a minimization modification strategy to ensure the minimum interference to the original code. This helps developers and students accurately locate and understand the defects in the code and learn how to make appropriate repairs. The method provided by the present invention can effectively improve the correctness of program repair and the similarity between the repaired code and the source code, while avoiding unnecessary patch generation processes, saving computing resources, and greatly improving the application value in actual development and educational scenarios.

[0096] Next, the embodiments of the present invention will be combined with a specific numerical example to verify the feasibility and progressiveness of the present invention.

[0097] First, determine that the problem description and the defective code are shown in Table 1 and Figure 3 respectively. Figure 3 In it, the bold underlined part is the line where the defect is located.

[0098] Table 1 Example of problem description

[0099]

[0100]

[0101] Based on the prompt word structure as Figure 4 shown, input the problem description, the defective code, and {x}, where {x} is the gradually iteratively increasing "modification line limit", initially 1, and increasing by 1 after each iteration. The problem description is the problem description shown in Table 1, which can be input in the form of a table or text. The defective code is as Figure 3 shown.

[0102] The large language model obtains the corresponding input according to the prompt structure. One input example and output example are as follows:

[0103] Input example:

[0104] "You are a teaching assistant for a C++ language course, helping students debug programs. The following is a defective program. Can you fix it?

[0105]

[0106]

[0107]

[0108] Can you fix the above defective code with just 1 line modification? If not, please directly reply "Unable to complete", otherwise directly generate the complete fixed code."

[0109] Output example:

[0110]

[0111]

[0112]

[0113] The output example is a program repair result output by the large language model. Use a test case to test the program repair result, and the test result is as Figure 5 shown.

[0114] An embodiment of the present invention also provides a device for repairing a minimized modified program based on a large language model, as Figure 6 shown. The device includes:

[0115] A text acquisition module 601, configured to acquire the program to be repaired and the problem description;

[0116] An initialization module 602, configured to initialize the modification line number limit to 1 and set the temperature of the large language model to 0;

[0117] An information determination module 603, configured to determine all information of the current defective code according to the program to be repaired and the problem description; wherein, all information of the current defective code includes defective code information in the program to be repaired and the error repair results of previous rounds;

[0118] The inference repair module 604 is configured to generate a repair result through inference based on the set maximum number of modified lines, using all the information of the current defective code input and the large language model.

[0119] The iterative repair module 605 is configured to verify the correctness of the repair result using test cases; when the repair result is correct, save the correct repair result to the database, and when the repair result is incorrect, increment the number of modified lines by 1, and the large language model re-performs inference based on all the information of the current defective code, updates the repair result, and uses test cases to verify the correctness of the updated repair result; if the current number of modified lines is greater than the set maximum number of modified lines, directly end the repair process.

[0120] In some embodiments, as Figure 7 shown, the apparatus further includes an equivalence comparison module 606, and the equivalence comparison module 606 is configured to:

[0121] Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records.

[0122] Convert the program to be repaired into an abstract syntax tree and compare it with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree in all historical repair records that is exactly the same as the current abstract syntax tree, directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired, and end the repair process.

[0123] In some embodiments, the problem description is: Given a matrix of data, find a non-empty submatrix in the matrix such that the sum of the elements in the non-empty submatrix is the largest.

[0124] It should be noted that the apparatus described in this embodiment and the method described above belong to the same inventive concept, have the same technical principle, and can achieve the same beneficial effects, so it will not be elaborated here.

[0125] An embodiment of the present invention further provides a minimized modified program repair system based on a large language model. The system includes: a memory for storing a computer program; a processor for executing the computer program to implement the method described in any of the above embodiments.

[0126] An embodiment of the present invention further provides a non-transitory computer-readable storage medium storing instructions, and when the instructions are executed by a processor, the method described in any of the above embodiments is executed.

[0127] The above embodiments are only used to illustrate the present invention and are not intended to limit the present invention. Those of ordinary skill in the relevant technical field can also make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, all equivalent technical solutions also fall within the scope of the present invention. The patent protection scope of the present invention shall be defined by the claims.

Claims

1. A method for repairing programs with minimal modifications based on large language models, characterized in that The method includes: Obtain the program to be repaired and the problem description; Initialize the limit of the number of lines to be modified to 1, and set the temperature of the large language model to 0; Determine all information of the current defective code according to the program to be repaired and the problem description; wherein, all information of the current defective code includes the defective code information in the program to be repaired and the error repair results of previous rounds; Based on the set maximum number of modified lines, the large language model generates a repair result in response to all information of the input current defective code; Verify the correctness of the repair result using test cases; if the repair result is correct, save the correct repair result to the database, if the repair result is incorrect, increment the number of modified lines by 1, and the large language model re-reasons based on all information of the current defective code, updates the repair result, and verifies the correctness of the updated repair result using test cases; if the current number of modified lines is greater than the set maximum number of modified lines, directly end the repair process; Before determining all information of the current defective code according to the program to be repaired and the problem description, the method includes: Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records; Compare the abstract syntax tree obtained by converting the program to be repaired with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree exactly the same as the current abstract syntax tree in all historical repair records, directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired, and end the repair process.

2. The method for repairing a minimized modification program based on a large language model according to claim 1, wherein The maximum number of large modifications is set by the following method: Based on the prompt, the maximum number of lines to be modified when the large language model generates a result according to the current setting requirements in the prompt.

3. The method for repairing a minimized modified program based on a large language model according to claim 2, wherein, The problem description is: Given a matrix of data, find a non-empty submatrix in the matrix such that the sum of the elements in the non-empty submatrix is the largest.

4. The method for repairing a minimized modified program based on a large language model according to claim 1, wherein The large language model includes: An input processing layer for converting the input text data into a sequence of tokens; wherein, the input text data is the program to be repaired, the problem description, and the set maximum number of modified lines; An embedding layer for converting the sequence of tokens into a vector representation; A self-attention mechanism layer, in response to the input of the embedding layer, calculates the relationships between various elements in the input sequence through a multi-head attention mechanism; A feed-forward neural network for processing the output of the self-attention mechanism layer; A layer normalization and residual connection layer for stabilizing the training process and alleviating the problem of gradient disappearance; A multi-layer stacking layer including multiple stacked Transformer layers; An output layer that generates the probability distribution of the next word through a softmax function.

5. A minimized modification program repair device based on a large language model, characterized in that The device: A text acquisition module configured to acquire the program to be repaired and the problem description; An initialization module configured to initialize the limit of the number of lines to be modified to 1 and set the temperature of the large language model to 0; An information determination module, configured to determine all information of the current defect code according to the program to be repaired and the problem description; wherein, all information of the current defect code includes defect code information in the program to be repaired and error repair results of previous rounds; An inference repair module, configured to generate a repair result by inference using the large language model in response to all information of the current defect code based on a set maximum number of modified lines; An iterative repair module, configured to verify the correctness of the repair result using test cases; in the case where the repair result is correct, save the correct repair result to the database, and in the case where the repair result is incorrect, increment the number of modified lines by 1, and the large language model re-infers based on all information of the current defect code, updates the repair result, and verifies the correctness of the updated repair result using test cases; if the current number of modified lines is greater than the set maximum number of modified lines, directly end the repair process; The device further includes an equivalence comparison module, and the equivalence comparison module is configured to: Obtain the abstract syntax trees in all historical repair records; wherein, the abstract syntax trees in the historical repair records are obtained by converting the programs successfully repaired by the historical repair records; Convert the program to be repaired into an abstract syntax tree and compare it with the abstract syntax trees in the historical repair records. If there is an abstract syntax tree in all historical repair records that is exactly the same as the current abstract syntax tree, directly use the repair result in the corresponding historical repair record as the repair result of the current program to be repaired, and end the repair process.

6. The device according to claim 5, characterized in that, The problem description is: Given a matrix of data, find a non-empty submatrix in the matrix such that the sum of the elements in the non-empty submatrix is the largest.

7. A minimized modified program repair system based on a large language model, characterized in that: The system includes: A memory, used to store computer programs; A processor, used to execute the computer program to implement the method according to any one of claims 1 to 4.

8. A non-transitory computer-readable storage medium storing instructions, which when executed by a processor, execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and system for automatically generating reusable API based on code snippets

    CN117892031A