Method for manufacturing intelligent programming assistant based on large language model

Through an intelligent programming assistant based on large language models, using massive code data and LORA technology to fine-tune it to generate code completion and multi-function models, the problem of code understanding and optimization in the existing technology is solved, real-time code completion and automatic code are realized Modification significantly improves programming efficiency.

CN118897672APending Publication Date: 2024-11-05GIANT MOBILE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411125881.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2024-11-05

AI Technical Summary

Technical Problem

Existing automatic code writing methods are difficult to understand the context and programmer's intentions, cannot generate long enough code completion suggestions, cannot refactor, translate, interpret and correct codes, and cannot optimize for user-specified projects.

Method used

By collecting massive code data for pre-training, a large language model for programming is obtained, and two fine-tunings are performed: the first fine-tuning uses user's proprietary data to generate a code completion model, and the second fine-tuning uses instructions to fine-tune data to generate multi-function The model can be reconstructed, translated, interpreted and corrected, and fine-tuned using LORA technology.

Benefits of technology

It provides real-time code completion and automatic code reconstruction, translation, interpretation and error correction functions, reduces programmers' input code time and thinking time, and improves programming efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118897672A_ABST
    Figure CN118897672A_ABST
Patent Text Reader

Abstract

The invention relates to a method for manufacturing an intelligent programming assistant based on a large language model. The method comprises the following steps: collecting mass code data; performing pre-training according to the collected code data to obtain a large language model for programming; performing first fine tuning on the large language model for programming, the first fine tuning mode being: collecting user proprietary data, and performing fine tuning according to the proprietary data to obtain a code completion model; the large language model used for programming is subjected to secondary fine tuning, and the secondary fine tuning mode is that instruction fine tuning data are collected, fine tuning is conducted on the large language model used for programming according to the instruction fine tuning data, a multifunctional model is obtained, and the multifunctional model can be reconstructed, translated, explained and corrected. According to the method, real-time code completion can be provided for programmers, and reconstruction, translation, explanation and error correction can be automatically carried out on the codes, so that the code input time and thinking time of the programmers can be shortened, and the programming efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent programming technology, and in particular to a method for making an intelligent programming assistant based on a large language model. Background Art

[0002] Existing automatic code writing methods have difficulty understanding the context and programmer's intentions in code completion, and are unable to generate sufficiently long code completion suggestions; secondly, they are unable to refactor, translate, interpret, and correct the code; finally, they cannot be optimized specifically for user-specified projects.

[0003] Therefore, it is necessary to provide a method for making an intelligent programming assistant based on a large language model to improve programming efficiency. Summary of the invention

[0004] The purpose of the present invention is to provide a method for making an intelligent programming assistant based on a large language model to improve programming efficiency.

[0005] In order to solve the problems existing in the prior art, the present invention provides a method for making an intelligent programming assistant based on a large language model, comprising the following steps:

[0006] Collect massive amounts of code data;

[0007] Pre-training is performed based on the collected code data to obtain a large language model for programming;

[0008] The large language model for programming is fine-tuned for the first time, and the first fine-tuning method is: collecting user-specific data, and fine-tuning the large language model for programming according to the proprietary data to obtain a code completion model;

[0009] The large language model for programming is fine-tuned for the second time. The second fine-tuning method is: collecting instruction fine-tuning data, and fine-tuning the large language model for programming according to the instruction fine-tuning data to obtain a multifunctional model. The multifunctional model can reconstruct, translate, interpret and correct errors.

[0010] Optionally, in the method for making an intelligent programming assistant based on a large language model, the user-specific data corresponds to the user's own code, so that the code completion model learns the user's coding habits and needs to output more accurate completion suggestions.

[0011] Optionally, in the method for making an intelligent programming assistant based on a large language model, the code completion model is used for completion in the following manner:

[0012] The input of the code completion model is the token sequence of the context above and below the cursor position in the edit box. The code completion model continuously generates the next token based on the input content until a stop symbol is encountered.

[0013] Optionally, in the method for making an intelligent programming assistant based on a large language model, the multifunctional model is used for reconstruction, translation, interpretation and error correction as follows:

[0014] Design different instruction templates for reconstruction, translation, interpretation and error correction functions;

[0015] Embed the code snippet input by the user into the corresponding instruction template to obtain the corresponding input;

[0016] The multifunctional model obtains a corresponding output based on the corresponding input;

[0017] Post-process the output text and return the result to the user.

[0018] Optionally, in the method for making an intelligent programming assistant based on a large language model, LORA technology is used for fine-tuning during the first fine-tuning and the second fine-tuning.

[0019] In the method for making an intelligent programming assistant based on a large language model provided by the present invention, real-time code completion can be provided to programmers, and the code can be automatically reconstructed, translated, interpreted and corrected, thereby reducing the programmer's code input time and thinking time and improving programming efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 A flow chart of a method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0021] The specific implementation of the present invention will be described in more detail below in conjunction with the schematic diagram. The advantages and features of the present invention will become clearer based on the following description. It should be noted that the drawings are all in a very simplified form and are not in exact proportions, and are only used to facilitate and clearly assist in explaining the purpose of the embodiments of the present invention.

[0022] Hereinafter, if the method described herein includes a series of steps, the order in which the steps are presented herein is not necessarily the only order in which the steps may be performed, and some of the steps described may be omitted and / or some other steps not described herein may be added to the method.

