Training of dialogue generation models, dialogue generation methods, devices and media

By constructing a dialogue generation model based on collaborative latent variables, the problem of insufficient external knowledge integration in existing systems is solved, enabling more efficient knowledge selection and response generation, and improving user experience.

CN117093676BActive Publication Date: 2025-10-31BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210498027.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-09
Publication Date
2025-10-31
Estimated Expiration
2042-05-09

AI Technical Summary

Technical Problem

Existing dialogue systems cannot effectively integrate external knowledge, resulting in poor interactive capabilities and the generation of irrelevant responses.

Method used

A dialogue generation model based on collaborative latent variables is constructed. By combining historical dialogue content, response information, and knowledge information through a first latent variable generation model, a second latent variable generation model, and a knowledge selection model, the model is adjusted using a loss function to improve the collaborative processing capability of knowledge selection and response generation.

Benefits of technology

It improved the ability to acquire relevant knowledge and the matching degree between user questions and answers, reduced irrelevant dialogue responses, and enhanced the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117093676B_ABST
    Figure CN117093676B_ABST
Patent Text Reader

Abstract

This disclosure provides a training method, apparatus, and storage medium for a dialogue generation model. The training method includes: generating a first variational latent variable using a first latent variable generation model and based on historical dialogue content information and knowledge selection history information; generating a second variational latent variable using a second latent variable generation model and based on historical dialogue content information and historical response information; generating knowledge selection information using a knowledge selection model and based on the first variational latent variable, historical dialogue content information, and a knowledge information set; obtaining response prediction information based on the knowledge selection information, historical dialogue content information, and the second variational latent variable; and performing adjustment processing based on the response prediction information. The method, apparatus, and storage medium of this disclosure can effectively coordinate knowledge selection and response generation, increasing the ability to acquire relevant knowledge, improving the accuracy of knowledge information acquisition, and improving the matching degree between questions and responses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of e-commerce, more and more users are choosing online shopping, leading to a huge increase in customer after-sales needs. In recent years, with the rapid development of artificial intelligence technology, automatic dialogue generation systems have been increasingly applied in e-commerce scenarios to help alleviate the pressure of growing customer demands. Currently, existing dialogue systems collect massive amounts of human customer service dialogue data to train large-scale deep learning models, accurately extracting and capturing user needs, understanding customer requirements, and simulating natural human responses. However, existing dialogue systems cannot effectively integrate external knowledge, resulting in poor interactivity and the generation of irrelevant responses. Summary of the Invention

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

[0004] According to a first aspect of this disclosure, a training method for a dialogue generation model is provided, wherein the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; the training method includes: acquiring historical dialogue content information, historical response information, and historical knowledge selection information as training samples; using the first latent variable generation model and based on the historical dialogue content information and the historical knowledge selection information to generate a first variational latent variable; using the second latent variable generation model and based on the historical dialogue content information and the historical response information to generate a second variational latent variable; using the knowledge selection model and based on the first variational latent variable, the historical dialogue content information, and a set of knowledge information to generate knowledge selection information; obtaining response prediction information based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable; and adjusting the dialogue generation model using a loss function and based on a comparison result between the response prediction information and the historical response information.

[0005] Optionally, the knowledge selection model includes: a heuristic matching model and a prediction model; the step of using the knowledge selection model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set to generate knowledge selection information includes: using the heuristic matching model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set to generate knowledge selection intermediate variable information; and using the prediction model and based on the knowledge selection intermediate variable information to generate the knowledge selection information.

[0006] Optionally, generating the first variational latent variable using the first latent variable generation model and based on the historical dialogue content information and the knowledge statement selection information includes: encoding the historical dialogue content information using a first encoding module to generate dialogue content encoding information; encoding the historical knowledge selection information using a second encoding module to generate knowledge selection encoding information; and inputting the dialogue content encoding information and the knowledge selection encoding information into the first latent variable generation model to generate the first variational latent variable.

[0007] Optionally, generating the second variational latent variable using the second latent variable generation model and based on the historical dialogue content information and the historical response information includes: encoding the historical response information using a third encoding module to generate historical response encoding information; and inputting the dialogue content encoding information and the historical response information into the second latent variable generation model to generate the second variational latent variable.

[0008] Optionally, generating intermediate variable information for knowledge selection using the heuristic matching model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set includes: encoding the knowledge information set using the fourth encoding module to generate knowledge set encoding information; and inputting the first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information into the heuristic matching model to obtain the intermediate variable information for knowledge selection.

[0009] Optionally, obtaining response prediction information based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable includes: encoding the knowledge selection information using a fifth encoding module to generate knowledge selection encoding information; and inputting the knowledge selection encoding information, the dialogue content encoding information, and the second variational latent variable into a decoder to obtain the response prediction information.

[0010] Optionally, the first variational latent variable includes: a variational latent variable based on a classification distribution; the second variational latent variable includes: a variational latent variable based on a normal distribution; and the loss function includes: a cross-entropy loss function.

