Dialogue generation model training, dialogue reply generation method and device, and medium

By employing a hierarchical attention mechanism to train the dialogue generation model, the importance of information from previous dialogue rounds is distinguished, thereby improving the response accuracy and user experience of the dialogue generation model.

CN114416949BActive Publication Date: 2026-04-17BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD
Filing Date
2022-01-19
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing dialogue generation models fail to effectively distinguish the importance of each round of questions and responses during training, resulting in noise affecting the accuracy of response generation.

Method used

A hierarchical attention mechanism is adopted to weight the dialogue information from previous rounds. By using importance scoring and attention weighting mechanisms, the weight of relevant information is increased and the weight of irrelevant information is reduced, thereby achieving information filtering and improving the quality of response generation.

Benefits of technology

It improves the accuracy of responses from the dialogue generation model and enhances the user experience, thereby improving the quality of responses generated in the current round.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416949B_ABST
    Figure CN114416949B_ABST
Patent Text Reader

Abstract

This disclosure provides a dialogue generation model training method, dialogue response generation method and apparatus, and storage medium. The method includes: generating training samples based on historical question information and current question information; processing the training samples using a dialogue generation model; determining the importance scores corresponding to historical question information and current question information; determining the target word generation probability corresponding to the current question information based on the importance scores; generating response prediction information corresponding to the current question information based on the target word generation probability; determining a loss function based on the response prediction information; and adjusting the dialogue generation model based on the loss function. The method, apparatus, and storage medium of this disclosure employ a hierarchical attention mechanism to weight historical dialogue information, increasing the weight between relevant historical dialogue information and current question information, thereby improving the generation quality of the current response.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a dialogue generation model training, dialogue response generation method and apparatus, and storage medium. Background Technology

[0002] Dialogue generation is a task that generates responses based on dialogue history and the questions asked in the current turn. Dialogue history typically consists of multiple turns, each containing a question and a response. In existing dialogue generation models, the input is a long text concatenated from the questions and responses of each turn in the dialogue history, without distinguishing between the questions and responses of each turn. In practical applications, the importance of questions and responses varies. Important questions and responses positively impact the generation of the current response, while irrelevant questions and responses constitute noise and affect the accuracy of the generated response. Summary of the Invention

[0003] In view of this, one technical problem to be solved by the present invention is to provide a dialogue generation model training, dialogue response generation method and apparatus, and storage medium.

[0004] According to a first aspect of this disclosure, a method for training a dialogue generation model is provided, comprising: generating historical turn question information corresponding to the historical dialogue information based on question information and response information in historical dialogue information; generating training samples based on the historical turn question information and current question information; processing the training samples using a dialogue generation model to determine an importance score corresponding to the historical turn question information and the current question information; determining an attention weight based on the importance score; using the dialogue generation model and based on the attention weight to determine a target word generation probability corresponding to the current turn question information; generating response prediction information corresponding to the current question information based on the target word generation probability; determining a loss function based on the response prediction information; and adjusting the dialogue generation model based on the loss function.

[0005] Optionally, the step of processing the training samples using a dialogue generation model to determine the importance score corresponding to the historical question information and the current question information includes: using question separators and response separators to isolate the question information and response information in the training samples; using the encoder of the dialogue generation model to encode the historical question information to obtain the encoded hidden state information corresponding to the historical question information; and obtaining the importance score between the current question information and the historical question information based on the encoded hidden state information.

[0006] Optionally, the encoded hidden state information includes: question encoded hidden state information and response encoded hidden state information; obtaining the importance score between the current question information and the question information in the historical rounds based on the encoded hidden state information includes: using the first activation function of the dialogue generation model to obtain a first activation function value corresponding to the question encoded hidden state information; using the first activation function to obtain a second activation function value corresponding to the response encoded hidden state information; and obtaining the importance score based on the first activation function value, the second activation function value, and the second activation function.

[0007] Optionally, determining the attention weight based on the importance score includes: determining the initial weight of the question information in the historical rounds; multiplying the initial weight by the corresponding importance score as the new weight; and summing the new weights of all the question information in the historical rounds to obtain the attention weight.