[0023] Existing automatic code writing methods have difficulty understanding the context and programmer's intentions in code completion, and are unable to generate sufficiently long code completion suggestions; secondly, they are unable to refactor, translate, interpret, and correct the code; finally, they cannot be optimized specifically for user-specified projects.

[0024] In order to solve the problems existing in the prior art, the present invention provides a method for making an intelligent programming assistant based on a large language model, such as Figure 1 As shown, the method comprises the following steps:

[0025] S1: Collect massive code data;

[0026] S2: Pre-training based on the collected code data to obtain a large language model for programming;

[0027] S3: fine-tuning the large language model for programming for the first time, wherein the first fine-tuning method is: collecting user-specific data, and fine-tuning the large language model for programming according to the proprietary data to obtain a code completion model;

[0028] Preferably, the user-specific data corresponds to the user's own code, so that the code completion model learns the user's coding habits and requirements to output more accurate completion suggestions.

[0029] Furthermore, the code completion model is used for completion in the following manner: the input of the code completion model is the token sequence of the context above and below the cursor position in the edit box, and the code completion model continuously generates the next token based on the input content until a stop symbol is encountered. Specifically, the input of the model is organized in the following format "<fim_prefix> Above<fim_suffix> Below<fim_middle> ", and then the model continuously generates tokens. Each time the model generates a token, it determines whether the token contains a line break "\n". If it does, it stops generating tokens. Finally, the generated token sequence is converted into code and displayed to the user.

[0030] When there is no need to customize a proprietary code completion model, a general code completion model is made based on conventional codes and conventional programming requirements.

[0031] S4: Perform a second fine-tuning on the large language model used for programming. The second fine-tuning method is: collect instruction fine-tuning data, and fine-tune the large language model used for programming according to the instruction fine-tuning data to obtain a multifunctional model. The multifunctional model can reconstruct, translate, interpret and correct errors.

[0032] Furthermore, the multifunctional model is used for reconstruction, translation, interpretation and error correction as follows: different instruction templates are designed for reconstruction, translation, interpretation and error correction functions; the code snippet input by the user is embedded in the corresponding instruction template to obtain the corresponding input; the multifunctional model obtains the corresponding output based on the corresponding input; the output text is post-processed and the result is returned to the user. Usually, each instruction template is similar. Taking code interpretation as an example, the instruction template is "What does the following code mean? Please answer in Chinese. \n```<input code>```".

[0033] Optionally, in the method for making an intelligent programming assistant based on a large language model, LORA technology is used for fine-tuning during the first fine-tuning and the second fine-tuning. Fine-tuning refers to the process of further training a pre-trained model in deep learning to adapt to a specific task or data set. Fine-tuning enables the model to better perform specific tasks by training with a smaller new data set based on the pre-trained model without the need to train the entire model from scratch. This method not only saves time and computing resources, but also effectively improves the performance of the model on specific tasks.

[0034] When using the present invention, the programmer can get suggestions for the next code in real time when writing each line of code, and choose whether to accept the code suggestion. If the code suggestion is accepted, the programmer does not need to write the code himself. The programmer can also use the code reconstruction, translation, interpretation, and error correction functions to quickly and conveniently modify and understand the existing code. Therefore, programming efficiency can be improved through these functions.

[0035] In summary, in the method for making an intelligent programming assistant based on a large language model provided by the present invention, real-time code completion can be provided to programmers, and the code can also be automatically reconstructed, translated, interpreted and corrected, thereby reducing the programmer's code input time and thinking time, and improving programming efficiency.

[0036] The above is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any technician in the relevant technical field, without departing from the scope of the technical solution of the present invention, makes any form of equivalent replacement or modification to the technical solution and technical content disclosed in the present invention, which does not depart from the content of the technical solution of the present invention and still falls within the protection scope of the present invention.

Claims

1. A method for making an intelligent programming assistant based on a large language model, characterized in that: The following steps are involved: Collect massive amounts of code data; Pre-training is performed based on the collected code data to obtain a large language model for programming; The large language model for programming is fine-tuned for the first time, and the first fine-tuning method is: collecting user-specific data, and fine-tuning the large language model for programming according to the proprietary data to obtain a code completion model; The large language model for programming is fine-tuned for the second time. The second fine-tuning method is: collecting instruction fine-tuning data, and fine-tuning the large language model for programming according to the instruction fine-tuning data to obtain a multifunctional model. The multifunctional model can reconstruct, translate, interpret and correct errors.

2. The method for making an intelligent programming assistant based on a large language model as claimed in claim 1, characterized in that: User-specific data corresponds to the user's own code, so that the code completion model learns the user's coding habits and needs to output more accurate completion suggestions.

3. The method for making an intelligent programming assistant based on a large language model as claimed in claim 1, characterized in that: The code completion model is used for completion as follows: The input of the code completion model is the token sequence of the context above and below the cursor position in the edit box. The code completion model continuously generates the next token based on the input content until a stop symbol is encountered.

4. The method for making an intelligent programming assistant based on a large language model as claimed in claim 1, characterized in that: The multifunctional model is used for reconstruction, translation, interpretation and error correction as follows: Design different instruction templates for reconstruction, translation, interpretation and error correction functions; Embed the code snippet input by the user into the corresponding instruction template to obtain the corresponding input; The multifunctional model obtains a corresponding output based on the corresponding input; Post-process the output text and return the result to the user.

5. The method for making an intelligent programming assistant based on a large language model as claimed in claim 1, characterized in that: During the first and second fine-tuning, LORA technology was used for fine-tuning.