[0011] According to a second aspect of this disclosure, a dialogue generation method is provided, comprising: acquiring a trained dialogue generation model; wherein the dialogue generation model is trained using the training method described above, and the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; generating a first variational latent variable using the first latent variable generation model and based on dialogue content information; generating a second variational latent variable using the second latent variable generation model and based on the dialogue content information; generating knowledge selection information using the knowledge selection model and based on the first variational latent variable, the dialogue content information, and a set of knowledge information; and obtaining response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable.

[0012] Optionally, the knowledge selection model includes: a heuristic matching model and a prediction model; the step of using the knowledge selection model and based on the first variational latent variable, the dialogue content information, and the knowledge information set to generate knowledge selection information includes: using the heuristic matching model and based on the first variational latent variable, the dialogue content information, and the knowledge information set to generate knowledge selection intermediate variable information; and using the prediction model and based on the knowledge selection intermediate variable information to generate the knowledge selection information.

[0013] Optionally, generating the first variational latent variable using the first latent variable generation model and based on the dialogue content information includes: encoding the dialogue content information using a first encoding module to generate dialogue content encoding information; and inputting the dialogue content encoding information into the first latent variable generation model to generate the first variational latent variable.

[0014] Optionally, generating a second variational latent variable using the second latent variable generation model and based on the dialogue content information includes: inputting the dialogue content encoding information into the second latent variable generation model to generate the second variational latent variable.

[0015] Optionally, generating intermediate variable information for knowledge selection using the heuristic matching model and based on the first variational latent variable, the dialogue content information, and the knowledge information set includes: encoding the knowledge information set using a fourth encoding module to generate knowledge set encoding information; and inputting the first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information into the heuristic matching model to obtain the intermediate variable information for knowledge selection.

[0016] Optionally, obtaining response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable includes: encoding the knowledge selection information using a fifth encoding module to generate knowledge selection encoding information; and inputting the knowledge selection encoding information, the dialogue content encoding information, and the second variational latent variable into a decoder to obtain the response prediction information.

[0017] Optionally, the first variational latent variable includes a variational latent variable based on a classification distribution; the second variational latent variable includes a variational latent variable based on a normal distribution.

[0018] According to a third aspect of this disclosure, a training apparatus for a dialogue generation model is provided, wherein the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; the training apparatus includes: a training sample acquisition module, used to acquire historical dialogue content information, historical response information, and historical knowledge selection information as training samples; a first variable generation module, used to generate a first variational latent variable using the first latent variable generation model and based on the historical dialogue content information and the historical knowledge selection information; a second variable generation module, used to generate a second variational latent variable using the second latent variable generation model and based on the historical dialogue content information and the historical response information; a first knowledge determination module, used to generate knowledge selection information using the knowledge selection model and based on the first variational latent variable, the historical dialogue content information, and a set of knowledge information; a first response prediction module, used to obtain response prediction information based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable; and a model adjustment module, used to adjust the dialogue generation model using a loss function and based on the comparison result between the response prediction information and the historical response information.

[0019] According to a fourth aspect of this disclosure, a dialogue generation apparatus is provided, comprising: a model acquisition module for acquiring a trained dialogue generation model; wherein the dialogue generation model is trained using the training method described above, and the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; a third variable generation module for generating a first variational latent variable using the first latent variable generation model and based on dialogue content information; a fourth variable generation module for generating a second variational latent variable using the second latent variable generation model and based on the dialogue content information; a second knowledge determination module for generating knowledge selection information using the knowledge selection model and based on the first variational latent variable, the dialogue content information, and a set of knowledge information; and a second response prediction module for obtaining response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable.

[0020] According to a fifth aspect of this disclosure, a training apparatus for a dialogue generation model 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.

[0021] According to a sixth aspect of this disclosure, a dialogue 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.

[0022] According to a seventh aspect of this disclosure, a computer-readable storage medium is provided that stores computer instructions which are executed by a processor as described above.

[0023] The training method, apparatus, and storage medium for the dialogue generation model disclosed herein, by constructing a dialogue generation model based on collaborative latent variables, can effectively coordinate knowledge selection and response generation, increase the ability to acquire relevant knowledge, improve the accuracy of knowledge information acquisition, improve the matching degree between user questions and responses, solve the problem of generating dialogue responses unrelated to knowledge, and improve the user experience. Attached Figure Description

[0024] 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.

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

[0026] Figure 2 A schematic diagram illustrating the principle framework of one embodiment of a dialogue generation model;

[0027] Figure 3 This is a schematic diagram illustrating the training method and data interaction process of the dialogue generation model according to this disclosure;

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

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

[0030] Figure 6 This is a schematic diagram of a module according to an embodiment of the dialogue generation apparatus of this disclosure;

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

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

[0033] 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. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present disclosure. The technical solutions of the present disclosure will be described in various aspects below with reference to the various figures and embodiments.

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

[0035] Knowledge-driven dialogue systems can leverage vast external knowledge sources, such as user profiles, user preferences, and shopping history, to better understand user intent and goals. With the advancements in Natural Language Processing (NLP) and Deep Learning technologies, knowledge-driven dialogue generation systems can have various models.

[0036] Dialogue generation models based on posterior knowledge selection: Posterior knowledge selection utilizes future information within the dialogue content to assist in knowledge selection, significantly improving the relevance between knowledge selection and dialogue content. Dialogue generation models based on serialization knowledge selection: Serialization knowledge selection models can track and save relevant knowledge content from different dialogue rounds across multiple rounds, effectively preserving historically selected knowledge and providing a reference for future knowledge selection.