[0008] Optionally, determining the initial weights of the historical rounds of questioning information includes: using the third activation function of the dialogue generation model to obtain a third activation function value corresponding to the historical rounds of questioning information; and obtaining the initial weights based on the third activation function value and the second activation function.

[0009] Optionally, determining the target word generation probability corresponding to the current round of question information using the dialogue generation model and based on the attention weights includes: using the decoder of the dialogue generation model and performing decoding processing based on the attention weights to obtain the decoded hidden state information corresponding to the current round of question information; and obtaining the target word generation probability based on the decoded hidden state information and the second activation function.

[0010] Optionally, generating response prediction information corresponding to the current question information based on the target word generation probability includes: selecting the candidate word with the highest target word generation probability as the target word, and generating the response prediction information.

[0011] Optionally, determining a loss function based on the response prediction information and adjusting the dialogue generation model based on the loss function includes: determining a cross-entropy loss function based on the response prediction information and adjusting the dialogue generation model based on the cross-entropy loss function.

[0012] According to a second aspect of this disclosure, a dialogue response generation method is provided, comprising: generating historical round question information corresponding to the historical dialogue information based on question information and response information in historical dialogue information; generating dialogue prediction information based on the historical round question information and the current question information; obtaining a trained dialogue generation model, and using the dialogue generation model to process the dialogue prediction information to generate response prediction information corresponding to the current question information; wherein the dialogue generation model is trained by the training method described above.

[0013] According to a third aspect of this disclosure, a dialogue generation model training apparatus is provided, comprising: a question turn generation module, configured to generate historical turn question information corresponding to the historical dialogue information based on question information and response information in historical dialogue information; a training sample generation module, configured to generate training samples based on the historical turn question information and current question information; an importance scoring module, configured to process the training samples using the dialogue generation model to determine an importance score corresponding to the historical turn question information and the current question information; an attention weight module, configured to determine an attention weight based on the importance score; a generation probability determination module, configured to determine a target word generation probability corresponding to the current turn question information using the dialogue generation model and based on the attention weight; a prediction information generation module, configured to generate response prediction information corresponding to the current question information based on the target word generation probability; and a model adjustment processing module, configured to determine a loss function based on the response prediction information and adjust the dialogue generation model based on the loss function.

[0014] Optionally, the importance scoring module is used to isolate the question information and response information in the training samples using a question separator and a response separator; to encode the historical round question information using the encoder of the dialogue generation model to obtain the encoded hidden state information corresponding to the historical round question information; and to obtain the importance score between the current question information and the historical round question information based on the encoded hidden state information.

[0015] Optionally, the encoded hidden state information includes: question encoded hidden state information and response encoded hidden state information; the importance scoring module is further configured to use the first activation function of the dialogue generation model to obtain a first activation function value corresponding to the question encoded hidden state information; use the first activation function to obtain a second activation function value corresponding to the response encoded hidden state information; and obtain the importance score based on the first activation function value, the second activation function value, and the second activation function.

[0016] Optionally, the attention weight module is used to determine the initial weight of the historical rounds of questioning information; multiply the initial weight by the corresponding importance score as the new weight; and sum the new weights of all historical rounds of questioning information to obtain the attention weight.

[0017] Optionally, the attention weight module is further configured to use the third activation function of the dialogue generation model to obtain a third activation function value corresponding to the question information in the historical rounds; and to obtain the initial weight based on the third activation function value and the second activation function.

[0018] Optionally, the generation probability determination module is used to use the decoder of the dialogue generation model and perform decoding processing according to the attention weights to obtain the decoded hidden layer state information corresponding to the question information of the current round; and to obtain the target word generation probability based on the decoded hidden layer state information and the second activation function.

[0019] Optionally, the prediction information generation module is specifically used to select the candidate word with the highest generation probability of the target word as the target word and generate the response prediction information.

[0020] Optionally, the model adjustment processing module is specifically used to determine the cross-entropy loss function based on the response prediction information, and to adjust the dialogue generation model based on the cross-entropy loss function.

