Code generation model training method and device, equipment and medium
By reconstructing the initial data and training with a low-rank adaptation module, a code generation model is generated, which solves the problem of difficulty in manipulating complex tabular data caused by insufficient and singular training data in large language models, and achieves more efficient tabular data processing capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2026-03-10
AI Technical Summary
Existing large language models suffer from insufficient and limited training data, making them difficult to adapt to complex tabular data manipulation scenarios and resulting in poor code generation.
By reconstructing the initial data, intermediate derivation and extension questions are generated to enrich the training data. A low-rank adaptation module is used to train the large language model to generate a code generation model.
It improves the ability of large language models to understand tabular data, enabling them to adapt more efficiently to complex application scenarios and meet users' daily office needs for processing tabular data.
Smart Images

Figure CN121635855A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of data processing, and particularly relates to a code generation model training method and device, equipment and medium. BACKGROUND
[0002] Large language models (LLMs) have excellent ability to process various natural language tasks, including text generation, translation, question answering, etc. With the advancement of technology, LLMs have also begun to be applied to code generation tasks, that is, LLMs can generate, interpret and debug code to provide assistance to developers through a large amount of code corpus training.
[0003] However, in the prior art, the amount of training data is small and relatively single, for example, the training data may only include questions and corresponding operation codes for part of single type table data, or only include questions and corresponding operation codes for part of single type table data, so due to the lack of training data, the code generated by the LLM can usually only perform single type operations on a certain type of table data, and performs poorly when processing table data that requires multiple operations or different types of table data, resulting in that the code generation model is difficult to adapt to more complex application scenarios. SUMMARY
[0004] To solve the above technical problems, the present disclosure provides a code generation model training method, device, equipment and medium.
[0005] In a first aspect, the present disclosure provides a code generation model training method, which comprises:
[0006] obtaining initial data; the initial data includes sample questions based on sample tables and corresponding sample operation codes;
[0007] reconstructing the sample questions and corresponding sample operation codes into multiple groups of training data;
[0008] training a large language model based on the multiple groups of training data to obtain a code generation model.
[0009] Optionally, the step of reconstructing the sample questions and corresponding sample operation codes into multiple groups of training data comprises:
[0010] inferring the derivation process from the sample questions to the sample operation codes for each group of sample questions and corresponding sample operation codes to obtain an intermediate derivation;
[0011] constructing each group of sample questions, the intermediate derivation and the sample operation code as a data point.
[0012] The multiple data points are reconstructed into multiple sets of training data.
[0013] Optionally, reconstructing the multiple data points into multiple sets of training data includes:
[0014] The data points are reconstructed to obtain multiple sets of training data.
[0015] For the target data point among the multiple data points, the reconstruction process includes:
[0016] Based on the logical processing order of the intermediate derivation of the target data points, the target data points are split into multiple rounds of inference input and inference output;
[0017] The first inference input and the first inference output are used as the first set of training data; the first inference input and the first inference output, the second inference input and the second inference output are used as the second set of training data; and so on, the inference inputs and outputs before the Nth inference input, as well as the Nth inference input and the Nth inference output, are used as a set of training data until the Nth inference output is the sample operation code, thus obtaining the multiple sets of training data; the first inference input is the sample problem, and N is an integer greater than 0.
[0018] Optionally, the step of reconstructing the sample problem and the corresponding sample operation code into multiple sets of training data includes:
[0019] For each sample question, generate an extended question for the sample table;
[0020] The extended question and the sample table data are input into the question-answering model, and the extended question is answered based on the sample table data to obtain the extended operation code;
[0021] The extended problem and the extended operation code are reconstructed into multiple sets of training data.
[0022] Optionally, after training the large language model based on the multiple sets of training data to obtain the code generation model, the method further includes:
[0023] Obtain the target question based on the target table;
[0024] The target problem is input into the code generation model, and reasoning is performed on the target problem to obtain multiple rounds of target reasoning output; wherein, the target reasoning output in the last round is the target operation code corresponding to the target problem.
[0025] Optionally, training the large language model based on the multiple sets of training data to obtain the code generation model includes:
[0026] Based on the aforementioned multiple sets of training data, the large language model is trained to obtain the model to be tested;
[0027] Obtain target test data, and test the model to be tested based on the target test data. If the test result of the model to be tested meets the test pass conditions, the model to be tested is used as the code generation model.
[0028] Secondly, embodiments of this disclosure provide a code generation model training apparatus, comprising:
[0029] The acquisition module is used to acquire initial data; the initial data includes sample questions based on the sample table and corresponding sample operation codes.
[0030] The reconstruction module is used to reconstruct each sample problem and its corresponding sample operation code into multiple sets of training data;
[0031] The training module is used to train the large language model based on the multiple sets of training data to obtain the code generation model.
[0032] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0033] Memory;
[0034] Processor; and
[0035] Computer programs;
[0036] The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in the first aspect.
[0037] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method as described in the first aspect.
[0038] Fifthly, embodiments of this disclosure also provide a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the code generation model training method described above.
[0039] In the code generation model training method provided in this embodiment, initial data is obtained; the initial data includes sample questions and corresponding sample operation codes based on sample tables; the sample questions and corresponding sample operation codes are reconstructed into multiple sets of training data; and a large language model is trained based on the multiple sets of training data to obtain a code generation model.
[0040] Compared to existing technologies, the solution provided in this application reconstructs the initial data, converting the sample problems and corresponding sample operation codes into multiple sets of training data. This improves both the amount of training data and the richness of samples compared to the initial data. Therefore, training a large language model based on the training data enhances the model's ability to understand the initial data, enabling more efficient training of a code generation model that can adapt to more complex application scenarios and further meeting users' daily office needs for processing spreadsheet data. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0042] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A flowchart of the code generation model training method provided in this embodiment of the disclosure;
[0044] Figure 2 This is a schematic diagram illustrating the construction of training and testing data provided in the embodiments of this disclosure;
[0045] Figure 3 This is a schematic diagram of the code generation model training process provided in the embodiments of this disclosure;
[0046] Figure 4 A structural diagram of the code generation model training apparatus provided in the embodiments of this disclosure;
[0047] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0048] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0049] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0050] This disclosure provides a method for training a code generation model, which will be described below with reference to specific embodiments.
[0051] Figure 1 A flowchart illustrating the code generation model training method provided in this embodiment of the disclosure is shown below. Figure 1 The code generation model training method shown is described below, and the specific steps of this method are as follows:
[0052] S11. Obtain initial data; the initial data includes sample questions based on the sample table and the corresponding sample operation code.
[0053] LLMs can be applied to code generation tasks. That is, LLMs, trained on a large corpus of code, can generate, interpret, and debug code, providing assistance to developers. However, due to insufficient training data, the code generated by LLMs can usually only perform a single type of operation on a certain type of tabular data. It performs poorly when dealing with tabular data that requires multiple operations or different types of tabular data, making it difficult for code generation models to adapt to more complex application scenarios.
[0054] Based on this, this application proposes a training method for a code generation model to solve the above problems.
[0055] In this step, initial data is first obtained, which refers to the available data that can be used for training the code generation task. In this application, the initial data includes sample questions based on sample tables and corresponding sample operation codes. The sample questions on the sample tables can include operations such as analysis, query, merging, and question answering that users need to perform on table data in their daily office work. Therefore, the code generation model trained based on the initial data can be used to process table data.
[0056] It is understandable that the data available in related technologies is usually based on English, with almost no data involving Chinese. This results in a lack of ability for models to understand Chinese commands, process Chinese data, and solve Chinese problems. Moreover, technologies involving Chinese are different from those involving English. English expressions are usually more direct, and the meaning can often be fully expressed in the sentence itself. However, Chinese expressions often contain implicit meanings, which need to be understood through context, linguistic context, and even cultural, academic, and professional backgrounds. This indirectness increases the difficulty of understanding.
[0057] Therefore, in one implementation, the initial data can be in Chinese. In this way, by using the solution provided in this application, through a series of processing of the initial data, the ability of the large language model to understand Chinese table data is enhanced. Even when only a small amount of limited Chinese table data is available, the code generation model can still be trained.
[0058] S12. Reconstruct the sample problem and the corresponding sample operation code into multiple sets of training data.
[0059] In this step, the initial data can be organized and reconstructed, transforming the sample questions and corresponding sample operation codes in the initial data into training data. Each set of training data includes a training question and a corresponding training response, which can be constructed using the format {"user": message, "assistant": message}, where "user" represents the training question (input to the large language model) and "assistant" represents the training response (output of the large language model), making the training data adaptable to the training paradigm of the large language model. This enhances the large language model's ability to understand the initial data, thereby enabling more efficient training of the code generation model to meet users' daily office needs for processing spreadsheet data.
[0060] In one implementation, the sample problem and the corresponding sample operation code are reconstructed into multiple sets of training data, which may include:
[0061] For each set of sample questions and corresponding sample operation codes, the derivation process from the sample question to the sample operation code is reasoned to obtain intermediate derivations;
[0062] Each set of sample questions, intermediate derivations, and sample operation code are all constructed as a data point;
[0063] Reconstruct multiple data points into multiple sets of training data.
[0064] In other words, by reasoning through the derivation process from sample questions to sample operation code, intermediate derivations can be obtained, which can expand and enhance the initial data. Then, each set of sample questions, intermediate derivations, and sample operation code is constructed as a data point. Compared with the initial data, the richness and amount of data of these data points are improved. Furthermore, multiple data points are reconstructed, and each data point is reconstructed into one or more sets of training data. The code generation model trained based on the training data will also have better processing performance.
[0065] This approach expands upon the initial data by generating intermediate derivations. It addresses the issue that existing initial data is often overly simplistic, typically in the format of (question, answer), lacking intermediate derivations. Therefore, by inputting the initial data into the inference model, the model reasones from the sample question to the sample operation code, generating intermediate derivations and data points in the form of (question, intermediate derivation, answer). This stimulates the large language model's ability to perform intermediate derivations and chain-like thinking, thereby enhancing the reasoning ability of the ultimately trained code generation model.
[0066] The inference model can be one or more of GPT3.5, GPT4, and deepseek-coder-33B. It can be the same model as the large language model used to train the code generation model, or it can be a different model. This application does not make any specific restrictions on this.
[0067] In one implementation, reconstructing multiple data points into multiple sets of training data may include:
[0068] Multiple data points are reconstructed to obtain multiple sets of training data;
[0069] For a target data point among multiple data points, the reconstruction process includes:
[0070] Based on the logical processing order of the intermediate derivation of the target data points, the target data points are split into multiple rounds of inference input and inference output;
[0071] The first inference input and the first inference output are used as the first set of training data; the first inference input and the first inference output, the second inference input and the second inference output are used as the second set of training data; and so on, the inference inputs and outputs before the Nth inference input, as well as the Nth inference input and the Nth inference output are used as a set of training data, until the Nth inference output is the sample operation code, to obtain multiple sets of training data; wherein, the first inference input is the sample problem, and N is an integer greater than 0.
[0072] In other words, by reconstructing the data points, the data points can be processed into the form of training data. Each set of training data includes a training question and a corresponding training answer, so that the data points can be adapted to the training paradigm of large language models after reconstruction.
[0073] For a target data point among the data points, the target data point may be reconstructed to obtain a set of training data. For example, the sample question and intermediate derivation can be used as the training question, and the sample operation code can be used as the training answer.
[0074] Alternatively, a target data point may also obtain multiple sets of training data. Specifically, the target data point can be split into multiple rounds of inference input and inference output according to the logical processing order of the intermediate derivation of the target data point. Taking the Nth round of inference process as an example, the inference input and inference output before the current Nth inference input, as well as the current Nth inference input, can be used as the training question, and the Nth inference output can be used as the training answer to obtain a set of training data. In this way, the multiple rounds of inference input and inference output of a target data point can correspond to multiple sets of training data.
[0075] Where N is an integer greater than 0, which is equal to the number of inferences included in the intermediate derivation. It can be understood that when N equals 1, the training data only includes the first inference input and the first inference output, and there are no inference inputs and inference outputs before the first inference input.
[0076] For example, the initial data is usually in the format of (question, answer). After derivation by the inference model, a sample question and its corresponding sample operation code in the initial data can be processed into a data point. The data point is usually in the format of (question, intermediate derivation, answer).
[0077] For example, a sample problem and its corresponding sample operation code in the initial data can be represented as (user1, assistant3). After inference, the data points corresponding to the sample problem and its corresponding sample operation code (user1, assistant3) are obtained, represented as (user1, assistant1, user2, assistant2, user3, assistant3), where assistant1, user2, assistant2, and user3 are intermediate derivations generated by the inference model. Then, these data points are reconstructed into training data, which can include the following three groups:
[0078] ①{"user":user1,"assistant":assistant1}
[0079] ②{"user":user1,assistant1,user2,"assistant":assistant2}
[0080] ③{"user":user1,assistant1,user2,assistant2,user3,"assistant":assistant3}
[0081] In another implementation, the sample problem and the corresponding sample operation code are reconstructed into multiple sets of training data, which may include:
[0082] For each sample question, generate an extended question for the sample table;
[0083] Input the extended questions and sample table data into the question-answering model, answer the extended questions based on the sample table data, and obtain the extended operation code;
[0084] The extended problem and extended operation code were refactored into multiple sets of training data.
[0085] In other words, new extended questions based on sample tables can be generated based on sample questions. Then, by answering the extended questions through a question-answering model, extended operation codes can be obtained. In this way, the extended questions and extended operation codes, after being reconstructed, can be used as training data for a large language model, thus realizing the expansion of the initial data.
[0086] In addition, when reconstructing the extended problem and the extended operation code, the sample problem and the corresponding sample operation code can also be reconstructed. The data obtained from the reconstruction of the sample problem and the corresponding sample operation code can also be used as training data, thereby further enriching the diversity of training data.
[0087] Thus, when the initial data has limited diversity and does not involve complex table operations, the code generation model trained will perform poorly in generating code for these complex operations. However, by generating new extended problems that can include complex operations such as updating, searching, and plotting on the sample table, the code generation model trained will improve its performance in generating code for these complex operations.
[0088] The question-answering model can be one or more of GPT3.5, GPT4, and deepseek-coder-33B. It can be the same model as the inference model and the large language model used to train the code generation model, or it can be a different model. This application does not make any specific restrictions on this.
[0089] In one implementation, the problem of generating an extension to the sample table data may include:
[0090] Based on the preset prompt word engineering, an extended question for the sample table is generated using a question generation model.
[0091] In other words, by using the preset prompt word (Prompt) project, questions can be asked to the question generation model, so that the question generation model can generate extended questions on the sample table. By setting the Prompt, more questions involving complex table operations can be included in the extended questions, further improving the code generation performance of the finally trained code generation model for these complex operations.
[0092] The question generation model can be one or more of GPT3.5, GPT4, and deepseek-coder-33B. It can be the same model as the inference model, question answering model, and large language model used to train the code generation model, or it can be a different model. This application does not make any specific restrictions on this.
[0093] S13. Based on multiple sets of training data, train the large language model to obtain the code generation model.
[0094] In this step, the large language model can be trained based on multiple sets of training data. For example, the training questions in the training data can be input into the large language model, and then the large language model can answer the training questions to obtain the corresponding predicted answers. Then, by calculating the loss value between the predicted answers and the training answers, it can be determined whether the predicted answers output by the large language model meet expectations.
[0095] If the loss value is less than the preset threshold, it means that the predicted answer output by the large language model meets expectations, and the large language model can be used as a code generation model. If the loss value is greater than or equal to the preset threshold, it means that the predicted answer output by the large language model does not meet expectations, and the model parameters of the large language model can be iteratively adjusted. Then, the next training question is input into the large language model for training, and the large language model answers the training question to obtain the corresponding predicted answer. This process continues until the loss value is less than the preset threshold, thus completing the training of the code generation model.
[0096] In one implementation, the large language model includes a low-rank adaptation module. Therefore, training the large language model based on multiple sets of training data to obtain a code generation model can include:
[0097] The training question is input into the large language model, which answers the training question to obtain the predicted answer. The loss value between the training answer and the predicted answer is calculated. If the loss value does not meet the preset threshold, the parameters of the low-rank adaptation module are iteratively adjusted until the loss value meets the preset threshold, thus obtaining the code generation model.
[0098] In other words, in this application, the Low-Rank Adaptation (LoRA) method can be used to fine-tune a large language model that has already been pre-trained. The LoRA algorithm is a low-resource fine-tuning method for large models. By introducing a low-rank adaptation module, it adapts and adjusts the model parameters of the large language model, thereby significantly reducing the computational cost and storage requirements of fine-tuning while maintaining the original capabilities of the large language model.
[0099] In other words, during the model tuning process, only the parameters of a small number of low-rank adaptation modules need to be iteratively adjusted. Based on the large language model, a code generation model that can adapt to the current application scenario can be quickly trained. The more complex original model parameters included in the large language model are frozen and do not need to be iteratively modified.
[0100] In one implementation, a large language model is trained based on multiple sets of training data to obtain a code generation model, which may include:
[0101] The large language model is trained based on multiple sets of training data to obtain the model to be tested; target test data is obtained, and the model to be tested is tested based on the target test data. If the test result of the model to be tested meets the test pass conditions, the model to be tested is used as the code generation model.
[0102] In other words, during the training process of the code generation model, it is also necessary to obtain target test data. The target test data is used to test the model to be tested obtained by training the large language model. If the test result meets the test pass condition, it means that the model to be tested has good code generation ability and can be used as a code generation model. Conversely, if the test result does not meet the preset test pass condition, it means that the code generation ability of the model to be tested is poor and further training is required.
[0103] The preset test pass condition may be that the accuracy of the code generated by the model under test based on the target test data is higher than the first preset threshold, or that the stability of the code generated by the model under test based on the same target test data is higher than the second preset threshold, etc. This application does not limit this.
[0104] In one implementation, obtaining the target test data may include:
[0105] Obtain initial test data; the initial test data includes test questions for the test table data and corresponding test operation code; reconstruct the initial test data into multiple sets of target test data.
[0106] In other words, the target test data can be generated in the same way as the training data, so that the data format used in the training and testing of the code generation model is consistent, and the test results are more reliable.
[0107] Alternatively, other methods may be used to generate the target test data, and this application does not specify any particular method.
[0108] In one implementation, a large language model is trained based on multiple sets of training data to obtain a code generation model, which may include:
[0109] Based on multiple sets of training data, a large language model is trained to obtain a test model; an ablation experiment is performed on the test model, and if the test model passes the ablation experiment, it is used as a code generation model.
[0110] In other words, model validation can be performed through ablation experiments on the model under test. Ablation experiments aim to verify the impact of key components of the model under test on the overall performance. By gradually removing or modifying specific parts of the model under test, we can observe how these changes affect the functionality, performance, or behavior of the model under test. This helps to understand the key elements of the model under test and verify their importance to the system functionality, thereby evaluating the robustness, stability, and performance of the model under test.
[0111] In one implementation, after training a large language model based on multiple sets of training data corresponding to each sample question to obtain a code generation model, it may further include:
[0112] Obtain the target question based on the target table;
[0113] The target problem is input into the code generation model, which performs reasoning on the target problem to obtain multiple rounds of target reasoning output; the final round of target reasoning output is the target operation code corresponding to the target problem.
[0114] In other words, after obtaining the code generation model, it can be used in the processing flow of the target table. After inputting the target question based on the target table into the code generation model, the model can analyze the target question, perform multiple rounds of reasoning according to the logical processing order, obtain multiple rounds of target reasoning output, and finally obtain the target operation code corresponding to the target question. The target operation code can be used to process the target table to implement the operation indicated by the target question.
[0115] It is understandable that during the reasoning process, the code generation model can output the target reasoning output obtained in each round of reasoning, that is, output the target reasoning output of each round of reasoning in sequence; or, it can output the target reasoning input and target reasoning output of each round of reasoning, that is, output the target reasoning input and target reasoning output of each round of reasoning in sequence. In this way, the overall reasoning process of the code generation model can be fully reflected, making it convenient for users to view and use.
[0116] For example, the reasoning process of a code generation model can be represented as:
[0117] (user1',assistant1',user2',assistant2',user3',assistant3');
[0118] In this context, user1' represents the target problem, which is also the target reasoning input for the first round of reasoning; assistant1' represents the target reasoning output for the first round of reasoning; user2' represents the target reasoning input for the second round of reasoning; assistant2' and assistant1' represent the target reasoning output for the second round of reasoning; user3' represents the target reasoning input for the third round of reasoning; and assistant3' represents the target reasoning output for the third round of reasoning, which is also the target operation code corresponding to the target problem.
[0119] During the reasoning process, the code generation model can output the target reasoning output for each round of reasoning in sequence, namely (assistant1', assistant2', assistant3').
[0120] Alternatively, the target reasoning input and target reasoning output for each round of reasoning can be output sequentially, i.e., (user1', assistant1', user2', assistant2', user3', assistant3').
[0121] If the initial data is in Chinese, the code generation model will have better analytical and reasoning capabilities for target problems in Chinese, and therefore can be better applied to Chinese office scenarios.
[0122] like Figure 2 The diagram shown is a schematic diagram of the construction of training data and test data provided in one embodiment. First, the task and requirements are defined. For example, Chinese users need to perform operations such as analysis, query, merging, and question answering on tables in their daily office work. However, Chinese data that can meet this requirement is relatively scarce. Therefore, it is necessary to obtain Chinese table data as initial data and expand it.
[0123] Then, the training dataset is constructed, including generating intermediate derivations and expanding training data. Generating intermediate derivations refers to generating intermediate derivations for each sample question and its corresponding sample operation code in the initial data, transforming it from the form of (question, answer) to the form of (question, intermediate derivation, answer), thus obtaining multiple data points. Expanding training data refers to generating extended questions involving complex table operations and their corresponding extended operation codes using a preset Prompt.
[0124] Then, the training set is organized and reconstructed. The multiple data points, extended questions and corresponding extended operation codes are reconstructed into multiple sets of training data. Each set of training data includes a training question and a corresponding training answer, which is constructed in the form of {"user": message, "assistant": message}.
[0125] Furthermore, a test set can be constructed and test data generated using a method similar to that used to construct the training dataset.
[0126] like Figure 3 The diagram illustrates a code generation model training process according to one embodiment. First, model tuning is performed. After obtaining training data, LoRA can be used to tune the large language model. Then, model testing and evaluation are conducted. The accuracy of the tuned model is evaluated on test data. Based on the accuracy, the model is further optimized. Simultaneously, training parameters can be changed, and ablation experiments can be performed on the model to find the optimal training parameter settings. Finally, the training data and code generation model can be saved locally for later use.
[0127] As can be seen from the above, the technical solution provided in this application reconstructs the initial data, reconstructing each sample problem and its corresponding sample operation code into multiple sets of training data. This improves the amount of training data and the richness of samples compared to the initial data. Therefore, training the large language model based on the training data enhances the large language model's ability to understand the initial data, and more efficiently trains a code generation model that can adapt to more complex application scenarios, further meeting users' daily office needs for processing spreadsheet data.
[0128] Figure 4 This is a schematic diagram of the structure of the code generation model training device provided in the embodiments of this disclosure, applied at the sending end, including:
[0129] The acquisition module 201 is used to acquire initial data; the initial data includes sample questions based on the sample table and corresponding sample operation codes.
[0130] The reconstruction module 202 is used to reconstruct the sample problem and the corresponding sample operation code into multiple sets of training data;
[0131] The training module 203 is used to train the large language model based on the multiple sets of training data to obtain a code generation model.
[0132] In one implementation, the reconstruction module 202 includes:
[0133] The reasoning unit is used to reason about the derivation process from the sample problem to the sample operation code for each sample problem and the corresponding sample operation code, and to obtain intermediate derivations.
[0134] A construction unit is used to construct each set of the sample problem, the intermediate derivation, and the sample operation code into a data point;
[0135] The first reconstruction unit is used to reconstruct multiple data points into multiple sets of training data.
[0136] In one implementation, the first reconstruction unit is specifically used for:
[0137] The data points are reconstructed to obtain multiple sets of training data.
[0138] For the target data point among the multiple data points, the reconstruction process includes:
[0139] Based on the logical processing order of the intermediate derivation of the target data points, the target data points are split into multiple rounds of inference input and inference output;
[0140] The first inference input and the first inference output are used as the first set of training data; the first inference input and the first inference output, the second inference input and the second inference output are used as the second set of training data; and so on, the inference inputs and outputs before the Nth inference input, as well as the Nth inference input and the Nth inference output are used as a set of training data, until the Nth inference output is the sample operation code, to obtain multiple sets of training data; wherein, the first inference input is the sample problem, and N is an integer greater than 0.
[0141] In one implementation, the reconstruction module 202 includes:
[0142] An extension unit is used to generate an extension question for the sample table for each sample question;
[0143] The question-answering unit is used to input the extended question and the sample table data into the question-answering model, answer the extended question based on the sample table data, and obtain extended operation code;
[0144] The second reconstruction unit is used to reconstruct the extended problem and the extended operation code into multiple sets of training data.
[0145] In one implementation, the device further includes an application module for:
[0146] Obtain the target question based on the target table;
[0147] The target problem is input into the code generation model, and reasoning is performed on the target problem to obtain multiple rounds of target reasoning output; wherein, the target reasoning output in the last round is the target operation code corresponding to the target problem.
[0148] In one implementation, the training module 203 is specifically used for:
[0149] Based on the aforementioned multiple sets of training data, the large language model is trained to obtain the model to be tested;
[0150] Obtain target test data, and test the model to be tested based on the target test data. If the test result of the model to be tested meets the test pass conditions, the model to be tested is used as the code generation model.
[0151] As can be seen from the above, the technical solution provided in this application reconstructs the initial data, reconstructing each sample problem and its corresponding sample operation code into multiple sets of training data. This improves the amount of training data and the richness of samples compared to the initial data. Therefore, training the large language model based on the training data enhances the large language model's ability to understand the initial data, and more efficiently trains a code generation model that can adapt to more complex application scenarios, further meeting users' daily office needs for processing spreadsheet data.
[0152] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 5 It shows a schematic diagram of a structure suitable for implementing the electronic device 600 in the embodiments of this disclosure. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0153] like Figure 5 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603 to implement the code generation model training method as described in the embodiments of this disclosure. The RAM 603 also stores various programs and data required for the operation of the electronic device 600. The processing device 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0154] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0155] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the code generation model training method as described above. In such embodiments, the computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from ROM 602. When the computer program is executed by processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0156] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0157] Additionally, this disclosure also provides a vehicle, including: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the code generation model training method as described above.
[0158] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0159] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0160] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the aforementioned embodiments.
[0161] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also perform other steps described in the above embodiments.
[0162] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0163] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0164] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0165] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0166] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0167] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0168] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0169] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A code generation model training method, characterized in that, The method comprises: acquiring initial data; the initial data includes sample problems based on a sample table and corresponding sample operation codes; reconstructing the sample problems and the corresponding sample operation codes into multiple groups of training data; training a large language model based on the multiple groups of training data to obtain a code generation model.
2. The method of claim 1, wherein, The reconstruction of the sample problems and the corresponding sample operation codes into multiple groups of training data comprises: for each group of sample problems and corresponding sample operation codes, inferring the derivation process of the sample problems to the sample operation codes to obtain an intermediate derivation; constructing each group of sample problems, the intermediate derivation, and the sample operation code as a data point; reconstructing multiple data points into multiple groups of training data.
3. The method of claim 2, wherein, The reconstruction of multiple data points into multiple groups of training data comprises: reconstructing multiple data points to obtain multiple groups of training data; for a target data point in the multiple data points, the reconstruction process comprises: according to the logical processing order of the intermediate derivation of the target data point, splitting the target data point into multiple rounds of inference input and inference output; taking the first inference input and the first inference output as the first group of training data; taking the first inference input and the first inference output, the second inference input and the second inference output as the second group of training data; and taking the inference input and the inference output before the Nth inference input and the Nth inference input and the Nth inference output as a group of training data, until the Nth inference output is the sample operation code, to obtain the multiple groups of training data; the first inference input is the sample problem, and N is an integer greater than 0.
4. The method of claim 1, wherein, The reconstruction of the sample problems and the corresponding sample operation codes into multiple groups of training data comprises: for each sample problem, generating an extended problem for the sample table; inputting the extended problem and the sample table data into a question and answer model, answering the extended problem based on the sample table data to obtain an extended operation code; reconstructing the extended problem and the extended operation code into multiple groups of training data.
5. The method of claim 1, wherein, After the training of the large language model based on the multiple groups of training data to obtain the code generation model, the method further comprises: acquiring a target problem based on a target table; inputting the target problem into the code generation model to infer the target problem to obtain multiple rounds of target inference output; wherein the last round of target inference output is a target operation code corresponding to the target problem.
6. The method of claim 1, wherein, The training of the large language model based on the multiple groups of training data to obtain the code generation model comprises: training a large language model based on the multiple groups of training data to obtain a to-be-tested model; acquiring target test data and testing the to-be-tested model based on the target test data; in a case where a test result of the to-be-tested model meets a test passing condition, taking the to-be-tested model as the code generation model. 7.A code generation model training apparatus, characterized by comprising: comprises: an acquisition module configured to acquire initial data; the initial data includes sample problems based on a sample table and corresponding sample operation codes; A reconstruction module is configured to reconstruct the sample problem and the corresponding sample operation code into a plurality of sets of training data. A training module is configured to train a large language model based on the plurality of sets of training data to obtain a code generation model.
8. An electronic device, comprising: comprise: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-6. The computer program is executed by the processor to implement the method of any one of claims 1-6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1-6.
10. A computer program product comprising a computer program, characterized in that,