[0037] Dialogue generation models based on knowledge distillation strategies: Dialogue models based on knowledge distillation strategies can increase the diversity of knowledge selection while utilizing future information in the dialogue content. The dialogue content provides possibilities through a variety of candidate knowledge choices. Dialogue generation models based on dual knowledge interaction: Dialogue models based on dual knowledge interaction accurately capture the two processes of knowledge tracking and knowledge shifting through dual interaction. They can not only effectively preserve the tracking of historical information, but also effectively select future knowledge information.

[0038] Existing knowledge-driven dialogue generation systems have the following drawbacks:

[0039] Overemphasizing knowledge selection while neglecting knowledge-based dialogue response generation: The knowledge selection process is an essential part of knowledge-driven dialogue systems, and it is also naturally coupled with the dialogue response generation process. Current work largely focuses on how to select suitable external knowledge, neglecting how to effectively introduce external knowledge into the response generation process. This results in dialogue systems that can effectively select knowledge but often produce knowledge-irrelevant dialogue responses, significantly weakening the enhancing effect of external knowledge on the dialogue system.

[0040] The existing methods neglect the interactive process between knowledge selection and dialogue response generation: To integrate selected knowledge into the dialogue content, they typically use pointer networks to replicate parts of the knowledge, often resulting in disjointed and incoherent dialogue responses. This problem stems from neglecting the interactive process between knowledge selection and dialogue response generation, necessitating improvements to enhance this interaction.

[0041] Figure 1 This is a flowchart illustrating an embodiment of the training method for a dialogue generation model according to the present disclosure. The dialogue generation model includes a first latent variable generation model, a second latent variable generation model, and a knowledge selection model, etc. Figure 1 As shown:

[0042] Step 101: Obtain historical dialogue content information, historical reply information, and historical knowledge selection information to use as training samples.

[0043] In one embodiment, historical dialogue content information can be historical dialogue data between the user and human customer service representatives, and historical response information is the information that human customer service representatives need to respond to in response to user questions in the historical dialogue data. A pre-set knowledge information set is included, comprising multiple pieces of knowledge information, such as statements like "Saturday and Sunday are weekends" and "Beijing is the capital." The historical knowledge selection information is the knowledge information selected from the knowledge information set when the dialogue generation model generates historical response information for user questions in the historical dialogue data.

[0044] Step 102: Using the first latent variable generation model and based on historical dialogue content information and knowledge selection historical information, generate the first variational latent variable. The first latent variable generation model can be of various types, such as the MLP (Multilayer Perceptron) model and other neural network models.

[0045] Step 103: Using the second latent variable generation model and based on historical dialogue content and historical response information, generate second variational latent variables. The second latent variable generation model can be of various types, such as MLP (Multilayer Perceptron) models and other neural network models.

[0046] Step 104: Use the knowledge selection model and generate knowledge selection information based on the first variational latent variable, historical dialogue content information, and knowledge information set.

[0047] In one embodiment, the knowledge selection model can be multiple models, and the knowledge selection information generated by the knowledge selection model is the knowledge information selected by the knowledge selection model from the knowledge information set.

[0048] Step 105: Use the loss function and select information based on knowledge, historical dialogue content information, and the second variational latent variable to obtain response prediction information.

[0049] In one embodiment, the first variational latent variable includes variational latent variables based on categorical distributions, and the second variational latent variable includes variational latent variables based on normal distributions. The response prediction information is the information that the dialogue generation model predicts the human customer service representative's response to based on the user's questions in historical dialogue data between the user and the human customer service representative.

[0050] Step 106: Adjust the dialogue generation model using a loss function and based on the comparison between predicted and historical responses. The loss function can be a cross-entropy loss function, etc.

[0051] Various existing model adjustment methods can be used to adjust the parameters of models such as the first latent variable generation model, the second latent variable generation model, and the knowledge selection model based on the differences determined by comparing the predicted response information with the historical response information, and using loss functions such as the cross-entropy loss function. This is done to ensure that the predicted response information is the same as the historical response information, or to keep the differences between the predicted response information and the historical response information within an acceptable range.

[0052] In one embodiment, such as Figure 2 As shown, the dialogue generation model is a novel knowledge-driven dialogue generation model based on collaborative latent variable modeling, which assigns two variational latent variables, namely the first variational latent variable z. k Second variational latent variable z r The first variational latent variable z k Second variational latent variable z r These are used for modeling knowledge selection and dialogue response generation, respectively. The first variational latent variable z is established. k Second variational latent variable z r And the dependencies between dialogue history content c, external knowledge (knowledge selection history information or knowledge selection information) k, and dialogue response r.

[0053] The choice of external knowledge k depends on the historical content c and z of the dialogue. k , use as Figure 2 The dotted lines and arrows in the diagram represent this dependency. The generation of the dialogue response (response prediction information) r depends on the dialogue's historical content c, external knowledge k, and the second variational latent variable z. r , use as Figure 2 The solid lines and arrows in the diagram represent this dependency. This corresponds to the dependencies during the training process of the dialogue generation model, as shown in... Figure 2 The dashed lines and arrows in the text are used for characterization.