[0021] According to a fourth aspect of this disclosure, a dialogue response generation apparatus is provided, comprising: a history information generation module, configured to generate historical turn question information corresponding to the historical dialogue information based on question information and response information in the historical dialogue information; a dialogue information generation module, configured to generate dialogue prediction information based on the historical turn question information and the current question information; and a prediction information processing module, configured to acquire a trained dialogue generation model, process the dialogue prediction information using the dialogue generation model, and generate response prediction information corresponding to the current question information; wherein the dialogue generation model is trained using the training method described above.

[0022] According to a fifth aspect of this disclosure, a dialogue generation model training apparatus is provided, comprising: a memory; and a processor coupled to the memory, the processor being configured to perform the method described above based on instructions stored in the memory.

[0023] According to a sixth aspect of this disclosure, a dialogue response generation apparatus is provided, comprising: a memory; and a processor coupled to the memory, the processor being configured to perform the method described above based on instructions stored in the memory.

[0024] According to a seventh aspect of this disclosure, a computer-readable storage medium is provided that stores computer instructions which, when executed by a processor, perform the method described above.

[0025] The dialogue generation model training, dialogue response generation method and apparatus, and storage medium disclosed herein employ a hierarchical attention mechanism to weight the dialogue information from previous rounds. This increases the weight between relevant historical dialogue information and the question information in the current round, while decreasing the weight between historical dialogue information unrelated to the question information in the current round. This achieves the effect of information filtering, improves the quality of the generated response in the current round, enhances the accuracy of the response information, and improves the user experience. Attached Figure Description

[0026] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 This is a flowchart illustrating an embodiment of the dialogue generation model training method according to the present disclosure;

[0028] Figure 2 This is a schematic diagram of the process for determining importance scores in one embodiment of the dialogue generation model training method according to the present disclosure;

[0029] Figure 3 This is a schematic diagram of the process for determining importance scores in another embodiment of the dialogue generation model training method according to the present disclosure;

[0030] Figure 4 This is a schematic diagram of the process for determining attention weights in one embodiment of the dialogue generation model training method according to the present disclosure;

[0031] Figure 5 This is a flowchart illustrating an embodiment of the dialogue response generation method according to the present disclosure;

[0032] Figure 6 A schematic diagram of a module of an embodiment of a dialogue generation model training apparatus according to the present disclosure;

[0033] Figure 7 A schematic diagram of a module of an embodiment of a dialogue response generation apparatus according to the present disclosure;

[0034] Figure 8This is a schematic diagram of a module of another embodiment of a dialogue generation model training apparatus according to the present disclosure;

[0035] Figure 9 This is a schematic diagram of a module according to another embodiment of the dialogue response generation apparatus according to the present disclosure. Detailed Implementation

[0036] The present disclosure will now be described more fully with reference to the accompanying drawings, which illustrate exemplary embodiments of the present disclosure. The technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present disclosure without creative effort are within the scope of protection of the present disclosure.

[0037] The terms "first" and "second" used in the following text are only used to describe the differences between them and have no other special meaning.

[0038] Figure 1 This is a flowchart illustrating an embodiment of the dialogue generation model training method according to the present disclosure, as follows: Figure 1 As shown:

[0039] Step 101: Based on the question and response information in the historical dialogue information, generate historical round question information corresponding to the historical dialogue information. The historical round question information includes the question and corresponding response information in a historical question.

[0040] Step 102: Generate training samples based on historical question information and current question information. Current question information refers to the question information in the current round of dialogue.

[0041] Step 103: Process the training samples using a dialogue generation model to determine the importance scores corresponding to the question information from previous rounds and the current question information. The dialogue generation model can be of various types, such as the Transformer model. The Transformer model is a model proposed by Google.

[0042] Step 104: Determine the attention weight based on the importance score, use the dialogue generation model and, based on the attention weight, determine the target word generation probability corresponding to the question information in the current round.

[0043] Step 105: Generate response prediction information corresponding to the current question information based on the target word generation probability.

[0044] Step 106: Determine the loss function based on the response prediction information, and adjust the dialogue generation model based on the loss function.

