Interaction method and device based on instruction following, equipment and storage medium
By breaking down complex instructions into multiple logical branch samples and training an instruction-following model, the problem of insufficient machine dialogue's ability to follow multi-branch instructions is solved, and the interaction effect is improved.
Patent Information
- Application Number
- CN202410485748.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2025-10-28
AI Technical Summary
Existing machine dialogue-based interaction solutions have poor compliance capabilities when processing complex instructions with multiple logical branches, and are prone to semantic understanding loss or errors, resulting in poor interaction effects.
The user input text is analyzed through the instruction following model, and training is performed using multi-branch instruction samples, instruction branch samples, and simulated input samples. Complex instructions are broken down into multiple logical branch samples, and accurate response samples are generated through the language model to ensure that the model responds under the correct trigger conditions.
It improves the instruction following model's ability to follow complex instructions with multiple branches, reduces semantic understanding gaps and errors, and enhances the interactive effect of machine dialogue.
Smart Images

Figure CN120849537A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an interactive method, apparatus, device, and storage medium based on instruction following. Background Technology
[0002] With the development of computer technology, machine dialogue-based interaction solutions enable flexible two-way communication with users, and their applications are becoming increasingly widespread. Machine dialogue-based interaction solutions typically utilize Large Language Models (LLMs). For example, a prompt text is embedded within the LLM, and the LLM generates a response text that follows the prompt based on the prompt text and the user's input, thus enabling dialogue with the user based on the picture book content.
[0003] As machine dialogue applications become more widespread, the instructions for large language models become increasingly complex. It is often necessary to generate complex instructions with logical branches for large language models. However, traditional large language models have poor ability to follow complex instructions with multiple logical branches, which can easily lead to missing or incorrect semantic understanding, resulting in poor interactive effects based on machine dialogue. Summary of the Invention
[0004] This application provides an instruction-following-based interaction method, apparatus, device, and storage medium to address the technical problems of poor follow-up ability on complex instructions with multiple branches, easy occurrence of semantic understanding loss or errors, and poor interaction effect based on machine dialogue. It can effectively improve the follow-up ability on complex instructions with multiple branches, reduce the occurrence of semantic understanding loss or errors, and improve the interaction effect based on machine dialogue.
[0005] In a first aspect, embodiments of this application provide an interaction method based on instruction compliance, comprising:
[0006] Get the user's input text;
[0007] The user input text is input into the instruction following model. The instruction following model determines the target response text based on the user input text and the instruction text parsed from the user input text. The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each of the simulated input samples. The instruction branch samples are obtained by branching the multi-branch instruction samples.
[0008] This application embodiment determines the target response text based on user input text and instruction text using an instruction following model. The instruction following model is trained on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample. Multiple instruction branch samples are obtained by branching the multi-branch instruction samples. By decomposing complex multi-branch instruction samples into multiple instruction branch samples, and training the instruction following model during the training phase based on the simulated input samples and response samples corresponding to each instruction branch sample, the instruction following model can better understand and process complex instruction tasks, improving its ability to follow instructions with multiple branches, reducing semantic understanding gaps or errors, and enhancing the interactive effect of machine dialogue.
[0009] Furthermore, the instruction branch sample includes trigger condition samples and processing logic samples, and the steps for collecting the simulated input samples and the response samples include:
[0010] By simulating the trigger condition samples of multiple instruction branch samples, simulated input samples that satisfy the trigger condition samples are obtained for each instruction branch sample.
[0011] Determine the response sample that responds to the simulated input sample based on the processing logic sample of the instruction branch sample.
[0012] As described above, by determining the simulated input samples corresponding to multiple instruction branch samples and the response samples of each simulated input sample under the corresponding processing logic sample, and by fine-tuning the training instruction following model based on the multi-branch instruction samples, the simulated input samples and the response samples, the instruction following model can better understand and process the task of complex instructions, and improve the following ability of the instruction following model on complex instructions with multiple branches.
[0013] Furthermore, the step of obtaining simulated input samples that satisfy the triggering condition samples for each instruction branch sample by simulating triggering condition samples of multiple instruction branch samples includes:
[0014] By simulating the triggering condition samples of multiple instruction branch samples of a multi-branch instruction sample using a set language model, candidate input samples that satisfy the triggering condition samples are obtained for each instruction branch sample.
[0015] The language model is used to generate verification conditions based on the candidate input samples, and the simulated input samples are determined from the candidate input samples according to the verification conditions and the instruction branch samples.
[0016] The above describes a method that simulates trigger condition samples of multiple instruction branch samples using a defined language model. This method obtains candidate input samples that satisfy the trigger condition samples for each instruction branch sample. Based on these candidate input samples, a verification condition is generated using the defined language model. The simulated input sample can be accurately determined according to the verification condition and the instruction branch sample. This method effectively ensures that the language model is correctly simulating the trigger condition, thereby improving the efficiency of the instruction compliance model and its performance in compliant with complex instructions.
[0017] Furthermore, determining the simulated input sample from the candidate input samples based on the verification conditions and the instruction branch samples includes:
[0018] Determine the verification classification label of the verification condition and the branch classification label of the instruction branch sample;
[0019] Candidate input samples whose verification classification labels and branch classification labels are consistent are identified as simulated input samples.
[0020] As described above, by accurately determining the simulated input samples based on the verification classification labels of the verification conditions and the branch classification labels of the instruction branch samples, the candidate input samples are ensured to meet the conditions and logic of the corresponding instruction branch samples, effectively improving the quality of the output simulated input samples and ensuring that the instructions follow the model training effect.
[0021] Furthermore, after determining the verification classification label of the verification condition and the branch classification label of the instruction branch sample, the method further includes:
[0022] If the verification classification label and the branch classification label are inconsistent, the trigger condition sample of the instruction branch sample is re-simulated using the set language model, and the candidate input sample corresponding to the instruction branch sample is updated.
[0023] As described above, by regenerating candidate input samples corresponding to the instruction branch samples when the verification classification label and the branch classification label are inconsistent, and only when the simulation and verification of the trigger condition sample are correct, the candidate input samples are used as simulated input samples, which effectively improves the accuracy of simulated input samples. It eliminates the need for manual construction and screening of simulated input samples, and effectively improves the training efficiency of the instruction following model while ensuring the training effect of the instruction following model.
[0024] Furthermore, determining the response sample for responding to the simulated input sample based on the processing logic sample of the instruction branch sample includes:
[0025] The response sample is determined by using a defined language model to respond to the simulated input sample based on the processing logic sample of the instruction branch sample.
[0026] As described above, the language model obtains the response samples of the simulated input samples under the corresponding processing logic samples. The language model has a good follow-up effect in the response task of a single logic branch. The pre-trained large language model can be used to obtain accurate response samples without the need for manual construction of response samples. While ensuring the training effect of the instruction follow-up model, it effectively improves the training efficiency of the instruction follow-up model.
[0027] Furthermore, before obtaining the simulated input sample where each instruction branch sample satisfies the trigger condition sample by simulating trigger condition samples of multiple instruction branch samples, the method further includes:
[0028] Based on the multiple logical branches of multiple multi-branch instruction samples, each multi-branch instruction sample is decomposed into multiple instruction branch samples, and the instruction branch samples include trigger condition samples and processing logic samples.
[0029] As described above, by decomposing the multi-branch instruction sample into multiple instruction branch samples based on the multiple logical branches of the multi-branch instruction sample, the efficiency of determining the simulated input sample corresponding to the instruction branch sample is effectively improved, thereby improving the training efficiency and accuracy of the instruction following model.
[0030] In a second aspect, embodiments of this application provide an instruction-following-based interactive device, including an input acquisition module and an instruction-following module, wherein:
[0031] The input acquisition module is used to acquire user input text;
[0032] The instruction following module is used to input the user input text into the instruction following model, and the instruction following model determines the target response text based on the user input text and the instruction text parsed from the user input text. The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each of the simulated input samples. The instruction branch samples are obtained by branching the multi-branch instruction samples.
[0033] This application embodiment determines the target response text based on user input text and instruction text using an instruction following model. The instruction following model is trained on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample. Instruction branch samples are obtained by branching multi-branch instruction samples. By decomposing complex multi-branch instruction samples into multiple instruction branch samples, and training the instruction following model on simulated input samples and response samples corresponding to each instruction branch sample during the training phase, the instruction following model can better understand and process complex instruction tasks, improve its following ability on complex instructions with multiple branches, reduce semantic understanding gaps or errors, and improve the interactive effect of machine dialogue.
[0034] In a third aspect, embodiments of this application provide an instruction-following interactive device, including: a memory and one or more processors;
[0035] The memory is used to store one or more programs;
[0036] When the one or more programs are executed by the one or more processors, the one or more processors implement the instruction-following-based interaction method as described in the first aspect.
[0037] In a fourth aspect, embodiments of this application provide a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform the instruction-following-based interaction method as described in the first aspect. Attached Figure Description
[0038] Figure 1 This is a flowchart of an instruction-based interaction method provided in an embodiment of this application;
[0039] Figure 2 This is a schematic diagram of a simulated input sample and response sample collection and training process provided in an embodiment of this application;
[0040] Figure 3 This is a schematic diagram of a simulated input sample determination process provided in an embodiment of this application;
[0041] Figure 4 This is a schematic diagram of the structure of an instruction-following interactive device provided in an embodiment of this application;
[0042] Figure 5 This is a schematic diagram of the structure of an interactive device based on instruction compliance provided in an embodiment of this application. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but additional steps not included in the drawings may also be present. The above processes can correspond to methods, functions, procedures, subroutines, subroutines, etc.
[0044] The instruction-following-based interaction method provided in this application can be applied to machine dialogue-based dialogue interaction scenarios (such as picture book reading, dialogue systems, automated customer service, and other machine dialogue scenarios). It aims to decompose complex multi-branch instruction samples into multiple instruction branch samples, and train the instruction-following model based on the simulated input samples and response samples corresponding to each instruction branch sample during the training phase. This enables the instruction-following model to better understand and process complex instruction tasks, improves the instruction-following model's ability to follow complex instructions with multiple branches, reduces the occurrence of semantic understanding gaps or errors, and improves the interaction effect of machine dialogue.
[0045] In existing machine dialogue-based interaction schemes, large language models (LLMs) are typically used to conduct dialogue based on set prompts, dialogue history, and user input. However, LLMs have poor adherence to complex instructions with multiple branches, easily leading to semantic misunderstandings or errors, resulting in poor interaction performance. Therefore, this application provides an instruction-following-based interaction method to address the technical problems of poor adherence to complex instructions with multiple branches, semantic misunderstandings, and poor interaction performance in existing machine dialogue-based interaction schemes.
[0046] Figure 1 A flowchart of an instruction-based interaction method provided in this application embodiment is given. The instruction-based interaction method provided in this application embodiment can be executed by an instruction-based interaction device. The instruction-based interaction device can be implemented by hardware and / or software and integrated into an instruction-based interaction device (e.g., a learning tablet).
[0047] The following description uses an instruction-following interactive device as an example to illustrate the execution of an instruction-following-based interaction method. (Reference) Figure 1 The interaction method based on instruction follow-up includes:
[0048] S110: Obtain user input text.
[0049] For example, the user input text is obtained. Optionally, the user input text can be entered by the user through text input or through voice input. After obtaining the user's voice information, speech recognition is performed on the voice information to obtain the corresponding user input text.
[0050] In one embodiment, user input text can be based on conversation history (e.g., the user has already engaged in conversation on the same conversation page before entering the current user input text, and the current user input text can be a continuation of the conversation history), or it can be a separate input (e.g., the user has not engaged in conversation on the same conversation page before entering the current user input text, or the user has already engaged in conversation on the same conversation page before entering the current user input text, but the current user input text may be unrelated to the conversation history).
[0051] In one embodiment, user-input text can be entered and displayed on a designated dialogue page. Within the same dialogue page, previously entered text and responses based on the user's input can serve as dialogue history text. Users can enter text on an existing dialogue page or on a newly created dialogue page. Optionally, a newly created dialogue page can display dialogue text based on predefined instructions. For example, in a picture book reading interaction scenario, dialogue text can be displayed based on the picture book content, such as "What are your thoughts on the picture book content?", to guide the user in dialogue. Optionally, multiple dialogue pages can be opened on an interactive device based on instructions. These multiple dialogue pages are independent of each other; that is, a dialogue on one dialogue page will not affect other dialogue pages.
[0052] S120: Input the user input text into the instruction follow-up model, and determine the target response text based on the user input text and the instruction text parsed from the user input text.
[0053] The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample. The multiple instruction branch samples are obtained by branching the multi-branch instruction samples.
[0054] For example, after receiving the user's input text, the user's input text and instruction text from the current dialogue page are input into the instruction follow-up model. The instruction follow-up model analyzes and processes the user's input text and instruction text to obtain the target response text for the user's input text. In one embodiment, the user's input text, dialogue history text, and instruction text from the current dialogue page can also be input into the instruction follow-up model. The instruction follow-up model analyzes and processes the user's input text, dialogue history text, and instruction text to obtain the target response text for the user's input text. Optionally, after obtaining the target response text, the target response text can be displayed on the dialogue page that received the user's input text, or the target response text can be converted into a corresponding response text audio and played, allowing for dialogue interaction with the user through voice interaction, thereby improving the user experience.
[0055] The instruction text provided in this solution can be obtained by parsing user input text. For example, if multiple instruction texts are configured in the instruction compliance model, after receiving user input text, the model parses the user input text and determines one instruction text from among the multiple instruction texts to indicate a response to the current user input text; that is, the instruction text obtained by parsing the user input text. Optionally, different instruction texts can correspond to different user intentions. The user intention can be analyzed based on the user input text, and an instruction text to indicate a response to the current user input text can be determined from among the multiple instruction texts based on the user intention.
[0056] In one embodiment, the instruction text provided by this solution can be instruction text containing logical branches, which can instruct the instruction following model to execute tasks containing logical branches. Here, a task containing logical branches can be understood as a task that requires selecting different processing logic based on the execution result of the previous step. For example, when the instruction is set as "Help me check if there are any meeting rooms for 10 people tomorrow; if so, book one for me; if not, check for the day after tomorrow," the operation logic of the instruction following model needs to decide based on whether there are meeting rooms that meet the conditions tomorrow. At this time, the task corresponding to the instruction needs to determine the corresponding operation based on "Are there any meeting rooms for 10 people tomorrow?", that is, based on the query result, there are two branches: "Book a meeting room" and "Check for a meeting room for the day after tomorrow." The query result of "Are there any meeting rooms for 10 people tomorrow?" (i.e., "A meeting room for 10 people is available tomorrow" and "There are no meeting rooms for 10 people tomorrow") can serve as the triggering conditions for the two branches. When the instruction is set to "Listen to your friend's reply. If what your friend says is harmful to the physical and mental health of children and adolescents, you should correct him and tell him the correct behavioral norms. If what your friend says is irrelevant to the current topic, suggest that he return to the topic discussion. If what your friend says is very pertinent, express your appreciation and your opinion," the instruction follows the operational logic that the model needs to execute, and is divided into three logical branches based on the user's answer (user input text): "Correct him and tell him the correct behavioral norms," "Suggest that he return to the topic discussion," and "Express your appreciation and your opinion." Different user answers correspond to different triggering conditions for different logical branches (e.g., answers of "harmful to the physical and mental health of children and adolescents," "irrelevant to the current topic," and "very pertinent").
[0057] The instruction following model provided in this scheme is trained based on simulated input samples corresponding to multi-branch instruction samples (containing prompts with multiple logical branches), multiple instruction branch samples (containing prompts with a single logical branch), and response samples corresponding to each simulated input sample. Multiple instruction branch samples are obtained by branching from the multi-branch instruction samples. A multi-branch instruction sample can be understood as an instruction containing multiple logical branches. A multi-branch instruction sample can be branched based on its contained logical branches to obtain multiple instruction branch samples containing paired trigger conditions and processing logic. Different instruction branch samples of the same multi-branch instruction sample are independent of each other. There is a one-to-one correspondence between instruction branch samples and simulated input samples; that is, when the trigger condition of an instruction branch sample is met, the operation corresponding to the instruction following model is performed according to the processing logic corresponding to that trigger condition.
[0058] The response samples provided in this scheme can be understood as the response text obtained by responding based on the instruction branch samples when the simulated input sample is satisfied. Optionally, since the instruction branch samples are instruction texts of a single logical branch, the large language model performs well in response tasks with a single logical branch. A pre-trained large language model can be used to output response samples corresponding to the simulated input sample based on the processing logic in the instruction branch samples. Here, instructions can be understood as text fragments used to guide the model (e.g., the large language model) to generate specific types of output, providing context for the model and stimulating it to generate topic-related responses.
[0059] It should be explained that, since the response samples provided by this solution are obtained based on the instruction branch samples and triggering conditions of a single logical branch, and the instruction branch samples are obtained by decomposing multi-branch instruction samples, the trained instruction following model can correctly handle complex instruction texts, and the instruction following effect is even better in multi-branch instruction texts.
[0060] In one possible embodiment, the instruction branch samples provided by this solution include trigger condition samples and processing logic samples, such as... Figure 2 The provided schematic diagram illustrates a process for collecting simulated input and response samples. The steps for collecting simulated input and response samples provided by this solution include S101-102:
[0061] S101: By simulating the trigger condition samples of multiple instruction branch samples, simulated input samples that satisfy the trigger condition samples of each instruction branch sample are obtained.
[0062] For example, multiple instruction branch samples are determined for each multi-branch instruction sample, and the triggering condition samples for each instruction branch sample are simulated to obtain the simulated input samples corresponding to each instruction branch sample. When the simulated input samples are input into the instruction compliance model, if the simulated input samples satisfy the triggering condition samples, the output of the instruction compliance model is obtained by processing the simulated input samples according to the processing logic corresponding to the instruction branch samples.
[0063] In one embodiment, the instruction-following-based interaction method provided by this solution, before obtaining the simulated input sample that satisfies the trigger condition sample of each instruction branch sample by simulating the trigger condition sample of multiple instruction branch samples, further includes: decomposing each multi-branch instruction sample into multiple instruction branch samples according to the multiple logical branches of multiple multi-branch instruction samples, wherein the instruction branch sample includes trigger condition sample and processing logic sample.
[0064] For example, multiple multi-branch instruction samples containing multiple logical branches are collected. Based on the multiple logical branches of each multi-branch instruction sample, each sample is further divided into multiple instruction branch samples. Each instruction branch sample corresponds to one logical branch, and each branch sample includes a one-to-one trigger condition sample and a processing logic sample. This solution effectively improves the efficiency of determining the simulated input samples corresponding to the instruction branch samples by decomposing the multi-branch instruction samples into multiple instruction branch samples based on their multiple logical branches, thereby improving the training efficiency and accuracy of the instruction following model.
[0065] For example, suppose a multi-branch instruction sample is: "During picture book reading, use a large model to provide appropriate feedback to what children say. When children discuss pictures related to the characters and plot, answer questions, provide feedback, and offer encouragement; when children discuss irrelevant things, guide them back to the picture book; when children discuss illegal or rule-breaking things, provide positive guidance and intervention; when children's expressions are unclear, make guesses and clarify." This contains four logical branches: Logical Branch 1: "When children discuss pictures related to the characters and plot, answer questions, provide feedback, and offer encouragement"; Logical Branch 2: "When children discuss irrelevant things, guide them back to the picture book"; Logical Branch 3: "When children discuss illegal or rule-breaking things, provide positive guidance and intervention"; and Logical Branch 4: "When children's expressions are unclear, make guesses and clarify." The multi-branch instruction sample was decomposed into four instruction branch samples (instruction branch samples 1-4). Among them, the trigger condition sample A corresponding to instruction branch sample 1 is "child users discuss picture book related images and plots", and the corresponding processing logic sample A is "answer questions, provide feedback, and encourage". The trigger condition sample B corresponding to instruction branch sample 2 is "child users discuss irrelevant things", and the corresponding processing logic sample B is "guide back to the picture book". The trigger condition sample C corresponding to instruction branch sample 3 is "child users discuss illegal and irregular things", and the corresponding processing logic sample C is "positive guidance and intervention". The trigger condition sample D corresponding to instruction branch sample 4 is "child users' expression is unclear", and the corresponding processing logic sample D is "guess and clarify".
[0066] In one possible embodiment, such as Figure 3 As shown in the schematic diagram of the simulated input sample determination process, the interactive method based on instruction compliance provided in this solution obtains simulated input samples that satisfy the triggering condition samples for each instruction branch sample by simulating the triggering condition samples of multiple instruction branch samples, including:
[0067] S1011: Simulate the triggering condition samples of multiple instruction branch samples of a multi-branch instruction sample using a set language model, and obtain candidate input samples that satisfy the triggering condition samples for each instruction branch sample.
[0068] S1012: Generate verification conditions based on candidate input samples using the set language model, and determine simulated input samples from candidate input samples according to the verification conditions and instruction branch samples.
[0069] For example, multiple instruction branch samples are determined for each multi-branch instruction sample, and each instruction branch sample includes a corresponding trigger condition sample and a processing logic sample. For the trigger condition sample of each instruction branch sample, the trigger condition sample is simulated using a pre-trained language model (e.g., a Large Language Model, LLM) to generate input text that satisfies the trigger condition sample (i.e., simulated user input text). The generated input text is then used as a candidate input sample for the corresponding instruction branch sample. For example, a prompt is input to the language model instructing it to simulate the corresponding input text based on the trigger condition, so that the language model can output the corresponding text based on the prompt.
[0070] In this approach, the candidate input text output by the language model may not correspond to the triggering conditions. To ensure that the language model is correctly simulating the triggering conditions, it is necessary to further determine whether to use the candidate input text as the simulated input sample. This scheme, after obtaining the candidate input samples corresponding to each instruction branch, generates verification conditions based on the candidate input samples for each candidate input sample through the language model. For example, an instruction is given to the language model requiring it to determine the conditions for outputting candidate input samples based on the input, such as requiring the language model to perform classification based on the input. In this case, the candidate input samples serve as the input for the language model's classification, and the verification conditions serve as the output of the language model's classification. By analyzing each candidate input sample based on the instruction, the language model obtains the verification conditions corresponding to each candidate input sample.
[0071] Furthermore, for each instruction branch sample, a simulated input sample is determined from the candidate input samples based on the corresponding verification conditions and the instruction branch sample itself. That is, the candidate input sample that matches the verification conditions is determined as the simulated input sample for the instruction branch sample. This scheme simulates the triggering condition samples of multiple instruction branch samples using a defined language model, obtaining candidate input samples that satisfy the triggering conditions for each instruction branch sample. Verification conditions are then generated based on these candidate input samples using the defined language model. This allows for accurate determination of the simulated input sample based on the verification conditions and instruction branch samples, effectively ensuring that the language model correctly simulates the triggering conditions, thus improving the efficiency of the instruction compliance model and its performance on complex instructions. For each instruction branch sample, this scheme uses a language model to simulate the triggering condition samples, generating candidate input samples that meet the triggering conditions. The language model then checks the generated candidate input samples to ensure they conform to the conditions and logic of the corresponding instruction branch sample. This allows for timely detection and correction of candidate input samples that do not meet the branch conditions, reducing the error rate of the simulated input samples, improving the quality of the output simulated input samples, and ensuring the training effect of the instruction compliance model.
[0072] In one possible embodiment, the instruction-following-based interactive method provided by this solution determines simulated input samples from candidate input samples based on verification conditions and instruction branch samples. This can be achieved by: determining the verification classification label of the verification conditions and the branch classification label of the instruction branch samples; and determining candidate input samples whose verification classification labels and branch classification labels are consistent as simulated input samples.
[0073] For example, after determining the verification conditions corresponding to the candidate input samples, the verification classification label of the verification conditions and the branch classification label of the instruction branch samples are determined. It is then determined whether the verification classification label and the branch classification label are consistent, and the candidate input samples whose verification classification labels and the branch classification labels of the instruction branch samples are consistent are determined as simulated input samples.
[0074] In one embodiment, branch classification labels corresponding to different instruction branch samples can be predetermined (e.g., when splitting a multi-branch instruction sample into multiple instruction branch samples, the branch classification label corresponding to each instruction branch sample is determined). Optionally, a verification classification label can be determined based on a character at a set position in the verification condition. When the verification classification label and the branch classification label are consistent, the candidate input sample is determined as a simulated input sample.
[0075] Optionally, the instructions input to the language model can be used to require the language model to output validation classification labels corresponding to the validation conditions. The instructions for the language model require it to classify the input, where candidate input samples serve as input for classification, and branch classification labels corresponding to different instruction branch samples serve as output. The language model analyzes each candidate input sample based on the instructions, and the first letter output by the language model is the validation classification label. This scheme accurately determines the simulated input samples based on the validation classification labels of the validation conditions and the branch classification labels of the instruction branch samples, ensuring that candidate input samples conform to the conditions and logic of the corresponding instruction branch samples, effectively improving the quality of the output simulated input samples and guaranteeing that the instructions follow the model training results.
[0076] In one embodiment, the instruction-following-based interaction method provided by this solution, after determining the verification classification label of the verification condition and the branch classification label of the instruction branch sample, further includes: when the verification classification label and the branch classification label are inconsistent, re-simulating the trigger condition sample of the instruction branch sample through a set language model, and updating the candidate input sample corresponding to the instruction branch sample.
[0077] For example, when the verification class label and the branch class label are inconsistent, the instruction branch sample can be put back into the language model. The trigger condition sample of the instruction branch sample is re-simulated using the set language model, the candidate input sample corresponding to the instruction branch sample is updated, and then it is determined whether the newly generated candidate input sample can be used as a simulated input sample. This solution effectively improves the accuracy of simulated input samples by regenerating the candidate input sample corresponding to the instruction branch sample when the verification class label and the branch class label are inconsistent. Only when the simulation and verification of the trigger condition sample are both correct is the candidate input sample used as a simulated input sample. It eliminates the need for manual construction and screening of simulated input samples, and effectively improves the training efficiency of the instruction compliance model while ensuring the training effect of the instruction compliance model.
[0078] In one embodiment, for each multi-branch instruction sample, different instruction branch samples or trigger condition samples within instruction branch samples are recorded using different branch classification labels. For example, the trigger condition sample A corresponding to instruction branch sample 1 is "child users discuss picture book-related images and storylines," and the corresponding processing logic sample A is "answering questions, providing feedback, and offering encouragement," with the corresponding branch classification label being "A." When generating verification conditions based on candidate input samples using a set language model, the corresponding verification conditions can be represented by outputting verification classification labels when the language model generates verification conditions based on candidate input samples. Based on this, whether the set consistency condition is met can be determined by whether the verification classification label of the verification condition is consistent with the verification classification label of the instruction branch sample or trigger condition sample. For example, if the verification classification label of the verification condition is the same as the verification classification label of the instruction branch sample or trigger condition sample, it can be determined that the set consistency condition is met.
[0079] For example, the multi-branch instruction sample is split into four instruction branch samples 1-4, with corresponding branch classification labels AD. The trigger condition sample A for instruction branch sample 1 is "child users discuss picture book related images and plots", and the corresponding processing logic sample A is "answer questions, provide feedback, and encourage". The trigger condition sample B for instruction branch sample 2 is "child users discuss irrelevant things", and the corresponding processing logic sample B is "guide back to the picture book". The trigger condition sample C for instruction branch sample 3 is "child users discuss illegal or irregular things", and the corresponding processing logic sample C is "positive guidance and intervention". The trigger condition sample D for instruction branch sample 4 is "child users' expression is unclear", and the corresponding processing logic sample D is "guessing and clarifying".
[0080] Taking the trigger condition sample B corresponding to instruction branch sample 2 as an example, the instruction (prompt) "Now please start a new topic for chatting. The new topic should not include the people, items, time, or place of the original topic, nor should it include the opinions (whether for or against) of the original topic." is input into the set language model. The language model outputs the text based on this instruction and the dialogue history. The text output by the language model is the candidate input sample corresponding to instruction branch sample 2. The same logic applies to other instruction branch samples to obtain the candidate input samples corresponding to each instruction branch sample.
[0081] Taking the candidate input sample corresponding to instruction branch sample 2 as an example, the instruction "Based on the dialogue history and user input, determine which category the user input belongs to: A. The child user discusses picture book related images and storylines, B. The child user discusses irrelevant matters, C. The child user discusses illegal or irregular matters, D. The child user's expression is unclear. Directly output one of the options A, B, C, or D." causes the language model to output based on this instruction and the dialogue history. The first character output by the language model is used as the verification classification label of the verification condition. If the verification classification label of the verification condition is consistent with the branch classification label of the instruction branch sample (for example, both the verification classification label and the branch classification label are "B"), then the candidate input sample is determined as a simulated input sample. When the verification classification label and the branch classification label are inconsistent, the instruction branch sample is put back into the language model to regenerate candidate input samples, and then it is determined whether the newly generated candidate input samples can be used as simulated input samples.
[0082] S102: Determine the response sample of the processing logic sample based on the instruction branch sample to the simulated input sample.
[0083] For example, after determining the simulated input samples corresponding to multiple instruction branch samples, the response sample for each simulated input sample under the corresponding processing logic sample is determined based on the simulated input sample and processing logic sample in each branch sample. The response sample can be understood as the simulated response given by the user when inputting the simulated input sample under the processing logic sample.
[0084] In one possible embodiment, the instruction-following-based interaction method provided by this solution determines the response sample of the processing logic sample responding to the simulated input sample based on the instruction branch sample, including: determining the response sample of the processing logic sample responding to the simulated input sample based on the instruction branch sample through a set language model.
[0085] For example, after obtaining simulated input samples, the simulated input samples are input into a pre-trained language model. The language model responds to the simulated input samples based on the processing logic samples of the instruction branch samples, and the response text output by the language model is used as the response sample. This solution obtains the response samples of simulated input samples under the corresponding processing logic samples through the language model. The language model has good compliance performance in the response task of a single logic branch. Accurate response samples can be obtained using a pre-trained large language model without the need for manual construction of response samples. This effectively improves the training efficiency of the instruction compliance model while ensuring its training effect.
[0086] In one embodiment, the language model used in generating candidate input samples, verification conditions, and response samples can be the same language model or multiple language models (the model types of multiple language models can be the same or different), for example, the language model can be a large language model.
[0087] In one embodiment, after collecting simulated input samples and response samples, the training instruction-following model can be fine-tuned based on multi-branch instruction samples, simulated input samples, and response samples.
[0088] For example, after collecting simulated input samples and response samples, the pre-trained instruction following model is fine-tuned using the simulated input samples, response samples, and corresponding multi-branch instruction samples, thus updating the network parameters of the instruction following model. For instance, the multi-branch instruction samples can be used as the given instruction (prompt), the triggering condition as the user input, and the response samples as the model output to fine-tune the instruction following model.
[0089] Optionally, the instruction following model provided in this solution can be a large language model. Training the instruction following model is a forward propagation training process. For example, a decoder structure based on a transformer can be used as the instruction following model. Fine-tuning the instruction following model can be done using a large model to predict the next token, trained based on multi-branch instruction samples, simulated input samples, and response samples. This solution determines the simulated input samples corresponding to multiple instruction branches of multiple multi-branch instruction samples, and determines the response samples of each simulated input sample under the corresponding processing logic sample. By fine-tuning the training of the instruction following model based on multi-branch instruction samples, simulated input samples, and response samples, the instruction following model can better understand and process complex instruction tasks, improving its following ability on complex instructions with multiple branches.
[0090] As described above, the instruction following model determines the target response text based on the user input text and the instruction text. The instruction following model is trained on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branches, and response samples corresponding to each simulated input sample. Multiple instruction branches are obtained by decomposing the multi-branch instruction samples into branches. By decomposing complex multi-branch instruction samples into multiple instruction branches, and training the instruction following model on the simulated input samples and response samples corresponding to each instruction branch during the training phase, the instruction following model can better understand and process complex instruction tasks, improve its following ability on complex instructions with multiple branches, reduce semantic misunderstandings or errors, and improve the interactive effect of machine dialogue.
[0091] Figure 4A schematic diagram of the structure of an instruction-following-based interactive device according to an embodiment of this application is provided. (Reference) Figure 4 The instruction-following interactive device includes an input acquisition module 41 and an instruction follow-up module 42.
[0092] The input acquisition module 41 is used to acquire user input text; the instruction following module 42 is used to input the user input text into the pre-trained instruction following model. The instruction following model determines the target response text based on the user input text and the instruction text parsed from the user input text. The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample. The instruction branch samples are obtained by branching the multi-branch instruction samples.
[0093] As described above, the instruction following model determines the target response text based on the user input text and the instruction text. The instruction following model is trained on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample. Instruction branch samples are obtained by branching multi-branch instruction samples. By decomposing complex multi-branch instruction samples into multiple instruction branch samples, and training the instruction following model on the simulated input samples and response samples corresponding to each instruction branch sample during the training phase, the instruction following model can better understand and process complex instruction tasks, improve its following ability on complex instructions with multiple branches, reduce semantic understanding gaps or errors, and improve the interactive effect of machine dialogue.
[0094] In one possible embodiment, the instruction branch sample includes a trigger condition sample and a processing logic sample. The instruction-based interactive device further includes a sample collection module, which is used for:
[0095] By simulating the trigger condition samples of multiple instruction branch samples, the simulated input samples that satisfy the trigger condition samples of each instruction branch sample are obtained.
[0096] Determine the response sample of the processing logic sample based on the instruction branch sample to the simulated input sample.
[0097] In one possible embodiment, the sample collection module obtains simulated input samples that satisfy the triggering condition samples for each instruction branch sample by simulating triggering condition samples of multiple instruction branch samples, including:
[0098] By simulating the triggering condition samples of multiple instruction branch samples of a multi-branch instruction sample using a set language model, candidate input samples that satisfy the triggering condition samples of each instruction branch sample are obtained.
[0099] The validation conditions are generated based on the candidate input samples using the established language model, and the simulated input samples are determined from the candidate input samples according to the validation conditions and instruction branch samples.
[0100] In one possible embodiment, the sample collection module determines simulated input samples from candidate input samples based on verification conditions and instruction branch samples, including:
[0101] Determine the verification classification labels for the verification conditions and the branch classification labels for the instruction branch samples;
[0102] Candidate input samples whose verification class labels and branch class labels are consistent are determined as simulated input samples.
[0103] In one possible embodiment, the sample collection module is further configured to, after determining the verification classification label of the verification condition and the branch classification label of the instruction branch sample, update the candidate input sample corresponding to the instruction branch sample by resimulating the trigger condition sample of the instruction branch sample through the set language model when the verification classification label and the branch classification label are inconsistent.
[0104] In one possible embodiment, the sample collection module determines the response sample of the processing logic sample based on the instruction branch sample to the simulated input sample, including: determining the response sample of the processing logic sample based on the instruction branch sample to the simulated input sample through a set language model.
[0105] In one possible embodiment, the sample collection module is further configured to, before obtaining the simulated input sample that satisfies the trigger condition sample of each instruction branch sample by simulating the trigger condition sample of multiple instruction branch samples, decompose each multi-branch instruction sample into multiple instruction branch samples according to the multiple logical branches of the multiple multi-branch instruction samples, wherein the instruction branch sample includes trigger condition sample and processing logic sample.
[0106] It is worth noting that in the above embodiments of the interactive device based on instruction compliance, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this application.
[0107] This application also provides an instruction-following interactive device, which can integrate the instruction-following interactive apparatus provided in this application. Figure 5 This is a schematic diagram of the structure of an instruction-following interactive device provided in an embodiment of this application. (Reference) Figure 5The instruction-based interactive device includes: an input device 53, an output device 54, a memory 52, and one or more processors 51; the memory 52 is used to store one or more programs; when one or more programs are executed by one or more processors 51, the one or more processors 51 implement the instruction-based interactive method provided in the above embodiments. The input device 53, output device 54, memory 52, and processor 51 can be connected via a bus or other means. Figure 5 The bus connection is taken as an example.
[0108] Memory 52, as a computing device readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the instruction-following interactive method provided in any embodiment of this application (e.g., input acquisition module 41 and instruction-following module 42 in an instruction-following interactive device). Memory 52 may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created according to the use of the device, etc. In addition, memory 52 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, memory 52 may further include memory remotely located relative to processor 51, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0109] Input device 53 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the device. Output device 54 may include display devices such as a display screen.
[0110] The processor 51 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory 52, thereby realizing the above-mentioned instruction-based interaction method.
[0111] The instruction-following interactive devices, equipment, and computers provided above can be used to execute the instruction-following interactive methods provided in any of the above embodiments, and have corresponding functions and beneficial effects.
[0112] This application embodiment also provides a storage medium for storing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are used to execute the instruction-following-based interaction method provided in the above embodiment. The instruction-following-based interaction method includes: acquiring user input text; inputting the user input text into an instruction-following model; determining a target response text through the instruction-following model based on the user input text and the instruction text parsed from the user input text; the instruction-following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each simulated input sample; the multiple instruction branch samples are obtained by branching the multi-branch instruction samples.
[0113] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROMs, floppy disks, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disks or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. Furthermore, storage media may reside in a first computer system in which a program is executed, or may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” can include two or more storage media that may reside in different locations (e.g., in different computer systems connected via a network). Storage media may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.
[0114] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the instruction-following interaction method provided above, but can also execute related operations in the instruction-following interaction method provided in any embodiment of this application.
[0115] The instruction-following interactive device, equipment, and storage medium provided in the above embodiments can execute the instruction-following interactive method provided in any embodiment of this application. For technical details not described in detail in the above embodiments, please refer to the instruction-following interactive method provided in any embodiment of this application.
[0116] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments provided herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.
Claims
1. An interactive method based on instruction compliance, characterized in that, include: Get the user's input text; The user input text is input into the instruction following model. The instruction following model determines the target response text based on the user input text and the instruction text parsed from the user input text. The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each of the simulated input samples. The multiple instruction branch samples are obtained by branching the multi-branch instruction samples.
2. The instruction-following-based interaction method according to claim 1, characterized in that, The instruction branch sample includes trigger condition samples and processing logic samples. The steps for collecting the simulated input samples and the response samples include: By simulating the trigger condition samples of multiple instruction branch samples, simulated input samples that satisfy the trigger condition samples are obtained for each instruction branch sample. Determine the response sample that responds to the simulated input sample based on the processing logic sample of the instruction branch sample.
3. The instruction-following-based interaction method according to claim 2, characterized in that, The step of obtaining simulated input samples that satisfy the triggering condition samples for each instruction branch sample by simulating triggering condition samples from multiple instruction branch samples includes: By simulating the triggering condition samples of multiple instruction branch samples of a multi-branch instruction sample using a set language model, candidate input samples that satisfy the triggering condition samples are obtained for each instruction branch sample. The language model is used to generate verification conditions based on the candidate input samples, and the simulated input samples are determined from the candidate input samples according to the verification conditions and the instruction branch samples.
4. The instruction-following-based interaction method according to claim 3, characterized in that, The step of determining the simulated input sample from the candidate input samples based on the verification conditions and the instruction branch samples includes: Determine the verification classification label of the verification condition and the branch classification label of the instruction branch sample; Candidate input samples whose verification classification labels and branch classification labels are consistent are identified as simulated input samples.
5. The instruction-following-based interaction method according to claim 4, characterized in that, After determining the verification classification label of the verification condition and the branch classification label of the instruction branch sample, the method further includes: If the verification classification label and the branch classification label are inconsistent, the trigger condition sample of the instruction branch sample is re-simulated using the set language model, and the candidate input sample corresponding to the instruction branch sample is updated.
6. The instruction-following-based interaction method according to claim 2, characterized in that, The determination of the response sample for responding to the simulated input sample based on the processing logic sample of the instruction branch sample includes: The response sample is determined by using a defined language model to respond to the simulated input sample based on the processing logic sample of the instruction branch sample.
7. The instruction-following-based interaction method according to claim 2, characterized in that, Before obtaining the simulated input sample that satisfies the trigger condition sample for each instruction branch sample by simulating trigger condition samples of multiple instruction branch samples, the method further includes: Based on the multiple logical branches of multiple multi-branch instruction samples, each multi-branch instruction sample is decomposed into multiple instruction branch samples, and the instruction branch samples include trigger condition samples and processing logic samples.
8. An interactive device based on instruction compliance, characterized in that, This includes an input acquisition module and an instruction compliance module, wherein: The input acquisition module is used to acquire user input text; The instruction following module is used to input the user input text into the instruction following model, and the instruction following model determines the target response text based on the user input text and the instruction text parsed from the user input text. The instruction following model is trained based on multi-branch instruction samples, simulated input samples corresponding to multiple instruction branch samples, and response samples corresponding to each of the simulated input samples. The instruction branch samples are obtained by branching the multi-branch instruction samples.
9. An interactive device based on instruction compliance, characterized in that, include: Memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the instruction-following-based interactive method as described in any one of claims 1-7.
10. A storage medium for storing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the instruction-following-based interactive method as described in any one of claims 1-7.