[0054] According to such Figure 2 The dependencies in the model are used to train the dialogue generation model, enabling it to collaboratively handle the knowledge selection and dialogue response generation steps. This allows the knowledge-driven dialogue generation model to achieve good performance in both steps.

[0055] In one embodiment, the first variational latent variable can be generated using various methods. For example, a first encoding module can be used to encode historical dialogue content information to generate dialogue content encoded information. A second encoding module can be used to encode historical knowledge selection information to generate knowledge selection encoded information. The dialogue content encoded information and the knowledge selection encoded information are then input into the first latent variable generation model to generate the first variational latent variable.

[0056] There are several methods for generating the second variational latent variable. For example, a third encoding module can be used to encode historical response information, generating encoded historical response information. The encoded dialogue content and historical response information can then be input into the second latent variable generation model to generate the second variational latent variable. Two KL divergence loss functions can be used during training to guide the generation and construction of the first variational latent variable during knowledge selection and the second variational latent variable during response generation, respectively.

[0057] Knowledge selection models include heuristic matching models and prediction models. Heuristic matching models can be any existing type of heuristic matching model; prediction models can be of various types, such as two neural network models. Using the heuristic matching model and based on the first variational latent variable, historical dialogue content information, and the knowledge information set, intermediate knowledge selection variables are generated. Using the prediction model and based on the intermediate knowledge selection variables, knowledge selection information is generated.

[0058] There are several methods for generating intermediate variable information for knowledge selection. For example, the fourth encoding module can be used to encode the knowledge information set, generating knowledge set encoding information. The first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information can then be input into the heuristic matching model to obtain intermediate variable information for knowledge selection.

[0059] There are several methods to obtain response prediction information. For example, the fifth encoding module can be used to encode the knowledge selection information to generate knowledge selection encoded information. The knowledge selection encoded information, the dialogue content encoded information, and the second variational latent variable are then input into the decoder to obtain the response prediction information.

[0060] In one embodiment, such as Figure 3 As shown, Figure 3 The dotted lines and arrows in the diagram represent the data input during model training. The historical dialogue content information c is "What's your lucky number? My lucky number is 7, what's yours?", the historical reply information r is "-Oh! I see, I know it's between 6 and 8", and the knowledge selection historical information k is "The number 7 is between 6 and 8".

[0061] The encoding module can employ various methods, such as BERT (Bidirectional Encoder Representation from Transformers) encoders. Using the first encoding module, BERT encoder 1, the historical dialogue content information C, "What is your lucky number? My lucky number is 7, what about yours?", is encoded to generate the dialogue content encoded information h. c .

[0062] The second encoding module, BERT encoder 2, is used to encode the knowledge selection history information k, "the number 7 is between 6 and 8," to generate the knowledge selection encoded information h. k Encode the dialogue content into information h. c And knowledge selection encoding information h k Input the first latent variable generative model MLP1, and generate the first variational latent variable z. k .

[0063] The third encoding module, BERT encoder 3, is used to encode the historical response information r "Oh! I see, I know it's between 6 and 8" to generate the historical response encoded information h. r Encode the dialogue content into information h. c and historical reply information h r Input the second latent variable generative model MLP2 to generate the second variational latent variable z. r .

[0064] The knowledge information set KP is encoded using the fourth encoding module, BERT encoder 4, to generate the knowledge set encoded information h. kp The first variational hidden variable z k Dialogue content encoding information h c and knowledge set encoding information h kp Input an existing heuristic matching search model to obtain information h about intermediate variables for knowledge selection. cat .

[0065] The prediction model comprises two existing linear (neural) networks; the decoder can be of various types, such as the existing Transformer encoder. Knowledge is selected from intermediate variable information h. cat Given two linear networks, the linear networks generate the revelation and termination position of the knowledge selection information, and generate the knowledge selection information ks "the number 7 is between 6 and 8".

[0066] The fifth encoding module, BERT encoder 5, is used to encode the knowledge selection information "the number 7 is between 6 and 8", generating the knowledge selection encoded information h. ks The knowledge is selected and encoded using information h. ks and dialogue content encoding information h c and the second variational latent variable z r Input the Transformer encoder and get the response prediction information "Oh! I see, I knew it was between 6 and 8".

[0067] During model training, various existing methods can be used to jointly adjust the parameters of each component model of the dialogue generation model by using a loss function and comparing the response prediction information with the historical response information, so that the response prediction information is the same as or similar to the historical response information.

[0068] For example, loss functions include cross-entropy loss functions, and there are various types of cross-entropy loss functions. Cross-entropy loss functions are used during training to guide the comparison between predicted and historical responses during dialogue response generation, enabling overall adjustments to the dialogue generation model. Existing cross-entropy loss function training methods can be used. Based on the cross-entropy loss function and the predicted and historical responses, a sample loss function value is calculated. This sample loss function value is then used to adjust the parameters of the dialogue generation model to minimize the difference between predicted and historical responses or to keep it within acceptable limits.