[0045] The dialogue generation model training method disclosed herein improves the encoder-decoder framework based on the Transformer model. It utilizes an improved hierarchical attention mechanism to weight the text of historical rounds, increasing the weight of dialogue rounds relevant to the current round and decreasing the weight of dialogue rounds unrelated to the current round, thereby achieving an information filtering effect and improving the generation quality of responses in the current round.

[0046] The question and response texts in a given round of dialogue are considered important only if they are important to the current round; otherwise, they are considered noise. First, an importance score is obtained for each round of dialogue corresponding to the current question. Then, this importance score is used to regularize the attention mechanism of the text in each round of dialogue, resulting in attention weights.

[0047] If the question in the historical k-th round of dialogue is very similar to the question in the current round of dialogue, then the k-th round of dialogue and the current round of dialogue are highly correlated. If the question in the historical k-th round of dialogue is not similar to the question in the current round of dialogue, then the response in the k-th round of dialogue is very likely not to have resolved the question in the current round of dialogue (because the current round of dialogue reposts the response to the k-th round of dialogue), and the k-th round of dialogue is likely to be noise.

[0048] For example, in the k-th round of dialogue: Question: "What material is the crystal of this watch made of?" Answer: "Mineral crystal glass." In the current round of dialogue: Question: "How hard is the watch crystal?" Answer: "Very hard, military-grade." As can be seen, the question in the current round of dialogue is related to the question in the k-th round of dialogue, and the k-th round of dialogue helps generate the response for the current round of dialogue.

[0049] In round k: Question: "How hard is the crystal material of this watch?" Answer: "The crystal material is mineral crystal glass." In the current round: Question: "What is mineral crystal glass?" Answer: "It's a type of reinforced glass with high transparency and good scratch resistance." As can be seen, the question in the current round is related to the response in round k, but the round k question did not resolve the user's problem and did not contribute to generating a response in the current round.

[0050] In one embodiment, given a historical dialogue, including K rounds of dialogue, each round of dialogue consists of a question. And a reply The structure of the question text in the i-th round of dialogue. ,in Representing a single character, the reply text in the i-th round of the dialogue. ,in, It represents a single character.

[0051] When training the dialogue generation model, assume the training objective is the response to the 5th round of dialogue, i.e., the output objective of the dialogue generation model is... The input consists of historical information from the first four rounds of dialogue and the question from the fifth round of dialogue (the current question information), meaning each training sample is:

[0052]

[0053] (1-1);

[0054] Among them, the question separator is used. and Symbols are used as separators to separate the question and response information in each round of dialogue in the training samples.

[0055] There are several methods to determine the importance score corresponding to the question information in the previous rounds and the current question information. Figure 2 This is a schematic diagram of the process for determining importance scores in one embodiment of the dialogue generation model training method according to the present disclosure, as shown below. Figure 2 As shown:

[0056] Step 201: Use question separators and response separators to isolate the question and response information in the training samples.

[0057] Step 202: Use the encoder of the dialogue generation model to encode the question information from previous rounds to obtain the encoded hidden state information corresponding to the question information from previous rounds.

[0058] Step 203: Based on the encoded hidden state information, obtain the importance score between the current question information and the question information in previous rounds.

[0059] Figure 3 This is a schematic diagram of the process for determining importance scores in another embodiment of the dialogue generation model training method according to this disclosure. The encoded hidden state information includes the question encoded hidden state information and the response encoded hidden state information, such as... Figure 3 As shown:

[0060] Step 301: Use the first activation function of the dialogue generation model to obtain the value of the first activation function corresponding to the hidden state information of the question encoding.

[0061] Step 302: Using the first activation function, obtain the value of the second activation function corresponding to the response encoded hidden state information.

[0062] Step 303: Obtain an importance score based on the first activation function value, the second activation function value, and the second activation function.

[0063] In one embodiment, the encoder of the Transformer model, a dialogue generation model, is used. Questions about historical rounds Encode the hidden state h to generate the encoded hidden state:

[0064] (1-2);

