Training data generation method and device, storage medium and equipment
By generating and combining computer code functions of simple problems, the problem of insufficient diversity and logic of training data of large language models is solved, and efficiently generated logically correct training data is achieved, and the advanced reasoning ability of large language models is improved.
Patent Information
- Application Number
- CN202510435573.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-08-08
AI Technical Summary
It is difficult for the prior art to generate high-quality and diverse training data to train the advanced reasoning ability of large language models, and the training data enhancement effect of existing methods is limited or the generated problem logical contradiction.
The first computer code used to solve simple problems is generated through a large language model, the function is extracted and stored, the objective function is selected to generate the second computer code, and then the corresponding second problem is generated as training data.
The diversity of training data is expanded, the logical correctness of the problem is ensured, and a large amount of training data for training advanced inference capabilities of large language models is obtained at low cost.
Smart Images

Figure CN120449820A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a method, apparatus, storage medium, and device for generating training data. Background Art
[0002] With the development of artificial intelligence (AI) technology, large language models have been widely used in various scenarios.
[0003] In some scenarios, users often need to use large language models to help solve mathematical or scientific problems or write computer code, which requires large language models with relatively advanced reasoning capabilities. Such large language models often need to be trained on large amounts of training data involving complex reasoning.
[0004] However, high-quality annotated training data involving complex reasoning is extremely scarce. To expand training data, one existing approach is to enhance existing training data, such as by rewriting and complicating sample questions or by sampling multiple paths of annotated answers. However, no matter how the training data is enhanced, the training effect is still based on the original training data itself and does not increase the diversity of the training data. Another approach is to use large language models to directly generate questions based on knowledge text materials (such as textbooks and teaching aids) as training samples. However, the questions generated in this way often contain logical contradictions and cannot be answered.
[0005] Therefore, how to generate training data that can be used to train large language models with advanced reasoning capabilities is an urgent problem to be solved. Summary of the Invention
[0006] The embodiments of this specification provide a method, device, storage medium, and electronic device for generating training data to partially solve the problems existing in the above-mentioned prior art.
[0007] The embodiments of this specification adopt the following technical solutions:
[0008] This specification provides a method for generating training data, the method comprising:
[0009] Inputting a plurality of first questions into the large language model in advance, and obtaining first computer codes output by the large language model for solving the first questions;
[0010] Extracting and storing the functions contained in each first computer code;
[0011] When training data needs to be generated, the target function is selected from the stored functions;
[0012] Inputting the selected objective function into the large language model to obtain a second computer code generated by the large language model using the objective function;
[0013] generating a second question corresponding to the second computer code by using the large language model;
[0014] Training data is generated based on at least the second question.
[0015] This specification provides a device for generating training data, the device comprising:
[0016] a decomposition module, configured to input a plurality of first questions into the large language model in advance, and obtain first computer codes output by the large language model for solving the first questions;
[0017] a storage module, configured to extract and store the functions contained in each first computer code;
[0018] The sampling module is used to select the target function from the stored functions when training data needs to be generated;
[0019] a first generating module, configured to input the selected objective function into the large language model, and obtain a second computer code generated by the large language model using the objective function;
[0020] a second generating module, configured to generate a second question corresponding to the second computer code using the large language model;
[0021] The third generating module is used to generate training data at least according to the second question.
[0022] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned method for generating training data.
[0023] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned method for generating training data is implemented.
[0024] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0025] The embodiments of this specification disclose a method for generating training data. This method pre-generates a first computer code for solving a first problem using a large language model, then extracts and stores functions in the first computer code. When generating training data, a target function is selected from the stored functions, and the large language model uses the target function to generate a second computer code. The large language model then generates a second problem corresponding to the second computer code, thereby obtaining training data with the second problem as a training sample. Because the generated second computer code is the answer to the second problem, this method generates the answer using the most basic function combination and then generates the problem using the answer. This method not only expands the diversity of training data, but also ensures the logical correctness of the problem. This method can obtain a large amount of training data for training the advanced reasoning ability of the large language model at a low cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:
[0027] Figure 1 A flow chart of a method for generating training data provided in an embodiment of this specification;
[0028] Figure 2 A schematic diagram of using a graph structure to organize various functions provided in the embodiments of this specification;
[0029] Figure 3 A flow chart of a method for selecting an objective function provided in an embodiment of this specification;
[0030] Figure 4 A schematic diagram of a device for generating training data provided in an embodiment of this specification;
[0031] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0032] In actual application scenarios, complex reasoning problems are often composed of several simple problems. Therefore, in order to make the generated training data cover more complex reasoning problems, improve the diversity of training data, and ensure the logical rationality of the generated problems, the embodiment of this specification simulates the process of educators setting questions. First, the problem-solving process corresponding to several simple problems is determined, and then the problem-solving process corresponding to these simple problems is combined into a complete and complex problem-solving process. Finally, a corresponding question, that is, a problem, is given for this complete and complex problem-solving process.
[0033] Therefore, when generating training data, the embodiments of this specification can first use a large language model to generate a first computer code for solving a simple first problem, then extract and store functions from it, and then select some target functions from all the stored functions, and combine these target functions into an executable second computer code through the large language model, and then generate a corresponding second problem based on the second computer code to obtain training data.
[0034] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.
[0035] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0036] Figure 1 A flow chart of a method for generating training data provided in an embodiment of this specification includes the following steps:
[0037] S100: Input a plurality of first questions into a large language model in advance, and obtain first computer codes output by the large language model for solving the first questions.
[0038] In the embodiment of this specification, the Figure 1 The device used to generate training data in the method shown can be any electronic device, and the following description will only take a server as an example.
[0039] Since the embodiments of this specification need to simulate the question-setting process of educators, that is, first determine the basic problem-solving process corresponding to all "test points", the server can first input several first questions into the large language model and construct a first prompt information, and also input the first prompt information into the large language model to obtain the computer code output by the large language model for each first question under the guidance of the first prompt information. The computer code is referred to as the first computer code in this specification, and the first computer code is the computer code used to solve the first problem.
[0040] The first problem does not need to be too complex and can be a relatively simple problem. For example, the first problem can be "find the largest positive integer less than 10,000, divisible by 95, and with all digits being even." The first computer code fragment generated by the large language model for this first problem can be:
[0041]
[0042] S102: Extracting and storing functions contained in each first computer code.
[0043] The reason why the answer to the first question is output in the form of computer code using the large language model in step S100 is because the computer code contains the functions required to solve the first question. These functions are precisely the basic problem-solving processes corresponding to the "test points" that educators need to identify when setting questions in the embodiments of this specification. Therefore, in step S102, the server can extract and store the functions from each first computer code.
[0044] Continuing with the above example, the three functions in the above example are:
[0045] generate_numbers() is used to generate numbers according to given conditions;
[0046] check_multiples() is used to check the multiples function;
[0047] find_largest() is used to find the maximum value.
[0048] In other words, generate_numbers() addresses the core question of how to generate numbers based on given conditions; check_multiples() addresses the core question of how to determine whether a number is a multiple of another; and find_largest() addresses the core question of how to find the largest value. These three functions provide the most fundamental problem-solving procedures for their respective core questions.
[0049] The server may store the extracted functions as “atomic” functions that need to be subsequently combined into a second computer code.
[0050] It can be seen that in order to enable the server to store as many functions corresponding to "test points" as possible, in step S100, as many first questions as possible can be input into the large language model to extract more "atomic" functions.
[0051] S104: When training data needs to be generated, a target function is selected from the stored functions.
[0052] When training data needs to be generated, the server can select an objective function from the functions stored in step S102. The number of selected objective functions can be set as needed. The more objective functions are selected, the more complex the second computer code generated subsequently will be. Conversely, the simpler the second computer code generated subsequently will be. The number of selected objective functions can be set according to the complexity of the required training data.
[0053] The server may select the target function by randomly selecting from the stored functions or by adopting other rules. The specific selection method will be described in detail later.
[0054] S106: Input the selected objective function into the large language model to obtain a second computer code generated by the large language model using the objective function.
[0055] In the embodiments of this specification, after the server selects a specified number of objective functions, it may input the selected specified number of objective functions into the large language model and construct a second prompt message, so that the large language model, guided by the second prompt message, uses each input objective function to generate a second computer code. The generated second computer code includes all objective functions selected by the server in step S104. A single objective function may be used once or multiple times in the second computer code, and the input parameters of the objective function are generated by the large language model through inference when generating the second computer code.
[0056] At this time, the second computer code generated by the large language model is a complete and complex problem-solving process obtained by combining the basic problem-solving processes corresponding to multiple target "test points".
[0057] In order to further ensure the logical rationality of the subsequently generated training data, after generating the second computer code, the server may first verify the executableness of the second computer code. After the verification is passed, the subsequent step S108 is executed. Otherwise, step S106 may be re-executed to regenerate the second computer code, or steps S104 to S106 may be re-executed to reselect the objective function and generate the second computer code based on the re-selected objective function.
[0058] When verifying the executability of the generated second computer code, the verification can still be performed using the large language model. Specifically, the large language model can be used to attempt to execute the second computer code, and based on the execution result, it can be determined whether the second computer code is executable.
[0059] S108: Generate a second question corresponding to the second computer code using the large language model.
[0060] In the embodiments of this specification, after the large language model generates the aforementioned second computer code, the large language model can then generate a second question corresponding to the second computer code. Because the second computer code itself is a solution to a problem, equivalent to generating the answer in step S106, and representing a complete and complex problem-solving process, the large language model can, based on its current reasoning capabilities, determine the problem that the answer can solve, namely the second question. Specifically, a third prompt message can be constructed and input into the large language model, so that, guided by the third prompt message, the large language model outputs the second question corresponding to the second computer code.
[0061] S110: Generate training data at least according to the second question.
[0062] Through step S106, the server first obtains the answer that can solve a certain problem, that is, the second computer code. Through step S108, the server obtains what problem the second computer code can solve, that is, the second problem. At this point, the data as samples and annotations have been obtained. Therefore, in step S110, the server can generate training data based on at least the second problem. The training data is used to train the large language model, especially for training the high-level reasoning ability of the large language model.
[0063] Among them, the second question itself can be used as a training sample, the second computer code can be used as the code-form answer to the second question, and can also be directly used as the annotation of the training sample. Of course, the text-form answer corresponding to the second question can also be generated based on the second computer code and then used as the annotation of the training sample.
[0064] The above method first uses the most basic function combination to generate a second computer code as the answer, and then uses the answer to generate a second problem that can be solved by the second computer code. On the one hand, it expands the diversity of training data, and on the other hand, it ensures the logical correctness of the problem. It can obtain a large amount of training data for training the advanced reasoning capabilities of large language models at a low cost.
[0065] Furthermore, in the embodiment of this specification, in order to improve the efficiency of generating training data, Figure 1 The functions extracted in step S102 can be organized and stored using a graph structure. Specifically, after extracting the functions contained in each first computer code, the relationships between the extracted functions can be determined, and nodes of the graph structure can be determined based on the extracted functions. The edges of the graph structure can be determined based on the relationships between the functions. Finally, a graph structure can be established based on the determined nodes and edges, and the graph structure can be stored.
[0066] Among them, the relationship between the various functions described in the embodiments of this specification includes at least one of a co-occurrence relationship and a topic consistency relationship.
[0067] Regarding the co-occurrence relationship, when determining the relationship between the extracted functions, if different functions appear in a first computer code for solving the same first problem, it can be determined that these different functions have a co-occurrence relationship.
[0068] For thematic consistency relationships, the server can determine the problem domains corresponding to different functions based on the preset problem domains. If different functions correspond to the same problem domain, it can be determined that there is a thematic consistency relationship between these different functions. The problem domain refers to the problem domain that a function can handle. When presetting the problem domain, it can be set according to the core function and purpose of the function. For example, the function used to determine the midpoint of a line segment and the function used to determine the intersection of a line segment and a straight line perpendicular to the line segment, both functions are used to handle problems about points in linear functions. Therefore, a problem domain can be preset as "determining points in linear functions", and it can be determined that both functions correspond to the problem domain, and the two functions have thematic consistency.
[0069] Figure 2 The schematic diagram of the embodiment of this specification using a graph structure to organize various functions is provided. Figure 2 In the figure, nodes 1 to 6 correspond to different functions respectively, where the solid line edges between nodes indicate that there is a collinear relationship between the nodes, and the dotted line edges between nodes indicate that there is a topic consistency relationship between the nodes.
[0070] from Figure 2 It can be seen that nodes 1 to 3 have a co-occurrence relationship, nodes 5 and 6 have a co-occurrence relationship, and nodes 3 and 4 have a topic consistency relationship, but nodes 5 to 6 have no relationship with nodes 1 to 4. In other words, after the functions are organized into a graph structure in the embodiments of this specification, the graph structure is not completely connected.
[0071] To further reduce the complexity of the graph structure, when determining the nodes of the graph structure, instead of directly treating different functions as different nodes, the types of each function can be determined based on the extracted computational logic and / or semantics of each function, and functions of the same type are assigned to the same node in the graph structure. In other words, functions of the same type are merged into a single node. For example, the function distance(p1,p2) and the function euclidean_dist(x1,y1,x2,y2) have the same mathematical essence—both calculate the distance between two points—but they pass parameters differently. The function distance(p1,p2) takes point objects as input, while the function euclidean_dist(x1,y1,x2,y2) takes coordinates directly as input. Therefore, the two functions belong to the same type. Alternatively, a function for performing matrix multiplication and a function for performing matrix mapping are both essentially matrix multiplications, so the two functions belong to the same type.
[0072] The nodes in the graph structure determined by the above method no longer correspond to a specific function, but to all functions of a type.
[0073] After the functions extracted in step S102 are organized and stored using a graph structure, when selecting a target function from the stored functions in step S104, the following method can be used: Figure 3 Select the method shown. Figure 3 The method flow chart of selecting the objective function provided in the embodiment of this specification includes the following steps:
[0074] S1040: Select a target node in the stored graph structure.
[0075] Initially, the server can randomly select a node in the graph structure as the target node.
[0076] S1042: Select the next node of the target node according to the edges in the graph structure and the target node.
[0077] In an embodiment of the present specification, after the server initially selects a node as a target node, it can select a node that is connected to the current target node by an edge as the next node based on the already selected nodes and preset conditions, or it can select a node that is not connected to the current target node by an edge as the next node.
[0078] The preset conditions may include: the number of nodes to be selected, the type of edges between nodes, and the number of long-tail nodes to be selected. The long-tail nodes are nodes that have no edges connected to any other currently selected nodes.
[0079] The number of nodes to be selected, the type of edges between nodes, and the number of long-tail nodes to be selected can all be set as needed. The greater the number of nodes to be selected, the more complex the subsequently generated second computer code will be, and the greater the reasoning capability required by the large language model to solve the corresponding second problem. The greater the number of long-tail nodes to be selected, the more likely the subsequently generated second problem will be a long-tail problem (that is, the more likely it will escape the overall framework of all the first problems in step S100).
[0080] S1044: Determine whether the currently selected node meets the preset conditions. If so, execute step S1046; otherwise, execute step S1048.
[0081] S1046: Determine the function corresponding to the currently selected node as the target function.
[0082] S1048: Re-determine the selected next node as the target node, and return to step S1042.
[0083] Still Figure 2 Assume that the preset condition is that the number of nodes to be selected is 4, of which 1 is a long-tail node, and the type of edge between nodes is a co-occurrence relationship (i.e. Figure 2 solid line edge in the middle).
[0084] Then, the server can initially Figure 2 The target node is randomly selected from the graph structure shown in . Assuming that node 1 is selected, then according to Figure 2 In the graph structure shown, there is a solid line edge and node 1. Node 2 connected to node 1 by a solid line edge is selected as the next node.
[0085] At this time, the nodes that have been selected are node 1 and node 2. However, according to the preset conditions, one co-occurrence node (a node connected to the already selected node with a solid line edge) and one long-tail node still need to be selected. Therefore, in step S1044, it can be determined that the preset conditions are not met, and step S1048 is executed, node 2 is re-selected as the target node, and the process returns to step S1042 to continue selecting node 3 as the next node.
[0086] At this point, the selected nodes are nodes 1-3. According to the preset conditions, a long-tail node still needs to be selected. Therefore, in step S1044, the preset conditions are still not met, and step S1048 is continued, with node 3 being selected as the target node again. The server then returns to step S1042 to continue selecting nodes. Since only long-tail nodes can be selected as the next node at this point, that is, only nodes that do not have any edge connections with nodes 1-3 can be selected, the server can select the next node from nodes 5 or 6.
[0087] Assuming that node 5 is selected, the nodes that have been selected at this time are nodes 1 to 3 and node 5, which meet the preset conditions that a total of 4 nodes are selected, there is 1 long-tail node, and the type of edges between nodes is a co-occurrence type. Therefore, step S1046 is executed, and the function corresponding to the currently selected nodes 1 to 3 and node 5 is determined as the target function.
[0088] It should be noted that if a node in the graph structure does not correspond to a specific function, but corresponds to all functions of a type, then in step S1046, for each selected node, a target function can be randomly selected from all functions of the type corresponding to the node.
[0089] Accordingly, in Figure 1 In step S106, after all selected objective functions are input into the large language model, a computation graph generated by the large language model based on the input objective functions can be used as the second computer code. This computation graph is a computation graph with the objective functions as nodes, including nodes corresponding to all objective functions. When verifying the executable nature of the second computer code, the executable nature of the computation graph generated by the large language model can be directly verified. That is, the computation graph generated by the large language model is attempted to be run. If the execution results are obtained normally, the verification passes; otherwise, the verification fails.
[0090] The above is a method for generating training data provided in an embodiment of this specification. Based on the same idea, this specification also provides corresponding devices, storage media and electronic devices.
[0091] Figure 4 A schematic diagram of a training data generation device provided in an embodiment of this specification, the device comprising:
[0092] A decomposition module 401 is configured to input a plurality of first questions into a large language model in advance, and obtain first computer codes output by the large language model for solving the first questions;
[0093] The storage module 402 is used to extract and store the functions contained in each first computer code;
[0094] The sampling module 403 is used to select a target function from the stored functions when training data needs to be generated;
[0095] A first generating module 404 is configured to input the selected target function into the large language model to obtain a second computer code generated by the large language model using the target function;
[0096] A second generating module 405 is configured to generate a second question corresponding to the second computer code using the large language model;
[0097] The third generating module 406 is configured to generate training data at least according to the second question.
[0098] Optionally, the storage module 402 is specifically used to extract the functions contained in each first computer code and determine the relationship between the extracted functions; determine the nodes of the graph structure according to the extracted functions, determine the edges of the graph structure according to the relationship between the functions, establish a graph structure according to the determined nodes and edges, and store the graph structure.
[0099] Optionally, the storage module 402 is specifically used to determine that the relationship between different functions is a co-occurrence relationship if different functions appear in a first computer code used to solve the same first problem; and / or, based on preset problem domains, determine the problem domains to which different functions correspond, and if the different functions correspond to the same problem domain, determine that the relationship between the different functions is a topic consistency relationship.
[0100] Optionally, the storage module 402 is specifically configured to determine the type of each function according to the extracted computational logic and / or semantics of each function; and determine functions of the same type as the same node of the graph structure.
[0101] Optionally, the sampling module 403 is specifically used to select a target node in the stored graph structure; select the next node of the target node based on the edges in the graph structure and the target node, and redetermine the selected next node as the target node, and continue to select the next node based on the edges in the graph structure and the redetermined target node until each selected node meets a preset condition; and determine the function corresponding to the selected node as the target function.
[0102] Optionally, the sampling module 403 is specifically configured to select a node connected to the target node by an edge as the next node, or select a node not connected to the target node by an edge as the next node, based on the selected nodes and the preset condition.
[0103] Optionally, the first generating module 404 is specifically configured to obtain a computational graph generated by the large language model based on the objective function, and use the computational graph as the second computer code; wherein the objective function is a node in the computational graph.
[0104] Optionally, the second generating module 405 is further configured to, before generating the second question corresponding to the second computer code through the large language model, determine, through the large language model, whether the second computer code is an executable computer code.
[0105] Optionally, the third generating module 406 is specifically configured to generate a training sample according to the second question, and generate an answer corresponding to the second question according to the second computer code as a label for the training sample.
[0106] This specification also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute the method for generating training data provided above.
[0107] based on Figure 1 The method for generating training data shown in the embodiment of this specification also provides Figure 5 The structural diagram of the electronic device shown in FIG. Figure 5 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for its operations. The processor reads the corresponding computer program from the non-volatile storage into the memory and then runs it to implement the above-mentioned training data generation method.
[0108] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
Claims
1. A method for generating training data, the method comprising: Inputting a plurality of first questions into the large language model in advance, and obtaining first computer codes output by the large language model for solving the first questions; Extracting and storing the functions contained in each first computer code; When training data needs to be generated, the target function is selected from the stored functions; Inputting the selected objective function into the large language model to obtain a second computer code generated by the large language model using the objective function; generating a second question corresponding to the second computer code by using the large language model; Training data is generated based on at least the second question.
2. The method according to claim 1, extracting and storing the functions contained in each first computer code, specifically comprising: extracting functions contained in each first computer code, and determining a relationship between the extracted functions; Nodes of a graph structure are determined according to the extracted functions, edges of the graph structure are determined according to the relationships between the functions, a graph structure is established according to the determined nodes and edges, and the graph structure is stored.
3. The method according to claim 2, wherein determining the relationship between the extracted functions comprises: If different functions appear in the first computer code for solving the same first problem, determining that the relationship between the different functions is a co-occurrence relationship; and / or According to the preset problem domains, the problem domains corresponding to different functions are determined. If the different functions correspond to the same problem domain, the relationship between the different functions is determined to be a subject consistency relationship.
4. The method according to claim 2, wherein determining the nodes of the graph structure according to the extracted functions comprises: Determine the type of each function based on the extracted calculation logic and / or semantics of each function; Functions of the same type are identified as the same node in the graph structure.
5. The method according to claim 2, wherein selecting the target function from the stored functions comprises: Selecting a target node in the stored graph structure; Selecting a next node of the target node according to the edge in the graph structure and the target node, and re-determining the selected next node as the target node, and continuing to select the next node according to the edge in the graph structure and the re-determined target node until each selected node meets a preset condition; The function corresponding to the selected node is determined as the target function.
6. The method according to claim 5, wherein selecting a next node of the target node according to the edge in the graph structure and the target node comprises: According to the selected nodes and the preset condition, a node connected to the target node by an edge is selected as the next node, or a node not connected to the target node by an edge is selected as the next node.
7. The method of claim 1, wherein obtaining the second computer code generated by the large language model using the objective function comprises: A calculation graph generated by the large language model based on the objective function is obtained, and the calculation graph is used as the second computer code; wherein the objective function is a node in the calculation graph.
8. The method of claim 1, before generating the second question corresponding to the second computer code using the large language model, the method further comprises: By using the large language model, it is determined that the second computer code is an executable computer code.
9. The method of claim 1, wherein generating training data based on at least the second question comprises: A training sample is generated according to the second question, and an answer corresponding to the second question is generated according to the second computer code as a label for the training sample.
10. A device for generating training data, the device comprising: a decomposition module, configured to input a plurality of first questions into the large language model in advance, and obtain first computer codes output by the large language model for solving the first questions; a storage module, configured to extract and store the functions contained in each first computer code; The sampling module is used to select the target function from the stored functions when training data needs to be generated; a first generating module, configured to input the selected objective function into the large language model, and obtain a second computer code generated by the large language model using the objective function; a second generating module, configured to generate a second question corresponding to the second computer code using the large language model; The third generating module is used to generate training data at least according to the second question.
11. A computer-readable storage medium storing a computer program, wherein the computer program implements the method according to any one of claims 1 to 9 when executed by a processor.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 9 when executing the program.