[0069] In one embodiment, a set of dialogues C is defined as being performed by two participants, consisting of |c| dialogue history entries (words) C = c1, ..., c2. |c| The knowledge candidate set (knowledge information set) KP contains |k| knowledge phrases (knowledge information) KP = k1, ..., k |K| Each piece of knowledge information is a short sentence k i k i It contains M words. Each time, the dialogue generation model selects the short knowledge phrase k from the knowledge base KP that best matches the dialogue history information C. i .

[0070] In the training sample set, each piece of dialogue history information c has a corresponding knowledge information k that matches it. During the training phase, the loss function of each model is adjusted to ensure that the model fits the correct knowledge information. The dialogue generation model uses the dialogue history information C and the selected knowledge information k... i Generates responses r that are related to knowledge and dialogue history information.

[0071] like Figure 3 As shown, a pre-trained model encoder (BERT Encoder) is used to process the dialogue history information C and each knowledge phrase k in the knowledge base KP. i Encoding is then performed. The BERT encoder considers the textual information, positional information, and round information of each word in the sentence simultaneously, and the encoded result is h. c and h k .

[0072] During the model training phase, it is necessary to obtain the representation h of the corresponding dialogue response. rThis is used to supervise the training of the model. Variational latent variables z for dialogue response and knowledge selection are constructed based on Gaussian and Categorical distributions, respectively. r and z k .

[0073] By using a Prior Network and a Posterior Network for the model prediction and training phases respectively, the existing KL divergence function can be used to reconcile the parameters between the Prior Network and the Posterior Network. During training, the Prior Network and Posterior Network generate two independent latent variable distributions. In the loss function, the existing KL divergence function is used to reduce the difference between the two independent latent variable distributions, thereby approximating the posterior distribution to the prior distribution.

[0074] Based on the MLP model, the latent variable z in dialogue response r Able to express h based on the content of the dialogue c By introducing random sampling of a Gaussian distribution, a variational latent variable z is generated. r , z r =μ r +∑⊙σ r Among them, σ r It is a standard Gaussian variable, μ r And ∑ are determined by a feedforward neural network. In the prior network, according to h c Perform calculations; in the posterior network, based on h c and h r Calculate. μ r ∑ is the mean, ∑ is the restricted diagonal covariance matrix, and ⊙ is the softplus function. Similarly, based on the MLP model, the knowledge latent variable z k Based on the conversation content, h c By introducing random sampling of the categorical distribution, a variational latent variable z is generated. k .

[0075] Based on the sampled collaborative latent variable z r and z k First, we obtain the intermediate variables that will be used for subsequent knowledge selection. in This represents the multiplication symbol. Then, the resulting intermediate variable h... cat Two linear prediction models are fed into the knowledge base KP to predict the positions of the start and end words of the knowledge phrases. Based on the predicted positions, the knowledge phrases are extracted to form the final knowledge k.

[0076] For example, the intermediate variable hcat is fed into two existing linear prediction models. The linear prediction model transforms hcat into a low-dimensional vector and finally selects the position with the highest probability score through softmax as the start and end positions of the knowledge phrase. Because the number of knowledge phrases in each dialogue content is limited, its candidate positions are also limited (512), which is equivalent to predicting the start and end positions from 512 categories.

[0077] The vector representations of hc and hk are concatenated and input into the existing Transformer decoder model. The Transformer decoder model first performs an attention operation and then selects the word with the highest current probability score from several words in the vocabulary via a softmax function, which is then used as the word for the current decoding step. The currently decoded word and the previous hc and hk are then iteratively input into the Transformer decoder model until the entire sentence is decoded.

[0078] For example, using the existing dialogue history content C corresponding to the representation h c The representation h corresponding to the selected knowledge phrase k. k This process involves progressively decoding to obtain each word in the final dialogue response. After decoding is complete, the final dialogue response sentence is obtained: r = TransformerDecoder(h c h k ).

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

[0080] Step 401: Obtain the trained dialogue generation model; wherein, the dialogue generation model is trained by the training method described above, and the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model, etc.

[0081] Step 402: Use the first latent variable to generate the model and generate the first variational latent variable based on the dialogue content information.

[0082] Step 403: Use the second latent variable to generate the model and generate the second variational latent variable based on the dialogue content information.

[0083] Step 404: Using the knowledge selection model and based on the first variational latent variable, dialogue content information, and knowledge information set, generate knowledge selection information.

[0084] Step 405: Based on the knowledge selection information, dialogue content information, and the second variational latent variable, obtain the response prediction information.

[0085] In one embodiment, a first encoding module is used to encode the dialogue content information to generate coded dialogue content information. This coded dialogue content information is then input into a first latent variable generation model to generate a first variational latent variable. Finally, the coded dialogue content information is input into a second latent variable generation model to generate a second variational latent variable.

[0086] Knowledge selection models include heuristic matching models and predictive models. The heuristic matching model, based on the first variational latent variable, dialogue content information, and the knowledge information set, generates intermediate knowledge selection variables. The predictive model, based on the intermediate knowledge selection variables, generates knowledge selection information.

[0087] There are several methods for generating intermediate variable information for knowledge selection. For example, the fourth encoding module can be used to encode the knowledge information set, generating knowledge set encoding information. The first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information can then be input into the heuristic matching model to obtain intermediate variable information for knowledge selection.

