Sample data generation method and apparatus, electronic device, and storage medium
By jointly using three large language models for multiple rounds of dialogue, high-quality and diverse sample data are generated, which solves the problem of inefficient sample data acquisition in the existing technology and improves the training effect of large language models.
Patent Information
- Application Number
- PCT/CN2024/127023
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-26
- Filing Date
- 2024-10-24
- Publication Date
- 2025-07-03
AI Technical Summary
The prior art cannot efficiently obtain high-quality and diverse sample data, resulting in inefficient training of large language models.
By jointly using three large language models, they are used to generate initial question instructions, answer text and question instructions, conduct multiple rounds of dialogue to construct sample data, use the first largest language model to generate high-quality initial question instructions, the second largest language model to generate high-quality answer text, and the third largest language model to generate high-quality diversified question instructions.
It improves the quality and diversity of sample data, enhances the performance of large language models in specific application fields, and realizes efficient sample data acquisition.
Smart Images

Figure CN2024127023_03072025_PF_FP_ABST
Abstract
Description
Sample data generation method, device, electronic device and storage medium
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 2023118100963, filed on December 26, 2023, entitled “Sample data generation method, device, electronic device and storage medium,” the entire text of which is hereby incorporated by reference. Technical Field
[0003] The present application relates to the field of artificial intelligence technology, and in particular to a sample data generation method, device, electronic device and storage medium. Background Art
[0004] In the field of artificial intelligence, large language model is the abbreviation of large language model (LLM), which refers to a deep learning model trained using a large amount of text data. It can generate natural language text or understand the meaning of language text. Large language model can handle a variety of natural language tasks, such as text classification, question answering, and dialogue.
[0005] Currently, sample data for training large language models can be obtained through a variety of acquisition methods. For example, high-quality sample data can be obtained through manual construction, but the manual construction method cannot efficiently obtain diversified sample data. For another example, a large amount of sample data can be collected through online platforms, but the quality of the sample data is generally low, and it takes a lot of time to clean the data. It can be seen that traditional sample data acquisition methods cannot efficiently obtain high-quality and diversified sample data, and there is an urgent need for a method that can efficiently obtain high-quality and diversified sample data.
[0006] Summary of the Invention
[0007] Embodiments of the present application provide a sample data generation method, device, electronic device, and storage medium.
[0008] In one aspect, an embodiment of the present application provides a method for generating sample data, which is executed by an electronic device and includes:
[0009] Obtaining a first prompt text, calling a first language model to predict a question instruction based on the first prompt text, and generating an initial question instruction;
[0010] Determining a question instruction for a first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue; wherein, in each round of dialogue, calling the second largest language model to generate an answer text for the current round of dialogue based on the question instruction of the current round of dialogue; and calling the third largest language model in the dialogue starting from the second round to generate a question instruction for the current round of dialogue based on the answer text of the previous round of dialogue;
[0011] Sample data is constructed based on question instructions in the multiple rounds of dialogue and answer texts in the multiple rounds of dialogue.
[0012] On the other hand, an embodiment of the present application further provides a sample data generating device, comprising:
[0013] A first generation module is configured to obtain a first prompt text, call a first language model to predict a question instruction based on the first prompt text, and generate an initial question instruction;
[0014] a second generation module, configured to determine, based on the initial question instruction, a question instruction for a first round of dialogue to conduct multiple rounds of dialogue; wherein, in each round of dialogue, the second largest language model is invoked to generate an answer text for the current round of dialogue based on the question instruction of the current round of dialogue; and, starting from the second round of dialogue, the third largest language model is invoked to generate a question instruction for the current round of dialogue based on the answer text of the previous round of dialogue;
[0015] The sample construction module is used to construct sample data based on question instructions in the multi-round dialogue and answer texts in the multi-round dialogue.
[0016] On the other hand, an embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned sample data generation method when executing the computer program.
[0017] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned sample data generation method.
[0018] In another aspect, embodiments of the present application further provide a computer program product, comprising a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium and executes the computer program, causing the electronic device to implement the above-described sample data generation method.
[0019] Other features and advantages of the present application will be set forth in the following description, and in part will be apparent from the description, or may be understood by practicing the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the conventional technology, the following briefly introduces the drawings required for use in the embodiments or the conventional technology descriptions. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without any creative work.
[0021] FIG1 is a schematic diagram of an optional implementation environment provided in an embodiment of the present application;
[0022] FIG2 is a schematic diagram of an optional flow chart of a method for generating sample data according to an embodiment of the present application;
[0023] FIG3 is a schematic diagram of a first optional structure of the first language model provided in an embodiment of the present application;
[0024] FIG4 is a schematic diagram of an optional structure of a multi-round dialogue provided in an embodiment of the present application;
[0025] FIG5 is a schematic diagram of an optional structure of a task tree provided in an embodiment of the present application;
[0026] FIG6 is a schematic diagram of an optional interface of a task configuration interface provided in an embodiment of the present application;
[0027] FIG7 is a schematic diagram of another optional interface of the task configuration interface provided in an embodiment of the present application;
[0028] FIG8 is a schematic diagram of a second optional structure of the first language model provided in an embodiment of the present application;
[0029] FIG9 is a schematic diagram of a third optional structure of the first language model provided in an embodiment of the present application;
[0030] FIG10 is a schematic diagram of an optional architecture of a sample data generation method provided in an embodiment of the present application;
[0031] FIG11 is a schematic diagram of an optional structure of a sample data generating device provided in an embodiment of the present application;
[0032] FIG12 is a partial structural block diagram of a terminal provided in an embodiment of the present application;
[0033] FIG13 is a partial structural block diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0035] It should be noted that, in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. Among them, the target object can be a user. In addition, when the embodiment of the present application needs to obtain target object attribute information, the target object's separate permission or separate consent will be obtained by means of a pop-up window or jumping to a confirmation page. After clearly obtaining the target object's separate permission or separate consent, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0036] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0037] Currently, sample data for training large language models can be obtained through a variety of acquisition methods. For example, high-quality sample data can be obtained through manual construction, but the manual construction method cannot efficiently obtain diversified sample data. For another example, a large amount of sample data can be collected through online platforms, but the quality of the sample data is generally low, and it takes a lot of time to clean the data. It can be seen that traditional sample data acquisition methods cannot efficiently obtain high-quality and diversified sample data, and there is an urgent need for a method that can efficiently obtain high-quality and diversified sample data.
[0038] Based on this, the embodiments of the present application provide a sample data generation method, device, electronic device and storage medium, which can efficiently obtain high-quality and diverse sample data.
[0039] 1 , which is a schematic diagram of an optional implementation environment provided by an embodiment of the present application, the implementation environment includes a terminal 101 and a server 102 , wherein the terminal 101 and the server 102 are connected via a communication network.
[0040] Exemplarily, the server 102 may obtain a first prompt text sent by the terminal 101 to prompt the first language model to generate a question instruction, call the first language model to predict the question instruction based on the first prompt text, and generate an initial question instruction; determine the question instruction of the first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue; wherein, in each round of dialogue, call the second language model to generate the answer text of the current round of dialogue according to the question instruction of the current round of dialogue; in the dialogue starting from the second round, call the third language model to generate the question instruction of the current round of dialogue according to the answer text of the previous round of dialogue; construct sample data based on the question instructions in the multiple rounds of dialogue and the answer texts in the multiple rounds of dialogue, and send the sample data to the terminal 101.
[0041] Server 102 generates an initial question instruction through the first largest language model, and then determines the first question instruction input into the second largest language model based on the initial question instruction. This is equivalent to using the initial question instruction as the starting point of multiple rounds of dialogue, and conducting multiple rounds of dialogue through the second largest language model and the third largest language model, so as to obtain answer texts and question instructions for multiple dialogue rounds, and then construct sample data through the initial question instruction, question instruction and answer text. Since the first largest language model can generate high-quality and diverse initial question instructions, and the second largest language model can generate high-quality and diverse answer texts, and the third largest language model can generate high-quality and diverse question instructions, it is possible to improve the complexity and diversity of question instructions by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0042] Server 102 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Furthermore, server 102 can be a node server in a blockchain network.
[0043] The terminal 101 may be a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be connected directly or indirectly via wired or wireless communication, which is not limited in this embodiment of the present application.
[0044] The method provided in the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios.
[0045] Referring to Figure 2, Figure 2 is an optional flow chart of the sample data generation method provided in an embodiment of the present application. The sample data generation method can be executed by the server, or by the terminal, or by the server in conjunction with the terminal. The text type determination method includes but is not limited to the following steps 201 to 203.
[0046] Step 201: Obtain a first prompt text, call a first large language model to predict a question instruction based on the first prompt text, and generate an initial question instruction.
[0047] Among them, the first prompt text is used to prompt the first language model to generate question instructions, that is, the first prompt text can guide the first language model to generate a specific output. By giving the first prompt text, the text content generated by the first language model can be affected.
[0048] Among them, the first large language model is a pre-trained large language model. The large language model is a deep learning model trained using a large amount of text data. It can generate natural language text or understand the meaning of language text. The large language model generally uses a recurrent neural network (RNN) or its variants, such as a long short-term memory network (LSTM) and a gated recurrent unit (GRU), to capture contextual information in text sequences, thereby realizing tasks such as natural language text generation, language model evaluation, text classification, and sentiment analysis. In the field of natural language processing, large language models have been widely used, such as speech recognition, machine translation, automatic summarization, dialogue systems, and intelligent question and answer.
[0049] Specifically, referring to FIG3 , FIG3 is a schematic diagram of a first optional structure of the first large language model provided in an embodiment of the present application.
[0050] Among them, inputting the first prompt text into the first largest language model and generating the initial question instructions through the first largest language model can improve the accuracy of the initial question instructions and have a higher generation quality. Moreover, the initial question instructions generated by the first largest language model are random, which is equivalent to the first largest language model being able to generate high-quality and diverse question instructions.
[0051] Step 202: Determine the question instructions for the first round of dialogue based on the initial question instructions to conduct multiple rounds of dialogue; wherein, in each round of dialogue, call the second largest language model to generate the answer text of the current round of dialogue according to the question instructions of the current round of dialogue; in the dialogue starting from the second round, call the third largest language model to generate the question instructions of the current round of dialogue according to the answer text of the previous round of dialogue.
[0052] Among them, the second largest language model is used to generate answer text according to the input question instruction, and the third largest language model is used to generate question instructions input into the second largest language model according to the answer text; the second largest language model is a pre-trained large language model, therefore, generating answer text through the second largest language model can improve the accuracy of the answer text and has a higher generation quality; the third largest language model is also a pre-trained large language model, therefore, generating question instructions through the third largest language model can improve the accuracy of the question instructions and also has a higher generation quality.
[0053] Based on this, the first question instruction input to the second largest language model is determined according to the initial question instruction, which is equivalent to taking the initial question instruction as the starting point of multiple rounds of dialogue. The second largest language model generates an answer text in the answering stage, and the answer text generated by the second largest language model is random. The third largest language model generates a question instruction in the questioning stage, and the question instruction generated by the third largest language model is random. Therefore, through the interaction between the second and third largest language models, high-quality and diverse answer texts and question instructions can be generated.
[0054] Specifically, one of the second largest language model and the third largest language model may be the same large language model as the first large language model.
[0055] In one possible implementation, before determining the question instructions for the first round of dialogue based on the initial question instructions to conduct multiple rounds of dialogue, the sample data generation method also includes: obtaining a first role definition text and a second role definition text, wherein the first role definition text is used to prompt the second largest language model to serve as the answerer for the target task in the multiple rounds of dialogue, and the second role definition text is used to prompt the third largest language model to serve as the questioner in the multiple rounds of dialogue, and the target task is a downstream task trained based on the sample data; inputting the first role definition text into the second largest language model, and inputting the second role definition text into the third largest language model.
[0056] Among them, the target task is a downstream task in a specific application field. For example, the target task can be JavaScript code generation in front-end development, and the target task can be plan generation for tourism planning; the content of the first role definition text is used to display the role that defines the second largest language model, and the content of the second role definition text is used to display the role that defines the third largest language model.
[0057] Based on this, before determining the question instruction of the first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue, the first role definition text is input into the second largest language model to prompt the second largest language model to serve as the answerer for the target task in the multiple rounds of dialogue. The second largest language model can better understand the answer generation task in the multiple rounds of dialogue, can improve the generation quality of the answer text, and the second largest language model can generate answer text related to the target task. Subsequently, sample data related to the target task can be obtained, and the sample data related to the target task can be used to train the large language model to achieve fine-tuning of the large language model. The fine-tuned large language model can better adapt to the target task, which helps to improve the performance of the large language model in specific application fields.
[0058] At the same time, the second role definition text is input into the third language model to prompt the third language model to act as the questioner in the multi-round dialogue. The third language model can better understand the question instruction generation task in the multi-round dialogue and improve the generation quality of the question instruction.
[0059] For example, when the target task is about JavaScript code generation in front-end development, the second role definition text can be "System role: You are a front-end development engineer with rich experience, especially good at JavaScript programming. I will ask you some questions related to JavaScript code generation in front-end development, and you need to give detailed answers"; the first role definition text can be "System role: You are chatting with a front-end code programming assistant, which will give answers, and you need to output question instructions."
[0060] It can be seen that by inputting the first role definition text into the second language model, it is equivalent to assigning the role of the respondent to the second language model, and inputting the second role definition text into the third language model, it is equivalent to assigning the role of the questioner to the third language model. The third language model interacts with the second language model by simulating the questioning operations of relevant personnel, and realizes the calling of the second language model and the third language model for multi-round dialogues. In real scenarios, a reliable dialogue assistant often needs to have the ability to conduct multi-round dialogues with the object, and be able to understand and solve the object's problems based on multi-round dialogues. Therefore, by conducting multi-round dialogues with the second language model and the third language model, constructing multi-round dialogue data can better imitate real dialogue scenarios, and subsequently obtain high-quality sample data.
[0061] In one possible implementation, the second role definition text can be used to prompt the third language model to act as the questioner for the target task in multiple rounds of dialogue. The third language model can generate question instructions related to the target task, and subsequently obtain sample data related to the target task. The sample data related to the target task is used to train the large language model to fine-tune the large language model. The fine-tuned large language model can better adapt to the target task, which helps to improve the performance of the large language model in specific application fields.
[0062] In one possible implementation, after obtaining the answer text of the first dialogue round, the sample data generation method may further include: constructing a second prompt text for prompting the third language model to generate question instructions based on the answer text whenever the answer text is received; inputting the second prompt text and the answer text of the first dialogue round into the third language model to predict question instructions and generate question instructions for the second dialogue round; and stopping the multi-round dialogue when the round of the multi-round dialogue is equal to a preset round threshold.
[0063] In this embodiment, the question instruction of the first round of dialogue is determined based on the initial question instruction to conduct multiple rounds of dialogue. Specifically, the initial question instruction can be input into the second largest language model for answer prediction to generate the answer text of the first dialogue round; a second prompt text is constructed to prompt the third largest language model to generate a question instruction according to the answer text whenever the answer text is received; the second prompt text and the answer text of the first dialogue round are input into the third largest language model for question instruction prediction to generate the question instruction of the next dialogue round; the question instruction of the next dialogue round is input into the second largest language model for answer prediction again until the number of dialogue rounds is equal to the preset turn threshold.
[0064] Among them, the turn threshold is a pre-set number of dialogue turns. For example, the turn threshold can be set to 5, or set to other values; the initial question instruction is input into the second largest language model for answer prediction. Specifically, a set of multiple initial question instructions can be used as a seed instruction set. The initial question instructions of the seed instruction set can be regarded as seed instructions. The initial question instructions input into the second largest language model can be selected in sequence from the seed instruction set, or the initial question instructions input into the second largest language model can be randomly selected from the seed instruction set.
[0065] Based on this, the initial question instruction serves as the question instruction for the first dialogue round. After the initial question instruction is input into the second largest language model, the second largest language model responds to the initial question instruction and generates an answer text. Assuming that the initial question instruction is a question raised for a specific downstream task, the answer text is the answer to the downstream task. Then, the second prompt text and the answer text of the first dialogue round are input into the third largest language model to generate the question instruction for the next dialogue round. Since the second prompt text can prompt the third largest language model to generate a question instruction based on the answer text, the question instruction is also a question raised for the downstream task. In subsequent dialogue rounds, the answer text generated by the second largest language model and the question instruction generated by the third largest language model can be considered to be for the same downstream task. Subsequently, sample data related to the downstream task can be obtained, and the large language model can be trained using the sample data related to the downstream task to achieve fine-tuning of the large language model. The fine-tuned large language model can better adapt to the downstream task, which helps to improve the performance of the large language model in specific application fields.
[0066] Specifically, while inputting the answer text of the first dialogue round into the third language model, the second prompt text is also input into the third language model, so that the third language model can understand the question instruction generation task. When the answer text of the subsequent dialogue round is input into the third language model, the second prompt text can be input again. Since the third language model has strong context processing capabilities, the third language model will consider the previously input second prompt text when generating new question instructions, so the second prompt text does not need to be input again.
[0067] For example, the second prompt text may be "You need to give question instructions based on the other party's reply." When the target task is about JavaScript code generation in front-end development, the second prompt text may also be "You need to give question instructions based on the other party's reply, for example, any question instructions related to JavaScript code generation in front-end development."
[0068] In one possible implementation, the second prompt text and the answer text of the first dialogue round are input into a third language model for question instruction prediction to generate the question instruction for the next dialogue round. Specifically, the initial question instruction can be added to the second prompt text to obtain a fused prompt text; the fused prompt text and the answer text of the first dialogue round are input into the third language model for question instruction prediction to generate the question instruction for the next dialogue round.
[0069] Among them, the fused prompt text is used to prompt the third language model to generate question instructions based on the question instructions input into the second language model and the answer text of each dialogue round; adding the initial question instruction to the second prompt text is equivalent to updating the second prompt text to obtain the fused prompt text; inputting the fused prompt text into the third language model, so that the third language model needs to refer to the answer text and question instructions of each historical dialogue round when generating question instructions.
[0070] Specifically, referring to FIG. 4 , FIG. 4 is a schematic diagram of an optional structure of a multi-round dialogue provided in an embodiment of the present application.
[0071] Since the initial question instruction is equivalent to the question instruction of the first dialogue round, when the third language model generates the question instruction for the second dialogue round, the initial question instruction belongs to the question instruction of the previous dialogue round. The fusion prompt text needs to include the initial question instruction. Then, the fusion prompt text and the answer text of the first dialogue round are input into the third language model. The third language model can generate the question instruction for the second dialogue round based on the initial question instruction and the answer text of the first dialogue round.
[0072] It can be seen that, assuming that the initial question instruction is a question posed for a specific downstream task, the answer text corresponding to the initial question instruction is the answer made for the downstream task, the third language model generates question instructions based on the question instructions and answer texts of each dialogue round, so that the newly generated question instructions are also questions posed for the downstream task. The newly generated question instructions can be closer to the real question instructions of the relevant personnel. Subsequently, sample data related to the downstream task can be obtained, and the sample data related to the downstream task can be used to train the large language model to achieve fine-tuning of the large language model. The fine-tuned large language model can better adapt to the downstream task, which helps to improve the performance of the large language model in specific application fields.
[0073] For example, when the target task is about JavaScript code generation in front-end development, the initial question instruction may be "How to use JavaScript to implement the image carousel function?"; adding the initial question instruction to the second prompt text can obtain a fused prompt text;
[0074] The fused prompt text can be "You have an initial question: How to use JavaScript to implement a carousel image function? You need to give question instructions based on the other party's reply; You need to give question instructions based on the other party's reply, such as: 1. Questions related to the previous question instructions; 2. Further questions based on the other party's previous answer; 3. Any question instructions related to JavaScript code generation in front-end development."
[0075] In addition, the format of the newly generated question instruction can also be limited in the fusion prompt text. For example, a requirement can be added to the fusion prompt text: "Your output format is: instruction: XXXX".
[0076] Step 203: Construct sample data based on question instructions in multiple rounds of dialogue and answer texts in multiple rounds of dialogue.
[0077] Based on this, sample data is constructed by initial question instructions, question instructions, and answer texts. Since the first large language model can generate high-quality and diverse initial question instructions, the second large language model can generate high-quality and diverse answer texts, and the third large language model can generate high-quality and diverse question instructions, it is possible to increase the complexity and diversity of question instructions by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0078] Therefore, sample data can be used to train the large language model in the future to fine-tune the large language model, which will help improve the performance of the large language model in specific application fields and inspire a large language model that can correctly understand various instructions and provide high-quality responses.
[0079] In one possible implementation, obtaining the first prompt text may specifically be obtaining task information of a target task, wherein the target task is a downstream task trained based on sample data; based on the task information, constructing a first prompt text for prompting the first language model to generate question instructions according to the task information.
[0080] Based on this, the target task is a downstream task in a specific application field. The first prompt text is constructed based on the task information of the target task. Subsequently, sample data related to the target task can be obtained. The sample data related to the target task is used to train the large language model to achieve fine-tuning of the large language model. The fine-tuned large language model can better adapt to the target task and help improve the performance of the large language model in specific application fields.
[0081] Specifically, the task content contained in the task information can be filled into the preset first prompt template to obtain the first prompt text. For example, assuming that the task information of the target task is "Generate JavaScript code used in front-end development", the task content contained in the task information includes code generation, front-end development and JavaScript. The first prompt template can be "Please provide some <task content> problem instructions". Based on the preset prompt construction strategy, the task content included in the task information is constructed accordingly, and the construction result is filled into the <task content> in the first prompt template to obtain the first prompt text "Please provide some problem instructions related to JavaScript code generation in front-end development".
[0082] In one possible implementation, based on the task information, a first prompt text is constructed to prompt the first language model to generate question instructions according to the task information. Specifically, based on the task information, a target node that matches the task information is determined in a preset task tree, wherein the task tree includes multiple layers of nodes, and each node carries its own candidate keywords; the candidate keywords carried by the target node are used as target keywords, and based on the target keywords, a first prompt text is constructed to prompt the first language model to generate question instructions according to the task information.
[0083] Among them, the task tree includes multiple layers of nodes. The candidate keywords carried by each node are used to indicate the specific task content of the target task. Two nodes with a parent-child relationship in the task tree will be connected to each other. Based on the connection relationship between each node, each node can correspond to a specific downstream task. If there is a parent-child relationship between two nodes in the task tree, it means that the downstream tasks corresponding to the two nodes have a hierarchical relationship. The task granularity ranges corresponding to nodes at different levels are usually different, and the task granularity ranges corresponding to nodes at the same level are usually the same.
[0084] Specifically, referring to FIG. 5 , FIG. 5 is a schematic diagram of an optional structure of a task tree provided in an embodiment of the present application.
[0085] Among them, assuming that the candidate keyword carried by the node node11 as the parent node is code generation, assuming that the child node corresponding to the node node11 includes the node node22, and the candidate keyword carried by the node node22 can be mathematical reasoning, it is equivalent to that the downstream task task11 corresponding to the node node11 is a code generation task, and the downstream task task22 corresponding to the node node22 is a code generation task about mathematical reasoning. It can be seen that the downstream task task22 can be regarded as a subtask of the downstream task task11, and there is a hierarchical relationship between the downstream task task22 and the downstream task task11. The downstream task task22 is a more specific task than the downstream task task11, that is, the task granularity range of the downstream task task22 is smaller than the task granularity range of the downstream task task11. Therefore, the task granularity ranges corresponding to nodes at different levels are different;
[0086] Further, assuming that the child nodes corresponding to node node22 include node node32 and node node33, the candidate keywords carried by node node32 can be junior high school math problems, and the candidate keywords carried by node node33 can be high school math problems, which is equivalent to the downstream task task32 corresponding to node node32 being a code generation task for mathematical reasoning about junior high school math problems, and the downstream task task33 corresponding to node node33 being a code generation task for mathematical reasoning about high school math problems. It can be seen that downstream task task32 and downstream task task33 can both be regarded as subtasks of downstream task task22, and there is a hierarchical relationship between downstream task task32 and downstream task task33 and downstream task task22 respectively. The task granularity range of downstream task task32 and downstream task task33 is the same. Therefore, the task granularity range corresponding to nodes of the same level is the same.
[0087] There are multiple ways to determine the target node, two of which are described in detail below.
[0088] Method 1: Refer to Figure 6, which is an optional interface diagram of the task configuration interface provided in an embodiment of the present application.
[0089] Among them, the task configuration interface can be configured with multiple first check box controls 610, multiple second check box controls 620, multiple third check box controls 630 and a first configuration confirmation control 640. The task configuration interface can also be configured with more levels of check box controls, which is not limited in the embodiment of the present application;
[0090] Taking the three-level check box control as an example, each check box control has corresponding task content, and the text of the corresponding task content will be displayed on one side of each check box control. The first check box control 610, the second check box control 620 and the third check box control 630 correspond to nodes at different levels of the task tree respectively. Each first check box control 610 is associated with its corresponding node at the second level, each second check box control 620 is associated with its corresponding node at the third level, and each third check box control 630 is associated with its corresponding node at the fourth level. Therefore, there is also a hierarchical relationship between the first check box control 610, the second check box control 620 and the third check box control 630.
[0091] In the task configuration interface of the terminal, multiple first checkbox controls 610 are usually displayed. A relevant person can click any displayed first checkbox control 610 in the task configuration interface. At a time, at most one first checkbox control 610 is allowed to be in a checked state. When one of the first checkbox controls 610 is in a checked state, the second checkbox controls 620 of the next level below the first checkbox control 610 are displayed in the task configuration interface.
[0092] Relevant personnel can click any displayed second checkbox control 620 in the task configuration interface. At a time, at most one second checkbox control 620 is allowed to be in a checked state. When one of the second checkbox controls 620 is in a checked state, each third checkbox control 630 of the next level of the second checkbox control 620 will be displayed in the task configuration interface.
[0093] The relevant personnel can click any displayed third check box control 630 in the task configuration interface. At a time, at most one third check box control 630 is allowed to be in a checked state;
[0094] After the relevant personnel completes the check, the first configuration determination control 640 can be triggered. The relevant personnel can trigger the first configuration determination control 640 after selecting the first check box control 610, or can trigger the first configuration determination control 640 after selecting the first check box control 610 and selecting the second check box control 620. By triggering the first configuration determination control 640, the terminal can respond to the operation of the first configuration determination control 640, and determine the target node in the task tree according to the check status of each check box control, and take the node corresponding to the last check box control in the checked state as the target node. In Figure 6, the task content is that the first check box control 610 generated by the code is in the checked state, the task content is that the second check box control 620 developed by the front-end is in the checked state, and the task content is that the third check box control 630 of the front-end JavaScript is in the checked state. Therefore, the target node of JavaScript can be determined in the task tree.
[0095] Method 2: Refer to Figure 7, which is another optional interface diagram of the task configuration interface provided in an embodiment of the present application.
[0096] The task configuration interface may be configured with a text input control 710 and a second configuration determination control 720;
[0097] In the task configuration interface of the terminal, relevant personnel can input the task information of the target task through the text input control 710, and then the relevant personnel can trigger the second configuration determination control 720. By triggering the second configuration determination control 720, the terminal can respond to the operation of the second configuration determination control 720 and determine the target node in the task tree according to the task information in the text input control 710.
[0098] Specifically, assuming that the task information is "Generate JavaScript related code in front-end development", you can refer to Figure 5 and first determine the nodes that match the task information in each node of the second level of the task tree. Assume that the node matched at the second level is node node11. For example, the candidate keyword carried by node node11 is code generation. Then, determine the nodes that match the task information in each child node of node node11. Assume that the node matched at the third level is node node21. For example, the candidate keyword carried by node node21 is front-end development. Then, determine the nodes that match the task information in each child node of node node21. Assume that the node matched at the fourth level is node node31. For example, the candidate keyword carried by node node31 is JavaScript. Then, determine the nodes that match the task information in each child node of node node31. Assume that there is no matching node at the fourth level, take node node31 as the target node.
[0099] It can be seen that among the nodes matching the task information, the task granularity range corresponding to the target node is the smallest. The candidate keywords carried by the target node are used as target keywords, and the task content indicated by the target keywords is the most specific. Since the first prompt text is constructed based on the target keywords, the first prompt text can more specifically prompt the first language model to generate initial question instructions for the target task. For example, the target keyword carried by the target node is JavaScript, and the constructed first prompt text can be "Please provide some question instructions related to JavaScript."
[0100] In a possible implementation, based on the target keyword, a first prompt text is constructed to prompt the first language model to generate a question instruction based on the task information, which may be:
[0101] When the target node is at a target level, constructing a first prompt text for prompting the first language model to generate a question instruction according to the task information based on the target keyword, wherein the target level is the level after the root node in the task tree;
[0102] Among them, after determining the target node that matches the task information in the task tree, it is judged whether the level where the target node is located belongs to the target level. When the level where the target node is located is the target level, the task information only matches the target node in the task tree. The task information can be more accurately represented by the target keyword, so the first prompt text is constructed based on the target keyword.
[0103] Alternatively, when the target node is located at a level after the target level, the associated node associated with the target node is determined in the task tree, and the candidate keywords carried by the associated node are used as associated keywords. Based on the associated keywords and the target keywords, a first prompt text is constructed to prompt the first language model to generate question instructions according to the task information, wherein the level at which the associated node is located is before the level at which the target node is located.
[0104] Among them, when the target node is located at a level after the target level, the task information will match multiple nodes in the task tree. It is necessary to determine the associated nodes associated with the target node, and then use the candidate keywords of the associated nodes as associated keywords. The task information can be more accurately represented by the combination of associated keywords and target keywords, so the first prompt text is constructed based on the associated keywords and target keywords.
[0105] Exemplarily, the target level is the level after the level where the root node is located in the task tree, that is, the target level is the second level. Assuming that the level where the target node is located is the fourth level, that is, the level where the target node is located is the level after the target level, the node connected to the target node can be determined in the third level as the first associated node, and the node connected to the first associated node can be determined in the target level as the second associated node. Then, a first prompt text is constructed based on the associated keywords carried by the two associated nodes and the target keywords carried by the target node. The first prompt text can more specifically prompt the first language model to generate initial question instructions for the target task. For example, the target keyword carried by the target node is JavaScript, the associated keyword carried by the first associated node is front-end development, and the associated keyword carried by the second associated node is code generation. The constructed first prompt text can be "Please provide some question instructions related to JavaScript code generation in front-end development."
[0106] In one possible implementation, the next level after the level where the root node in the task tree is located is the target level, and the node located at the target level carries a third role definition text. Before the candidate keyword carried by the target node is used as the target keyword, the sample data generation method also includes: using the node associated with the target node and located at the target level as the target role definition node, and using the third role definition text carried by the target role definition node as the target role definition text, wherein the target role definition text is used to prompt the first language model as the questioner for the target task; and inputting the target role definition text into the first language model.
[0107] Based on this, the target level of the task tree can contain one or more nodes, and the nodes located at the target level in the task tree are used as role definition nodes. Since the candidate keywords carried by different role definition nodes are different, which is equivalent to the specific task content corresponding to different role definition nodes being different, each role definition node must be configured with its own corresponding third role definition text. The content of the third role definition text is used to display the role defined by the first language model. Moreover, since the task granularity range corresponding to the role definition node in the task tree is the largest, the task granularity range corresponding to other nodes associated with the role definition node belongs to the sub-range of the task granularity range corresponding to the role definition node. Therefore, the target role definition text can adapt to the target role definition node and other nodes associated with the target role definition node. By inputting the target role definition text into the first language model, the first language model can better understand the target task and improve the generation quality of the initial question instructions.
[0108] Referring again to FIG5 , assuming that the candidate keyword carried by the role definition node node11 is code generation, the third role definition text configured for the role definition node node11 may be “System role: You are an assistant who is good at code programming and problem-related issues.” For another example, assuming that the candidate keyword carried by the role definition node node12 is travel planning, the third role definition text configured for the role definition node node12 may be “System role: You are a virtual tour guide who is good at travel planning.”
[0109] Assume that the role definition node node11 is the target role definition node, and the target role definition text is "System role: You are an assistant who is good at code programming and problem-related." By inputting the target role definition text into the first language model, the first language model can better understand the target task of code generation and improve the generation quality of the initial problem instructions.
[0110] In one possible implementation, there are multiple initial question instructions. Before determining the question instructions for the first round of dialogue based on the initial question instructions to conduct multiple rounds of dialogue, the sample data generation method also includes: randomly sampling a first question instruction from the multiple initial question instructions; constructing a third prompt text based on a preset expansion strategy to prompt the first large language model to expand the instruction according to the expansion strategy; inputting the third prompt text and the first question instruction into the first large language model, expanding the first question instruction to generate a first extended question instruction, and using the first extended question instruction as the initial question instruction.
[0111] Specifically, referring to FIG8 , FIG8 is a schematic diagram of a second optional structure of the first language model provided in an embodiment of the present application.
[0112] Among them, the first question instruction is randomly sampled from multiple initial question instructions. Specifically, the set of multiple initial question instructions generated by the first largest language model can be used as a seed instruction set, the initial question instruction of the seed instruction set can be regarded as a seed instruction, and the first question instruction is randomly sampled from the seed instruction set; the expansion strategy can be a strategy text for complicating the question instruction, and the expansion strategy is used to prompt the first largest language model how to complicate the question instruction. The expansion strategy can be used to make requirements on the first expanded question instruction generated by the first largest language model. For example, the expansion strategy can make word count requirements, word usage requirements, reasoning step number requirements or complexity requirements for the first expanded question instruction, etc. The expansion strategies required by different downstream tasks are usually different. Therefore, it is necessary to preset multiple expansion strategies to cope with different downstream tasks.
[0113] Based on this, a third prompt text is constructed based on the extension strategy. The third prompt text can prompt the first large language model to handle the task of complicating the question instruction. The third prompt text and the first question instruction are input into the first large language model, so that the first large language model can complicate the first question instruction. The first large language model can generate a first extended question instruction based on the model input. The number of the first extended question instructions can be one or more, which is not limited in the embodiment of the present application. The first extended question instruction can be regarded as the result of the complication of the question instruction of the first question instruction. Since relevant personnel may input more complex question instructions, the first extended question instruction with higher complexity is usually closer to the more complex question instructions input by relevant personnel in real scenarios than the first question instruction with lower complexity. When the first extended question instruction is used to train the large language model in subsequent downstream tasks, the training effect of the large language model can be effectively improved.
[0114] Specifically, before determining the question instruction for the first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue, multiple first extended question instructions can be generated through multiple complication rounds. In each complication round, it is necessary to randomly sample the first question instruction from multiple initial question instructions so that some of the initial question instructions can be complicated. The first extended question instruction obtained by complicating the question instruction is used as the initial question instruction, which can further enhance the diversity of the initial question instructions and subsequently improve the training effect of the large language model.
[0115] Taking the downstream task of JavaScript code generation in front-end development as an example, the first extended problem instruction can be obtained in multiple ways. The following takes one of the ways as an example to describe in detail the process of obtaining the first extended problem instruction.
[0116] Method 1: Assume that the first randomly sampled question instruction is "How to implement a carousel image function using JavaScript?" and the expansion strategy is "Add new constraints and requirements to the original instruction and increase the length of the instruction content." The third prompt text constructed based on this expansion strategy can be "Please increase the complexity of the given question instruction. You can use the following methods to increase the complexity of the question instruction: Method 1: Add new constraints and requirements to the original instruction and increase the length of the instruction content."
[0117] Fill the second prompt template with the third prompt text and the first question instruction, resulting in the first input text being "Please increase the complexity of the given question instruction. You can use the following methods to increase the complexity of the instruction: Method 1: Add new constraints and requirements to the original instruction to increase the length of the instruction content. Original instruction: How to use JavaScript to implement the image carousel function?";
[0118] Then, the first input text is input into the first large language model, and the first large language model generates a first extended question instruction.
[0119] Among them, the content of the fourth role definition text is used to display the role defined by the first language model. Before the first input text is input into the first language model, the fourth role definition text is input into the first language model to prompt the first language model as the questioner for the target task. For example, in the downstream task of JavaScript code generation in front-end development, the fourth role definition text can be "System role: You are an assistant who is good at code programming and problem-related". By inputting the fourth role definition text into the first language model, the first language model can better understand the complex task of the question instruction and improve the generation quality of the second extended question instruction.
[0120] In one possible implementation, there are multiple extension strategies, and the first problem instruction is extended to generate an extended problem instruction. Specifically, the first problem instruction is extended multiple times to obtain a first extended problem instruction generated by each instruction extension; wherein, each time the first problem instruction is extended, the first problem instruction is extended according to at least one of the multiple extension strategies.
[0121] Based on this, after the third prompt text and the first question instruction are input into the first large language model, the first large language model will perform multiple instruction expansions on the first question instruction. Therefore, by complicating the same first question instruction multiple times, multiple first expanded question instructions can be obtained, and each time the instruction expansion is performed, one or more expansion strategies will be randomly selected to perform instruction expansion on the first question instruction, which can improve the randomness and diversity of the first expanded question instruction. Taking each first expanded question instruction as the initial question instruction can further enhance the diversity of the initial question instruction.
[0122] Specifically, assuming that there are four extension strategies preset, extension strategy a is "adding new constraints and requirements to the original instructions and increasing the content length of the instructions", extension strategy b is "replacing common concepts in the original instructions with more specific but uncommon concepts", extension strategy c is "increasing the reasoning steps of the original instructions", and extension strategy d is "increasing the time complexity or space complexity of the original instructions". The third prompt text constructed based on the extension strategy can be "Please increase the complexity of the given problem instructions while ensuring the integrity of the problem instructions. Methods for increasing the complexity of problem instructions include but are not limited to: Method 1: adding new constraints and requirements to the original instructions and increasing the content length of the instructions; Method 2: replacing common concepts in the original instructions with more specific but uncommon concepts; Method 3: increasing the reasoning steps of the original instructions; Method 4: increasing the time complexity or space complexity of the original instructions".
[0123] In one possible implementation, there are multiple initial question instructions. Before determining the question instructions for the first round of dialogue based on the initial question instructions to conduct multiple rounds of dialogue, the sample data generation method also includes: randomly sampling a second question instruction from the multiple initial question instructions; constructing a fourth prompt text for prompting the first large language model to generate a question instruction with reference to the second question instruction, inputting the fourth prompt text and the second question instruction into the first large language model for question instruction prediction, generating a second extended question instruction, and using the second extended question instruction as the initial question instruction.
[0124] Specifically, referring to FIG9 , FIG9 is a schematic diagram of a third optional structure of the first language model provided in an embodiment of the present application.
[0125] Among them, the second question instruction is randomly sampled from multiple initial question instructions. Specifically, the set of multiple initial question instructions generated by the first large language model can be used as a seed instruction set. The initial question instruction of the seed instruction set can be regarded as a seed instruction. A preset number of question instructions are randomly sampled from the seed instruction set to obtain the second question instruction. Therefore, a fourth prompt text is constructed to prompt the first large language model to generate a question instruction with reference to the second question instruction. This is equivalent to regarding the second question instruction as a reference example of the question instruction generation task, and inputting the fourth prompt text and the second question instruction into the first large language model. The first large language model can generate a second extended question instruction based on the model input, and then use the second extended question instruction as a new initial question instruction, and then add the new initial question instruction to the seed instruction set. The number of second extended question instructions can be one or more, and the embodiment of the present application is not limited here.
[0126] Based on this, under the influence of the fourth prompt text, the second question instruction is regarded as a reference example, and the first large language model is enabled to learn the task through several reference examples organized in the form of demonstration. The knowledge contained in the second question instruction is temporarily inserted into the first large language model, so that the first large language model can better understand the current question instruction generation task, thereby generating a second extended question instruction with better quality. Since the first large language model generates the second extended question instruction based on the knowledge contained in the second question instruction, the second extended question instruction and the second question instruction contain similar knowledge, which is equivalent to the second extended question instruction and the second question instruction being used to process the same downstream task. Therefore, the second extended question instruction can be used as a new initial question instruction, and the second extended question instruction generated by the first large language model is usually different from the second question instruction, that is, the first large language model can output generalized instructions, realize effective expansion of the initial question instruction, and increase the diversity of the initial question instruction.
[0127] Specifically, before determining the question instruction for the first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue, multiple second extended question instructions can be generated through multiple generation rounds. In each generation round, the second question instruction needs to be randomly sampled from multiple initial question instructions. Since the second extended question instruction will serve as the new initial question instruction, the second question instruction sampled in the current generation round may be the second extended question instruction generated in the previous generation round.
[0128] Taking the downstream task of JavaScript code generation in front-end development as an example, the second extended problem instruction can be obtained in a variety of ways. The following takes two of these ways as examples to describe in detail the process of obtaining the second extended problem instruction.
[0129] Method 1: Assume that two second question instructions are randomly sampled, second question instruction a is "How to use JavaScript to implement the image carousel function?", and second question instruction b is "How to use JavaScript to create a timer?", and the constructed fourth prompt text can be "The following are some question instructions related to JavaScript code generation in front-end development", wherein the embodiment of the application does not limit the specific form of the fourth prompt text;
[0130] Fill the fourth prompt text and the second question instruction into the third prompt template, and the resulting second input text is "Below are some question instructions related to JavaScript code generation in front-end development. Example 1: Instruction: How to use JavaScript to implement the image carousel function? Example 2: Instruction: How to use JavaScript to create a timer? Example 3:";
[0131] Then the second input text is input into the first language model, and the first language model generates a second extended question instruction. Assuming that the output of the first language model is "Instruction: How to use JavaScript to implement click event detection?", the second extended question instruction is "How to use JavaScript to implement click event detection?".
[0132] Method 2: Assume that two second question instructions are randomly sampled, second question instruction a is "How to use JavaScript to implement the image carousel function?", and second question instruction b is "How to use JavaScript to create a timer?", and the constructed fourth prompt text can be "Please refer to the following question instructions related to JavaScript code generation in front-end development to generate new question instructions." The specific form of the fourth prompt text is not limited in this embodiment of the application;
[0133] The fourth prompt text, the second question instruction a, and the second question instruction b are sequentially concatenated to obtain a first concatenated text: "Please refer to the following question instructions related to JavaScript code generation in front-end development to generate new question instructions. How to use JavaScript to implement the image carousel function? How to use JavaScript to create a timer?";
[0134] Then the first concatenated text is input into the first large language model, and the first large language model generates a second extended question instruction. Assuming that the output of the first large language model is "How to use JavaScript to implement click event detection?", the second extended question instruction is "How to use JavaScript to implement click event detection?".
[0135] In one possible implementation, before calling the first large language model to predict question instructions based on the first prompt text, the sample data generation method also includes: obtaining a target sampling temperature value; configuring the temperature parameter of the first large language model to the target sampling temperature value, wherein the target sampling temperature value is used to indicate the degree of randomness of the output result of the first large language model.
[0136] Among them, the temperature parameter of the first language model is a hyperparameter. A hyperparameter is a parameter configured for the first language model before the first language model starts learning. The hyperparameter is not obtained through model training, but is usually assigned based on existing experience to configure the hyperparameter for the first language model. Since the initial question instructions generated by the first language model are usually obtained by sampling the vocabulary based on a probability distribution, the temperature parameter is used to adjust the probability distribution. The target sampling temperature value can be manually input or pre-set.
[0137] Based on this, when the target sampling temperature value is higher, the probability distribution is smoother, which is equivalent to smoothing the initial probability of each word in the vocabulary, increasing the generation probability of words with lower initial probability, and increasing the randomness of the initial question instructions, making the initial question instructions more diverse, but the initial question instructions are more likely to have quality problems, such as inaccurate grammar or inaccurate content, etc.; conversely, when the target sampling temperature value is lower, the probability distribution is sharper, reducing the generation probability of words with lower initial probability, so that the first language model usually generates words with higher initial probability, which can improve the quality of the initial question instructions, but reduce the randomness of the initial question instructions; under the premise of ensuring quality, it is usually necessary to select a higher target sampling temperature value to increase the diversity of the initial question instructions generated by the first language model, so as to obtain a diverse and high-quality seed instruction set formed by the initial question instructions.
[0138] Specifically, before calling the first large language model to predict the question instruction based on the first prompt text, the temperature parameter of the first large language model is configured as the target sampling temperature value, which is equivalent to the temperature parameter corresponding to the first large language model when generating the initial question instruction being the target sampling temperature value. Assuming that the temperature parameter corresponding to the first large language model when generating the first extended question instruction is the first sampling temperature value, and the temperature parameter corresponding to the first large language model when generating the second extended question instruction is the second sampling temperature value, the target sampling temperature value, the first sampling temperature value and the second sampling temperature value can be the same, partially the same or completely different. The embodiment of the present application is not limited here. Under normal circumstances, it is also necessary to select a higher first sampling temperature value and a higher second sampling temperature value to improve the diversity of the results generated by the first large language model, thereby obtaining a diverse and high-quality seed instruction set.
[0139] In one possible implementation, the first largest language model is called to predict question instructions based on the first prompt text to generate initial question instructions. Specifically, the first largest language model is called to predict question instructions based on the first prompt text to generate multiple initial question instructions in sequence; wherein, each time an initial question instruction is generated, the instruction similarity between the currently generated initial question instruction and the historically generated initial question instruction is determined, and when the instruction similarity is greater than or equal to a preset similarity threshold, the currently generated initial question instruction is eliminated.
[0140] Among them, calling the first large language model to predict question instructions based on the first prompt text, and generating multiple initial question instructions in sequence, the implementation methods include but are not limited to: Method 1: After the first prompt text is input into the first large language model, the first large language model can continuously generate new initial question instructions until the stopping condition is met, which is equivalent to inputting the first prompt text into the first large language model once, and the first large language model can generate multiple initial question instructions in sequence based on the first prompt text. At this time, the first prompt text can be "Please provide some question instructions related to JavaScript code generation in front-end development"; Method 2: Input the first prompt text into the first large language model multiple times, and each time the first prompt text is input into the first large language model, the first large language model can generate an initial question instruction. At this time, the first prompt text can be "Please provide question instructions related to JavaScript code generation in front-end development".
[0141] Specifically, the stopping condition may be that the total number of initial question instructions is equal to a preset first threshold value, or the stopping condition may be that the relevant personnel manually stops the generation process of the first language model, for example, the relevant personnel clicks a stop button on the display interface or enters a stop instruction. The embodiment of the present application does not limit the specific form of the stopping condition.
[0142] Typically, in the same target task, the first prompt text input by the first language model is the same. Since the initial question instructions generated by the first language model are usually obtained by sampling the vocabulary based on a probability distribution, the output of the first language model is random. Even if the input text of the first language model is the same, the first language model can generate different initial question instructions and obtain multiple different initial question instructions.
[0143] Based on this, since the output of the first language model is random, the initial question instructions generated by the first language model are usually different, but the first language model may generate similar initial question instructions. In order to improve the diversity of the initial question instructions, each time an initial question instruction is generated, the instruction similarity between the currently generated initial question instruction and the historically generated initial question instruction is determined, and then, based on the size relationship between the instruction similarity and the similarity threshold, it is determined whether to retain or eliminate the currently generated initial question instruction. When the instruction similarity is less than the similarity threshold, it means that the content difference between the currently generated initial question instruction and the historically generated initial question instruction is large, and the currently generated initial question instruction is retained. Conversely, when the instruction similarity is greater than or equal to the similarity threshold, it means that the content difference between the currently generated initial question instruction and the historically generated initial question instruction is small, and the currently generated initial question instruction is eliminated. Since initial question instructions with high content repetition have been eliminated, the retained initial question instructions have a higher diversity. The set of retained initial question instructions is used as a seed instruction set, and a seed instruction set with higher diversity can be obtained.
[0144] Among them, if the number of initial problem instructions generated historically is zero, the instruction similarity between the currently generated initial problem instruction and the historically generated initial problem instruction is zero, and the similarity threshold is usually greater than zero, and the currently generated initial problem instruction will be retained; if the number of initial problem instructions generated historically is multiple, the instruction similarity between the currently generated initial problem instruction and each initial problem instruction generated historically can be calculated separately, and then the largest instruction similarity can be selected. According to the size relationship between the instruction similarity and the similarity threshold, it is determined whether to retain or eliminate the currently generated initial problem instruction.
[0145] Among them, there are many ways to determine the instruction similarity. For example, the cosine similarity between the currently generated initial question instruction and the historically generated initial question instruction can be used as the instruction similarity. For another example, the number of common word units and the total number of word units between the currently generated initial question instruction and the historically generated initial question instruction can be determined, and the ratio of the number of common word units to the total number of word units can be used as the instruction similarity. The instruction similarity can also be determined by other methods, which are not limited in the embodiments of the present application.
[0146] The similarity threshold can be a real number between 0 and 1. It can be seen that when the similarity threshold is larger, the currently generated initial question instructions that are more similar to the historically generated initial question instructions can be retained, which is equivalent to retaining initial question instructions with smaller content differences from the historically generated instructions. Usually, the initial question instructions that are less retained may have quality problems, thereby improving the overall quality of the initial question instructions generated by the first language model, but reducing the diversity of the initial question instructions generated by the first language model. Conversely, when the similarity threshold is smaller, the currently generated initial question instructions that are less similar to the historically generated initial question instructions can be eliminated, which can improve the diversity of the initial question instructions generated by the first language model, but only the initial question instructions with larger content differences from the historically generated instructions can be retained. It is possible that more retained initial question instructions may have quality problems, such as inaccurate grammar or inaccurate content, etc., which reduces the overall quality of the initial question instructions generated by the first language model. Therefore, it is necessary to select an appropriate similarity threshold based on existing experience obtained from multiple experiments or based on other strategies to achieve a balance between diversity and quality of the initial question instructions generated by the first language model, so as to obtain a diverse and high-quality seed instruction set formed by the initial question instructions.
[0147] The complete process of the sample data generation method is described in detail below.
[0148] Refer to FIG. 10 , which is a schematic diagram of an optional architecture of a sample data generation method provided in an embodiment of the present application.
[0149] The overall architecture may include an instruction generation module, an instruction complication module, and a multi-round dialogue module;
[0150] The processing procedure of the instruction generation module is described in detail below.
[0151] First, the instruction generation module obtains the first prompt text;
[0152] Then, the instruction generation module obtains the target sampling temperature value; configures the temperature parameter of the first language model as the target sampling temperature value, wherein the target sampling temperature value is used to indicate the randomness of the output result of the first language model
[0153] Then, the instruction generation module obtains task information of the target task, where the target task is a downstream task trained based on the sample data;
[0154] Then, the instruction generation module determines the target node that matches the task information in the preset task tree based on the task information. The task tree includes multiple layers of nodes, each of which carries its own candidate keywords. The task tree is pre-built.
[0155] Then, the instruction generation module uses the node associated with the target node and located at the target level as the target role definition node, and uses the third role definition text carried by the target role definition node as the target role definition text, wherein the target role definition text is used to prompt the first language model as the questioner for the target task; and inputs the target role definition text into the first language model;
[0156] Then, the instruction generation module uses the candidate keywords carried by the target node as the target keywords;
[0157] Then, when the target node is at the target level, the instruction generation module constructs, based on the target keyword, a first prompt text for prompting the first language model to generate a question instruction based on the task information, wherein the target level is the level after the root node in the task tree.
[0158] Alternatively, when the target node is located at a level after the target level, the instruction generation module determines an associated node associated with the target node in the task tree, uses the candidate keyword carried by the associated node as the associated keyword, and constructs, based on the associated keyword and the target keyword, a first prompt text for prompting the first language model to generate a question instruction according to the task information, wherein the level at which the associated node is located is before the level at which the target node is located;
[0159] Then, the instruction generation module calls the first language model to predict the question instruction based on the first prompt text, and generates multiple initial question instructions in sequence; wherein, each time an initial question instruction is generated, the instruction similarity between the currently generated initial question instruction and the historically generated initial question instruction is determined, and when the instruction similarity is greater than or equal to a preset similarity threshold, the currently generated initial question instruction is eliminated, wherein the initial question instruction is a single-round question instruction, and the set of each initial question instruction can be used as a seed instruction set, and the initial question instructions in the seed instruction set are all seed instructions;
[0160] Then, the instruction generation module randomly samples a first question instruction from the multiple initial question instructions;
[0161] Then, the instruction generation module constructs a third prompt text based on the preset expansion strategy for prompting the first language model to perform instruction expansion according to the expansion strategy;
[0162] Then, the instruction generation module inputs the third prompt text and the first question instruction into the first large language model, performs multiple instruction expansions on the first question instruction, and obtains the first extended question instruction generated each time the instruction expansion is performed; wherein, whenever the first question instruction is expanded, the first question instruction is expanded according to at least one of the multiple expansion strategies, wherein the newly generated first extended question instruction is also a single-round question instruction, the first extended question instruction can be used as the initial question instruction, and the newly generated initial question instruction can be added to the seed instruction set to perform diversified expansion on the seed instruction set.
[0163] The processing process of the instruction complication module is described in detail below.
[0164] First, the instruction complication module randomly samples a second problem instruction from multiple initial problem instructions;
[0165] Then, the instruction complication module constructs a fourth prompt text for prompting the first large language model to generate a question instruction with reference to the second question instruction, and inputs the fourth prompt text and the second question instruction into the first large language model for question instruction prediction to generate a second extended question instruction, wherein the newly generated second extended question instruction is also a single-round question instruction, and the second extended question instruction can be used as the initial question instruction.
[0166] The processing of the multi-round dialogue module is described in detail below.
[0167] First, the multi-turn dialogue module obtains a first role definition text and a second role definition text. The first role definition text is used to prompt the second language model to act as the answerer for the target task in the multi-turn dialogue, and the second role definition text is used to prompt the third language model to act as the questioner in the multi-turn dialogue. The target task is a downstream task trained based on sample data.
[0168] Then, the multi-turn dialogue module inputs the first role definition text into the second language model and the second role definition text into the third language model;
[0169] The multi-turn dialogue module then inputs the initial question instruction into the second language model for answer prediction, generating the answer text for the first dialogue round;
[0170] Then, the multi-turn dialogue module constructs a second prompt text for prompting the third language model to generate a question instruction according to the answer text whenever it receives the answer text;
[0171] Then, the multi-turn dialogue module adds the initial question instruction to the second prompt text to obtain the fused prompt text;
[0172] The multi-turn dialogue module then inputs the fused prompt text and the answer text from the first dialogue turn into the third language model to predict the question instruction and generate the question instruction for the next dialogue turn. The fused prompt text is used to prompt the third language model to generate the question instruction based on the question instructions input to the second language model and the answer text from each dialogue turn.
[0173] Then, the multi-turn dialogue module inputs the question instruction of the next dialogue round into the second largest language model to predict the answer again until the number of dialogue rounds reaches the preset turn threshold;
[0174] Finally, we construct sample data based on the question instructions and answer texts in multi-round conversations.
[0175] Among them, sample data can also be constructed through single-round question instructions generated by the instruction generation module and single-round question instructions generated by the instruction complication module, which is not limited in the embodiment of the present application.
[0176] Based on this, an initial question instruction is generated by the first largest language model, and then the first question instruction input to the second largest language model is determined according to the initial question instruction. This is equivalent to taking the initial question instruction as the starting point of multiple rounds of dialogue, and conducting multiple rounds of dialogue through the second largest language model and the third largest language model. Answer texts and question instructions for multiple dialogue rounds can be obtained, and then sample data is constructed through the initial question instruction, question instruction and answer text. Since the first largest language model can generate high-quality and diverse initial question instructions, and the second largest language model can generate high-quality and diverse answer texts, and the third largest language model can generate high-quality and diverse question instructions, it is possible to improve the complexity and diversity of question instructions by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0177] The sample data generation method provided in the embodiments of the present application can be applied to a variety of scenarios.
[0178] For example, in a scenario where a target large language model is applied to an image text retrieval task, first, task information of the image text retrieval task is obtained; then, based on the task information, a first prompt text is constructed to prompt the first large language model to generate a question instruction according to the task information; then, the first prompt text is obtained, and the first large language model is called to predict the question instruction based on the first prompt text to generate an initial question instruction; then, based on the initial question instruction, the first question instruction input to the second large language model is determined, and the second large language model and the third large language model are called to conduct multiple rounds of dialogue, wherein the second large language model is used to generate an answer text according to the input question instruction, and the third large language model is used to generate a question instruction input to the second large language model according to the answer text; then, based on the question instructions in the multiple rounds of dialogue and the answer text in the multiple rounds of dialogue, sample data is constructed; then, based on the sample data, the target large language model is trained so that the target large language model can better adapt to the image text retrieval task.
[0179] Specifically, the training effect of the target large language model is shown in Table 1 below:
[0180] Table 1
[0181] Among them, sample data is constructed based on the sample data generation method provided in the embodiment of the present application. For example, 100,000 sample data are constructed, and then the target large language model a is trained based on the sample data, and the target large language model b is trained based on the sample data. It can be seen that both the target large language model a and the target large language model b have significant improvement effects.
[0182] It will be appreciated that, although the various steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless clearly stated in the present embodiment, the execution of these steps does not have strict order restrictions, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.
[0183] 11 , which is a schematic diagram of an optional structure of a sample data generating apparatus provided in an embodiment of the present application, the sample data generating apparatus 1100 includes:
[0184] A first generating module 1101 is configured to obtain a first prompt text, invoke a first language model to predict a question instruction based on the first prompt text, and generate an initial question instruction;
[0185] The second generation module 1102 is configured to determine the question instruction for the first round of dialogue based on the initial question instruction to conduct multiple rounds of dialogue; wherein, in each round of dialogue, the second largest language model is called to generate the answer text of the current round of dialogue based on the question instruction of the current round of dialogue; and in the dialogue starting from the second round, the third largest language model is called to generate the question instruction of the current round of dialogue based on the answer text of the previous round of dialogue;
[0186] The sample construction module 1103 is used to construct sample data based on question instructions and answer texts in multiple rounds of dialogue.
[0187] Furthermore, the number of knowledge granularity types of the candidate text is at least one, and the above-mentioned second generation module 1102 is also used to: obtain a first role definition text and a second role definition text, wherein the first role definition text is used to prompt the second largest language model to serve as the respondent for the target task in a multi-round dialogue, and the second role definition text is used to prompt the third largest language model to serve as the questioner in a multi-round dialogue, and the target task is a downstream task trained based on sample data; input the first role definition text into the second largest language model, and input the second role definition text into the third largest language model.
[0188] Furthermore, the above-mentioned second generation module 1102 is specifically used to: construct a second prompt text for prompting the third language model to generate a question instruction based on the answer text whenever an answer text is received; input the second prompt text and the answer text of the first dialogue round into the third language model to predict the question instruction, and generate the question instruction of the second round of dialogue; when the round of the multi-round dialogue is equal to the preset round threshold, stop the multi-round dialogue.
[0189] Furthermore, the above-mentioned second generation module 1102 is specifically used to: add the initial question instruction to the second prompt text to obtain a fused prompt text; input the fused prompt text and the answer text of the first dialogue round into the third language model to predict the question instruction, and generate the question instruction of the next dialogue round, wherein the fused prompt text is used to prompt the third language model to generate a question instruction based on each question instruction input into the second language model and the answer text of each dialogue round.
[0190] Furthermore, the above-mentioned first generation module 1101 is specifically used to: obtain task information of the target task, wherein the target task is a downstream task trained based on sample data; based on the task information, construct a first prompt text for prompting the first language model to generate question instructions according to the task information.
[0191] Furthermore, the above-mentioned first generation module 1101 is specifically used to: determine the target node that matches the task information in the preset task tree according to the task information, wherein the task tree includes multiple layers of nodes, and each node carries its own candidate keywords; use the candidate keywords carried by the target node as target keywords, and construct a first prompt text based on the target keywords to prompt the first language model to generate question instructions according to the task information.
[0192] Furthermore, the first generating module 1101 is specifically configured to: when the target node is at the target level, construct, based on the target keyword, a first prompt text for prompting the first language model to generate a question instruction based on the task information;
[0193] Alternatively, when the target node is located at a level after the target level, the associated node associated with the target node is determined in the task tree, and the candidate keywords carried by the associated node are used as associated keywords. Based on the associated keywords and the target keywords, a first prompt text is constructed to prompt the first language model to generate question instructions according to the task information, wherein the level at which the associated node is located is before the level at which the target node is located.
[0194] Furthermore, the node located at the target level carries a third role definition text, and the above-mentioned first generation module 1101 is specifically used to: use the node associated with the target node and located at the target level as the target role definition node, and use the third role definition text carried by the target role definition node as the target role definition text, wherein the target role definition text is used to prompt the first language model as the questioner for the target task; based on the target keywords, construct a first prompt text for prompting the first language model to generate question instructions based on the task information, and add the target role definition text to the first prompt text.
[0195] Furthermore, the number of initial question instructions is multiple, and the sample data generating device also includes a third generating module (not shown in the figure), which is specifically used to: randomly sample a first question instruction from multiple initial question instructions; construct a third prompt text based on a preset expansion strategy to prompt the first large language model to expand the instruction according to the expansion strategy; input the third prompt text and the first question instruction into the first large language model, expand the first question instruction, generate a first extended question instruction, and use the first extended question instruction as the initial question instruction.
[0196] Furthermore, there are multiple extension strategies, and the above-mentioned third generation module is specifically used to: perform multiple instruction extensions on the first problem instruction to obtain the first extended problem instruction generated by each instruction extension; wherein, whenever the first problem instruction is extended, the first problem instruction is extended according to at least one of the multiple extension strategies.
[0197] Furthermore, there are multiple initial question instructions, and the above-mentioned first generation module 1101 is also used to: randomly sample a second question instruction from multiple initial question instructions; construct a fourth prompt text for prompting the first large language model to generate a question instruction with reference to the second question instruction, input the fourth prompt text and the second question instruction into the first large language model for question instruction prediction, generate a second extended question instruction, and use the second extended question instruction as the initial question instruction.
[0198] Furthermore, the first generating module 1101 is further configured to: obtain a target sampling temperature value; and configure the temperature parameter of the first large language model as the target sampling temperature value, wherein the target sampling temperature value is used to indicate the degree of randomness of the output result of the first large language model.
[0199] Furthermore, the above-mentioned first generation module 1101 is specifically used to: call the first large language model to predict question instructions based on the first prompt text, and generate multiple initial question instructions in sequence; wherein, whenever an initial question instruction is generated, the instruction similarity between the currently generated initial question instruction and the historically generated initial question instruction is determined, and when the instruction similarity is greater than or equal to a preset similarity threshold, the currently generated initial question instruction is eliminated.
[0200] The above-mentioned sample data generation device 1100 and the sample data generation method applied to the central node are based on the same inventive concept. The initial question instruction is generated by the first largest language model, and then the first question instruction input to the second largest language model is determined based on the initial question instruction. This is equivalent to using the initial question instruction as the starting point of multiple rounds of dialogue, and conducting multiple rounds of dialogue through the second largest language model and the third largest language model. Answer texts and question instructions for multiple dialogue rounds can be obtained, and then sample data is constructed through the initial question instruction, question instruction and answer text. Since the first largest language model can generate high-quality and diverse initial question instructions, and the second largest language model can generate high-quality and diverse answer texts, and the third largest language model can generate high-quality and diverse question instructions, the complexity and diversity of the question instructions can be improved by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0201] The electronic device for executing the above-mentioned sample data generation method provided in the embodiment of the present application may be a terminal. Referring to FIG12 , FIG12 is a partial structural block diagram of the terminal provided in the embodiment of the present application, and the terminal includes: a camera assembly 1210, a memory 1220, an input unit 1230, a display unit 1240, a sensor 1250, an audio circuit 1260, a wireless fidelity (WiFi) module 1270, a processor 1280, and a power supply 1290. Those skilled in the art will understand that the terminal structure shown in FIG12 does not constitute a limitation on the terminal, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0202] The camera assembly 1210 can be used to capture images or videos. Optionally, the camera assembly 1210 includes a front camera and a rear camera. Typically, the front camera is set on the front panel of the terminal, and the rear camera is set on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.
[0203] The memory 1220 may be used to store software programs and modules. The processor 1280 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1220 .
[0204] The input unit 1230 may be configured to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1230 may include a touch panel 1231 and other input devices 1232 .
[0205] The display unit 1240 may be configured to display input information or provided information and various menus of the terminal. The display unit 1240 may include a display panel 1241 .
[0206] The audio circuit 1260 , the speaker 1261 , and the microphone 1262 may provide an audio interface.
[0207] The power source 1290 may be AC power, DC power, disposable batteries, or rechargeable batteries.
[0208] The number of sensors 1250 can be one or more, and the one or more sensors 1250 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:
[0209] The accelerometer can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal. For example, the accelerometer can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 1280 can control the display unit 1240 to display the user interface in a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer. The accelerometer can also be used to collect game or user motion data.
[0210] The gyroscope sensor can detect the device's orientation and rotation angle. It can also work with the accelerometer to capture the user's 3D movements. Based on the data collected by the gyroscope sensor, the processor 1280 can implement the following functions: motion sensing (such as changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0211] The pressure sensor can be set on the side frame of the terminal and / or the lower layer of the display unit 1240. When the pressure sensor is set on the side frame of the terminal, it can detect the user's grip signal of the terminal, and the processor 1280 performs left and right hand recognition or shortcut operations based on the grip signal collected by the pressure sensor. When the pressure sensor is set on the lower layer of the display unit 1240, the processor 1280 controls the operability controls on the UI interface based on the user's pressure operation on the display unit 1240. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0212] The optical sensor is used to collect ambient light intensity. In one embodiment, the processor 1280 can control the display brightness of the display unit 1240 based on the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1240 is increased; when the ambient light intensity is low, the display brightness of the display unit 1240 is decreased. In another embodiment, the processor 1280 can also dynamically adjust the shooting parameters of the camera assembly 1210 based on the ambient light intensity collected by the optical sensor.
[0213] In this embodiment, the processor 1280 included in the terminal can execute the sample data generating method of the previous embodiment.
[0214] The electronic device for executing the above-mentioned sample data generation method provided in the embodiment of the present application can also be a server. Referring to Figure 13, Figure 13 is a partial structural block diagram of the server provided in the embodiment of the present application. The server 1300 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1322 (for example, one or more processors) and a memory 1332, and one or more storage media 1330 (for example, one or more mass storage devices) storing application programs 1342 or data 1344. Among them, the memory 1332 and the storage medium 1330 can be temporary storage or permanent storage. The program stored in the storage medium 1330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server 1300. Furthermore, the central processing unit 1322 can be configured to communicate with the storage medium 1330 to execute a series of instruction operations in the storage medium 1330 on the server 1300.
[0215] The server 1300 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input and output interfaces 1358, and / or one or more operating systems 1341, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0216] The processor in the server 1300 can be used to execute the sample data generating method.
[0217] An embodiment of the present application further provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the sample data generation method of each of the aforementioned embodiments.
[0218] The present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium and executes the computer program, causing the electronic device to implement the above-mentioned sample data generation method.
[0219] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0220] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0221] It should be understood that in the description of the embodiments of the present application, multiple (or multiple items) means more than two, greater than, less than, exceed, etc. are understood to exclude the number itself, and above, below, within, etc. are understood to include the number itself.
[0222] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0223] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0224] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0225] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0226] It should also be understood that the various implementation methods provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0227] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0228] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that variations and improvements are possible within the scope of the present application, as would be apparent to one skilled in the art. These variations and improvements fall within the scope of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for generating sample data, executed by an electronic device, comprising: Obtaining a first prompt text, and invoking a first large language model to predict a question instruction based on the first prompt text to generate an initial question instruction; Determining a question instruction for the first round of conversation based on the initial question instruction to conduct a multi-round conversation; wherein, in each round of conversation, invoking a second large language model to generate an answer text for the current round of conversation according to the question instruction of the current round of conversation; In the conversations starting from the second round, invoking a third large language model to generate a question instruction for the current round of conversation according to the answer text of the previous round of conversation; and Constructing sample data based on the question instructions in the multi-round conversation and the answer texts in the multi-round conversation.
2. The method according to claim 1, before determining the question instruction for the first round of conversation based on the initial question instruction to conduct a multi-round conversation, the method further comprises: Obtaining a first role definition text and a second role definition text, wherein the first role definition text is used to prompt the second large language model to act as an answerer for the target task in the multi-round conversation, and the second role definition text is used to prompt the third large language model to act as a questioner in the multi-round conversation, and the target task is a downstream task trained based on the sample data; Inputting the first role definition text into the second large language model, and inputting the second role definition text into the third large language model.
3. The method according to claim 1 or 2, the method further comprises: Constructing a second prompt text for prompting the third large language model to generate a question instruction according to the answer text whenever the answer text is received; Inputting the second prompt text and the answer text of the first conversation round into the third large language model for question instruction prediction to generate a question instruction for the second round of conversation; When the number of rounds of the multi-round conversation is equal to a preset round threshold, stopping the multi-round conversation.
4. The method according to claim 3, the step of inputting the second prompt text and the answer text of the first conversation round into the third large language model for question instruction prediction to generate a question instruction for the second round of conversation comprises: Adding the initial question instruction to the second prompt text to obtain a fused prompt text; Inputting the fused prompt text and the answer text of the first conversation round into the third large language model for question instruction prediction to generate a question instruction for the second round of conversation, wherein the fused prompt text is used to prompt the third large language model to generate a question instruction according to each question instruction input into the second large language model and the answer text of each conversation round.
5. The method according to any one of claims 1 to 4, the step of obtaining the first prompt text comprises: Obtaining task information of the target task, wherein the target task is a downstream task trained based on the sample data; Based on the task information, constructing a first prompt text for prompting the first large language model to generate a question instruction according to the task information.
6. The method according to claim 5, wherein the constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information based on the task information includes: Determining a target node matching the task information in a preset task tree according to the task information, wherein the task tree includes multiple layers of nodes, and each of the nodes carries its own candidate keywords; Taking the candidate keywords carried by the target node as target keywords, and constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information according to the target keywords.
7. The method according to claim 6, wherein the constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information according to the target keywords includes: When the level where the target node is located is the target level, constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information according to the target keywords, wherein the target level is the level after the level where the root node of the task tree is located.
8. The method according to claim 6 or 7, wherein the constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information according to the target keywords includes: When the level where the target node is located is a level after the target level, determining an associated node associated with the target node in the task tree; Taking the candidate keywords carried by the associated node as associated keywords, and constructing a first prompt text for prompting a first large language model to generate a question instruction according to the task information according to the associated keywords and the target keywords, wherein the level where the associated node is located is before the level where the target node is located.
9. The method according to any one of claims 6 to 8, wherein the level after the level where the root node of the task tree is located is the target level, and the nodes at the target level carry third role definition texts. Before taking the candidate keywords carried by the target node as target keywords, the method further includes: Taking the node associated with the target node and located at the target level as a target role definition node, and taking the third role definition text carried by the target role definition node as a target role definition text, wherein the target role definition text is used to prompt the first large language model to be the questioner for the target task; Inputting the target role definition text into the first large language model.
10. The method according to any one of claims 1 to 9, wherein the number of the initial question instructions is multiple, and the determining a question instruction for the first round of conversation based on the initial question instructions to perform a multi-round conversation includes: Randomly sampling a first question instruction from the multiple initial question instructions; Constructing a third prompt text for prompting a first large language model to perform instruction expansion according to a preset expansion strategy based on the first question instruction; Input the third prompt text and the first question instruction into the first large language model to expand the instruction of the first question instruction and generate a first expanded question instruction; Use the first expanded question instruction as the question instruction for the first round of conversation to conduct multi-round conversations.
11. According to the method described in claim 10, the number of expansion strategies is multiple. The expanding the instruction of the first question instruction to generate a first expanded question instruction includes: Conduct multiple expansions of the instruction of the first question instruction to obtain the first expanded question instruction generated by each instruction expansion; Wherein, whenever expanding the instruction of the first question instruction, expand the first question instruction according to at least one of the multiple expansion strategies.
12. According to the method described in any one of claims 1 to 9, the number of initial question instructions is multiple. The determining the question instruction for the first round of conversation based on the initial question instruction to conduct multi-round conversations includes: Randomly sample a second question instruction from the multiple initial question instructions; Construct a fourth prompt text for prompting the first large language model to generate a question instruction with reference to the second question instruction; Input the fourth prompt text and the second question instruction into the first large language model for question instruction prediction to generate a second expanded question instruction; Use the second expanded question instruction as the question instruction for the first round of conversation to conduct multi-round conversations.
13. According to the method described in any one of claims 1 to 12, before calling the first large language model to conduct question instruction prediction based on the first prompt text, the method further includes: Obtain a target sampling temperature value; Configure the temperature parameter of the first large language model as the target sampling temperature value, where the target sampling temperature value is used to indicate the randomness of the output result of the first large language model.
14. According to the method described in any one of claims 1 to 13, the calling the first large language model to conduct question instruction prediction based on the first prompt text to generate an initial question instruction includes: Call the first large language model to conduct question instruction prediction based on the first prompt text to sequentially generate multiple initial question instructions; Wherein, whenever generating the initial question instruction, determine the instruction similarity between the currently generated initial question instruction and the historically generated initial question instruction. When the instruction similarity is greater than or equal to a preset similarity threshold, eliminate the currently generated initial question instruction.
15. A sample data generation device, comprising: A first generation module, configured to obtain a first prompt text, call a first large language model to conduct question instruction prediction based on the first prompt text, and generate an initial question instruction; A second generation module, configured to determine a question instruction for the first round of conversation based on the initial question instruction for multi-round conversation; wherein, in each round of conversation, a second large language model is invoked to generate a response text for the current round of conversation according to the question instruction for the current round of conversation; in the conversation starting from the second round, a third large language model is invoked to generate a question instruction for the current round of conversation according to the response text of the previous round of conversation; and A sample construction module, configured to construct sample data based on the question instructions in the multi-round conversation and the response texts in the multi-round conversation.
16. An electronic device, comprising a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the sample data generation method according to any one of claims 1 to 14 is implemented.
17. A computer-readable storage medium, where the storage medium stores a computer program, and when the computer program is executed by a processor, the sample data generation method according to any one of claims 1 to 14 is implemented.
18. A computer program product, comprising a computer program, and when the computer program is executed by a processor, the sample data generation method according to any one of claims 1 to 14 is implemented.
Citation Information
Patent Citations
Self-service equipment navigation method and navigation system thereof
CN111290677A
Method and device for constructing medical training sample and medical text retrieval method
CN113571196A
Answer generation method and device based on knowledge base, equipment and storage medium
CN117194641A
Question model training method, question text processing method and related equipment
CN117271737A
State evaluation interaction method, device and equipment
CN117271746A
Cited By
Cloud function configuration detection method based on large language model
CN120822615A
Training data generation method, electronic equipment, storage medium and product
CN120994799A
Voice interaction model evaluation method, electronic equipment and readable storage medium
CN121122240A
Simulation scene generation method and device based on large language model
CN121365503A
Robot simulation scene intelligent generation method and system based on large language model
CN122413755A