Sample data generation method and device, electronic equipment and storage medium
Through a multi-round dialogue mechanism, three large language models are used to call each other to generate high-quality and diverse sample data, which solves the problem of insufficient data quality and diversity in the existing technology and improves the performance and adaptability of the large language model. .
Patent Information
- Application Number
- CN202311810096.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2043-12-26
AI Technical Summary
Existing technologies are difficult to efficiently obtain high-quality and diverse sample data, and traditional methods cannot effectively solve the data quality and diversity issues required for large language model training.
Through a multi-round dialogue mechanism, three large language models are used to call each other to generate initial question instructions, target answer texts and target question instructions, build sample data, and improve the complexity and diversity of question instructions.
It achieves efficient generation of high-quality and diverse sample data, improving the performance and adaptability of large language models in specific application fields.
Smart Images

Figure CN118861218A_ABST
Abstract
Description
Technical Field
[0001] 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
[0002] In the field of artificial intelligence, big language model is the abbreviation of large language model (Large Language Modeling, LLM), which refers to a deep learning model trained with a large amount of text data. It can generate natural language text or understand the meaning of language text. The large language model can handle a variety of natural language tasks, such as text classification, question and answer, dialogue, etc.
[0003] 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 an online platform, 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 the traditional sample data acquisition method 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. Summary of the invention
[0004] The following is a summary of the subject matter described in detail in this application. This summary is not intended to limit the scope of the claims.
[0005] 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 diversified sample data.
[0006] On the one hand, an embodiment of the present application provides a method for generating sample data, including:
[0007] Acquire a first prompt text for prompting 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;
[0008] The initial question instruction is used as the first question instruction input to the second largest language model, and the second largest language model is called to conduct multiple rounds of dialogue with the third largest language model, wherein the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input to the second largest language model according to the target answer text;
[0009] Sample data is constructed based on the initial question instruction, the target question instructions in multiple rounds of dialogue, and the target answer texts in multiple rounds of dialogue.
[0010] On the other hand, the embodiment of the present application further provides a sample data generating device, including:
[0011] A first generating module is used to obtain a first prompt text for prompting the first large language model to generate a question instruction, call the first large language model to predict the question instruction based on the first prompt text, and generate an initial question instruction;
[0012] A second generation module is used to use the initial question instruction as the first question instruction input to the second largest language model, and call the second largest language model and the third largest language model to conduct multiple rounds of dialogue, wherein the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input to the second largest language model according to the target answer text;
[0013] The sample construction module is used to construct sample data based on the initial question instruction, the target question instruction in multiple rounds of dialogue, and the target answer text in multiple rounds of dialogue.
[0014] Furthermore, the number of the knowledge granularity types of the candidate text is at least one, and the second generation module is further used for:
[0015] 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 an answerer for a 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 a questioner in the multiple rounds of dialogue, and the target task is a downstream task trained based on the sample data;
[0016] The first role definition text is input into the second largest language model, and the second role definition text is input into the third largest language model.
[0017] Furthermore, the second generation module is specifically used for:
[0018] Inputting the initial question instruction into the second largest language model for answer prediction to generate a target answer text for the first dialogue round;
[0019] Constructing a second prompt text for prompting the third language model to generate a question instruction according to the target answer text whenever receiving the target answer text;
[0020] Inputting the second prompt text and the target answer text of the first dialogue round into the third language model to perform question instruction prediction, and generate a target question instruction of the next dialogue round;
[0021] The target question instruction of the next dialogue round is input into the second largest language model to perform answer prediction again until the number of dialogue rounds is equal to a preset number threshold.
[0022] Furthermore, the second generation module is specifically used for:
[0023] Adding the initial question instruction to the second prompt text to obtain a target prompt text;
[0024] The target prompt text and the target answer text of the first dialogue round are input into the third largest language model to predict question instructions, and generate target question instructions for the next dialogue round, wherein the target prompt text is used to prompt the third largest language model to generate question instructions based on each question instruction input into the second largest language model and the target answer text of each dialogue round.
[0025] Furthermore, the first generation module is specifically used for:
[0026] Acquire task information of a target task, wherein the target task is a downstream task trained based on the sample data;
[0027] Based on the task information, a first prompt text is constructed for prompting the first large language model to generate a question instruction according to the task information.
[0028] Furthermore, the first generation module is specifically used for:
[0029] According to the task information, determining a target node matching the task information in a preset task tree, wherein the task tree includes multiple layers of nodes, each of which carries its own candidate keyword;
[0030] The candidate keyword carried by the target node is used as a target keyword, and a first prompt text is constructed based on the target keyword to prompt the first language model to generate a question instruction according to the task information.
[0031] Furthermore, the first generation module is specifically used for:
[0032] When the level where the target node is located is the target level, constructing a first prompt text for prompting the first language model to generate a question instruction according to the task information according to the target keyword, wherein the target level is a level after the level where the root node is located in the task tree;
[0033] Alternatively, when the level at which the target node is located is a level after the target level, an 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 based on the task information, wherein the level at which the associated node is located is before the level at which the target node is located.
[0034] Furthermore, 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 the third role definition text, and the first generation module is further used for:
[0035] Using a node associated with the target node and located at the target level as a target role definition node, and using 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 language model to serve as a questioner for the target task;
[0036] The target role definition text is input into the first language model.
[0037] Furthermore, the number of the initial question instructions is multiple, and the sample data generating device further includes a third generating module, and the third generating module is specifically used for:
[0038] Randomly sampling a first question instruction from the plurality of initial question instructions;
[0039] Based on a preset expansion strategy, construct a third prompt text for prompting the first language model to perform instruction expansion according to the expansion strategy;
[0040] The third prompt text and the first question instruction are input into the first large language model, the first question instruction is extended to generate a first extended question instruction, and the first extended question instruction is used as the initial question instruction.
[0041] Furthermore, there are multiple extension strategies, and the third generation module is specifically used for:
[0042] Performing multiple instruction expansions on the first problematic instruction to obtain a first extended problematic instruction generated by each instruction expansion;
[0043] Wherein, whenever the first problematic instruction is expanded, the first problematic instruction is expanded according to at least one of the plurality of expansion strategies.
[0044] Furthermore, the number of the initial question instructions is multiple, and the first generating module is further used for:
[0045] Randomly sampling a second question instruction from the plurality of initial question instructions;
[0046] 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.
[0047] Furthermore, the first generating module is also used for:
[0048] Get the target sampling temperature value;
[0049] The temperature parameter of the first large language model is configured as the target sampling temperature value, wherein the target sampling temperature value is used to indicate the degree of randomness of an output result of the first large language model.
[0050] Furthermore, the first generation module is specifically used for:
[0051] Calling the first language model to predict question instructions based on the first prompt text, and sequentially generating a plurality of initial question instructions;
[0052] Wherein, whenever the 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.
[0053] 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.
[0054] 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.
[0055] On the other hand, the embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned sample data generation method.
[0056] The embodiments of the present application include at least the following beneficial effects: an initial question instruction is generated by the first largest language model, and then the initial question instruction is used as the first question instruction input into the second largest language model, which is equivalent to using the initial question instruction as the starting point of multiple rounds of dialogue, and multiple rounds of dialogue are conducted through the second largest language model and the third largest language model, so that target answer texts and target question instructions for multiple dialogue rounds can be obtained, and then sample data is constructed through the initial question instruction, the target question instruction and the target 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 target answer texts, and the third largest language model can generate high-quality and diverse target question instructions, the complexity and diversity of question instructions can be improved by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0057] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent from the description, or may be understood by practicing the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0059] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application;
[0060] Figure 2 A schematic diagram of an optional flow chart of a sample data generation method provided in an embodiment of the present application;
[0061] Figure 3 A first optional structural diagram of the first language model provided in an embodiment of the present application;
[0062] Figure 4 An optional structural diagram of a multi-round dialogue provided in an embodiment of the present application;
[0063] Figure 5 An optional structural diagram of a task tree provided in an embodiment of the present application;
[0064] Figure 6 A schematic diagram of an optional interface of a task configuration interface provided in an embodiment of the present application;
[0065] Figure 7 A schematic diagram of another optional interface of the task configuration interface provided in the embodiment of the present application;
[0066] Figure 8A schematic diagram of a second optional structure of the first language model provided in an embodiment of the present application;
[0067] Fig. 9 A third optional structural diagram of the first language model provided in the embodiment of the present application;
[0068] Fig.10 A schematic diagram of an optional architecture of a sample data generation method provided in an embodiment of the present application;
[0069] Fig.11 A schematic diagram of an optional structure of a sample data generating device provided in an embodiment of the present application;
[0070] Fig.12 A partial structural block diagram of a terminal provided in an embodiment of the present application;
[0071] Fig.13 A partial structural block diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0073] 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 the 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, etc., and after the separate permission or separate consent of the target object is clearly obtained, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0074] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with 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.
[0075] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:
[0076] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0077] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction system, mechatronics, etc. Among them, the pre-trained model is also called the large model or basic model. After fine-tuning, it can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0078] Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.
[0079] 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 an online platform, 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 the traditional sample data acquisition method 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.
[0080] 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 diversified sample data.
[0081] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for 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.
[0082] Exemplarily, server 102 may obtain a first prompt text sent by 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; use the initial question instruction as the first question instruction input to the second language model, call the second language model and the third language model to conduct multiple rounds of dialogues, wherein the second language model is used to generate a target answer text according to the input question instruction, and the third language model is used to generate a target question instruction input to the second language model according to the target answer text; based on the initial question instruction, the target question instructions in multiple rounds of dialogues, and the target answer texts in multiple rounds of dialogues, construct sample data and send it to terminal 101.
[0083] Server 102 generates an initial question instruction through the first largest language model, and then uses the initial question instruction as the first question instruction input into the second largest language model, which 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 target answer texts and target question instructions for multiple dialogue rounds, and then construct sample data through the initial question instruction, the target question instruction and the target answer text. Since the first largest language model can generate high-quality and diverse initial question instructions, the second largest language model can generate high-quality and diverse target answer texts, and the third largest language model can generate high-quality and diverse target question instructions, the complexity and diversity of question instructions can be improved by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0084] Server 102 can be an independent physical server, or a server cluster or distributed system composed 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. In addition, server 102 can also be a node server in a blockchain network.
[0085] The terminal 101 may be a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present embodiment.
[0086] 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 the like.
[0087] Reference Figure 2 , Figure 2 An optional flow chart of a sample data generation method provided in an embodiment of the present application. The sample data generation method can be executed by a server, or by a terminal, or by a server in cooperation with a terminal. The text type determination method includes but is not limited to the following steps 201 to 203.
[0088] Step 201: Obtain a first prompt text for prompting 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.
[0089] 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.
[0090] Among them, the first large language model is a pre-trained large language model. The large language model is a deep learning model trained with 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 achieving natural language text generation, language model evaluation, text classification, sentiment analysis and other tasks. In the field of natural language processing, large language models have been widely used, such as speech recognition, machine translation, automatic summarization, dialogue systems, intelligent question and answer, etc.
[0091] Specifically, refer to Figure 3 , Figure 3 A first optional structural diagram of the first language model provided in an embodiment of the present application.
[0092] Among them, inputting the first prompt text into the first largest language model and generating 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 target question instructions.
[0093] Step 202: using the initial question instruction as the first question instruction input to the second largest language model, and calling the second largest language model and the third largest language model to conduct multiple rounds of dialogue;
[0094] Among them, the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input into the second largest language model according to the target answer text; the second largest language model is a pre-trained large language model, therefore, generating the target answer text through the second largest language model can improve the accuracy of the target answer text and has a higher generation quality; the third largest language model is also a pre-trained large language model, therefore, generating the target question instruction through the third largest language model can improve the accuracy of the target question instruction and also has a higher generation quality.
[0095] Based on this, taking the initial question instruction as the first question instruction input into the second largest language model is equivalent to taking the initial question instruction as the starting point of multiple rounds of dialogue. The second largest language model generates the target answer text in the answering stage, and the target answer text generated by the second largest language model is random. The third largest language model generates the target question instruction in the questioning stage, and the target question instruction generated by the third largest language model is random. Therefore, under the interaction of the second largest language model and the third largest language model, high-quality and diverse target answer texts and target question instructions can be generated.
[0096] 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.
[0097] In one possible implementation, before the initial question instruction is used as the first question instruction input to the second largest language model, 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 respondent for a target task in 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 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.
[0098] 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 defining the second largest language model, and the content of the second role definition text is used to display the role defining the third largest language model.
[0099] Based on this, before the initial question instruction is used as the first question instruction input to the second largest language model, the first role definition text is input into the second largest language model to prompt the second largest language model to serve as the respondent for the target task in the multi-round dialogue. The second largest language model can better understand the answer generation task in the multi-round dialogue, and can improve the generation quality of the target answer text. Moreover, the second largest language model can generate the target answer text 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, so as 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.
[0100] 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 target question instruction.
[0101] 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."
[0102] It can be seen that by inputting the first role definition text into the second largest language model, it is equivalent to assigning the role of the respondent to the second largest language model, and inputting the second role definition text into the third largest language model is equivalent to assigning the role of the questioner to the third largest language model. The third largest language model interacts with the second largest language model by simulating the questioning operation of relevant personnel, and realizes calling the second largest language model and the third largest language model to conduct multiple rounds of dialogue. In real scenarios, a reliable dialogue assistant often needs to have the ability to conduct rounds of dialogue with the object, and can understand and solve the object's problems based on multiple rounds of dialogue. Therefore, by conducting multiple rounds of dialogue with the second largest language model and the third largest language model, constructing multi-round dialogue data can better imitate real dialogue scenarios, and higher-quality sample data can be obtained later.
[0103] 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 target 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 areas.
[0104] In one possible implementation, an initial question instruction is used as the first question instruction input into the second largest language model, and the second largest language model and the third largest language model are called to conduct multiple rounds of dialogue. Specifically, the initial question instruction may be input into the second largest language model for answer prediction to generate a target answer text for 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 target answer text whenever the target answer text is received; the second prompt text and the target answer text of the first dialogue round are input into the third largest language model for question instruction prediction to generate a target question instruction for the next dialogue round; the target question instruction for 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 a preset number threshold.
[0105] Among them, the quantity threshold is a pre-set number of dialogue turns, for example, the quantity 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, and 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.
[0106] Based on this, the initial question instruction is used as the question instruction of 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 a target answer text. Assuming that the initial question instruction is a question raised for a specific downstream task, the target answer text is the answer made for the downstream task. Then the second prompt text and the target answer text of the first dialogue round are input into the third largest language model to generate the target question instruction for the next dialogue round. Since the second prompt text can prompt the third largest language model to generate a question instruction according to the target answer text, the target question instruction is also a question raised for the downstream task. In subsequent dialogue rounds, the target answer text generated by the second largest language model and the target 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.
[0107] Specifically, when the target answer text of the first dialogue round is input into the third largest language model, the second prompt text is input into the third largest language model, so that the third largest language model can understand the question instruction generation task, and when the target answer text of the subsequent dialogue round is input into the third largest language model, the second prompt text can be input again. Since the third largest language model has strong context processing capabilities, the third largest language model will consider the previously input second prompt text when generating new target question instructions, so the second prompt text does not need to be input again.
[0108] Exemplarily, 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".
[0109] In a possible implementation, the second prompt text and the target answer text of the first dialogue round are input into the third language model for question instruction prediction to generate the target question instruction of the next dialogue round. Specifically, the initial question instruction is added to the second prompt text to obtain the target prompt text; the target prompt text and the target answer text of the first dialogue round are input into the third language model for question instruction prediction to generate the target question instruction of the next dialogue round;
[0110] Among them, the target prompt text is used to prompt the third language model to generate question instructions according to the question instructions input into the second language model and the target answer text of each dialogue round; adding the initial question instruction to the second prompt text is equivalent to updating the second prompt text, so as to obtain the target prompt text; inputting the target prompt text into the third language model, so that the third language model needs to refer to the target answer text and question instructions of each historical dialogue round when generating the target question instruction.
[0111] Specifically, refer to Figure 4 , Figure 4 An optional structural diagram of a multi-round dialogue provided in an embodiment of the present application.
[0112] Among them, since the initial question instruction is equivalent to the question instruction of the first dialogue round, when the third language model generates the target question instruction of the second dialogue round, the initial question instruction belongs to the question instruction of the historical dialogue round, and the target prompt text needs to include the initial question instruction. Then the target prompt text and the target answer text of the first dialogue round are input into the third language model. The third language model can generate the target question instruction of the second dialogue round according to the initial question instruction and the target answer text of the first dialogue round.
[0113] It can be seen that, assuming that the initial question instruction is a question asked for a specific downstream task, the target answer text corresponding to the initial question instruction is the answer to the downstream task, and the third language model generates a target question instruction based on the question instructions and the target answer text of each dialogue round, so that the newly generated target question instruction is also a question asked for the downstream task. The newly generated target question instruction can be closer to the real question instruction of the relevant personnel, and sample data related to the downstream task can be obtained subsequently. The sample data related to the downstream 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 downstream task, which helps to improve the performance of the large language model in specific application fields.
[0114] 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 the target prompt text;
[0115] The target prompt text can be "You have an initial question: How to use JavaScript to implement the image carousel 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 previous question instructions; 2. Further questions based on the other party's previous answers; 3. Any question instructions related to JavaScript code generation in front-end development";
[0116] In addition, the format of the newly generated target question instruction can also be limited in the target prompt text. For example, a requirement can be added to the target prompt text: "Your output format is: instruction: XXXX".
[0117] Step 203: construct sample data based on the initial question instruction, the target question instruction in the multi-round dialogue, and the target answer text in the multi-round dialogue.
[0118] Based on this, sample data is constructed through initial question instructions, target question instructions, and target answer texts. Since the first language model can generate high-quality and diverse initial question instructions, the second language model can generate high-quality and diverse target answer texts, and the third language model can generate high-quality and diverse target question instructions, the complexity and diversity of question instructions can be improved by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0119] 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 areas and inspire a large language model that can correctly understand a variety of instructions and provide high-quality responses.
[0120] In one possible implementation, obtaining a first prompt text for prompting the first largest language model to generate a question instruction 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 largest language model to generate a question instruction according to the task information.
[0121] 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 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.
[0122] Specifically, the task content included 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 included 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, and the first prompt text is "Please provide some problem instructions related to JavaScript code generation in front-end development".
[0123] In one possible implementation, based on the task information, a first prompt text is constructed to prompt the first language model to generate a question instruction according to the task information. Specifically, based on the task information, a target node matching 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 a question instruction according to the task information.
[0124] 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 two nodes in the task tree have a parent-child relationship, it means that the downstream tasks corresponding to the two nodes have a hierarchical relationship. The task granularity ranges corresponding to nodes of different levels are usually different, and the task granularity ranges corresponding to nodes of the same level are usually the same.
[0125] Specifically, refer to Figure 5 , Figure 5 An optional structural diagram of a task tree provided in an embodiment of the present application.
[0126] Among them, assuming that the candidate keyword carried by node node11 as the parent node is code generation, assuming that the child nodes corresponding to node node11 include node node22, and the candidate keyword carried by node node22 can be mathematical reasoning, which is equivalent to the downstream task task11 corresponding to node node11 being a code generation task, and the downstream task task22 corresponding to node node22 being a code generation task about mathematical reasoning. It can be seen that downstream task task22 can be regarded as a subtask of downstream task task11, and there is a hierarchical relationship between downstream task task22 and downstream task task11. Downstream task task22 is a more specific task than downstream task task11, that is, the task granularity range of downstream task task22 is smaller than the task granularity range of downstream task task11. Therefore, the task granularity ranges corresponding to nodes of different levels are different;
[0127] Further, assume 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 respectively and the downstream task task22, and the task granularity range of downstream task task32 and downstream task task33 is the same, so the task granularity range corresponding to nodes of the same level is the same.
[0128] There are multiple ways to determine the target node, two of which are described in detail below.
[0129] Method 1: Reference Figure 6 , Figure 6 An optional interface diagram of the task configuration interface provided in an embodiment of the present application.
[0130] 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 determination 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;
[0131] 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, the first check box control 610, the second check box control 620 and the third check box control 630 also have a hierarchical relationship.
[0132] In the task configuration interface of the terminal, a plurality of first check box controls 610 are usually displayed. The relevant personnel can click any displayed first check box control 610 in the task configuration interface. At a time, at most one first check box control 610 is allowed to be in a checked state. When one of the first check box controls 610 is in a checked state, each second check box control 620 of the next level of the first check box control 610 will be displayed in the task configuration interface;
[0133] The relevant personnel can click any displayed second check box control 620 in the task configuration interface. At a time, at most one second check box control 620 is allowed to be in a checked state. When one of the second check box controls 620 is in a checked state, each third check box control 630 of the next level of the second check box control 620 will be displayed in the task configuration interface;
[0134] 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;
[0135] After the relevant personnel complete 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, determine the target node in the task tree according to the check state of each check box control, and use the node corresponding to the last check box control in the check state as the target node. Figure 6 In the example, the first check box control 610 whose task content is code generation is in a checked state, the second check box control 620 whose task content is front-end development is in a checked state, and the third check box control 630 whose task content is front-end JavaScript is in a checked state. Therefore, the target node of JavaScript can be determined in the task tree.
[0136] Method 2: Reference Figure 7 , Figure 7 A schematic diagram of another optional interface of the task configuration interface provided in an embodiment of the present application.
[0137] The task configuration interface may be configured with a text input control 710 and a second configuration determination control 720;
[0138] 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.
[0139] Specifically, assuming the task information is "Generate JavaScript related code in front-end development", you can refer to Figure 5First, determine the nodes that match the task information in each node of the second level of the task tree. Assume that the matching node of 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 matching node of 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 matching node of 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.
[0140] It can be seen that among the nodes matching the task information, the target node corresponds to the smallest task granularity range. The candidate keywords carried by the target node are used as the target keywords. 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."
[0141] In a possible implementation, based on the target keyword, a first prompt text is constructed for prompting the first language model to generate a question instruction based on the task information, which may be:
[0142] When the target node is at the target level, constructing a first prompt text for prompting the first language model to generate a question instruction according to the task information according to the target keyword, wherein the target level is a level after the level at which the root node is located in the task tree;
[0143] 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 keywords, so the first prompt text is constructed according to the target keywords.
[0144] Alternatively, when the target node is located at a level after the target level, an 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.
[0145] Among them, when the level where the target node is located is the level after the target level, the task information will match multiple nodes in the task tree, and 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 the target keywords.
[0146] 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 according to the associated keywords carried by the two associated nodes and the target keyword 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."
[0147] In one possible implementation, the level after the level where the root node in the task tree is located is the target level, the node located at the target level carries a third role definition text, and 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 largest language model as the questioner for the target task; and inputting the target role definition text into the first largest language model.
[0148] Based on this, the target level of the task tree can include 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 contents corresponding to different role definition nodes are different, each role definition node needs to 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, and 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, 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.
[0149] Refer again Figure 5 , assuming that the candidate keyword carried by the role definition node node11 is code generation, the third role definition text configured by the role definition node node11 may be "system role: you are an assistant who is good at code programming and problem-related", for another example, the candidate keyword carried by the role definition node node12 is travel planning, the third role definition text configured by the role definition node node12 may be "system role: you are a virtual tour guide who is good at travel planning";
[0150] 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.
[0151] In a possible implementation, there are multiple initial question instructions. Before the initial question instruction is used as the first question instruction input into the second largest language model, 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 largest language model to expand the instruction according to the expansion strategy; inputting the third prompt text and the first question instruction into the first largest 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.
[0152] Specifically, refer to Figure 8 , Figure 8 A second optional structural diagram of the first language model provided in an embodiment of the present application.
[0153] Among them, a first question instruction is randomly sampled from multiple initial question instructions. Specifically, a set of multiple initial question instructions generated by the first largest language model can be used as a seed instruction set, and 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 extension strategy can be a strategy text for complicating the question instruction, and the extension strategy is used to prompt the first largest language model how to complicate the question instruction. The extension strategy can be used to make requirements on the first extended question instruction generated by the first largest language model. For example, the extension strategy can make word count requirements, word usage requirements, reasoning step number requirements or complexity requirements for the first extended question instruction. The extension strategies required by different downstream tasks are usually different. Therefore, it is necessary to preset multiple extension strategies to cope with different downstream tasks.
[0154] Based on this, a third prompt text is constructed based on the extension strategy, and 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, and the embodiment of the present application is not limited here; the first extended question instruction can be regarded as the result of the complicated question instruction of the first question instruction. Since relevant personnel may input more complex question instructions, compared with the first question instruction with lower complexity, the first extended question instruction with higher complexity is usually closer to the more complex question instructions input by relevant personnel in the real scene. 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.
[0155] Specifically, before the initial question instruction is used as the first question instruction input into the second largest language model, multiple first extended question instructions can be generated through multiple rounds of complication. In each round of complication, 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.
[0156] Taking the downstream task of JavaScript code generation in front-end development as an example, the first extended problem instruction can be obtained in a variety of ways. The following takes one of the ways as an example to describe in detail the process of obtaining the first extended problem instruction.
[0157] Method 1: Assume that the first randomly sampled question instruction is "How to use JavaScript to implement the image carousel function?", and assume that the extension strategy is "add new constraints and requirements to the original instruction and increase the content length of the instruction". The third prompt text constructed based on the extension strategy can be "Please increase the complexity of the given question instruction. The following methods can be used to increase the complexity of the question instruction: Method 1: Add new constraints and requirements to the original instruction and increase the content length of the instruction";
[0158] Fill the third prompt text and the first question instruction into the second prompt template, and the first input text obtained is "Please increase the complexity of the given question instruction. The following methods can be used to increase the complexity of the instruction: Method 1: Add new constraints and requirements to the original instruction to increase the content length of the instruction. Original instruction: How to use JavaScript to implement the image carousel function?";
[0159] 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.
[0160] 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 task of complicating the problem instruction and can improve the generation quality of the second extended problem instruction.
[0161] 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.
[0162] 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 expand the first question instruction, which can improve the randomness and diversity of the first expanded question instructions. Taking each first expanded question instruction as the initial question instruction can further enhance the diversity of the initial question instructions.
[0163] 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 the 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: Replace common concepts in the original instructions with more specific but uncommon concepts; Method 3: Increase the reasoning steps of the original instructions; Method 4: Increase the time complexity or space complexity of the original instructions".
[0164] In one possible implementation, there are multiple initial question instructions. Before the initial question instruction is used as the first question instruction input into the second largest language model, 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 largest 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 largest language model for question instruction prediction, generating a second extended question instruction, and using the second extended question instruction as the initial question instruction.
[0165] Specifically, refer to Fig. 9 , Fig. 9 A third optional structural diagram of the first language model provided in an embodiment of the present application.
[0166] 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, and 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, which is equivalent to regarding the second question instruction as a reference example of the question instruction generation task, and the fourth prompt text and the second question instruction are input 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 the second extended question instruction is used as a new initial question instruction, and the new initial question instruction is added to the seed instruction set. The number of the second extended question instructions can be one or more, and the embodiment of the present application is not limited here.
[0167] 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, and 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 knowledge contained in the second question instruction are similar, which is equivalent to the second extended question instruction and the second question instruction can be used to process the same downstream task, so 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.
[0168] Specifically, before the initial question instruction is used as the first question instruction input into the second largest language model, 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 be used as a 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.
[0169] 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 the ways as examples to describe in detail the process of obtaining the second extended problem instruction.
[0170] Method 1: Assuming that two second question instructions are randomly sampled, the second question instruction a is "How to use JavaScript to implement the image carousel function?", and the second question instruction b is "How to use JavaScript to create a timer?", the constructed fourth prompt text may be "The following are some question instructions related to JavaScript code generation in front-end development", wherein the embodiment of the present application does not limit the specific form of the fourth prompt text;
[0171] Fill the fourth prompt text and the second question instruction into the third prompt template, and the obtained second input text is "The following 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: ";
[0172] The second input text is then 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?".
[0173] Method 2: Assuming that two second question instructions are randomly sampled, the second question instruction a is "How to use JavaScript to implement the image carousel function?", and the second question instruction b is "How to use JavaScript to create a timer?", 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", wherein the embodiment of the present application does not limit the specific form of the fourth prompt text;
[0174] The fourth prompt text, the second question instruction a and the second question instruction b are sequentially spliced to obtain a first spliced text of "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?";
[0175] The first concatenated text is then 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?".
[0176] In a possible implementation, before calling the first largest 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 largest 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 largest language model.
[0177] Among them, the temperature parameter of the first language model is a hyperparameter. The 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.
[0178] 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; usually, under the premise of ensuring quality, it is 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.
[0179] Specifically, before calling the first largest language model to predict the question instruction based on the first prompt text, the temperature parameter of the first largest language model is configured as the target sampling temperature value, which is equivalent to the temperature parameter corresponding to the first largest language model when generating the initial question instruction being the target sampling temperature value. It is assumed that the temperature parameter corresponding to the first largest language model when generating the first extended question instruction is the first sampling temperature value, and the temperature parameter corresponding to the first largest 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 may 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 largest language model, thereby obtaining a diverse and high-quality seed instruction set.
[0180] In a 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.
[0181] Among them, calling the first largest 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 largest language model, the first largest language model can continuously generate new initial question instructions until the stop condition is met, which is equivalent to inputting the first prompt text into the first largest language model once, and the first largest 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 largest language model multiple times, and each time the first prompt text is input into the first largest language model, the first largest 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".
[0182] 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 a relevant person manually stops the generation process of the first language model, for example, a relevant person clicks a stop button on the display interface or inputs a stop command. The embodiment of the present application does not limit the specific form of the stopping condition.
[0183] Normally, in the same target task, the first prompt text input by the first language model is the same. Since the initial question instruction generated by the first language model is usually obtained by sampling the vocabulary based on 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.
[0184] 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 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 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. On the contrary, 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 the initial question instructions with high content repetition have been eliminated, the retained initial question instructions have a high diversity. The set of retained initial question instructions is used as a seed instruction set, and a seed instruction set with high diversity can be obtained.
[0185] 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 similarities between the currently generated initial problem instruction and each initial problem instruction generated historically can be calculated respectively, and then the largest instruction similarity is selected, and based on the relationship between the instruction similarity and the similarity threshold, it is determined whether to retain or eliminate the currently generated initial problem instruction.
[0186] 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 common number of 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.
[0187] Among them, 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 the initial question instructions with smaller differences in content from the historically generated instructions. Usually, the initial question instructions that are less retained will 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 differences in content from the historically generated instructions will be retained. It is possible that more initial question instructions that are retained will have quality problems, such as inaccurate grammar or inaccurate content, etc., thereby reducing 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, so that the initial question instructions generated by the first language model can strike a balance between diversity and quality, and a diverse and high-quality seed instruction set formed by the initial question instructions can be obtained.
[0188] The complete process of the sample data generation method is described in detail below.
[0189] Reference Fig.10 , Fig.10 A schematic diagram of an optional architecture of a sample data generation method provided in an embodiment of the present application.
[0190] Among them, the overall architecture can include an instruction generation module, an instruction complication module, and a multi-round dialogue module;
[0191] The processing procedure of the instruction generation module is described in detail below.
[0192] First, the instruction generation module obtains a first prompt text for prompting the first language model to generate a question instruction;
[0193] Then, the instruction generation module obtains the target sampling temperature value; configures 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 randomness of the output result of the first large language model
[0194] Then, the instruction generation module obtains task information of the target task, wherein the target task is a downstream task trained based on the sample data;
[0195] Then, the instruction generation module determines the target node matching the task information in the preset task tree according to the task information, wherein the task tree includes multiple layers of nodes, each node carries its own candidate keyword, and the task tree is pre-constructed;
[0196] 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;
[0197] Then, the instruction generation module uses the candidate keyword carried by the target node as the target keyword;
[0198] Then, when the target node is at the target level, the instruction generation module constructs, according to 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 target level is the level after the level at which the root node is located in the task tree;
[0199] 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 a first prompt text for prompting the first language model to generate a question instruction according to the task information based on the associated keyword and the target keyword, wherein the level at which the associated node is located is before the level at which the target node is located;
[0200] 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;
[0201] Then, the instruction generation module randomly samples a first question instruction from the multiple initial question instructions;
[0202] 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;
[0203] 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 a first extended question instruction generated by each instruction expansion; wherein, whenever the first question instruction is expanded, the first question instruction is expanded according to at least one of a plurality of 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 an initial question instruction, and the newly generated initial question instruction is added to the seed instruction set to perform diversified expansions on the seed instruction set.
[0204] The processing procedure of the instruction complication module is described in detail below.
[0205] First, the instruction complication module randomly samples a second problem instruction from a plurality of initial problem instructions;
[0206] 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.
[0207] The processing procedure of the multi-round dialogue module is described in detail below.
[0208] First, the multi-round dialogue module obtains 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 be the answerer for the target task in the multi-round dialogue, and the second role definition text is used to prompt the third largest language model to be the questioner in the multi-round dialogue, and the target task is a downstream task trained based on sample data;
[0209] Then, the multi-round dialogue module inputs the first role definition text into the second largest language model, and inputs the second role definition text into the third largest language model;
[0210] Then, the multi-turn dialogue module inputs the initial question instruction into the second largest language model for answer prediction and generates the target answer text for the first dialogue round;
[0211] 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 target answer text whenever the target answer text is received;
[0212] Then, the multi-turn dialogue module adds the initial question instruction to the second prompt text to obtain the target prompt text;
[0213] Then, the multi-round dialogue module inputs the target prompt text and the target answer text of the first dialogue round into the third language model for question instruction prediction, and generates the target question instruction of the next dialogue round, wherein the target prompt text is used to prompt the third language model to generate question instructions according to each question instruction input into the second language model and the target answer text of each dialogue round;
[0214] Then, the multi-round dialogue module inputs the target question instruction of the next dialogue round into the second largest language model for answer prediction again, until the number of dialogue rounds equals the preset number threshold;
[0215] Finally, sample data is constructed based on the initial question instructions, the target question instructions in multiple rounds of dialogue, and the target answer texts in multiple rounds of dialogue;
[0216] Among them, sample data can also be constructed through single-round problem instructions generated by the instruction generation module and single-round problem instructions generated by the instruction complication module, which is not limited in the embodiments of the present application.
[0217] Based on this, an initial question instruction is generated through the first largest language model, and then the initial question instruction is used as the first question instruction input into the second largest language model, which is equivalent to using the initial question instruction as the starting point of multiple rounds of dialogue. Multiple rounds of dialogue are conducted through the second largest language model and the third largest language model, so that target answer texts and target question instructions for multiple dialogue rounds can be obtained. Then, sample data is constructed through the initial question instruction, the target question instruction and the target answer text. Since the first largest language model can generate high-quality and diverse initial question instructions, the second largest language model can generate high-quality and diverse target answer texts, and the third largest language model can generate high-quality and diverse target question instructions, the complexity and diversity of question instructions can be improved by combining multiple large language models, thereby efficiently obtaining high-quality and diverse sample data.
[0218] The sample data generation method provided in the embodiment of the present application can be applied to a variety of scenarios.
[0219] 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 to prompt the first large language model to generate a question instruction, 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, the initial question instruction is used as the first question instruction input to the second large language model, and the second large language model is called to conduct multiple rounds of dialogue with the third large language model, wherein the second large language model is used to generate a target answer text according to the input question instruction, and the third large language model is used to generate a target question instruction input to the second large language model according to the target answer text; then, based on the initial question instruction, the target question instruction in multiple rounds of dialogue, and the target answer text in 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.
[0220] Specifically, the training effect of the target large language model is shown in Table 1 below:
[0221] Table 1
[0222] Model Target large language model a Target large language model b Baseline 24.39 23.17 After training based on sample data 53.66 51.83
[0223] 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.
[0224] It is to be understood that, although the 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 there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, 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 a plurality of steps or a plurality of 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.
[0225] Reference Fig.11 , Fig.11 This is an optional structural diagram of a sample data generating device provided in an embodiment of the present application. The sample data generating device 1100 includes:
[0226] The first generating module 1101 is used to obtain a first prompt text for prompting 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;
[0227] The second generation module 1102 is used to use the initial question instruction as the first question instruction input to the second largest language model, and call the second largest language model and the third largest language model to conduct multiple rounds of dialogue, wherein the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input to the second largest language model according to the target answer text;
[0228] The sample construction module 1103 is used to construct sample data based on the initial question instruction, the target question instruction in the multi-round dialogue, and the target answer text in the multi-round dialogue.
[0229] Furthermore, the number of the knowledge granularity types of the candidate text is at least one, and the second generating module 1102 is further used for:
[0230] 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 an answerer for a 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 a questioner in a multi-round dialogue, and the target task is a downstream task trained based on sample data;
[0231] The first role definition text is input into the second largest language model, and the second role definition text is input into the third largest language model.
[0232] Furthermore, the second generating module 1102 is specifically used for:
[0233] The initial question instruction is input into the second largest language model for answer prediction, generating the target answer text for the first dialogue round;
[0234] Constructing a second prompt text for prompting the third language model to generate a question instruction according to the target answer text whenever the target answer text is received;
[0235] The second prompt text and the target answer text of the first dialogue round are input into the third language model to predict the question instruction and generate the target question instruction of the next dialogue round;
[0236] The target 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 equals the preset number threshold.
[0237] Furthermore, the second generating module 1102 is specifically used for:
[0238] Adding the initial question instruction to the second prompt text to obtain the target prompt text;
[0239] The target prompt text and the target answer text of the first dialogue round are input into the third largest language model for question instruction prediction to generate the target question instruction of the next dialogue round, wherein the target prompt text is used to prompt the third largest language model to generate question instructions according to each question instruction input into the second largest language model and the target answer text of each dialogue round.
[0240] Furthermore, the first generating module 1101 is specifically used for:
[0241] Obtaining task information of a target task, where the target task is a downstream task trained based on sample data;
[0242] Based on the task information, a first prompt text is constructed for prompting the first language model to generate a question instruction according to the task information.
[0243] Furthermore, the first generating module 1101 is specifically used for:
[0244] According to the task information, a target node matching the task information is determined in a preset task tree, wherein the task tree includes multiple layers of nodes, each of which carries its own candidate keyword;
[0245] The candidate keyword carried by the target node is used as the target keyword, and according to the target keyword, a first prompt text is constructed for prompting the first language model to generate a question instruction according to the task information.
[0246] Furthermore, the first generating module 1101 is specifically used for:
[0247] When the target node is at the target level, constructing a first prompt text for prompting the first language model to generate a question instruction according to the task information according to the target keyword;
[0248] Alternatively, when the target node is located at a level after the target level, an 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.
[0249] Furthermore, the node at the target level carries the third role definition text, and the first generation module 1101 is specifically used for:
[0250] The node associated with the target node and located at the target level is used as the target role definition node, and the third role definition text carried by the target role definition node is used 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;
[0251] According to the target keywords, a first prompt text is constructed for prompting the first language model to generate question instructions according to the task information, and the target role definition text is added to the first prompt text.
[0252] Furthermore, the number of the initial question instructions is multiple, and the sample data generating device further includes a third generating module (not shown in the figure), and the third generating module is specifically used for:
[0253] Randomly sampling a first question instruction from a plurality of initial question instructions;
[0254] Based on the preset expansion strategy, a third prompt text is constructed to prompt the first language model to expand the instruction according to the expansion strategy;
[0255] The third prompt text and the first question instruction are input into the first large language model, the first question instruction is extended to generate a first extended question instruction, and the first extended question instruction is used as the initial question instruction.
[0256] Furthermore, there are multiple extension strategies, and the third generation module is specifically used for:
[0257] Performing multiple instruction expansions on the first problematic instruction to obtain a first extended problematic instruction generated by each instruction expansion;
[0258] Wherein, whenever instruction expansion is performed on the first problematic instruction, instruction expansion is performed on the first problematic instruction according to at least one of a plurality of expansion strategies.
[0259] Furthermore, the number of the initial question instructions is multiple, and the first generating module 1101 is also used for:
[0260] Randomly sampling a second question instruction from a plurality of initial question instructions;
[0261] Construct a fourth prompt text for prompting the first 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 language model for question instruction prediction, generate a second extended question instruction, and use the second extended question instruction as the initial question instruction.
[0262] Furthermore, the first generating module 1101 is also used for:
[0263] Get the target sampling temperature value;
[0264] The temperature parameter of the first large language model is configured as a target sampling temperature value, wherein the target sampling temperature value is used to indicate the degree of randomness of an output result of the first large language model.
[0265] Furthermore, the first generating module 1101 is specifically used for:
[0266] Calling the first language model to predict question instructions based on the first prompt text, and sequentially generating multiple initial question instructions;
[0267] 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.
[0268] The above-mentioned sample data generating device 1100 and the sample data generating method applied to the central node are based on the same inventive concept. An initial question instruction is generated through the first largest language model, and then the initial question instruction is used as the first question instruction input to the second largest language model, which is equivalent to using the initial question instruction as the starting point of multiple rounds of dialogue. Multiple rounds of dialogue are carried out through the second largest language model and the third largest language model, so that target answer texts and target question instructions of multiple dialogue rounds can be obtained, and then sample data is constructed through the initial question instruction, the target question instruction and the target 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 target answer texts, and the third largest language model can generate high-quality and diverse target 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.
[0269] The electronic device for executing the above-mentioned sample data generation method provided in the embodiment of the present application may be a terminal. Fig.12 , Fig.12 This is a partial structural block diagram of a terminal provided in an 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 can understand that Fig.12 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0270] 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 disposed on the front panel of the terminal, and the rear camera is disposed 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 the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.
[0271] 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 .
[0272] The input unit 1230 may be used 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 .
[0273] The display unit 1240 may be used to display input information or provided information and various menus of the terminal. The display unit 1240 may include a display panel 1241 .
[0274] The audio circuit 1260 , the speaker 1261 , and the microphone 1262 may provide an audio interface.
[0275] The power source 1290 may be alternating current, direct current, a disposable battery, or a rechargeable battery.
[0276] The number of sensors 1250 may 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:
[0277] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1280 can control the display unit 1240 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting game or user motion data.
[0278] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The processor 1280 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0279] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1240. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the processor 1280 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1240, the processor 1280 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1240. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0280] The optical sensor is used to collect the ambient light intensity. In one embodiment, the processor 1280 can control the display brightness of the display unit 1240 according to 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 according to the ambient light intensity collected by the optical sensor.
[0281] In this embodiment, the processor 1280 included in the terminal can execute the sample data generating method of the previous embodiment.
[0282] The electronic device for executing the above-mentioned sample data generation method provided in the embodiment of the present application may also be a server. Fig.13 , Fig.13This is a partial structural block diagram of a server provided in an 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 may be short-term 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 in the server 1300. Furthermore, the central processing unit 1322 may 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.
[0283] 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 ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0284] The processor in the server 1300 can be used to execute the sample data generating method.
[0285] The embodiment of the present application also 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 above embodiments.
[0286] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned sample data generation method.
[0287] 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 sequence. 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 be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising 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.
[0288] It should be understood that in the present 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 objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single 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.
[0289] It should be understood that in the description of the embodiments of the present application, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0290] In the several embodiments provided in the present 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 only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, 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 interfaces, devices or units, which can be electrical, mechanical or other forms.
[0291] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0292] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0293] 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 is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0294] It should also be understood that the various implementations provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0295] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Technical personnel familiar with the field can also make various equivalent modifications or substitutions under the shared conditions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for generating sample data, characterized in that: include: Acquire a first prompt text for prompting 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; The initial question instruction is used as the first question instruction input to the second largest language model, and the second largest language model is called to conduct multiple rounds of dialogue with the third largest language model, wherein the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input to the second largest language model according to the target answer text; Sample data is constructed based on the initial question instruction, the target question instructions in multiple rounds of dialogue, and the target answer texts in multiple rounds of dialogue.
2. The sample data generation method according to claim 1, characterized in that: Before the initial question instruction is used as the first question instruction input into the second largest language model, the sample data generation method further 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 an answerer for a 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 a questioner in the multiple rounds of dialogue, and the target task is a downstream task trained based on the sample data; The first role definition text is input into the second largest language model, and the second role definition text is input into the third largest language model.
3. The sample data generation method according to claim 1, characterized in that: The step of using the initial question instruction as the first question instruction input into the second largest language model, and calling the second largest language model to conduct multiple rounds of dialogue with the third largest language model includes: Inputting the initial question instruction into the second largest language model for answer prediction to generate a target answer text for the first dialogue round; Constructing a second prompt text for prompting the third language model to generate a question instruction according to the target answer text whenever receiving the target answer text; Inputting the second prompt text and the target answer text of the first dialogue round into the third language model to perform question instruction prediction, and generate a target question instruction of the next dialogue round; The target question instruction of the next dialogue round is input into the second largest language model to perform answer prediction again until the number of dialogue rounds is equal to a preset number threshold.
4. The sample data generation method according to claim 3, characterized in that: The step of inputting the second prompt text and the target answer text of the first dialogue round into the third language model to predict question instructions and generate a target question instruction of the next dialogue round includes: Adding the initial question instruction to the second prompt text to obtain a target prompt text; The target prompt text and the target answer text of the first dialogue round are input into the third largest language model to predict question instructions, and generate target question instructions for the next dialogue round, wherein the target prompt text is used to prompt the third largest language model to generate question instructions based on each question instruction input into the second largest language model and the target answer text of each dialogue round.
5. The sample data generation method according to claim 1, characterized in that: The step of obtaining a first prompt text for prompting the first language model to generate a question instruction includes: Acquire task information of a target task, wherein the target task is a downstream task trained based on the sample data; Based on the task information, a first prompt text is constructed for prompting the first large language model to generate a question instruction according to the task information.
6. The sample data generation method according to claim 5, characterized in that: The step of constructing, based on the task information, a first prompt text for prompting the first language model to generate a question instruction according to the task information includes: According to the task information, determining a target node matching the task information in a preset task tree, wherein the task tree includes multiple layers of nodes, each of which carries its own candidate keyword; The candidate keyword carried by the target node is used as a target keyword, and a first prompt text is constructed based on the target keyword to prompt the first language model to generate a question instruction according to the task information.
7. The sample data generation method according to claim 6, characterized in that: The step of constructing, 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 includes: When the level where the target node is located is the target level, constructing a first prompt text for prompting the first language model to generate a question instruction according to the task information according to the target keyword, wherein the target level is a level after the level where the root node is located in the task tree; Alternatively, when the level at which the target node is located is a level after the target level, an 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 based on the task information, wherein the level at which the associated node is located is before the level at which the target node is located.
8. The sample data generation method according to claim 6, characterized in that: The level after the level where the root node in the task tree is located is the target level, and the node at the target level carries the third role definition text. Before taking the candidate keyword carried by the target node as the target keyword, the sample data generation method further includes: Using a node associated with the target node and located at the target level as a target role definition node, and using 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 language model to serve as a questioner for the target task; The target role definition text is input into the first language model.
9. The sample data generation method according to claim 1, characterized in that: The number of the initial question instructions is multiple, and before the initial question instruction is used as the first question instruction input into the second largest language model, the sample data generation method further includes: Randomly sampling a first question instruction from the plurality of initial question instructions; Based on a preset expansion strategy, construct a third prompt text for prompting the first language model to perform instruction expansion according to the expansion strategy; The third prompt text and the first question instruction are input into the first large language model, the first question instruction is extended to generate a first extended question instruction, and the first extended question instruction is used as the initial question instruction.
10. The sample data generation method according to claim 9, characterized in that: The number of the extension strategies is multiple, and the step of extending the first problem instruction to generate an extended problem instruction includes: Performing multiple instruction expansions on the first problematic instruction to obtain a first extended problematic instruction generated by each instruction expansion; Wherein, whenever the first problematic instruction is expanded, the first problematic instruction is expanded according to at least one of the plurality of expansion strategies.
11. The sample data generation method according to claim 1, characterized in that: The number of the initial question instructions is multiple, and before the initial question instruction is used as the first question instruction input into the second largest language model, the sample data generation method further includes: Randomly sampling a second question instruction from the plurality of 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.
12. The sample data generation method according to claim 1, characterized in that: Before calling the first language model to predict question instructions based on the first prompt text, the sample data generation method further includes: Get the target sampling temperature value; The temperature parameter of the first large language model is configured as the target sampling temperature value, wherein the target sampling temperature value is used to indicate the degree of randomness of an output result of the first large language model.
13. The sample data generation method according to claim 1, characterized in that: The calling the first language model to predict a question instruction based on the first prompt text to generate an initial question instruction includes: Calling the first language model to predict question instructions based on the first prompt text, and sequentially generating a plurality of initial question instructions; Wherein, whenever the 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.
14. A sample data generating device, characterized in that: include: A first generating module is used to obtain a first prompt text for prompting the first large language model to generate a question instruction, call the first large language model to predict the question instruction based on the first prompt text, and generate an initial question instruction; A second generation module is used to use the initial question instruction as the first question instruction input to the second largest language model, and call the second largest language model and the third largest language model to conduct multiple rounds of dialogue, wherein the second largest language model is used to generate a target answer text according to the input question instruction, and the third largest language model is used to generate a target question instruction input to the second largest language model according to the target answer text; The sample construction module is used to construct sample data based on the initial question instruction, the target question instruction in multiple rounds of dialogue, and the target answer text in multiple rounds of dialogue.
15. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the sample data generating method according to any one of claims 1 to 13 is implemented.
16. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the sample data generating method according to any one of claims 1 to 13 is implemented.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the sample data generating method according to any one of claims 1 to 13 is implemented.
Citation Information
Patent Citations
Method for establishing pre-training language model and semantic analysis method and device
CN114547329A
Intelligent dialogue processing method and device, equipment and storage medium
CN116737910A
Large language model training method and device and text processing method and device
CN117149989A
Synthetic data generation for training of natural language understanding models
US20220084510A1
User intention recognition method and apparatus based on statement context relationship prediction
US20230080671A1
Cited By
Method and device for testing multi-round dialogue ability of large model
CN119066182A
Model knowledge distillation method and device, electronic equipment and readable storage medium
CN119670806A
Multi-user large model interaction method, device and platform based on tree structure
CN120234397A
Cloud function configuration detection method based on large language model
CN120822615A
Training data generation method, electronic equipment, storage medium and product
CN120994799A