[0088] The knowledge selection information is encoded using the fifth encoding module to generate knowledge selection encoded information; the knowledge selection encoded information, dialogue content encoded information, and the second variational latent variable are input into the decoder to obtain response prediction information.

[0089] In one embodiment, such as Figure 3 As shown, the dialogue content information C is "What is your lucky number? My lucky number is 7, what about yours?". The first encoding module, BERT encoder 1, encodes the dialogue content information C "What is your lucky number? My lucky number is 7, what about yours?" to generate the dialogue content encoded information h. c .

[0090] Encode the dialogue content into information h c Input the first latent variable generative model MLP1, and generate the first variational latent variable z. k Encode the dialogue content into information h. c Input the second latent variable generative model MLP2 to generate the second variational latent variable z. r .

[0091] The knowledge information set KP is encoded using the fourth encoding module, BERT encoder 4, to generate the knowledge set encoded information h. kp The first variational hidden variable z k Dialogue content encoding information h c and knowledge set encoding information h kp Input the heuristic matching model h to obtain information about intermediate variables for knowledge selection.cat .

[0092] Select intermediate variable information h from knowledge cat Input a linear model, and generate the knowledge selection information ks: "The number 7 is between 6 and 8". Use the fifth encoding module, BERT Encoder 5, to encode the knowledge selection information "The number 7 is between 6 and 8", generating the knowledge selection encoded information h. ks Alternatively, the dialogue content information C can be encoded using the fifth encoding module, BERT encoder 5.

[0093] Encode the knowledge selection information h ks and dialogue content encoding information h c and the second variational latent variable z r Input the Transformer encoder and obtain the response prediction information "Oh! I see, I know it's between 8 and 6".

[0094] The training method and dialogue generation method of the dialogue generation model in the above embodiments, by constructing a dialogue generation model based on collaborative latent variables, can effectively coordinate knowledge selection and response generation, increase the ability to acquire relevant knowledge, improve the accuracy of knowledge information acquisition, improve the matching degree between user questions and responses, solve the problem of generating dialogue responses unrelated to knowledge, and improve the user experience.

[0095] In one embodiment, such as Figure 5 As shown, this disclosure provides a training device 50 for a dialogue generation model, including a training sample acquisition module 51, a first variable generation module 52, a second variable generation module 53, a first knowledge determination module 54, a first response prediction module 55, and a model adjustment module 56.

[0096] The training sample acquisition module 51 acquires historical dialogue content information, historical response information, and historical knowledge selection information to serve as training samples. The first variable generation module 52 uses the first latent variable generation model and, based on the historical dialogue content information and historical knowledge selection information, generates the first variational latent variable. The second variable generation module 53 uses the second latent variable generation model and, based on the historical dialogue content information and historical response information, generates the second variational latent variable.

[0097] The first knowledge determination module 54 uses a knowledge selection model and generates knowledge selection information based on the first variational latent variable, historical dialogue content information, and a knowledge information set. The first response prediction module 55 obtains response prediction information based on the knowledge selection information, historical dialogue content information, and the second variational latent variable. The model adjustment module 56 uses a loss function and adjusts the dialogue generation model based on the comparison results between the response prediction information and historical response information.

[0098] In one embodiment, the knowledge selection model includes a heuristic matching model and a prediction model, etc. The first knowledge determination module 54 uses the heuristic matching model and, based on the first variational latent variable, historical dialogue content information, and a knowledge information set, generates intermediate variable information for knowledge selection. The first knowledge determination module 54 uses the prediction model and, based on the intermediate variable information for knowledge selection, generates knowledge selection information.

[0099] The first variable generation module 52 uses the first encoding module to encode the historical dialogue content information, generating dialogue content encoding information. The first variable generation module 52 uses the second encoding module to encode the historical knowledge selection information, generating knowledge selection encoding information. The first variable generation module 52 inputs the dialogue content encoding information and the knowledge selection encoding information into the first latent variable generation model to generate the first variational latent variable.

[0100] The second variable generation module 53 uses the third encoding module to encode the historical response information, generating encoded historical response information. The second variable generation module 53 then inputs the encoded dialogue content information and the historical response information into the second latent variable generation model to generate the second variational latent variable.

[0101] In one embodiment, the first knowledge determination module 54 uses the fourth encoding module to encode the knowledge information set, generating knowledge set encoding information. The first knowledge determination module 54 inputs the first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information into the heuristic matching model to obtain intermediate variable information for knowledge selection.

[0102] The first response prediction module 55 uses the fifth encoding module to encode the knowledge selection information, generating knowledge selection encoded information. The first response prediction module 55 then inputs the knowledge selection encoded information, the dialogue content encoded information, and the second variational latent variable into the decoder to obtain response prediction information.

[0103] In one embodiment, such as Figure 6 As shown, this disclosure provides a dialogue generation device 60, including: a model acquisition module 61, a third variable generation module 62, a fourth variable generation module 63, a second knowledge determination module 64, and a second response prediction module 65.