[0065] in, For the information of the historical rounds in round i, This is the encoded hidden state information corresponding to the historical round question information of round i.

[0066] Determine the importance of information from previous rounds and information from the current round:

[0067] (1-3);

[0068] (1-4);

[0069] in, It is the question separator in the k-th round of the dialogue. The corresponding encoded hidden layer vector, It is the reply separator for the k-th round of dialogue. The corresponding encoded hidden layer vector. Let be the importance parameter between the question information in the t-th round of dialogue and the question information in the k-th round of dialogue; , It is a 1*p dimensional vector. Let p be a matrix. It is a p*1 dimensional vector. for , After vector multiplication, the result is a real number; where... , , .

[0070] The function is the first excitation function. The function is the second excitation function. That is, the input at time t. The importance score of each turn of dialogue (corresponding to the current question information).

[0071] There are several methods for determining attention weights. Figure 4This is a schematic diagram illustrating the process of determining attention weights in one embodiment of the dialogue generation model training method according to this disclosure, as shown below. Figure 4 As shown:

[0072] Step 401: Determine the initial weights of the questions asked in the historical rounds.

[0073] Step 402: The product of the initial weight and the corresponding importance score is used as the new weight.

[0074] Step 403: Sum the new weights of all historical question information to obtain the attention weights.

[0075] There are several methods to determine the initial weights of the questions asked in previous rounds. For example, one method is to use the third activation function of the dialogue generation model to obtain the value of the third activation function corresponding to the questions asked in previous rounds, and then obtain the initial weights based on the value of the third activation function and the second activation function.

[0076] There are several methods to determine the target word generation probability corresponding to the current round of question information. For example, the decoder of the dialogue generation model can be used to perform decoding processing based on attention weights to obtain the decoded hidden state information corresponding to the current round of question information. Based on the decoded hidden state information and the second activation function, the target word generation probability can be obtained.

[0077] In one embodiment, word-level attention weights are calculated using the following formula:

[0078] (1-5);

[0079] in, , . Let t be the attention weight value corresponding to the question information from the i-th round in the previous rounds. The encoded hidden state information is the output of the encoder of the dialogue generation model after the question information of the i-th round in the previous rounds is encoded.

[0080] This is the third activation function for the Transformer dialogue generation model.

[0081] (1-6);

[0082] in, The initial weights are the historical question information for the i-th round.

[0083] (1-7);

[0084] in, This refers to the attention weight of the i-th character in the historical question information from the k-th round. Decoding is performed using this weight:

[0085] (1-8);

[0086] (1-9);

