A method for training a multi-turn dialogue model, a method for generating multi-turn dialogues, and an apparatus.
By constructing a multi-turn dialogue policy graph to automatically generate a multi-turn dialogue dataset, the problem of high human involvement in existing technologies is solved, and the training efficiency of multi-turn dialogue models is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, training multi-turn dialogue models requires a large amount of manual sorting and writing of intents, slots, and dialogue data, resulting in low training efficiency, high degree of human involvement, and incomplete coverage.
By acquiring task scenarios, pre-setting intent type data, slot seed templates, and robot behaviors, a multi-turn dialogue strategy graph is constructed, and a multi-turn dialogue dataset is automatically generated, reducing the degree of human intervention and improving training efficiency.
It enables the automatic generation of multi-turn dialogue datasets, reduces human intervention in the training sample formation process, and improves model training efficiency.
Smart Images

Figure CN115563243B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method for training a multi-turn dialogue model, a method for generating multi-turn dialogues, and an apparatus. Background Technology
[0002] AI dialogue systems primarily come in two forms: single-turn and multi-turn. In single-turn dialogue, the user inputs a sentence, and the chatbot provides an answer based on that input. This is mainly used in common question answering or help centers. In multi-turn dialogue, the chatbot remembers the conversation history, maintains a dialogue state internally, and provides an answer by combining the dialogue state with the user input. Multi-turn dialogue is defined as a continuous dialogue based on context to achieve the goal of solving a specific type of task.
[0003] In existing technologies, to complete multi-turn dialogues, it is necessary to customize an artificial intelligence model with multi-turn dialogue capabilities. The construction process involves manually sorting out the business service process, collecting single-turn corpus for each node to develop intent and slot models, manually writing process corpus to train an action prediction model based on the output of the intent and slot models, and then taking corresponding responses and actions based on the behavior prediction output.
[0004] The drawback of existing technologies is that a large amount of manual work is required to sort and write intent, slot, and dialogue data as training samples to meet the model training requirements. However, manually written samples may have incomplete coverage, resulting in low model training efficiency and a high degree of human involvement in the training data writing process. Summary of the Invention
[0005] Based on this, embodiments of this application provide a method for training a multi-turn dialogue model, a method for generating multi-turn dialogues, and an apparatus, which aim to improve model training efficiency and reduce the degree of human involvement in writing training sample data.
[0006] In a first aspect, embodiments of this application provide a method for training a multi-turn dialogue model, the method comprising:
[0007] Obtain the task scenario;
[0008] Obtain the set of intent types based on the task scenario;
[0009] A slot seed template is obtained according to the task scenario, wherein the slot seed template includes a slot type and a slot value corresponding to the slot type;
[0010] Construct triple data, wherein a triple data contains an intent type from the intent type set, a slot type, and a slot value corresponding to the slot type;
[0011] Obtain robot behavior and corresponding robot response data based on the task scenario;
[0012] A multi-turn dialogue strategy graph is constructed based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior;
[0013] Construct a multi-turn dialogue dataset based on the multi-turn dialogue strategy graph;
[0014] The multi-turn dialogue dataset is used as the model training sample to train a multi-turn dialogue model.
[0015] Optionally, obtaining the slot seed template based on the task scenario includes:
[0016] Determine the set of slot types based on the task scenario;
[0017] Obtain a slot type from the set of slot types, and determine the slot value based on the slot type;
[0018] The slot type and slot value are determined as the slot seed template.
[0019] Preferably, obtaining the slot seed template according to the task scenario includes:
[0020] Determine the set of slot types based on the task scenario;
[0021] Obtain a slot type from the set of slot types, and determine the slot value for the slot type;
[0022] The slot type and slot value are determined as the slot seed template;
[0023] Sample at least two slot seed templates and splice them together to obtain a complex slot seed template.
[0024] Optionally, constructing a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior includes:
[0025] Set a set of dialogue state nodes, wherein each dialogue state node in the set corresponds to at least one triplet data and a robot behavior and robot response data corresponding to the robot behavior;
[0026] A set of directed edges is set up, wherein any directed edge in the set of directed edges consists of a head node and a tail node, and the head node and the tail node are any dialogue state node in the set of dialogue state nodes. Each directed edge corresponds to at least one decision condition, which is used to determine the dialogue state node that needs to be called in the multi-turn dialogue task.
[0027] A multi-turn dialogue strategy graph is generated based on the set of directed edges.
[0028] Optionally, constructing multi-turn dialogue data based on the multi-turn dialogue strategy graph includes:
[0029] The first dialogue state node is sampled from the set of dialogue state nodes contained in the multi-turn dialogue strategy graph, and the sampled first dialogue state node is set as the dialogue flow start node. The sampled node set is constructed and the dialogue flow end node is set. The sampled node set contains the dialogue state nodes that have been sampled.
[0030] Determine whether the first dialogue state node is the end node of the dialogue process. If it is, use the triplet data corresponding to the first dialogue state node as the multi-turn dialogue dataset.
[0031] If the first dialogue state node is not the dialogue process end node, then a first triplet data is sampled from at least one triplet data corresponding to the first dialogue state node, and the intent type contained in the collected first triplet data is used as the first data.
[0032] A random number is sampled within a preset range. If the random number satisfies the first judgment condition, a first number threshold number of second dialogue state nodes are sampled from the unsampled node set outside the sampled node set. At least one triplet data corresponding to the collected second dialogue state node is sampled to obtain a second triplet data. The intent type contained in the second triplet data is concatenated with the first data to obtain the second data. The first number threshold number of second dialogue state nodes are added to the collected node set.
[0033] If the random number satisfies the second judgment condition, then sample a second number threshold of third dialogue state nodes from the set of tail nodes corresponding to the directed edges with the first dialogue state node as the head node, and sample at least one triplet data corresponding to the third dialogue state node to obtain a third triplet data. Then, concatenate the intent type contained in the third triplet data with the first data to obtain the second data, and add the second number threshold of third dialogue state nodes to the set of collected nodes.
[0034] If the random number satisfies the third judgment condition, then the first data is determined as the second data;
[0035] The slot type contained in the first triplet data corresponding to the first dialogue state node is sampled, and the slot value corresponding to the slot type is obtained. The slot value is then concatenated with the second data to obtain the third data.
[0036] The third data is added to the multi-turn dialogue dataset, and the first dialogue state node is added to the visited node set.
[0037] A fourth dialogue state node is sampled from the dialogue state nodes that form a directed edge with the first dialogue state node. The steps of determining whether the fourth dialogue state node is the dialogue process end node and subsequent steps are repeated until the sampled dialogue state node is the dialogue process end node.
[0038] Preferably, after constructing the multi-turn dialogue dataset based on the multi-turn dialogue strategy graph, the method further includes:
[0039] The multi-turn dialogue dataset is input into a pre-trained language model with data rewriting capabilities, and the multi-turn dialogue dataset is rewritten to a level no less than the rewriting turn threshold.
[0040] Each rewritten multi-turn dialogue dataset is added to the training dataset. When the number of rewritten turns exceeds the rewritten turn threshold, the training dataset is used as the training sample.
[0041] Secondly, embodiments of this application provide a method for generating multi-turn dialogues, the method comprising:
[0042] Input a given question into a multi-turn dialogue model;
[0043] The multi-turn dialogue model determines the triplet data to be invoked based on the intent type of the given question;
[0044] The dialogue state node is determined based on the triplet data, the robot behavior is determined based on the dialogue state node, and the robot response data corresponding to the robot behavior is determined based on the robot behavior.
[0045] The multi-turn dialogue model outputs robot response data corresponding to the robot's behavior, wherein the multi-turn dialogue model is trained by the training method of the multi-turn dialogue model described in the first aspect.
[0046] Thirdly, embodiments of this application provide a multi-turn dialogue model training device, the multi-turn dialogue model training device comprising:
[0047] The task scenario acquisition module is used to acquire task scenarios;
[0048] The intent type set acquisition module is used to acquire the intent type set according to the task scenario.
[0049] The slot seed template acquisition module is used to acquire a slot seed template according to the task scenario.
[0050] The triplet data construction module is used to construct triplet data.
[0051] The robot behavior data acquisition module is used to acquire robot behavior and robot response data corresponding to the robot behavior based on the task scenario.
[0052] A multi-turn dialogue strategy graph construction module is used to construct a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior.
[0053] A multi-turn dialogue dataset construction module is used to construct a multi-turn dialogue dataset based on the multi-turn dialogue policy graph.
[0054] The model training module is used to train a multi-turn dialogue model by using the multi-turn dialogue dataset as model training samples.
[0055] Fourthly, embodiments of this application provide a multi-turn dialogue generation apparatus, the multi-turn dialogue generation apparatus comprising:
[0056] The question input module is used to input a given question into the multi-turn dialogue model;
[0057] The triplet invocation module is used to determine the triplet data to be invoked based on the intent type of the given question.
[0058] The determination module is used to determine the dialogue state node based on the triplet data, and to determine the robot behavior based on the dialogue state node.
[0059] The output module is used to output robot response data corresponding to the robot's behavior.
[0060] Fifthly, embodiments of this application provide an apparatus comprising a memory and a processor, the memory for storing instructions or code, and the processor for executing the instructions or code to cause the apparatus to perform the training method for a multi-turn dialogue model as described in any of the first aspects, or the generation method for a multi-turn dialogue as described in any of the second aspects.
[0061] Sixthly, embodiments of this application provide a computer storage medium storing code, wherein when the code is executed, a device running the code implements the training method for the multi-turn dialogue model described in any of the first aspects, or the multi-turn dialogue generation method described in any of the second aspects.
[0062] Compared with the prior art, this application has the following beneficial effects:
[0063] This application acquires a task scenario and, based on the acquired task scenario, presets intent type data, slot seed templates, robot behaviors, and robot response data corresponding to the robot behaviors, and constructs a multi-turn dialogue strategy graph. Based on the multi-turn dialogue strategy graph, a multi-turn dialogue dataset is constructed. Since the multi-turn dialogue dataset can be automatically generated from the elements and data contained in the multi-turn dialogue strategy graph, the degree of human intervention in the training sample formation process is reduced, and the model training efficiency is improved. Attached Figure Description
[0064] To more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings used in the description of the embodiment or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0065] Figure 1 A flowchart illustrating one method of training a multi-turn dialogue model provided in this application embodiment;
[0066] Figure 2 A flowchart illustrating a method for constructing a multi-turn dialogue dataset, as provided in an embodiment of this application;
[0067] Figure 3 A flowchart illustrating a method for generating a multi-turn dialogue, as provided in an embodiment of this application;
[0068] Figure 4 A schematic diagram of the structure of a training device for a multi-turn dialogue model provided in an embodiment of this application;
[0069] Figure 5 This is a schematic diagram of a multi-turn dialogue generation device provided in an embodiment of this application. Detailed Implementation
[0070] In existing technologies, to complete multi-turn dialogues, it is necessary to customize an artificial intelligence model with multi-turn dialogue capabilities. The construction process involves manually sorting out the business service process, collecting single-turn corpus for each node to develop intent and slot models, manually writing process corpus to train an action prediction model based on the output of the intent and slot models, and then taking corresponding responses and actions based on the behavior prediction output.
[0071] Research has shown that existing technologies require a large amount of manual work to sort and write intents, slots, and dialogue data as training samples to meet model training requirements. However, manually written samples may not fully cover task scenarios and specific dialogue tasks, resulting in low model training efficiency and a high degree of human involvement in the training data writing process.
[0072] Based on this, embodiments of this application provide a multi-turn dialogue model training method, a multi-turn dialogue generation method, and an apparatus. By acquiring a task scenario, and based on the acquired task scenario, pre-setting intent type data, slot seed templates, robot behaviors, and robot response data corresponding to the robot behaviors, a multi-turn dialogue strategy graph is constructed. A multi-turn dialogue dataset is then constructed based on the multi-turn dialogue strategy graph. Since the multi-turn dialogue dataset can be automatically generated using the elements and data contained in the multi-turn dialogue strategy graph, the degree of human intervention in the training sample formation process is reduced, and the model training efficiency is improved.
[0073] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0074] See Figure 1 , Figure 1 A flowchart of a method for training a multi-turn dialogue model provided in the embodiments of this application includes:
[0075] S101: Obtain the task scenario.
[0076] Task scenarios refer to scenarios that require performing multi-round dialogue tasks, such as scenarios where intelligent customer service robots automatically reply.
[0077] Task scenarios can be obtained randomly from multiple task scenarios, or selectively from multiple task scenarios with a specific purpose.
[0078] The purpose of this step is to train corresponding multi-turn dialogue models for different task scenarios.
[0079] S102: Obtain the set of intent types based on the task scenario.
[0080] The intent type refers to the various desired objectives involved in the task scenario. For example, in the task scenario of requesting after-sales service from an online store, the intent types involved include inquiring about the exchange process and inquiring about the return process.
[0081] The intent type set is a set that includes all possible intent types, and each intent type is an element in the set.
[0082] The purpose of this step is to extract the corresponding intent type for the acquired task scenario.
[0083] S103: Obtain the slot seed template according to the task scenario.
[0084] The slot seed template includes a slot type and a slot value corresponding to the slot type.
[0085] To make it easier to understand, let's take an example to illustrate the slot seed template. For instance, when a user requests to purchase a service in an online store, slot seed templates such as "Buy Fruit" or "Buy Vegetables" will appear. "Fruit" and "Vegetables" represent the slot types. If the user selects "Buy Fruit," then the "Target Fruit to Buy" will appear, such as apples or bananas. Here, "Apple" and "Banana" are called slot values, thus completing a multi-turn dialogue task.
[0086] In one possible implementation, obtaining the slot seed template based on the task scenario includes:
[0087] Determine the set of slot types based on the task scenario;
[0088] Obtain a slot type from the set of slot types, and determine the slot value based on the slot type;
[0089] The slot type and slot value are determined as the slot seed template.
[0090] Each slot seed template includes a slot type and at least one slot value.
[0091] In one possible implementation, obtaining the slot seed template based on the task scenario includes:
[0092] Determine the set of slot types based on the task scenario;
[0093] Obtain a slot type from the set of slot types, and determine the slot value for the slot type;
[0094] The slot type and slot value are determined as the slot seed template;
[0095] Sample at least two slot seed templates and splice them together to obtain a complex slot seed template.
[0096] The sampling is equal probability sampling, which means that the sampling probability is equal for all elements in the set.
[0097] The sampling of at least two slot seed templates and splicing them together refers to splicing the slot types of the sampled slot seed templates, thereby obtaining more combinations of slot values. For example, slot type A corresponds to m slot values, and slot type B corresponds to n slot values. Then, splicing the two slot types together can yield m*n combinations.
[0098] For example, when a user requests to purchase services in an online store, the slot types of the two slot seed templates, "Buy Fruit" and "Buy Vegetables," can be combined to obtain a more complex slot seed template, "Buy Fruits and Vegetables." When a user purchases multiple categories of goods, the more complex slot seed template can be used to ask the customer questions, thereby completing a multi-round dialogue task.
[0099] S104: Construct triplet data.
[0100] The triplet data constructed in this embodiment is triplet data in the form of (intent type, slot type, slot value), such as (buy something, buy fruit, apple).
[0101] Wherein, a triplet data includes an intent type from the intent type set, a slot type, and a slot value corresponding to the slot type.
[0102] S105: Obtain robot behavior and robot response data corresponding to the robot behavior based on the task scenario.
[0103] The robot behavior refers to the different behaviors the robot may perform for different specific tasks in the task scenario. For example, in the task scenario of buying daily necessities online, the specific task is to buy fruit. The corresponding robot behavior may include asking about the specific type of fruit or asking if other types of goods need to be purchased.
[0104] The robot response data corresponding to the robot behavior refers to the fact that for each robot behavior, there is at least one robot response data. For example, when the robot behavior is to ask for the specific type of fruit to buy, the robot response data may include: whether to buy apples, whether to buy bananas, etc.
[0105] S106: Construct a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior.
[0106] A multi-turn dialogue strategy graph refers to the process of generating multi-turn dialogues, including the judgment conditions for determining which triple data to call and setting dialogue state nodes.
[0107] In one possible implementation, constructing a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior includes:
[0108] Set the set of dialogue status nodes;
[0109] Set a set of directed edges;
[0110] A multi-turn dialogue strategy graph is generated based on the set of directed edges.
[0111] Each dialogue state node in the set of dialogue state nodes represents a dialogue event. The dialogue state nodes are mainly used to determine the dialogue state, such as nodes that are in a dialogue state, dialogue start nodes, and dialogue end nodes. Each dialogue state node corresponds to at least one triplet of data and a robot action and robot response data corresponding to the robot action.
[0112] Directed edges represent dialogue state transition conditions and are used to determine the dialogue state nodes that need to be invoked in a multi-turn dialogue task. Each directed edge in the set of directed edges consists of a head node and a tail node, and the head node and tail node are any dialogue state nodes in the set of dialogue state nodes. Each directed edge corresponds to at least one determination condition.
[0113] Since each directed edge corresponds to at least one condition for determining the calling node, a node calling network can be constructed using the set of directed edges. This node calling network is the multi-turn dialogue strategy graph described above.
[0114] S107: Construct a multi-turn dialogue dataset based on the multi-turn dialogue strategy graph.
[0115] The multi-turn dialogue dataset refers to a data set that contains at least one dialogue state node data.
[0116] The multi-turn dialogue dataset is constructed by sampling the dialogue state nodes and corresponding directed edges in the multi-turn dialogue policy graph and calling the corresponding data.
[0117] In one possible implementation, constructing a multi-turn dialogue dataset based on the multi-turn dialogue policy graph includes:
[0118] In the set of dialogue state nodes contained in the multi-turn dialogue strategy graph, an initial dialogue state node and a dialogue process end node are determined. When the initial dialogue state node and the dialogue process end node are not the same, other dialogue state nodes that form a directed edge relationship with the initial dialogue state node are sampled.
[0119] Each dialogue state node corresponds to at least one triplet data, and each triplet data corresponds to an intent type, a robot behavior, and robot response data corresponding to the robot behavior;
[0120] The intent types are combined to form a given question, and the robot's response data is combined to form an answer to the given question. The given question and the answer to the given question constitute single-turn dialogue data, and multiple single-turn dialogue data constitute a multi-turn dialogue dataset.
[0121] S108: Use the multi-turn dialogue dataset as training samples to train a multi-turn dialogue model.
[0122] Preferably, after S107 and before S108, the following is also included:
[0123] The multi-turn dialogue dataset is input into a pre-trained language model with data rewriting capabilities, and the multi-turn dialogue dataset is rewritten to a level no less than the rewriting turn threshold.
[0124] Each rewritten multi-turn dialogue dataset is added to the training dataset. When the number of rewritten turns exceeds the rewritten turn threshold, the training dataset is used as the training sample.
[0125] The main rewriting methods for performing rewriting processing on the multi-turn dialogue dataset at a level not lower than the rewriting turn threshold include:
[0126] Add conjunctions, for example, rewrite "fruit price" as "the price of fruit";
[0127] Synonym replacement.
[0128] This also includes many other data rewriting methods, which will not be listed here.
[0129] The rewriting of the multi-turn dialogue dataset is mainly to enrich the training sample information.
[0130] According to the task scenario, this application embodiment presets intent type data, slot seed template, robot behavior and robot response data corresponding to the robot behavior, and constructs a multi-turn dialogue strategy graph. Based on the multi-turn dialogue strategy graph, a multi-turn dialogue dataset is constructed. Since the multi-turn dialogue dataset can be automatically generated by the elements and data contained in the multi-turn dialogue strategy graph, the degree of human intervention in the training sample formation process is reduced and the model training efficiency is improved.
[0131] In the embodiments of this application, the above Figure 1 There are several possible implementations of step S107, which will be described below. It should be noted that the implementations given below are merely illustrative examples and do not represent all implementations of the embodiments of this application.
[0132] See Figure 2 , Figure 2 A flowchart illustrating a method for constructing a multi-turn dialogue dataset provided in this application embodiment, the method specifically including:
[0133] In one possible implementation, constructing multi-turn dialogue data based on the multi-turn dialogue strategy graph includes:
[0134] S201: Sample the first dialogue state node from the set of dialogue state nodes contained in the multi-turn dialogue strategy graph, set the sampled first dialogue state node as the dialogue flow start node, construct the sampled node set and set the dialogue flow end node.
[0135] The sampled node set includes nodes that have already been sampled;
[0136] The sampling is equal probability sampling, which means that the sampling probability is equal for all elements in the set.
[0137] S202: Determine whether the first dialogue state node is the end node of the dialogue process. If so, use the triplet data corresponding to the first dialogue state node as the multi-turn dialogue dataset.
[0138] The dialogue process ends when the dialogue process ends. Therefore, this step is to determine whether the dialogue process has ended. If this step determines that the dialogue process has ended, then the subsequent steps will not be executed.
[0139] S203: If the first dialogue state node is not the dialogue process end node, then a first triplet data is sampled from at least one triplet data corresponding to the first dialogue state node, and the intent type contained in the collected first triplet data is used as the first data.
[0140] The purpose of this step is to determine the intent type of the first dialogue state node.
[0141] S204: Sample a random number within a preset range, and determine the conditions satisfied by the random number based on its magnitude.
[0142] If the random number satisfies the first judgment condition, proceed to step S205;
[0143] If the random number satisfies the second judgment condition, proceed to step S206;
[0144] If the random number satisfies the third judgment condition, proceed to step S207.
[0145] The first, second, and third judgment conditions can set a range for the numerical value, or they can set a single value for the numerical value.
[0146] The step of sampling a random number within a preset range is to randomly sample the number of dialogue state nodes. Alternatively, the method of directly setting the number of dialogue state nodes to be sampled, or other methods, can be used.
[0147] S205: Step S205 includes the following sub-steps:
[0148] S205a: Sample a first number threshold number of second dialogue state nodes from the set of unsampled nodes outside the set of sampled nodes.
[0149] S205b: Sample at least one triplet data corresponding to the collected second dialogue state node to obtain a second triplet data.
[0150] S205c: The intent type of the first data contained in the second triplet data is concatenated to obtain the second data, and the first number threshold number of second dialogue state nodes are added to the collected node set.
[0151] The first quantity threshold is set according to requirements.
[0152] S206: Step S206 includes the following sub-steps:
[0153] S206a: Sample a second number of third dialogue state nodes from the set of tail nodes corresponding to the directed edges with the first dialogue state node as the head node.
[0154] S206b: Sample at least one triplet data corresponding to the third dialogue state node to obtain a third triplet data.
[0155] S206c: The intent type contained in the third triplet data is concatenated with the first data to obtain the second data, and the second number threshold third dialogue state nodes are added to the collected node set.
[0156] The second quantity threshold is set according to requirements, and the second quantity threshold is not equal to the first quantity threshold.
[0157] S207: The first data is determined as the second data.
[0158] The second data is obtained by concatenating the intent type in the first triplet data with the intent type contained in the sampled second or third dialogue state node.
[0159] S208: Sample the slot type contained in the first triplet data corresponding to the first dialogue state node, obtain the slot value corresponding to the slot type, and concatenate the slot value with the second data to obtain the third data.
[0160] S209: Add the third data as a given question to the multi-turn dialogue dataset, and add the first dialogue state node to the visited node set.
[0161] In step S209, adding the third data as a given question to the multi-turn dialogue dataset is to determine the dialogue question.
[0162] Adding the first dialogue state node to the visited node set is to avoid sampling the same node repeatedly.
[0163] S210: Obtain the robot response data corresponding to the first triplet data, and add the robot response data as the answer to the given question to the multi-turn dialogue dataset.
[0164] Step S210 specifically includes: obtaining the robot behavior corresponding to the first triplet data, and determining the robot response data based on the robot behavior.
[0165] S211: Sample the fourth dialogue state node from the dialogue state nodes that form a directed edge with the first dialogue state node, and repeat steps S202-S210 until the sampled dialogue state node is the dialogue process end node.
[0166] The purpose of step S211 is to increase the amount of data in the multi-turn dialogue dataset, making the training samples richer.
[0167] S212: Construct a multi-turn dialogue dataset.
[0168] Steps S209 and S210 obtain single-turn dialogue data by constructing a given question and its answer. Multiple single-turn dialogue data can be used to construct a multi-turn dialogue dataset.
[0169] In this embodiment, the intent type corresponding to the sampled dialogue state node is used as the given question. At the same time, the triplet data corresponding to the dialogue state node is obtained. Then, the robot's response data is determined through the triplet data, and the robot's response data is used as the answer to the given question, thereby generating single-turn dialogue data. By repeatedly performing the operation of sampling dialogue state nodes, multiple single-turn dialogue data are obtained. The multiple single-turn dialogue data are used to construct a multi-turn dialogue dataset, which enriches the training samples of the multi-turn dialogue model and improves the efficiency of model training.
[0170] This application also provides a method for generating multi-turn dialogues, see [link to relevant documentation]. Figure 3 , Figure 3 The flowchart below shows the method for generating the multi-turn dialogue, which specifically includes:
[0171] S301: Input the given question into the multi-turn dialogue model.
[0172] The multi-turn dialogue model is trained using the training method described above.
[0173] The given question is a specific multi-turn dialogue task in a specific task scenario. For example, if the task scenario is that a user is making a purchase in an online store, the given question could be "Buy daily necessities" or similar.
[0174] In one possible implementation, the input of a given question into the multi-turn dialogue model can be from a device or from other agents.
[0175] The purpose of this step is to enable the multi-turn dialogue model to receive information about the given question so that it can answer the given question and conduct a multi-turn dialogue process.
[0176] S302: The multi-turn dialogue model determines the triplet data to be invoked based on the intent type of the given question.
[0177] Since the triple data contains intent types, once the multi-turn dialogue model obtains the intent type of a given question, it can call up all triple data that contain the intent type corresponding to the given question.
[0178] S303: Determine the dialogue state node based on the triplet data, determine the robot behavior based on the dialogue state node, and determine the robot response data corresponding to the robot behavior based on the robot behavior.
[0179] Since each dialogue state node corresponds to at least one triplet data, it means that each triplet data corresponds to a specific dialogue state node, and each dialogue state node corresponds to a robot behavior. After determining the robot behavior, the robot response data corresponding to the robot behavior can be determined.
[0180] S304: The multi-turn dialogue model outputs robot response data corresponding to the robot's behavior.
[0181] Since a robot action corresponds to a robot response data, after the robot action is determined in step S303, the robot response data corresponding to the robot action can be directly called and output by the multi-turn dialogue model to answer the given question.
[0182] Steps S301-S304 of this embodiment can be repeated multiple times as needed, thereby achieving the effect of solving specific multi-turn dialogue tasks.
[0183] This application embodiment analyzes the intent type of a given question, then determines a robot behavior based on the intent type, thereby outputting robot response data corresponding to the robot behavior. By outputting the robot response data, the given question is solved, ultimately realizing the output of robot response data for a given question by the model trained using the multi-turn dialogue model training method.
[0184] The above are some specific implementations of the training method for a multi-turn dialogue model provided in the embodiments of this application. Based on this, this application also provides a corresponding apparatus. The apparatus provided in the embodiments of this application will be described below from the perspective of functional modularity.
[0185] See Figure 4 , Figure 4 This is a schematic diagram of a training device for a multi-turn dialogue model, the device comprising:
[0186] Task scenario acquisition module 401 is used to acquire task scenarios;
[0187] The intent type set acquisition module 402 is used to acquire an intent type set according to the task scenario;
[0188] The slot seed template acquisition module 403 is used to acquire a slot seed template according to the task scenario, wherein the slot seed template includes a slot type and a slot value corresponding to the slot type;
[0189] The triplet data construction module 404 is used to construct triplet data, wherein a triplet data includes an intent type from the intent type set, a slot type, and a slot value corresponding to the slot type.
[0190] The robot behavior data acquisition module 405 is used to acquire robot behavior and robot response data corresponding to the robot behavior according to the task scenario.
[0191] The multi-turn dialogue strategy graph construction module 406 is used to construct a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior.
[0192] A multi-turn dialogue dataset construction module 407 is used to construct a multi-turn dialogue dataset based on the multi-turn dialogue strategy graph.
[0193] The model training module 408 is used to train a multi-turn dialogue model by using the multi-turn dialogue dataset as model training samples.
[0194] In one possible implementation, the slot seed template acquisition module 403 includes:
[0195] The slot type set determination unit is used to determine the slot type set according to the task scenario.
[0196] The slot value determination unit is used to obtain a slot type from the slot type set and determine the slot value according to the slot type;
[0197] The slot seed template determination unit is used to determine the slot type and slot value as a slot seed template.
[0198] The slot seed template splicing unit is used to sample at least two slot seed templates and splice them together to obtain a complex slot seed template.
[0199] In one possible implementation, the multi-turn dialogue strategy graph construction module 406 includes:
[0200] The dialog state node set setting unit is used to set the dialog state node set;
[0201] The directed edge set setting unit is used to set the directed edge set;
[0202] A multi-turn dialogue strategy graph generation unit is used to generate a multi-turn dialogue strategy graph based on the set of directed edges.
[0203] In one possible implementation, the multi-turn dialogue dataset construction module 407 includes:
[0204] The dialogue state node sampling unit is used to sample dialogue state nodes from the set of dialogue state nodes contained in the multi-turn dialogue strategy graph.
[0205] A node setting unit is used to set the dialogue flow start node and the dialogue flow end node, and to set a set of sampled nodes, wherein the set of sampled nodes includes dialogue state nodes that have been sampled.
[0206] The judgment unit is used to determine whether the sampled dialogue state node is the end node of the dialogue process;
[0207] The data splicing unit is used to splice the data contained in each dialogue state node to obtain a multi-turn dialogue dataset;
[0208] In one possible implementation, the training device further includes:
[0209] The data rewriting module is used to rewrite the multi-turn dialogue dataset to a level not lower than the rewriting round threshold, and add the rewritten multi-turn dialogue dataset to the training dataset after each round. When the number of rewriting rounds exceeds the rewriting round threshold, the training dataset is used as the training sample.
[0210] According to the task scenario, this application embodiment presets intent type data, slot seed template, robot behavior and robot response data corresponding to the robot behavior, and constructs a multi-turn dialogue strategy graph. Based on the multi-turn dialogue strategy graph, a multi-turn dialogue dataset is constructed. Since the multi-turn dialogue dataset can be automatically generated by the elements and data contained in the multi-turn dialogue strategy graph, the degree of human intervention in the training sample formation process is reduced and the model training efficiency is improved.
[0211] This application also provides a multi-turn dialogue generation apparatus, see [link to relevant documentation]. Figure 5 , Figure 5 This is a schematic diagram of a multi-turn dialogue generation device, the device comprising:
[0212] Question input module 501 is used to input a given question into the multi-turn dialogue model;
[0213] The triplet invocation module 502 is used to determine the triplet data to be invoked based on the intent type of the given question.
[0214] The determination module 503 is used to determine the dialogue state node based on the triplet data and to determine the robot behavior based on the dialogue state node.
[0215] The output module 504 is used to output robot response data corresponding to the robot's behavior.
[0216] The multi-turn dialogue model is trained using the training method for multi-turn dialogue models.
[0217] In one possible implementation, the determining module 503 includes:
[0218] The first determining unit is used to determine the dialogue state node based on the triplet data;
[0219] The second determining unit is used to determine the robot's behavior based on the dialogue state node;
[0220] The third determining unit is used to determine the robot response data corresponding to the robot behavior based on the robot behavior.
[0221] This application embodiment analyzes the intent type of a given question, then determines a robot behavior based on the intent type, thereby outputting robot response data corresponding to the robot behavior. By outputting the robot response data, the given question is solved, ultimately realizing the output of robot response data for a given question by the model trained using the multi-turn dialogue model training method.
[0222] This application also provides corresponding devices and computer storage media for implementing the solutions provided in this application.
[0223] The device includes a memory and a processor. The memory stores instructions or code, and the processor executes the instructions or code to enable the device to perform the training method for the multi-turn dialogue model described in any embodiment of this application, or the multi-turn dialogue generation method described in any embodiment of this application.
[0224] The computer storage medium stores code. When the code is run, the device running the code implements the training method for the multi-turn dialogue model described in any embodiment of this application, or the multi-turn dialogue generation method described in any embodiment of this application.
[0225] In the embodiments of this application, the terms "first" and "second" (if they exist) are used only as name identifiers and do not represent the order of first and second.
[0226] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus a general-purpose hardware platform. Based on this understanding, the technical solution of this application can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as a read-only memory (ROM) / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0227] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0228] The above description is merely an exemplary implementation of this application and is not intended to limit the scope of protection of this application.
Claims
1. A method for training a multi-turn dialogue model, characterized in that, The method includes: Obtain the task scenario; Obtain the set of intent types based on the task scenario; A slot seed template is obtained according to the task scenario, wherein the slot seed template includes a slot type and a slot value corresponding to the slot type; Construct triple data, wherein a triple data contains an intent type from the intent type set, a slot type, and a slot value corresponding to the slot type; Obtain robot behavior and corresponding robot response data based on the task scenario; A multi-turn dialogue strategy graph is constructed based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior; Construct a multi-turn dialogue dataset based on the multi-turn dialogue strategy graph; The multi-turn dialogue dataset is used as the model training sample to train a multi-turn dialogue model. The step of constructing multi-turn dialogue data based on the multi-turn dialogue strategy graph includes: The first dialogue state node is sampled from the set of dialogue state nodes contained in the multi-turn dialogue strategy graph, and the sampled first dialogue state node is set as the dialogue flow start node. The sampled node set is constructed and the dialogue flow end node is set. The sampled node set contains the dialogue state nodes that have been sampled. Determine whether the first dialogue state node is the end node of the dialogue process. If it is, use the triplet data corresponding to the first dialogue state node as the multi-turn dialogue dataset. If the first dialogue state node is not the dialogue process end node, then a first triplet data is sampled from at least one triplet data corresponding to the first dialogue state node, and the intent type contained in the first triplet data is used as the first data. A random number is sampled within a preset range. If the random number satisfies the first judgment condition, a first number threshold number of second dialogue state nodes are sampled from the unsampled node set outside the sampled node set. At least one triplet data corresponding to the collected second dialogue state node is sampled to obtain a second triplet data. The intent type contained in the second triplet data is concatenated with the first data to obtain the second data. The first number threshold number of second dialogue state nodes are added to the collected node set. If the random number satisfies the second judgment condition, then sample a second number threshold of third dialogue state nodes from the set of tail nodes corresponding to the directed edges with the first dialogue state node as the head node, and sample at least one triplet data corresponding to the third dialogue state node to obtain a third triplet data. Then, concatenate the intent type contained in the third triplet data with the first data to obtain the second data, and add the second number threshold of third dialogue state nodes to the set of collected nodes. If the random number satisfies the third judgment condition, then the first data is determined as the second data; The slot type contained in the first triplet data corresponding to the first dialogue state node is sampled, and the slot value corresponding to the slot type is obtained. The slot value is then concatenated with the second data to obtain the third data. The third data is added to the multi-turn dialogue dataset, and the first dialogue state node is added to the collected node set; A fourth dialogue state node is sampled from the dialogue state nodes that form a directed edge with the first dialogue state node. The steps of determining whether the fourth dialogue state node is the dialogue process end node and subsequent steps are repeated until the sampled dialogue state node is the dialogue process end node.
2. The method according to claim 1, characterized in that, The step of obtaining the slot seed template according to the task scenario includes: Determine the set of slot types based on the task scenario; Obtain a slot type from the set of slot types, and determine the slot value based on the slot type; The slot type and slot value are determined as the slot seed template.
3. The method according to any one of claims 1-2, characterized in that, The step of obtaining the slot seed template according to the task scenario includes: Sample at least two slot seed templates and splice them together to obtain a complex slot seed template.
4. The method according to claim 1, characterized in that, The step of constructing a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior includes: Set a set of dialogue state nodes, wherein each dialogue state node in the set corresponds to at least one triplet data and a robot behavior and robot response data corresponding to the robot behavior; A set of directed edges is set up, wherein any directed edge in the set of directed edges consists of a head node and a tail node, and the head node and the tail node are any dialogue state node in the set of dialogue state nodes. Each directed edge corresponds to at least one decision condition, which is used to determine the dialogue state node that needs to be called in the multi-turn dialogue task. A multi-turn dialogue strategy graph is generated based on the set of directed edges.
5. The method according to claim 1, characterized in that, After constructing the multi-turn dialogue dataset based on the multi-turn dialogue policy graph, the process further includes: The multi-turn dialogue dataset is input into a pre-trained language model with data rewriting capabilities, and the multi-turn dialogue dataset is rewritten to a level no less than the rewriting turn threshold. Each rewritten multi-turn dialogue dataset is added to the training dataset. When the number of rewritten turns exceeds the rewritten turn threshold, the training dataset is used as the training sample.
6. A method for generating multi-turn dialogues, characterized in that, The method includes: Input a given question into a multi-turn dialogue model; The multi-turn dialogue model determines the triplet data to be invoked based on the intent type of the given question; The dialogue state node is determined based on the triplet data, the robot behavior is determined based on the dialogue state node, and the robot response data corresponding to the robot behavior is determined based on the robot behavior. The multi-turn dialogue model outputs robot response data corresponding to the robot's behavior, wherein the multi-turn dialogue model is trained by the method described in any one of claims 1-5.
7. A multi-turn dialogue model training device, characterized in that, The device includes: The task scenario acquisition module is used to acquire task scenarios; The intent type set acquisition module is used to acquire the intent type set according to the task scenario. The slot seed template acquisition module is used to acquire slot seed templates according to the task scenario. The triplet data construction module is used to construct triplet data. The robot behavior data acquisition module is used to acquire robot behavior and robot response data corresponding to the robot behavior based on the task scenario. A multi-turn dialogue strategy graph construction module is used to construct a multi-turn dialogue strategy graph based on the triplet data, the robot behavior, and the robot response data corresponding to the robot behavior. A multi-turn dialogue dataset construction module is used to construct a multi-turn dialogue dataset based on the multi-turn dialogue policy graph. The model training module is used to train a multi-turn dialogue model by using the multi-turn dialogue dataset as model training samples. The multi-turn dialogue dataset construction module is specifically used for: The first dialogue state node is sampled from the set of dialogue state nodes contained in the multi-turn dialogue strategy graph, and the sampled first dialogue state node is set as the dialogue flow start node. The sampled node set is constructed and the dialogue flow end node is set. The sampled node set contains the dialogue state nodes that have been sampled. Determine whether the first dialogue state node is the end node of the dialogue process. If it is, use the triplet data corresponding to the first dialogue state node as the multi-turn dialogue dataset. If the first dialogue state node is not the dialogue process end node, then a first triplet data is sampled from at least one triplet data corresponding to the first dialogue state node, and the intent type contained in the first triplet data is used as the first data. A random number is sampled within a preset range. If the random number satisfies the first judgment condition, a first number threshold number of second dialogue state nodes are sampled from the unsampled node set outside the sampled node set. At least one triplet data corresponding to the collected second dialogue state node is sampled to obtain a second triplet data. The intent type contained in the second triplet data is concatenated with the first data to obtain the second data. The first number threshold number of second dialogue state nodes are added to the collected node set. If the random number satisfies the second judgment condition, then sample a second number threshold of third dialogue state nodes from the set of tail nodes corresponding to the directed edges with the first dialogue state node as the head node, and sample at least one triplet data corresponding to the third dialogue state node to obtain a third triplet data. Then, concatenate the intent type contained in the third triplet data with the first data to obtain the second data, and add the second number threshold of third dialogue state nodes to the set of collected nodes. If the random number satisfies the third judgment condition, then the first data is determined as the second data; The slot type contained in the first triplet data corresponding to the first dialogue state node is sampled, and the slot value corresponding to the slot type is obtained. The slot value is then concatenated with the second data to obtain the third data. The third data is added to the multi-turn dialogue dataset, and the first dialogue state node is added to the collected node set; A fourth dialogue state node is sampled from the dialogue state nodes that form a directed edge with the first dialogue state node. The steps of determining whether the fourth dialogue state node is the dialogue process end node and subsequent steps are repeated until the sampled dialogue state node is the dialogue process end node.
8. A multi-turn dialogue generation device, characterized in that, The device includes: The question input module is used to input a given question into the multi-turn dialogue model; The triplet invocation module is used to determine the triplet data to be invoked based on the intent type of the given question. The determination module is used to determine the dialogue state node based on the triplet data, and to determine the robot behavior based on the dialogue state node. An output module is used to output robot response data corresponding to the robot's behavior. The robot response data is obtained through a multi-turn dialogue model, which is trained by the method described in any one of claims 1-5.
9. A training device for a multi-turn dialogue model, characterized in that, The device includes: A memory for storing the training program or code of the multi-turn dialogue model; A processor is configured to execute the training program or code of the multi-turn dialogue model to implement the training method of the multi-turn dialogue model according to any one of claims 1-5, or the multi-turn dialogue generation method according to claim 6.
Citation Information
Patent Citations
Education robot dialogue data set generation method and device and storage medium
CN112256851A