[0104] The model acquisition module 61 acquires the trained dialogue generation model. The third variable generation module 62 uses the first latent variable generation model and generates the first variational latent variable based on the dialogue content information. The fourth variable generation module 63 uses the second latent variable generation model and generates the second variational latent variable based on the dialogue content information. The second knowledge determination module 64 uses the knowledge selection model and generates knowledge selection information based on the first variational latent variable, the dialogue content information, and the knowledge information set. The second response prediction module 65 obtains response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable.

[0105] In one embodiment, the knowledge selection model includes a heuristic matching model and a prediction model, etc.; the second knowledge determination module 64 uses the heuristic matching model and, based on the first variational latent variable, dialogue content information, and knowledge information set, generates intermediate variable information for knowledge selection. The second knowledge determination module 64 uses the prediction model and, based on the intermediate variable information for knowledge selection, generates knowledge selection information.

[0106] The third variable generation module 62 uses the first encoding module to encode the dialogue content information, generating coded dialogue content information. The third variable generation module 62 then inputs the coded dialogue content information into the first latent variable generation model to generate the first variational latent variable. The fourth variable generation module 63 inputs the coded dialogue content information into the second latent variable generation model to generate the second variational latent variable.

[0107] The second knowledge determination module 64 uses the fourth encoding module to encode the knowledge information set, generating knowledge set encoding information. The second knowledge determination module 64 inputs the first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information into the heuristic matching model to obtain intermediate variable information for knowledge selection.

[0108] The second response prediction module 65 uses the fifth encoding module to encode the knowledge selection information, generating knowledge selection encoded information. The second response prediction module 65 then inputs the knowledge selection encoded information, the dialogue content encoded information, and the second variational latent variable into the decoder to obtain response prediction information.

[0109] In one embodiment, such as Figure 7 As shown, this disclosure provides a training apparatus for a dialogue generation model, which may include a memory 72, a processor 71, a communication interface 73, and a bus 74. The memory 72 is used to store instructions, and the processor 71 is coupled to the memory 72. The processor 71 is configured to execute the above-described training method for the dialogue generation model based on the instructions stored in the memory 72.

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

[0111] In one embodiment, such as Figure 8 As shown, this disclosure provides a dialogue generation apparatus that may include a memory 82, a processor 81, a communication interface 83, and a bus 84. The memory 82 is used to store instructions, and the processor 81 is coupled to the memory 82. The processor 81 is configured to execute the dialogue generation method described above based on the instructions stored in the memory 82.

[0112] The memory 82 can be a high-speed RAM, non-volatile memory, or a memory array. The memory 82 may also be divided into blocks, and these blocks can be combined into virtual volumes according to certain rules. The processor 81 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 method of this disclosure.

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

[0114] The training of the dialogue generation model, the dialogue generation method, the device, and the storage medium in the above embodiments, by constructing a dialogue generation model based on collaborative latent variables, can effectively coordinate knowledge selection and response generation, increase the ability to acquire relevant knowledge, improve the accuracy of acquiring knowledge information, improve the matching degree between user questions and responses, solve problems such as generating dialogue responses unrelated to knowledge, and improve the user experience.

[0115] The methods and systems of this disclosure can be implemented in many ways. For example, they can 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.

[0116] 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 training method for a dialogue generation model, wherein, The dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; the training method includes: Historical dialogue content, historical response information, and historical knowledge selection information are obtained and used as training samples. The first latent variable is used to generate a model and the first variational latent variable is generated based on the historical dialogue content information and the knowledge selection historical information. The second latent variable is used to generate a model and a second variational latent variable is generated based on the historical dialogue content information and the historical response information; The knowledge selection model is used to generate knowledge selection information based on the first variational latent variable, the historical dialogue content information, and the knowledge information set; Based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable, response prediction information is obtained; The dialogue generation model is adjusted using a loss function and based on the comparison results between the predicted response information and the historical response information.

2. The training method as described in claim 1, wherein, The knowledge selection model includes: a heuristic matching model and a prediction model; the step of using the knowledge selection model and generating knowledge selection information based on the first variational latent variable, the historical dialogue content information, and the knowledge information set includes: Using the heuristic matching model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set, knowledge selection intermediate variable information is generated; The knowledge selection information is generated by using the prediction model and selecting intermediate variable information based on the knowledge.

3. The training method as described in claim 2, wherein generating the first variational latent variable using the first latent variable generation model and based on the historical dialogue content information and the knowledge selection historical information includes: The historical dialogue content information is encoded using the first encoding module to generate dialogue content encoding information; The knowledge selection history information is encoded using the second encoding module to generate knowledge selection encoded information; The dialogue content encoding information and the knowledge selection encoding information are input into the first latent variable generation model to generate the first variational latent variable.

4. The training method as described in claim 3, wherein generating the second variational latent variable using the second latent variable generation model and based on the historical dialogue content information and the historical response information includes: The historical reply information is encoded using a third encoding module to generate historical reply encoded information; The dialogue content encoding information and the historical reply information are input into the second latent variable generation model to generate the second variational latent variable.

5. The training method as described in claim 3, wherein generating intermediate variable information for knowledge selection using the heuristic matching model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set includes: The knowledge information set is encoded using the fourth encoding module to generate knowledge set encoded information; The first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information are input into the heuristic matching model to obtain the knowledge selection intermediate variable information.