[0087] in, The vector after the attention mechanism That is, the input at time t (or Attention weights, representing The importance of time t; yt-1 is the standard output at time t-1; Hidden state vector of the decoder at time t The hidden state vector of the decoder at time t-1; The attention context vector at time t; N is the total number of rounds.

[0088] The decoder calculates the target word based on the decoded hidden state s. The generation probability:

[0089] (1-10);

[0090] in, .

[0091] The candidate word with the highest generation probability is selected as the target word, and response prediction information is generated. The cross-entropy loss function is determined based on the response prediction information, and the dialogue generation model is adjusted accordingly.

[0092] For example, the loss function is the cross-entropy loss function: ; It is the generation probability of the target word w.

[0093] The dialogue generation model is adjusted based on the existing cross-entropy loss function. Cross-entropy is used to measure the difference between two probability distributions. In machine learning, it can be used as a loss function to measure the similarity between two values. When using the sigmoid function in gradient descent, it can avoid the problem of reduced learning rate caused by the mean squared error loss function.

[0094] Figure 5 This is a flowchart illustrating an embodiment of the dialogue response generation method according to the present disclosure, as follows: Figure 5 As shown:

[0095] Step 501: Generate historical round question information corresponding to the historical dialogue information based on the question and reply information in the historical dialogue information.

[0096] Step 502: Generate dialogue prediction information based on historical question information and current question information.

[0097] Step 503: Obtain the trained dialogue generation model, process the dialogue prediction information using the dialogue generation model, and generate response prediction information corresponding to the current question information. The dialogue generation model is trained using the dialogue generation model training method described in any of the above embodiments.

[0098] In one embodiment, such as Figure 6 As shown, this disclosure provides a dialogue generation model training device 60, including a question turn generation module 61, a training sample generation module 62, an importance scoring module 63, an attention weight module 64, a generation probability determination module 65, a prediction information generation module 66, and a model adjustment processing module 67.

[0099] The question turn generation module 61 generates historical turn question information corresponding to the historical dialogue information based on the question and response information in the historical dialogue information. The training sample generation module 62 generates training samples based on the historical turn question information and the current question information. The importance scoring module 63 processes the training samples using the dialogue generation model to determine the importance score corresponding to the historical turn question information and the current question information.

[0100] Attention weight module 64 determines attention weights based on importance scores. Generation probability determination module 65 uses the dialogue generation model and, based on the attention weights, determines the target word generation probability corresponding to the current round's question information. Prediction information generation module 66 generates response prediction information corresponding to the current question information based on the target word generation probability. Model adjustment module 67 determines the loss function based on the response prediction information and adjusts the dialogue generation model based on the loss function.

[0101] In one embodiment, the importance scoring module 63 uses question separators and response separators to isolate question and response information in the training samples. The importance scoring module 63 uses the encoder of the dialogue generation model to encode the question information from previous rounds, obtaining encoded hidden state information corresponding to the question information from previous rounds. Based on the encoded hidden state information, the importance scoring module 63 obtains an importance score between the current question information and the question information from previous rounds.

[0102] The encoded hidden state information includes the question encoded hidden state information and the response encoded hidden state information. The importance scoring module 63 uses the first activation function of the dialogue generation model to obtain the first activation function value corresponding to the question encoded hidden state information. The importance scoring module 63 uses the first activation function to obtain the second activation function value corresponding to the response encoded hidden state information. Based on the first activation function value, the second activation function value, and the second activation function, the importance scoring module 63 obtains an importance score.

[0103] In one embodiment, the attention weighting module 64 determines the initial weights of the question information from previous rounds, and uses the product of the initial weights and the corresponding importance scores as the new weights. The attention weighting module 64 sums the new weights of all the question information from previous rounds to obtain the attention weights.

[0104] The attention weighting module 64 uses the third activation function of the dialogue generation model to obtain the third activation function value corresponding to the question information in the previous rounds. Based on the third activation function value and the second activation function, the attention weighting module 64 obtains the initial weights.

[0105] In one embodiment, the generation probability determination module 65 uses the decoder of the dialogue generation model and performs decoding processing according to attention weights to obtain the decoded hidden layer state information corresponding to the question information in the current round. Based on the decoded hidden layer state information and the second activation function, the generation probability determination module 65 obtains the target word generation probability.

[0106] The prediction information generation module 66 selects the candidate word with the highest generation probability as the target word and generates response prediction information. The model adjustment and processing module 67 determines the cross-entropy loss function based on the response prediction information and adjusts the dialogue generation model based on the cross-entropy loss function.

[0107] In one embodiment, such as Figure 7 As shown, this disclosure provides a dialogue response generation device 70, including a historical information generation module 71, a dialogue information generation module 72, and a prediction information processing module 73. The historical information generation module 71 generates historical turn question information corresponding to the historical dialogue information based on the question and response information in the historical dialogue information. The dialogue information generation module 72 generates dialogue prediction information based on the historical turn question information and the current question information. The prediction information processing module 73 uses a trained dialogue generation model to process the dialogue prediction information and generate response prediction information corresponding to the current question information.

[0108] Figure 8 This is a schematic diagram of a module of another embodiment of the dialogue generation model training apparatus according to the present disclosure. Figure 8As shown, the device may include a memory 81, a processor 82, a communication interface 83, and a bus 84. The memory 81 is used to store instructions, and the processor 82 is coupled to the memory 81. The processor 82 is configured to execute the dialogue generation model training method described above based on the instructions stored in the memory 81.

[0109] The memory 81 can be a high-speed RAM, non-volatile memory, or a memory array. The memory 81 may also be divided into blocks, and these blocks can be combined into virtual volumes according to certain rules. The processor 82 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the dialogue generation model training method of this disclosure.

[0110] Figure 9 This is a schematic diagram of a module according to another embodiment of the dialogue response generation apparatus according to the present disclosure. Figure 9 As shown, the device may include a memory 91, a processor 92, a communication interface 93, and a bus 94. The memory 91 is used to store instructions, and the processor 92 is coupled to the memory 91. The processor 92 is configured to execute the above-described dialogue response generation method based on the instructions stored in the memory 91.

[0111] The memory 91 can be a high-speed RAM, non-volatile memory, or a memory array. The memory 91 may also be divided into blocks, and these blocks can be combined into virtual volumes according to certain rules. The processor 92 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the dialogue response generation method of this disclosure.

[0112] In one embodiment, this disclosure provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the dialogue generation model training method as described in any of the preceding embodiments.

[0113] The dialogue generation model training, dialogue response generation method and device, and storage medium in the above embodiments employ a hierarchical attention mechanism to weight the historical dialogue information, thereby increasing the weight between relevant historical dialogue information and the current dialogue question information, and decreasing the weight between historical dialogue information unrelated to the current dialogue question information. This achieves the effect of information filtering, improves the generation quality of the current response, enhances the accuracy of the response information, and improves the user experience.

[0114] The methods and systems of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.

[0115] The description in this disclosure is provided for illustrative and descriptive purposes only and is not intended to be exhaustive or to limit the disclosure to its forms. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of this disclosure and to enable those skilled in the art to understand this disclosure and to design various embodiments with various modifications suitable for a particular purpose.

Claims

1. A method for training a dialogue generation model, comprising: Based on the question and response information in the historical dialogue information, generate historical round question information corresponding to the historical dialogue information; Training samples are generated based on the historical question information and the current question information. The training samples are processed using a dialogue generation model to determine the importance scores corresponding to the historical question information and the current question information, including: Question separators and response separators are used to isolate the question and response information in the training samples; The encoder of the dialogue generation model is used to encode the historical round question information to obtain the encoded hidden state information corresponding to the historical round question information. The encoded hidden state information includes question encoded hidden state information and response encoded hidden state information. Using the first activation function of the dialogue generation model, obtain the value of the first activation function corresponding to the hidden state information of the question encoding; Using the first activation function, obtain the value of the second activation function corresponding to the hidden state information of the response encoding; The importance score is obtained based on the first activation function value, the second activation function value, and the second activation function. Based on the importance score, an attention weight is determined, and the dialogue generation model is used to determine the target word generation probability corresponding to the question information in the current round, based on the attention weight. Based on the target word generation probability, generate response prediction information corresponding to the current question information; The loss function is determined based on the response prediction information, and the dialogue generation model is adjusted based on the loss function.

2. The method of claim 1, wherein determining the attention weight based on the importance score comprises: Determine the initial weights of the historical rounds of questions; The product of the initial weight and the corresponding importance score is used as the new weight; The attention weights are obtained by summing the new weights of all historical question information.

3. The method as described in claim 2, wherein determining the initial weights of the historical rounds of questioning information includes: Using the third activation function of the dialogue generation model, obtain the third activation function value corresponding to the question information of the historical rounds; The initial weights are obtained based on the value of the third activation function and the second activation function.

4. The method as described in claim 2, wherein determining the target word generation probability corresponding to the current round of question information using the dialogue generation model and based on the attention weights includes: The decoder of the dialogue generation model is used and the decoding process is performed according to the attention weights to obtain the decoded hidden layer state information corresponding to the question information of the current round; Based on the decoded hidden layer state information and the second activation function, the target word generation probability is obtained.

5. The method as described in claim 1, wherein generating response prediction information corresponding to the current question information based on the target word generation probability includes: The candidate word with the highest generation probability of the target word is selected as the target word, and the response prediction information is generated.

6. The method according to any one of claims 1 to 5, wherein determining a loss function based on the response prediction information and adjusting the dialogue generation model based on the loss function comprises: The cross-entropy loss function is determined based on the response prediction information, and the dialogue generation model is adjusted based on the cross-entropy loss function.

7. A method for generating dialogue responses, comprising: Based on the question and response information in the historical dialogue information, generate historical round question information corresponding to the historical dialogue information; Dialogue prediction information is generated based on the historical questioning information and the current questioning information. Obtain a trained dialogue generation model, use the dialogue generation model to process the dialogue prediction information, and generate response prediction information corresponding to the current question information; The dialogue generation model is trained using the training method described in any one of claims 1 to 6.

8. A dialogue generation model training device, comprising: The question turn generation module is used to generate historical turn question information corresponding to the historical dialogue information based on the question information and response information in the historical dialogue information; The training sample generation module is used to generate training samples based on the historical round question information and the current question information. The importance scoring module is used to process the training samples using a dialogue generation model to determine the importance score corresponding to the question information in the historical rounds and the current question information; The importance scoring module is configured to: isolate question and response information in the training samples using question separators and response separators; encode the historical question information using the encoder of the dialogue generation model to obtain encoded hidden state information corresponding to the historical question information, wherein the encoded hidden state information includes question encoded hidden state information and response encoded hidden state information; obtain a first activation function value corresponding to the question encoded hidden state information using the first activation function of the dialogue generation model; obtain a second activation function value corresponding to the response encoded hidden state information using the first activation function; and obtain the importance score based on the first activation function value, the second activation function value, and the second activation function. An attention weighting module is used to determine attention weights based on the importance score; A probability generation module is used to determine the generation probability of the target word corresponding to the question information in the current round using the dialogue generation model and based on the attention weight; The prediction information generation module is used to generate response prediction information corresponding to the current question information based on the target word generation probability; The model adjustment processing module is used to determine a loss function based on the response prediction information and adjust the dialogue generation model based on the loss function.

9. The apparatus of claim 8, wherein, The attention weighting module is used to determine the initial weight of the question information in the historical rounds; and to use the product of the initial weight and the corresponding importance score as the new weight. The attention weights are obtained by summing the new weights of all historical question information.

10. The apparatus of claim 9, wherein, The attention weight module is further configured to use the third activation function of the dialogue generation model to obtain a third activation function value corresponding to the question information in the historical rounds; and to obtain the initial weight based on the third activation function value and the second activation function.

11. The apparatus of claim 9, wherein, The generation probability determination module is used to use the decoder of the dialogue generation model and perform decoding processing according to the attention weights to obtain the decoded hidden layer state information corresponding to the question information of the current round. Based on the decoded hidden layer state information and the second activation function, the target word generation probability is obtained.

12. The apparatus of claim 8, wherein, The prediction information generation module is specifically used to select the candidate word with the highest generation probability of the target word as the target word and generate the response prediction information.

13. The apparatus according to any one of claims 8 to 12, wherein, The model adjustment processing module is specifically used to determine the cross-entropy loss function based on the response prediction information, and to adjust the dialogue generation model based on the cross-entropy loss function.

14. A dialogue response generation device, comprising: The historical information generation module is used to generate historical round question information corresponding to the historical dialogue information based on the question and reply information in the historical dialogue information; The dialogue information generation module is used to generate dialogue prediction information based on the historical round question information and the current question information; The prediction information processing module acquires a trained dialogue generation model, processes the dialogue prediction information using the dialogue generation model, and generates response prediction information corresponding to the current question information. The dialogue generation model is trained using the training method described in any one of claims 1 to 6.

15. A dialogue generation model training device, comprising: Memory; And a processor coupled to the memory, the processor being configured to perform the method as described in any one of claims 1 to 6 based on instructions stored in the memory.

16. A dialogue response generation device, comprising: Memory; and a processor coupled to the memory, the processor being configured to perform the method of claim 7 based on instructions stored in the memory.

17. A computer-readable storage medium storing computer instructions that are executed by a processor according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Generative multi-round chat dialogue method and system and computer-readable storage medium

    CN108681610A

  • Single-user personalized dialogue method and system adopting PCC dialogue model

    CN112199481A