Code large model fine tuning data generation method, multi-agent system and device
By obtaining code seed data from the target code base and using multi-agent systems to generate and test code data, the problem of low data quality in the existing technology is solved, and the data quality and model reliability of the code big model fine-tuning are improved.
Patent Information
- Application Number
- CN202411771488.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-02-28
AI Technical Summary
The existing data used for fine-tuning of code large models is of low quality, resulting in low reliability of code large models obtained by fine-tuning.
Code execution tests are performed by obtaining code seed data from the pre-built object code base and using agents in the multi-agent system to generate description prompt words and code data to be executed that match the code seed data. If the test passes, the code data to be executed is used as fine-tuning data.
The data quality used for fine-tuning of code large models is improved, ensuring the diversity and accuracy of the code data to be executed, thereby improving the reliability of the code large models obtained by fine-tuning.
Smart Images

Figure CN119536706A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for generating fine-tuning data for a large code model, a multi-agent system, an apparatus, a computer device, and a computer-readable storage medium. Background Art
[0002] With the development of computer technology, a technology that uses large code models to assist in code writing and debugging has emerged. Large code models can help understand the semantics of the code, thereby providing users with code suggestions, helping to find errors in the code, and providing repair suggestions. In addition, large code models can also be used to automate programming tasks, such as automated code generation and code refactoring. It can be seen that large code model technology can effectively improve development efficiency, reduce error rates, and help users better solve problems.
[0003] Before a large code model is put into use, it usually needs to go through pre-training and fine-tuning steps. It can be pre-trained with a large data set, and then fine-tuned on a specific code task to improve the performance of the large code model in a specific scenario. However, the data used for fine-tuning the large code model is currently of low quality, so the reliability of the fine-tuned large code model is low. Summary of the invention
[0004] Based on this, it is necessary to provide a code large model fine-tuning data generation method, multi-agent system, device, computer equipment, computer-readable storage medium and computer program product that can improve the reliability of the fine-tuned code large model in response to the above-mentioned technical problems.
[0005] In a first aspect, the present application provides a method for generating fine-tuning data for a large code model, comprising:
[0006] Get code seed data from a pre-built target code repository;
[0007] Inputting the code seed data into a first agent in a pre-built multi-agent system, and generating a first description prompt word matching the code seed data through the first agent;
[0008] Inputting the first description prompt word into a second agent in the multi-agent system, and generating code data to be executed matching the first description prompt word through the second agent;
[0009] A code execution test result of the code data to be executed is obtained. If the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model.
[0010] In one embodiment, the multi-agent system also includes: a third agent; after obtaining the code execution test result of the code data to be executed, it also includes: when the code execution test result indicates that the execution fails, obtaining error information of the code data to be executed; inputting the error information into the third agent, and generating a code modification suggestion matching the error information through the third agent; inputting the code modification suggestion and the error information into the first agent, and generating code data matching the code modification suggestion as new code data to be executed through the first agent and the second agent, and returning to execute the step of obtaining the code execution test result of the code data to be executed, until the code execution test result indicates that the execution passes, or the number of executions of the code data to be executed reaches a preset number threshold.
[0011] In one of the embodiments, the code modification suggestion and the error message are input into the first intelligent agent, and code data matching the code modification suggestion is generated through the first intelligent agent and the second intelligent agent, including: inputting the code modification suggestion and the error message into the first intelligent agent, and generating a second description prompt word based on the code modification suggestion and the error message through the first intelligent agent; inputting the second description prompt word into the second intelligent agent, and generating code data matching the second description prompt word as the code data matching the code modification suggestion.
[0012] In one of the embodiments, the method further includes: when the execution times reaches the preset times threshold, canceling the to-be-executed code data as the fine-tuning data.
[0013] In one of the embodiments, before obtaining the code seed data from the pre-built target code library, the method further includes: obtaining each original code data contained in the original code library; inputting the original code data into a pre-built large language model, and obtaining a code quality score of each original code data through the large language model; using the original code data whose code quality score meets a pre-set quality score threshold as target code data, and using each target code data to build the target code library.
[0014] In a second aspect, the present application also provides a multi-agent system, comprising: a first agent and a second agent; wherein:
[0015] The first agent is used to obtain code seed data from a pre-built target code library and generate a first description prompt word matching the code seed data; and input the first description prompt word into the second agent;
[0016] The second intelligent agent is used to generate code data to be executed that matches the first description prompt word; the code data to be executed is used to use the code data to be executed as fine-tuning data for fine-tuning a pre-trained code model when the code execution test result of the code data to be executed indicates that the execution is passed.
[0017] In one embodiment, the multi-agent system further includes: a third agent; wherein the third agent is used to receive error information of the code data to be executed when the code execution test result indicates that the execution fails, and generate a code modification suggestion matching the error information; input the code modification suggestion and the error information into the first agent; the first agent is also used to generate a second description prompt word based on the code modification suggestion and the error information; input the second description prompt word into the second agent; the second agent is also used to generate code data matching the second description prompt word as code data matching the code modification suggestion; the code data matching the code modification suggestion is used as new code data to be executed, and when the code execution test result of the code data to be executed indicates that the execution passes, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code large model.
[0018] In a third aspect, the present application also provides a device for generating code large model fine-tuning data, comprising:
[0019] A code seed acquisition module is used to obtain code seed data from a pre-built target code library;
[0020] A description prompt generating module, used for inputting the code seed data into a first agent in a pre-built multi-agent system, and generating a first description prompt word matching the code seed data through the first agent;
[0021] An execution code generation module, used for inputting the first description prompt word into a second agent in the multi-agent system, and generating to-be-executed code data matching the first description prompt word through the second agent;
[0022] An execution result acquisition module is used to obtain a code execution test result of the code data to be executed. When the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning a pre-trained code large model.
[0023] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in any embodiment of the first aspect are implemented.
[0024] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method described in any embodiment of the first aspect are implemented.
[0025] In a fifth aspect, the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in any embodiment of the first aspect,
[0026] The above-mentioned code large model fine-tuning data generation method, multi-agent system, device, computer equipment, computer-readable storage medium and computer program product obtain code seed data from a pre-built target code library; input the code seed data into the first agent in the pre-built multi-agent system, and generate a first description prompt word matching the code seed data through the first agent; input the first description prompt word into the second agent in the multi-agent system, and generate the code data to be executed that matches the first description prompt word through the second agent; obtain the code execution test result of the code data to be executed, and when the code execution test result indicates that the execution is passed, use the code data to be executed as the fine-tuning data for fine-tuning the pre-trained code large model. The present application can obtain code seeds from a pre-built target code library, and then use the first intelligent agent to generate a first description prompt word that matches the code seed data, and use the second intelligent agent to generate code data to be executed, so as to run the code data to be executed to obtain an execution result. If the execution passes, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model. In this way, the diversity and accuracy of the code data to be executed can be ensured, thereby improving the data quality of the data used for fine-tuning the code model, and then improving the reliability of the fine-tuned code model. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0028] FIG1 is a schematic diagram of a flow chart of a method for generating fine-tuning data for a large code model in one embodiment;
[0029] FIG2 is a schematic diagram of a process for updating code data to be executed in one embodiment;
[0030] FIG3 is a schematic diagram of a process for constructing a target code library in one embodiment;
[0031] FIG4 is a schematic diagram of the structure of a multi-agent system in one embodiment;
[0032] FIG5 is a schematic diagram of the structure of a multi-agent system in another embodiment;
[0033] FIG6 is a schematic diagram of data interaction between agents in a multi-agent system according to an embodiment;
[0034] FIG7 is a schematic diagram of a process for generating fine-tuning data for a large code model in one embodiment;
[0035] FIG8 is a structural block diagram of a device for generating code large model fine-tuning data in one embodiment;
[0036] FIG. 9 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0038] In one embodiment, as shown in FIG1 , a method for generating fine-tuning data for a large code model is provided. This embodiment is illustrated by applying the method to a server. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0039] Step S101, obtaining code seed data from a pre-built target code library.
[0040] The target code library refers to a pre-built database for storing code data. The code data in the database may be composed of high-quality code data. For example, the target code library may be constructed by cleaning and filtering different collected codes to obtain high-quality code data. The code seed data is the code data selected from the target code library. The code seed data can be used to generate new code data, and the new code data can be used as fine-tuning data for the large code model to achieve fine-tuning of the large code model.
[0041] Specifically, when it is necessary to generate fine-tuning data for a large code model, the server can randomly extract code from a pre-built target code library as seed data for generating new code, that is, as code seed data.
[0042] Step S102: input the code seed data into the first agent in the pre-built multi-agent system, and generate a first description prompt word matching the code seed data through the first agent.
[0043] The pre-built multi-agent system is a pre-built multi-agent system for generating fine-tuning data for a large code model. The multi-agent system consists of multiple agents that can interact, collaborate, and even compete. Each agent is a relatively independent individual. For example, each agent can be an independent large model with its own goals and can make autonomous decisions based on environmental conditions. The first agent is an agent in the multi-agent system that is used to issue instructions to generate prompts to guide the model, that is, it is mainly used to generate prompt information to guide the model. The first description prompt word is a description prompt word generated by the first agent, which can be generated by the first agent based on the code seed data.
[0044] Specifically, the server can input the code seed data into the first agent in the multi-agent system, and the first agent can understand the code content and then summarize the prompt that can combine the seed data as the first description prompt word based on the results of the understanding analysis.
[0045] Step S103, inputting the first description prompt word into the second agent in the multi-agent system, and generating code data to be executed matching the first description prompt word through the second agent.
[0046] The second agent is an agent in the multi-agent system that is used to generate new codes, and the code data to be executed is the code data generated by the second agent, which needs to be used for execution testing to test whether the code is accurate. Specifically, after obtaining the first description prompt word, the server can also input the first description prompt word into the second agent, and the second agent outputs the code data to be executed that matches the first description prompt word.
[0047] Step S104, obtaining a code execution test result of the code data to be executed, and when the code execution test result indicates that the execution is passed, using the code data to be executed as fine-tuning data for fine-tuning the pre-trained code large model.
[0048] The code execution test result refers to the execution result obtained by running the code data to be executed. If the code execution test result indicates that the execution is successful, for example, the code execution module may perform an execution test on the code data to be executed. If the execution test passes, then the code execution test result indicates that the execution is successful. At this time, the server can use the code data to be executed as fine-tuning data for fine-tuning the pre-trained code model, and then use the above fine-tuning data to fine-tune the pre-trained code model.
[0049] In the method for generating fine-tuning data for the code model, code seed data is obtained from a pre-built target code library; the code seed data is input into a first agent in a pre-built multi-agent system, and a first description prompt word matching the code seed data is generated by the first agent; the first description prompt word is input into a second agent in the multi-agent system, and the second agent generates code data to be executed that matches the first description prompt word; the code execution test result of the code data to be executed is obtained, and when the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model. The present application can obtain code seeds from a pre-built target code library, and then the first agent can be used to generate a first description prompt word matching the code seed data, and the second agent can be used to generate the code data to be executed, so as to run the code data to be executed to obtain the execution result. If the execution is passed, the code data to be executed is used as the fine-tuning data for fine-tuning the pre-trained code model. In this way, the diversity and accuracy of the code data to be executed can be ensured, thereby improving the data quality of the data used for fine-tuning the code model, and then improving the reliability of the fine-tuned code model.
[0050] In one embodiment, the multi-agent system further includes: a third agent; as shown in FIG2 , after obtaining the code execution test result of the code data to be executed, it also includes:
[0051] Step S201, when the code execution test result indicates that the execution fails, error information of the code data to be executed is obtained;
[0052] Step S202, input the error information into the third agent, and generate code modification suggestions matching the error information through the third agent.
[0053] In this embodiment, the multi-agent system includes, in addition to a first agent for generating descriptive prompt words and a second agent specifically for generating new code data, a third agent for providing correction information for error codes. The third agent can be used to generate code modification suggestions based on the output error information when the code execution test results fail. The code modification suggestions are the correction information output by the third agent and are used to correct the error code.
[0054] Specifically, if the code execution test result of the code data to be executed indicates that the execution failed, that is, the code data to be executed failed, the server can also input the execution error information of the code data to be executed to the third agent, and the third agent can understand the error information, summarize it and give modification suggestions.
[0055] In step S203, the code modification suggestions and error information are input into the first agent, and code data matching the code modification suggestions are generated through the first agent and the second agent as new code data to be executed, and the execution returns to step S104 until the code execution test result indicates that the execution is passed, or the execution times of the code data to be executed reaches a preset threshold.
[0056] If the code execution test result of the code data to be executed indicates that the execution fails, that is, the code data to be executed fails, the server can also update the code data to be executed according to the execution error information of the code data to be executed, so as to execute the code again, that is, the server can also input the code modification suggestions and the error information into the first agent again, and use the first agent and the second agent again to generate new code data that matches the code modification suggestions, and perform execution test again as new code data to be executed to obtain test results, until the code execution test result indicates that the execution passes, thereby stopping the above-mentioned cycle process.
[0057] At the same time, in order to ensure the efficiency of the code execution test, the number of repeated executions can also be pre-set with a maximum threshold, that is, a preset execution count threshold. Only when the code execution count does not reach the execution count threshold will the code update be executed again. Therefore, if the execution count of the code data to be executed reaches the preset execution count threshold, that is, the code data to be executed has reached the maximum execution count, the server can also terminate the above loop at this time.
[0058] For example, the preset execution count threshold may be 3 times. After the code data to be executed is generated for the first time, if the code execution test fails, the error information of the code data to be executed generated for the first time may be input into the third agent, and the third agent outputs code modification suggestions. Afterwards, the third agent can input the code modification opinions and error information into the first agent, so that the first agent and the second agent can generate code data again as the second generated code data to be executed, to obtain the code execution test result of the second generated code data to be executed. If the code execution test result of the second generated code data to be executed is passed, the second generated code data to be executed can be used as the fine-tuning data for fine-tuning the large model. If it still fails, since the execution times of the code data to be executed have not reached the preset number threshold of 3 times at this time, the error information of the second generated code data to be executed can be input into the third agent again. After the third agent generates code modification opinions again, the above code modification opinions and error information are input into the first agent again, so that the first agent and the second agent can generate code data again as the third generated code data to be executed, and perform code execution test. If the code execution test result of the third generated code data to be executed is passed, the third generated code data to be executed can be used as the fine-tuning data for fine-tuning the large model. If it still fails, since the execution times of the code data to be executed have reached the preset number threshold of 3 times at this time, the cycle will no longer be performed, that is, new code data to be executed will no longer be generated.
[0059] In this embodiment, the multi-agent system may also include a third agent, which can be used to generate code modification suggestions based on the error information of the code data to be executed, thereby updating the code. In this way, the accuracy and quality of subsequent code generation can be improved, and a repetition threshold can also be set to ensure the efficiency of code execution testing.
[0060] Furthermore, step S203 may further include: inputting the code modification suggestions and error information into the first intelligent agent, and generating a second description prompt word based on the code modification suggestions and the error information by the first intelligent agent; inputting the second description prompt word into the second intelligent agent, and generating code data matching the second description prompt word as the code data matching the code modification suggestions.
[0061] The second descriptive prompt word may be a prompt word generated by the first intelligent agent in combination with the code modification suggestions and the error message. For example, it may be a prompt word generated by the first intelligent agent directly based on the error message and the modification suggestions, or it may be a prompt word generated by the first intelligent agent in combination with the code seed data, error message, modification suggestions and the generated code data to be executed.
[0062] Specifically, the server can input the code modification suggestions and error information output by the third agent into the first agent, and the first agent can generate a second description prompt word based on the code modification suggestions and the error information. The second description prompt word can then be input into the second agent, and the second agent can generate code data matching the second description prompt word as the code data matching the code modification suggestions.
[0063] In this embodiment, the server can also input code modification suggestions and error information into the first agent, and after the first agent generates a second description prompt word, the second agent generates code data matching the second description prompt word. In this way, the accuracy and quality of subsequent code generation can be further improved.
[0064] In addition, the method for generating fine-tuning data for a large code model may further include: when the number of executions reaches a preset threshold, canceling the use of the code data to be executed as fine-tuning data.
[0065] However, if the number of executions reaches a preset threshold, that is, the code data to be executed still cannot pass the code execution test after multiple code modifications, in this case, in order to ensure the accuracy of the fine-tuning data used to fine-tune the pre-trained code model, and to ensure the efficiency of the code execution test, the present embodiment can also cancel the use of the code data to be executed as fine-tuning data, that is, the code data to be executed is no longer used as fine-tuning data.
[0066] In this embodiment, if the number of executions reaches a preset threshold and the code data to be executed still cannot pass the code execution test, the server can cancel the use of the code data to be executed as fine-tuning data. In this way, the accuracy of the fine-tuning data used to fine-tune the pre-trained code model can be ensured, as well as the efficiency of the code execution test.
[0067] In one embodiment, as shown in FIG3 , before step S101, the following steps may also be included:
[0068] Step S301, obtaining each original code data contained in the original code library.
[0069] The original code data refers to the code data contained in the original code library, and the original code library is a data set storing a large amount of unprocessed original code data. In this embodiment, the server can collect each original code data contained in the original code library from the original code library.
[0070] Step S302: input the original code data into a pre-built large language model, and obtain a code quality score for each original code data through the large language model.
[0071] The pre-built big language model is used to score the code snippets, thereby outputting a code quality score. The code quality score can be used to evaluate the code quality of the original code data. Specifically, the server can input the original code data into the pre-built big language model, so that the big language model can score the original code data snippets and remove meaningless variable definitions or loops.
[0072] Step S303: original code data whose code quality scores meet a preset quality score threshold are used as target code data, and a target code library is constructed using the target code data.
[0073] Finally, the original code data whose code quality score meets a preset quality score threshold can be used as the target code data. For example, the original code data with a higher code quality score can be used as the target code data, so as to construct a target code library through the target code data to ensure that the code data contained in the target code library are all high-quality code data.
[0074] In this embodiment, the target code library can be constructed by collecting original code data from the original code library, outputting the code quality score of the original code data through the large language model, and taking the original code data whose code quality score meets the quality score threshold as the target code data, that is, the original code library data is cleaned and filtered through the large language model to ensure that the code seeds used are all high-quality code data, thereby reducing unnecessary errors and corrections in the subsequent generation process.
[0075] In one embodiment, a multi-agent system is also provided. As shown in FIG4 , the multi-agent system may include a first agent 401 and a second agent 402; wherein:
[0076] The first agent 401 is used to obtain code seed data from a pre-built target code library and generate a first description prompt word matching the code seed data; and input the first description prompt word into the second agent 402;
[0077] The second agent 402 is used to generate code data to be executed that matches the first description prompt word; the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model when the code execution test result of the code data to be executed indicates that the execution is passed.
[0078] In this embodiment, the generation of code large model fine-tuning data can be achieved by using a pre-built multi-agent system. The multi-agent system may include a first agent 401 and a second agent 402, wherein the first agent 401 is mainly used to issue instructions to generate prompt information to guide the model, and the second agent 402 is mainly used to generate new code.
[0079] Specifically, when it is necessary to generate fine-tuning data for the large code model, the first agent 401 can randomly select code seed data from a pre-built target code library, that is, from a pre-built target code library that stores high-quality code data. After that, the first agent 401 can understand the code content, and then summarize the prompt that can combine the seed data as the first description prompt word based on the results of the understanding analysis, and input the first description prompt word into the second agent 402 in the multi-agent system. The second agent 402 can then output the code data to be executed that matches the first description prompt word. The code data to be executed can be used to perform code execution testing. By obtaining the code execution test results of the code data to be executed, if the code execution test results indicate that the execution is passed, the generated code data to be executed can be used as fine-tuning data for fine-tuning the pre-trained large code model.
[0080] The above-mentioned multi-agent system includes: a first agent 401 and a second agent 402; the first agent 401 is used to obtain code seed data from a pre-built target code library and generate a first description prompt word matching the code seed data; the first description prompt word is input into the second agent; the second agent 402 is used to generate code data to be executed matching the first description prompt word; the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model when the code execution test result of the code data to be executed indicates that the execution is passed. In this embodiment, the first agent 401 can obtain a code seed from a pre-built target code library and generate a first description prompt word matching the code seed data. The second agent 402 can then generate code data to be executed. The code data to be executed can then be run to obtain an execution result. If the execution passes, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model. The multi-agent system can make the generated code data to be executed diverse and accurate, thereby improving the data quality of the data used for fine-tuning the code model, and further improving the reliability of the fine-tuned code model.
[0081] In one embodiment, as shown in FIG5 , the multi-agent system further includes: a third agent 403; wherein the third agent 403 is used to receive error information of the code data to be executed when the code execution test result indicates that the execution fails, and generate code modification suggestions matching the error information; input the code modification suggestions and the error information into the first agent 401; the first agent 401 is also used to generate a second description prompt word based on the code modification suggestions and the error information; input the second description prompt word into the second agent 402; the second agent 402 is also used to generate code data matching the second description prompt word as code data matching the code modification suggestions; the code data matching the code modification suggestions is used as new code data to be executed, and when the code execution test result of the code data to be executed indicates that the execution passes, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code large model.
[0082] In this embodiment, the multi-agent system includes, in addition to a first agent 401 for generating descriptive prompt words and a second agent 402 specifically for generating new code data, a third agent 403 for providing correction information for error codes. The third agent can be used to generate code modification suggestions based on the output error information when the code execution test results fail. The code modification suggestions are the correction information output by the third agent and are used to correct the error code.
[0083] Specifically, if the code execution test result of the code data to be executed indicates that the execution fails, the error message can also be input into the third agent, which will understand the error message, summarize it and give modification suggestions. After that, the third agent 403 can input the code modification suggestions and the error message into the first agent 401, and the first agent 401 can generate a second description prompt word in combination with the code modification suggestions and the error message, and then the second agent 402 generates code data that matches the second description prompt word as the code data that matches the code modification suggestions. The code data can be used as new code data to be executed for code execution test again to obtain the code execution test result again. If the code execution test result of the new code data to be executed indicates that the execution passes, the new code data to be executed can be used as fine-tuning data for fine-tuning the pre-trained code model.
[0084] In this embodiment, the multi-agent system also includes a third agent 403, which can be used to generate code modification suggestions based on the error information of the code data to be executed, and input the code modification suggestions and the error information into the first agent 401. After the first agent generates the second description prompt word, the second agent 402 generates code data matching the second description prompt word to achieve code update. In this way, the accuracy and quality of subsequent code generation can be improved.
[0085] In one embodiment, a method for generating fine-tuning data for a large code model based on a multi-agent system is also provided, which specifically includes the following steps:
[0086] 1. First, we build a multi-agent system with different roles and functions, where each agent is a large model. However, they have different functions: an agent that issues instructions to generate prompts to guide the model, an agent that specifically generates new codes, and an agent that gives correction information for error codes, as shown in Figure 6.
[0087] 2. Secondly, we need to filter a raw data set with a large amount of code data to initially screen out high-quality code and form a high-quality code library. Specifically, we can use a large language model to score code snippets and remove meaningless variable definitions or loops.
[0088] 3. The agent that issues instructions randomly selects N seed data to be used to generate code from the high-quality code library. It needs to understand the code content first, and then summarize the prompt that can combine the N seed data based on the results of the understanding and analysis.
[0089] 4. The code-generating agent generates new code based on the incoming prompt data.
[0090] 5. The code execution module detects the generated code. If the execution passes, the code generation process ends; if the execution fails, the error information is input into the error correction agent.
[0091] 6. The error correction agent generates suggestions for error correction based on the error information and historical codes.
[0092] 7. After the modification opinions are sent to the instruction agent, it can be input again to the code generation agent according to the prompt containing the context history information to generate new code. This process can be repeated M times.
[0093] The above process can be applied to the generation of fine-tuning data for a large code model. The specific implementation process is shown in FIG7 and includes the following steps:
[0094] 1. First, clean and filter the initial code base data to obtain a high-quality code database. This process can be scored through a large model, and the scoring criteria can be customized according to different programming languages.
[0095] 2. Then randomly extract codes from the high-quality code database. If you want to get complex and difficult codes, you can set N to a larger number, such as 5; if you want to get simpler codes, you can set N to a smaller number, such as 2.
[0096] 3. The prompt-generating agent understands the code seed, summarizes and innovatively generates more description prompts; or generates new guidance prompts based on the incoming error code information and correction suggestions.
[0097] 4. The code generation agent generates new code data based on the input prompt.
[0098] 5. Perform unit tests on the generated code. If the code passes the test, the code generation is completed. If the code fails the test, the error correction agent needs to understand the error message, summarize it, give modification suggestions, and pass this information to the prompt-generating agent. The code can be executed M times, where M can be determined based on the efficiency and accuracy of the model, for example, 3 times.
[0099] In this embodiment, by cleaning and filtering preliminary data, it is ensured that high-quality code is used, thereby reducing unnecessary errors and corrections in the subsequent generation process, that is, improving the efficiency and quality of code generation. The agent is also used to generate innovative and instructive prompts to effectively guide the subsequent code generation process and improve the adaptability and practicality of the generated code, that is, enhance the diversity and practicality of the generated prompts, and verify the quality of each generated code through unit testing, timely discover and correct errors, and further improve the reliability and stability of the generated code. That is, the accuracy of the generated code is guaranteed by optimizing unit testing and feedback mechanisms.
[0100] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0101] Based on the same inventive concept, the embodiment of the present application also provides a device for generating code large model fine-tuning data for implementing the method for generating code large model fine-tuning data involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more embodiments of the device for generating code large model fine-tuning data provided below can refer to the limitations of the method for generating code large model fine-tuning data above, and will not be repeated here.
[0102] In one embodiment, as shown in FIG8 , a device for generating fine-tuning data for a large code model is provided, including: a code seed acquisition module 801, a description prompt generation module 802, an execution code generation module 803, and an execution result acquisition module 804, wherein:
[0103] The code seed acquisition module 801 is used to acquire code seed data from a pre-built target code library;
[0104] A description prompt generating module 802, configured to input the code seed data into a first agent in a pre-built multi-agent system, and generate a first description prompt word matching the code seed data through the first agent;
[0105] An execution code generation module 803 is used to input the first description prompt word into a second agent in the multi-agent system, and generate to-be-executed code data matching the first description prompt word through the second agent;
[0106] The execution result acquisition module 804 is used to obtain the code execution test result of the code data to be executed. When the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model.
[0107] In one embodiment, the multi-agent system also includes: a third agent; a code large model fine-tuning data generating device, and also includes: an execution code update module, which is used to obtain error information of the code data to be executed when the code execution test result indicates that the execution fails; input the error information into the third agent, and generate a code modification suggestion matching the error information through the third agent; input the code modification suggestion and the error information into the first agent, and generate code data matching the code modification suggestion as new code data to be executed through the first agent and the second agent, and return to the step of obtaining the code execution test result of the code data to be executed, until the code execution test result indicates that the execution passes, or the number of executions of the code data to be executed reaches a preset number threshold.
[0108] In one embodiment, the execution code update module is further used to input the code modification suggestion and the error message into the first intelligent agent, and generate a second description prompt word based on the code modification suggestion and the error message through the first intelligent agent; the second description prompt word is input into the second intelligent agent, and code data matching the second description prompt word is generated as code data matching the code modification suggestion.
[0109] In one embodiment, the execution code update module is further used to cancel the to-be-executed code data as the fine-tuning data when the execution times reaches the preset times threshold.
[0110] In one embodiment, the device for generating fine-tuning data for a large code model further includes: a code library construction module, which is used to obtain various original code data contained in the original code library; input the original code data into a pre-constructed large language model, and obtain a code quality score of each of the original code data through the large language model; use the original code data whose code quality score meets a pre-set quality score threshold as target code data, and use each of the target code data to construct the target code library.
[0111] Each module in the above-mentioned code model fine-tuning data generation device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0112] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store code data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for generating code large model fine-tuning data is implemented.
[0113] Those skilled in the art will understand that the structure shown in FIG. 9 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0114] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0115] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0116] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0117] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0118] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0119] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0120] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating fine-tuning data for a large code model, characterized in that: The method comprises: Get code seed data from a pre-built target code repository; Inputting the code seed data into a first agent in a pre-built multi-agent system, and generating a first description prompt word matching the code seed data through the first agent; Inputting the first description prompt word into a second agent in the multi-agent system, and generating code data to be executed matching the first description prompt word through the second agent; A code execution test result of the code data to be executed is obtained. If the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code model.
2. The method according to claim 1, characterized in that: The multi-agent system further includes: a third agent; after obtaining the code execution test result of the code data to be executed, further includes: When the code execution test result indicates that the execution fails, obtaining error information of the code data to be executed; Inputting the error information into the third agent, and generating a code modification suggestion matching the error information through the third agent; The code modification suggestion and the error message are input into the first agent, and code data matching the code modification suggestion is generated through the first agent and the second agent as new code data to be executed, and the step of obtaining the code execution test result of the code data to be executed is returned to execute until the code execution test result indicates that the execution is passed, or the execution times of the code data to be executed reaches a preset threshold number of times.
3. The method according to claim 2, characterized in that The step of inputting the code modification suggestion and the error information into the first agent, and generating code data matching the code modification suggestion through the first agent and the second agent, comprises: Inputting the code modification suggestion and the error message into the first agent, and generating a second description prompt word based on the code modification suggestion and the error message by the first agent; The second description prompt word is input into the second agent, and code data matching the second description prompt word is generated as code data matching the code modification opinion.
4. The method according to claim 2, characterized in that: The method further comprises: When the execution times reaches the preset times threshold, the to-be-executed code data is cancelled as the fine-tuning data.
5. The method according to any one of claims 1 to 4, characterized in that: Before obtaining the code seed data from the pre-built target code library, the method further includes: Obtaining each original code data contained in the original code library; Inputting the original code data into a pre-built large language model, and obtaining a code quality score of each of the original code data through the large language model; The original code data whose code quality score meets a preset quality score threshold is used as target code data, and the target code library is constructed using the target code data.
6. A multi-agent system, characterized in that: include: A first agent and a second agent; wherein, The first agent is used to obtain code seed data from a pre-built target code library and generate a first description prompt word matching the code seed data; and input the first description prompt word into the second agent; The second agent is used to generate code data to be executed that matches the first description prompt word; The code data to be executed is used as fine-tuning data for fine-tuning a pre-trained code large model when a code execution test result of the code data to be executed indicates that the execution is passed.
7. The multi-agent system according to claim 6, characterized in that: Also includes: The third agent; wherein, The third agent is used to receive error information of the code data to be executed when the code execution test result indicates that the execution fails, and generate a code modification suggestion matching the error information; and input the code modification suggestion and the error information into the first agent; The first intelligent agent is further used to generate a second description prompt word based on the code modification suggestion and the error message; and input the second description prompt word into the second intelligent agent; The second intelligent agent is also used to generate code data matching the second description prompt word as code data matching the code modification opinion; the code data matching the code modification opinion is used as new code data to be executed, and when the code execution test result of the code data to be executed indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning the pre-trained code large model.
8. A device for generating fine-tuning data for a large code model, characterized in that: The device comprises: A code seed acquisition module is used to obtain code seed data from a pre-built target code library; A description prompt generating module, used for inputting the code seed data into a first agent in a pre-built multi-agent system, and generating a first description prompt word matching the code seed data through the first agent; An execution code generation module, used for inputting the first description prompt word into a second agent in the multi-agent system, and generating to-be-executed code data matching the first description prompt word through the second agent; An execution result acquisition module is used to obtain a code execution test result of the code data to be executed. When the code execution test result indicates that the execution is passed, the code data to be executed is used as fine-tuning data for fine-tuning a pre-trained code large model.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Cited By
Multi-agent-based query statement correction method and device, equipment and product
CN120336361A
Computing device and method for synthesizing code to generate training data
CN120524999A