6. The training method as described in claim 3, wherein obtaining response prediction information based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable includes: The knowledge selection information is encoded using the fifth encoding module to generate knowledge selection encoded information; The knowledge selection encoding information, the dialogue content encoding information, and the second variational latent variable are input into the decoder to obtain the response prediction information.

7. The training method according to any one of claims 1 to 6, wherein, The first variational latent variable includes: variational latent variables based on the classification distribution; The second variational latent variable includes: variational latent variables based on a normal distribution; The loss function includes: cross-entropy loss function.

8. A dialogue generation method, comprising: A pre-trained dialogue generation model is obtained; wherein the dialogue generation model is trained by any one of the training methods of claims 1 to 7, and the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; The model is generated using the first latent variable and the first variational latent variable is generated based on the dialogue content information; The second latent variable is used to generate the model and, based on the dialogue content information, the second variational latent variable is generated. The knowledge selection model is used to generate knowledge selection information based on the first variational latent variable, the dialogue content information, and the knowledge information set. Based on the knowledge selection information, the dialogue content information, and the second variational latent variable, response prediction information is obtained.

9. The method of claim 8, wherein, The knowledge selection model includes: a heuristic matching model and a prediction model; the step of using the knowledge selection model and generating knowledge selection information based on the first variational latent variable, the dialogue content information, and the knowledge information set includes: Using the heuristic matching model and based on the first variational latent variable, the dialogue content information, and the knowledge information set, knowledge selection intermediate variable information is generated; The knowledge selection information is generated by using the prediction model and selecting intermediate variable information based on the knowledge.

10. The method of claim 9, wherein generating the first variational latent variable using the first latent variable generation model and based on dialogue content information comprises: The first encoding module is used to encode the dialogue content information to generate dialogue content encoded information; The dialogue content encoding information is input into the first latent variable generation model to generate the first variational latent variable.

11. The method of claim 10, wherein generating the second variational latent variable using the second latent variable generation model and based on the dialogue content information comprises: The dialogue content encoding information is input into the second latent variable generation model to generate the second variational latent variable.

12. The method of claim 10, wherein generating intermediate variable information for knowledge selection using the heuristic matching model and based on the first variational latent variable, the dialogue content information, and the knowledge information set includes: The knowledge information set is encoded using the fourth encoding module to generate knowledge set encoded information; The first variational latent variable, the dialogue content encoding information, and the knowledge set encoding information are input into the heuristic matching model to obtain the knowledge selection intermediate variable information.

13. The method of claim 10, wherein obtaining response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable includes: The knowledge selection information is encoded using the fifth encoding module to generate knowledge selection encoded information; The knowledge selection encoding information, the dialogue content encoding information, and the second variational latent variable are input into the decoder to obtain the response prediction information.

14. The method according to any one of claims 8 to 13, wherein, The first variational latent variable includes: variational latent variables based on the classification distribution; The second variational latent variable includes: variational latent variables based on a normal distribution.

15. A training device for a dialogue generation model, wherein, The dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; the training device includes: The training sample acquisition module is used to acquire historical dialogue content information, historical response information, and knowledge selection history information, which are used as training samples. The first variable generation module is used to generate a first variational latent variable by using the first latent variable generation model and based on the historical dialogue content information and the knowledge selection historical information. The second variable generation module is used to generate a second variational latent variable using the second latent variable generation model and based on the historical dialogue content information and the historical response information; The first knowledge determination module is used to generate knowledge selection information using the knowledge selection model and based on the first variational latent variable, the historical dialogue content information, and the knowledge information set; The first response prediction module is used to obtain response prediction information based on the knowledge selection information, the historical dialogue content information, and the second variational latent variable; The model adjustment module is used to adjust the dialogue generation model using a loss function and based on the comparison results between the predicted response information and the historical response information.

16. A dialogue generation apparatus, comprising: The model acquisition module is used to acquire a trained dialogue generation model; wherein the dialogue generation model is trained by the training method of any one of claims 1 to 7, and the dialogue generation model includes: a first latent variable generation model, a second latent variable generation model, and a knowledge selection model; The third variable generation module is used to generate the first variational latent variable using the first latent variable generation model and based on the dialogue content information; The fourth variable generation module is used to generate a second variational latent variable using the second latent variable generation model and based on the dialogue content information; The second knowledge determination module is used to generate knowledge selection information using the knowledge selection model and based on the first variational latent variable, the dialogue content information, and the knowledge information set; The second response prediction module is used to obtain response prediction information based on the knowledge selection information, the dialogue content information, and the second variational latent variable.

17. A training device for a dialogue generation model, 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 7 based on instructions stored in the memory.

18. A dialogue generation apparatus, comprising: Memory; and a processor coupled to the memory, the processor being configured to perform the method as described in any one of claims 8 to 14 based on instructions stored in the memory.

19. A computer-readable storage medium that non-transitoryly stores computer instructions, which are executed by a processor according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Training method of dialogue generation model and dialogue generation method and device

    CN110457457A

  • Construction method of knowledge enhancement model for multi-sub-target dialogue recommendation system

    CN114168721A