Difference-aware response generation method and system based on remote supervision and knowledge distillation
Through the differentially perceived reply generation method of remote supervision and knowledge distillation, the deep learning network model is used to select background knowledge, which solves the problem of single reply and inconsistent context in the dialogue generation model, and improves the accuracy of generating replies and the fun of dialogue.
Patent Information
- Application Number
- CN202310794764.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2043-06-30
AI Technical Summary
The existing dialogue generation model lacks specificity and context consistency when generating replies, resulting in a single reply content, affecting the persistence and fun of the conversation, and there are errors when selecting external knowledge, affecting the quality of the generation.
The differentially perceived reply generation method based on remote supervision and knowledge distillation is adopted. By collecting conversations in social platforms and searching background knowledge in Wikipedia, a training data set is constructed, background knowledge is selected using deep learning network models, and the accuracy of responses is improved through knowledge distillation and remote supervision methods.
It improves the accuracy and context consistency of the dialogue generation model when generating replies, enhances the continuity and fun of the dialogue, reduces the probability of choosing wrong knowledge, and improves the quality of the response.
Smart Images

Figure CN116775840B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing, and specifically relates to a difference-aware response generation method and system based on remote supervision and knowledge distillation. Background Art
[0002] Dialogue generation is a key task in the field of natural language processing (NLP), focusing on how to enable computers to engage in conversational communication with humans. In 1950, Turing published a method for evaluating computer systems in his paper "Computers and Intelligence," known as the "Turing Test." This unprecedentedly clear goal and direction for computer intelligence—demonstrating a computer's intelligence through human-computer dialogue—grabbed widespread attention from scholars. With the rapid development of the internet, dialogue generation systems have been widely used in education, language learning, intelligent customer service, personal assistants, and other fields, bringing convenience to people's lives. Dialogue generation systems have a wide range of applications and profound research potential. They can not only serve as helpful assistants in our daily lives, but also as friendly companions, significantly improving people's quality of life and social productivity.
[0003] With the continuous advancement of deep learning research, many researchers have also applied deep learning models to the field of dialogue generation. Sequence-to-sequence (Seq2Seq) models based on the encoder-decoder framework are the mainstream models for generative dialogue systems. Vinyals proposed using a Long Short-Term Memory Network (LSTM) as the encoder and decoder network structure. The encoder encodes the context, and the decoder generates the corresponding response based on the encoded context information. This Seq2Seq-based generative dialogue system can be trained in an end-to-end manner and can generate responses based on learned language skills.
[0004] During further research, researchers discovered that traditional Seq2Seq-based conversation generation models tend to generate generic, safe responses such as "OK," "I don't know," and "Me too." These responses contain little conversational information, easily discouraging the interlocutor from continuing the conversation and hindering its continued flow. To address this issue, researchers mimicked the way people think during conversations. When formulating responses, people typically consider not only the current conversation but also their own background knowledge about the topic. Therefore, knowledge selection, which selects appropriate sentences from pre-retrieved knowledge bases, has attracted considerable attention. Zhang et al. pointed out that previous models lacked specificity and did not represent consistent personalities, resulting in less engaging conversations. They proposed the Persona-chat dataset, which consists of crowdsourced conversations in which each person plays a designated role and attempts to understand the other person, aiming to generate richer and more engaging conversations for the model to learn to emulate. Zhou et al. noted that knowledge-driven conversation systems are significantly limited by the lack of multi-topic, knowledge-annotated, multi-turn conversation datasets. To this end, they transformed the topics in multi-turn conversations into knowledge graphs and proposed KdConv, a Chinese multi-domain knowledge-driven conversation dataset. Dinan et al. first proposed to divide the knowledge dialogue task into two sub-problems: first, select knowledge from a large number of candidate knowledge bases, and then generate responses based on the selected knowledge and dialogue context, and proposed the Wizard of Wikipedia dataset to handle the knowledge dialogue task.
[0005] Existing research on conversational response generation that incorporates external knowledge primarily focuses on how to select and incorporate knowledge. Long et al. convoluted textual knowledge and then fed it into a decoder along with historical information for response generation. Ghazvininejad et al. used a memory network to store textual knowledge and then generate responses containing richer information. Zhu et al. proposed using a copy mechanism to copy required entities from the conversation history and background knowledge into the response. Furthermore, some researchers have attempted to adopt a pipeline approach, decomposing the task into two subtasks: knowledge selection and dialogue generation based on knowledge selection, achieving excellent performance. Lian et al. proposed using posterior knowledge distribution to guide knowledge selection, thereby generating more appropriate and informative responses in conversations. Kim et al. proposed a sequential latent variable model that, by modeling historical knowledge selection, reduces the range of possible candidate knowledge and improves the accuracy of knowledge selection. Zhan et al. abstracted knowledge into topic tags, explicitly modeling knowledge transfer in multi-turn conversations, and pre-trained a knowledge-aware response generator to focus more on the selected knowledge. However, existing pipeline methods rarely pay attention to the relevance of candidate knowledge within a specific round, and the prior distribution is difficult to approximate the posterior distribution during training, resulting in the selection of incorrect knowledge, which in turn affects the quality of generated responses. Summary of the Invention
[0006] The purpose of the present invention is to provide a difference-aware response generation method and system based on remote supervision and knowledge distillation, which is conducive to improving the accuracy of generated responses.
[0007] To achieve the above objectives, the present invention adopts a technical solution: a difference-aware response generation method based on remote supervision and knowledge distillation, comprising the following steps:
[0008] Step A: Collect natural, open-domain conversations on social platforms, use a retrieval system to retrieve background knowledge related to the conversations from Wikipedia, and annotate the labels of the real responses to construct the training dataset DE;
[0009] Step B: Use the training dataset DE to train a deep learning network model M based on distant supervision and knowledge distillation. This model selects the required background knowledge and generates responses based on the selected background knowledge.
[0010] Step C: Input the conversation context and background knowledge base into the trained deep learning network model M to generate the corresponding response.
[0011] Furthermore, the step B specifically includes the following steps:
[0012] Step B1: Initially encode all training samples in the training dataset DE to obtain the sentence representation vector of the current conversation. The sentence representation vector of the true response in this round The sentence representation vector of the candidate knowledge in this round
[0013] Step B2: The sentence representation vector of the previous conversation obtained in step B1 is And the sentence representation vector of the real response in this round Get the dialogue history information representation through GRU encoding The sentence representation vector of candidate knowledge The vector representation r with inter-sentence relationship information is obtained by BiGRU encoding t ;
[0014] Step B3: Represent the sentences of candidate knowledge selected by the previous M rounds of models The candidate knowledge vector representation r of the current round with the inter-sentence relationship information obtained in step B2 t Perform difference calculations and sum the difference information of different rounds according to the order of rounds through a weighted function based on time decay to obtain the difference information representation of candidate knowledge
[0015] Step B4: Use the distant supervision method to obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge
[0016] Step B5: Using the knowledge distillation method, the student knowledge selector uses the conversation history information of the previous round The sentence representation vector of the conversation above this round As the query vector, the real response vector is added to the query vector of the teacher knowledge selector, and then the sentence representation vector of the candidate knowledge of this round is The difference information obtained in step B3 is connected as the key vector of the teacher selector and the student selector, and the attention scores of the two are calculated respectively. The knowledge with the highest score is used as the knowledge selected by the two selectors, and the distribution of the student selector is trained to approximate the distribution of the teacher selector, and the knowledge selected by the student selector is used as the key vector of the teacher selector. As the knowledge of this round of selection;
[0017] Step B6: Adopt a two-stage training strategy based on self-paced learning, and transform the knowledge selected in this round into or pseudo-true knowledge The information from the conversation is input into the decoder to generate the response for this round. Specifically, the pseudo-real knowledge obtained in step B4 is used in the pre-training phase. During the training, the self-paced learning strategy is used in the fine-tuning stage, and the pseudo-real knowledge is used according to the size of the scoring function. or knowledge selected in this round Input the selected knowledge and context information into the decoder to generate the response y of this round t ;
[0018] Step B7: When the loss value change generated by each iteration of the deep learning network model is less than a given threshold or reaches the maximum number of iterations, the training process of the deep learning network model is terminated.
[0019] Furthermore, the step B1 specifically includes the following steps:
[0020] Step B11: traverse the training dataset DE, perform word segmentation on the conversation content and knowledge, and remove special symbols and stop words. Each training sample in DE is represented as de = (x t ,y t , k t ); where x t For the content of the previous dialogue, y t is x t The corresponding set of true responses, k t is the background knowledge set corresponding to this round of dialogue;
[0021] The text content of the previous dialogue x t Expressed as:
[0022]
[0023] in, For the dialogue above x t The i-th word in , i = 1, 2, ..., |x t |,|x t |For the previous conversation x t The number of words;
[0024] True reply y t Expressed as:
[0025]
[0026] in, For true reply y t The i-th word in y, i = 1, 2, ..., |y t |,|y t | is the real reply y t The number of words;
[0027] Background knowledge set k t Expressed as:
[0028]
[0029] Among them, N represents the number of candidate knowledge in this round, and each candidate knowledge Expressed as:
[0030]
[0031] in, For each candidate knowledge The jth word in Candidate knowledge The number of words;
[0032] Step B12: Get the dialogue context of step B11 Encode it through BERT and then use the average pooling layer to get the representation vector of the conversation above The calculation process is as follows:
[0033]
[0034]
[0035] Among them, MeanPool(·) represents the average pooling function;
[0036] Step B13: Get the dialogue context of step B11 Encoded by BERT, and then the sentence representation vector of the real response is obtained through the average pooling layer The calculation process is as follows:
[0037]
[0038]
[0039] Among them, MeanPool(·) represents the average pooling function;
[0040] Step B14: Background knowledge obtained in step B11 Encode each one through BERT, and then obtain the sentence representation vector of the candidate knowledge through the average pooling layer The calculation process is as follows:
[0041]
[0042]
[0043] Among them, MeanPool(·) represents the average pooling function.
[0044] Furthermore, the step B2 specifically includes the following steps:
[0045] Step B21: Vector representation of the conversation context through GRU and the vector representation of the true response Encode and get the dialogue history information representation The calculation process is as follows:
[0046]
[0047] Step B22: The sentence representation vector of the candidate knowledge obtained in step B14 is further encoded by BiGRU to obtain the candidate knowledge vector representation of the inter-sentence relationship perception The calculation process is as follows:
[0048]
[0049] Furthermore, the step B3 specifically includes the following steps:
[0050] Step B31: Calculate the weight λ of each round using the time decay function m , the calculation process is as follows:
[0051]
[0052] f(m)=e -αm
[0053] Step B32: The knowledge selected by the past M rounds of models The difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 is calculated, and the result λ obtained in step B31 is used to calculate the difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 and the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B31 is calculated. m Perform weighted summation of the difference information of different rounds to obtain the difference information representation of candidate knowledge The calculation results are as follows:
[0054]
[0055] Diff(a,b)=FullConnect([ab;a⊙b])
[0056] Where [;] represents the connection operation, FullConnect(·) is the fully connected layer activated by tanh, and α is the attenuation coefficient.
[0057] Furthermore, the step B4 specifically includes the following steps:
[0058] Step B41: Obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge The calculation process is as follows:
[0059]
[0060]
[0061]
[0062] Furthermore, the step B5 specifically includes the following steps:
[0063] Step B51: The student knowledge selector uses the conversation history information obtained in step B21 And the conversation vector of this round obtained in step B12 Perform splicing as a query, use the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 as the key, and calculate the attention score to obtain the probability distribution of the selected knowledge The calculation process is as follows:
[0064]
[0065] Among them, tanh(·) is the activation function, W stuque , W stukey , v T is a trainable parameter;
[0066] Step B52: Distribute the student knowledge selection obtained in step B51 Perform normalization operation and take the knowledge with the highest probability as the selected knowledge of this round of knowledge selector The calculation process is as follows:
[0067]
[0068]
[0069] Among them, softmax() is a normalization function, and argmax() is a function that finds the independent variable corresponding to the maximum value of the function;
[0070] Step B53: The teacher knowledge selector uses the conversation context information obtained in step B21 combined with the real response of this round As a query, the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 are used as keys, and the probability distribution of the selected knowledge is obtained by calculating the attention score. The calculation process is as follows:
[0071]
[0072] Among them, tanh(·) is the activation function, W teaque , W teakey , v T is a trainable parameter;
[0073] Step B54: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The student knowledge selector is trained using cross entropy loss. The calculation process is as follows:
[0074]
[0075] in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the student’s knowledge selector;
[0076] Step B55: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The teacher knowledge selector is trained using cross entropy loss. The calculation process is as follows:
[0077]
[0078] in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the teacher's knowledge selector;
[0079] Step B56: The selection distribution of the student knowledge selector is trained by minimizing the distillation loss to fit the selection distribution of the teacher knowledge selector. The calculation process is as follows:
[0080]
[0081] in, KL divergence of the student selection distribution and the teacher selection distribution;
[0082] Step B57: Add the student selector loss of step B54, the teacher selector loss of step B55, and the distillation loss of step B56 as the overall loss of the knowledge selector. The calculation process is as follows:
[0083]
[0084] Furthermore, the step B6 specifically includes the following steps:
[0085] Step B61: A two-stage training method based on a self-paced learning strategy is used, and pseudo-real knowledge is used in the pre-training stage. As the knowledge selected in this round, the fine-tuning stage adopts a self-paced learning strategy. The knowledge selected by the knowledge selector is regarded as a complex sample, and the pseudo-true knowledge is regarded as a simple sample. The loss of the student knowledge selector is used as the score of the self-paced learning. A weight V is set to indicate whether the complex sample should be used for response generation. V is calculated as follows:
[0086]
[0087]
[0088] δ=h(T)=δ0e T
[0089] Step B62: Select the knowledge Dialogue above x t The concatenation is performed and the input is combined with the Transformer decoder with the replication mechanism to generate the response of this round. The process is as follows:
[0090]
[0091]
[0092]
[0093]
[0094]
[0095]
[0096] Among them, [;] represents the connection operation, TransformerDecoder() represents the Transformer decoder, is the hidden vector of the nth word in this round of reply, MultHead() represents the multi-head attention mechanism, represents the vocabulary, is the final generated distribution;
[0097] Step B63: Calculate the loss value based on the weight V obtained in step B61 And the confidence weight of the pseudo-true knowledge label obtained in step B41 The generation loss is weighted and calculated as follows:
[0098]
[0099]
[0100] Step B64: Take the sum of the knowledge selection loss obtained in step B57 and the generation loss obtained in step B63 as the total loss, and use backpropagation to iteratively update the model parameters to minimize the loss function to train the model. The total loss is calculated as follows:
[0101]
[0102] The present invention also provides a difference-aware response generation system using the above method, comprising:
[0103] The data collection module is used to extract the conversation content and background knowledge of open-domain conversations on social platforms, annotate real responses, and construct a training set;
[0104] The preprocessing module is used to preprocess the training samples in the training set, including word segmentation and stop word removal;
[0105] The encoding module is used to find the word vectors of the pre-processed input content, response content, and background knowledge content in the pre-trained word vector matrix, and encode this information to obtain the representation vectors of the input content, response content, and background knowledge;
[0106] The difference information construction module calculates the difference between the knowledge selected in the previous round and the candidate knowledge in the current round, and uses the time-decay weighting function to weight and sum the difference information of different rounds to obtain the difference information representation of the knowledge in this round;
[0107] The network model training module is used to input the representation vector of the input dialogue, the representation vector of the response, the representation vector of the background knowledge, and the difference information representation into the deep learning network. It selects the background knowledge required for the current round of dialogue and inputs the selected knowledge and context into the decoder to generate the response for this round. The loss is calculated by comparing with the real responses in the training set. The entire deep learning network is trained with the goal of minimizing the loss, resulting in a deep learning network model for difference-aware response generation based on distant supervision and knowledge distillation.
[0108] The reply generation module is used to generate replies. It uses a trained deep learning network model for difference-aware reply generation based on remote supervision and knowledge distillation to analyze and process the input conversation, select the knowledge for this round based on the context and difference information, and then generate a reply based on the selected knowledge.
[0109] Compared with the existing technology, the present invention has the following beneficial effects: the present invention provides a difference-aware reply generation method and system based on remote supervision and knowledge distillation. The method constructs a deep learning network model based on remote supervision and knowledge distillation, and uses this model to select the required background knowledge, and generates replies based on the selected background knowledge, thereby improving the accuracy of reply generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0110] Figure 1 is a flowchart of a method implementation of an embodiment of the present invention;
[0111] Figure 2 is an architectural diagram of a deep learning network model in an embodiment of the present invention;
[0112] Figure 3 This is a flowchart of processing the previous conversation, the current round of real responses, and candidate knowledge in an embodiment of the present invention;
[0113] Figure 4 Schematic diagram of the system structure of an embodiment of the present invention. DETAILED DESCRIPTION
[0114] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0115] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.
[0116] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0117] like Figure 1 As shown, this embodiment provides a difference-aware response generation method based on remote supervision and knowledge distillation, including the following steps:
[0118] Step A: Collect natural, open-domain conversations on social platforms, use a retrieval system to retrieve background knowledge related to the conversation in Wikipedia, and annotate the labels of the real replies to construct the training dataset DE.
[0119] Step B: Use the training dataset DE to train a deep learning network model M based on distant supervision and knowledge distillation. This model selects the required background knowledge and generates a response based on the selected background knowledge.
[0120] Step C: Input the conversation context and background knowledge base into the trained deep learning network model M to generate the corresponding response.
[0121] In this embodiment, the architecture of the deep learning network model M based on remote supervision and knowledge distillation and its specific process of processing the previous conversation, the real response of this round and the candidate knowledge are as follows: Figure 2 、 3 In this embodiment, step B specifically includes the following steps:
[0122] Step B1: Initially encode all training samples in the training dataset DE to obtain the sentence representation vector of the current conversation. The sentence representation vector of the true response in this round The sentence representation vector of the candidate knowledge in this round
[0123] In this embodiment, step B1 specifically includes the following steps:
[0124] Step B11: traverse the training dataset DE, perform word segmentation on the conversation content and knowledge, and remove special symbols and stop words. Each training sample in DE is represented as de = (x t ,y t , k t ); where x t For the content of the previous dialogue, y t is x t The corresponding set of true responses, k t is the background knowledge set corresponding to this round of dialogue;
[0125] The text content of the previous dialogue x t Expressed as:
[0126]
[0127] in, For the dialogue above x t The i-th word in , i = 1, 2, ..., |x t |,|x t |For the previous conversation x t The number of words.
[0128] True reply y t Expressed as:
[0129]
[0130] in, For true reply y t The i-th word in y, i = 1, 2, ..., |y t |,|y t | is the real reply y t The number of words.
[0131] Background knowledge set k t Expressed as:
[0132]
[0133] Among them, N represents the number of candidate knowledge in this round, and each candidate knowledge Expressed as:
[0134]
[0135] in, For each candidate knowledge The jth word in Candidate knowledge The number of words.
[0136] Step B12: Get the dialogue context of step B11 Encode it through BERT and then use the average pooling layer to get the representation vector of the conversation above The calculation process is as follows:
[0137]
[0138]
[0139] Among them, MeanPool(·) represents the average pooling function.
[0140] Step B13: Get the dialogue context of step B11 Encoded by BERT, and then the sentence representation vector of the real response is obtained through the average pooling layer The calculation process is as follows:
[0141]
[0142]
[0143] Among them, MeanPool(·) represents the average pooling function.
[0144] Step B14: Background knowledge obtained in step B11 Encode each one through BERT, and then obtain the sentence representation vector of the candidate knowledge through the average pooling layer The calculation process is as follows:
[0145]
[0146]
[0147] Among them, MeanPool(·) represents the average pooling function.
[0148] Step B2: The sentence representation vector of the previous conversation obtained in step B1 is And the sentence representation vector of the real response in this round Get the dialogue history information representation through GRU encoding The sentence representation vector of candidate knowledge The vector representation r with inter-sentence relationship information is obtained by BiGRU encoding t .
[0149] In this embodiment, step B2 specifically includes the following steps:
[0150] Step B21: Vector representation of the conversation context through GRU and the vector representation of the true response Encode and get the dialogue history information representation The calculation process is as follows:
[0151]
[0152] Step B22: The sentence representation vector of the candidate knowledge obtained in step B14 is further encoded by BiGRU to obtain the candidate knowledge vector representation of the inter-sentence relationship perception The calculation process is as follows:
[0153]
[0154] Step B3: Represent the sentences of candidate knowledge selected by the previous M rounds of models The candidate knowledge vector representation r of the current round with the inter-sentence relationship information obtained in step B2 t Perform difference calculations and sum the difference information of different rounds according to the order of rounds through a weighted function based on time decay to obtain the difference information representation of candidate knowledge
[0155] In this embodiment, step B3 specifically includes the following steps:
[0156] Step B31: Calculate the weight λ of each round using the time decay functionm , the calculation process is as follows:
[0157]
[0158] f(m)=e -αm
[0159] Step B32: The knowledge selected by the past M rounds of models The difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 is calculated, and the result λ obtained in step B31 is used to calculate the difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 and the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B31 is calculated. m Perform weighted summation of the difference information of different rounds to obtain the difference information representation of candidate knowledge The calculation results are as follows:
[0160]
[0161] Diff(a,b)=FullConnect([ab;a⊙b])
[0162] Where [;] represents the connection operation, FullConnect(·) is the fully connected layer activated by tanh, and α is the attenuation coefficient.
[0163] Step B4: Use the distant supervision method to obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge
[0164] In this embodiment, step B4 specifically includes the following steps:
[0165] Step B41: Obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge The calculation process is as follows:
[0166]
[0167]
[0168]
[0169] Step B5: Using the knowledge distillation method, the student knowledge selector uses the conversation history information of the previous round The sentence representation vector of the conversation above this round As the query vector, the real response vector is added to the query vector of the teacher knowledge selector, and then the sentence representation vector of the candidate knowledge of this round is The difference information obtained in step B3 is connected as the key vector of the teacher selector and the student selector, and the attention scores of the two are calculated respectively. The knowledge with the highest score is used as the knowledge selected by the two selectors, and the distribution of the student selector is trained to approximate the distribution of the teacher selector, and the knowledge selected by the student selector is used as the key vector of the teacher selector. As knowledge selected in this round.
[0170] In this embodiment, step B5 specifically includes the following steps:
[0171] Step B51: The student knowledge selector uses the conversation history information obtained in step B21 And the conversation vector of this round obtained in step B12 Perform splicing as a query, use the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 as the key, and calculate the attention score to obtain the probability distribution of the selected knowledge The calculation process is as follows:
[0172]
[0173] Among them, tanh(·) is the activation function, W stuque , W stukey , v T are trainable parameters.
[0174] Step B52: Distribute the student knowledge selection obtained in step B51 Perform normalization operation and take the knowledge with the highest probability as the selected knowledge of this round of knowledge selector The calculation process is as follows:
[0175]
[0176]
[0177] Among them, softmax() is a normalization function, and argmax() is a function that finds the independent variable corresponding to the maximum value of the function.
[0178] Step B53: The teacher knowledge selector uses the conversation context information obtained in step B21 combined with the real response of this round As a query, the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 are used as keys, and the probability distribution of the selected knowledge is obtained by calculating the attention score. The calculation process is as follows:
[0179]
[0180] Among them, tanh(·) is the activation function, W teaque , W teakey , v T are trainable parameters.
[0181] Step B54: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The student knowledge selector is trained using cross entropy loss. The calculation process is as follows:
[0182]
[0183] in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the student knowledge selector.
[0184] Step B55: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The teacher knowledge selector is trained using cross entropy loss. The calculation process is as follows:
[0185]
[0186] in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the teacher knowledge selector.
[0187] Step B56: The selection distribution of the student knowledge selector is trained by minimizing the distillation loss to fit the selection distribution of the teacher knowledge selector. The calculation process is as follows:
[0188]
[0189] in, KL divergence of the student selection distribution and the teacher selection distribution.
[0190] Step B57: Add the student selector loss of step B54, the teacher selector loss of step B55, and the distillation loss of step B56 as the overall loss of the knowledge selector. The calculation process is as follows:
[0191]
[0192] Step B6: Adopt a two-stage training strategy based on self-paced learning, and transform the knowledge selected in this round into or pseudo-true knowledge The information from the conversation is input into the decoder to generate the response for this round. Specifically, the pseudo-real knowledge obtained in step B4 is used in the pre-training phase. During the training, the self-paced learning strategy is used in the fine-tuning stage, and the pseudo-real knowledge is used according to the size of the scoring function. or knowledge selected in this round Input the selected knowledge and context information into the decoder to generate the response y of this round t .
[0193] In this embodiment, step B6 specifically includes the following steps:
[0194] Step B61: A two-stage training method based on a self-paced learning strategy is used, and pseudo-real knowledge is used in the pre-training stage. As the knowledge selected in this round, the fine-tuning stage adopts a self-paced learning strategy. The knowledge selected by the knowledge selector is regarded as a complex sample, and the pseudo-true knowledge is regarded as a simple sample. The loss of the student knowledge selector is used as the score of the self-paced learning. A weight V is set to indicate whether the complex sample should be used for response generation. V is calculated as follows:
[0195]
[0196]
[0197] δ=h(T)=δ0e T
[0198] Step B62: Select the knowledge Dialogue above x t The concatenation is performed and the input is combined with the Transformer decoder with the replication mechanism to generate the response of this round. The process is as follows:
[0199]
[0200]
[0201]
[0202]
[0203]
[0204]
[0205] Among them, [;] represents the connection operation, TransformerDecoder() represents the Transformer decoder, is the hidden vector of the nth word in this round of reply, MultHead() represents the multi-head attention mechanism, represents the vocabulary, is the final generated distribution.
[0206] Step B63: Calculate the loss value based on the weight V obtained in step B61 And the confidence weight of the pseudo-true knowledge label obtained in step B41 The generation loss is weighted and calculated as follows:
[0207]
[0208]
[0209] Step B64: Take the sum of the knowledge selection loss obtained in step B57 and the generation loss obtained in step B63 as the total loss, and use backpropagation to iteratively update the model parameters to minimize the loss function to train the model. The total loss is calculated as follows:
[0210]
[0211] Step B7: When the loss value change generated by each iteration of the deep learning network model is less than a given threshold or reaches the maximum number of iterations, the training process of the deep learning network model is terminated.
[0212] like Figure 4 As shown, this embodiment provides a difference-aware response generation system for implementing the above method, including:
[0213] The data collection module is used to extract the conversation content and background knowledge of open-domain conversations on social platforms, annotate real responses, and construct a training set;
[0214] The preprocessing module is used to preprocess the training samples in the training set, including word segmentation and stop word removal;
[0215] The encoding module is used to find the word vectors of the pre-processed input content, response content, and background knowledge content in the pre-trained word vector matrix, and encode this information to obtain the representation vectors of the input content, response content, and background knowledge;
[0216] The difference information construction module calculates the difference between the knowledge selected in the previous round and the candidate knowledge in the current round, and uses the time-decay weighting function to weight and sum the difference information of different rounds to obtain the difference information representation of the knowledge in this round;
[0217] The network model training module is used to input the representation vector of the input dialogue, the representation vector of the response, the representation vector of the background knowledge, and the difference information representation into the deep learning network. It selects the background knowledge required for the current round of dialogue and inputs the selected knowledge and context into the decoder to generate the response for this round. The loss is calculated by comparing with the real responses in the training set. The entire deep learning network is trained with the goal of minimizing the loss, resulting in a deep learning network model for difference-aware response generation based on distant supervision and knowledge distillation.
[0218] The reply generation module is used to generate replies. It uses a trained deep learning network model for difference-aware reply generation based on remote supervision and knowledge distillation to analyze and process the input conversation, select the knowledge for this round based on the context and difference information, and then generate a reply based on the selected knowledge.
[0219] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0220] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0221] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0222] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0223] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other manner. Any person skilled in the art may utilize the above-disclosed technical content to modify or modify the present invention into equivalent embodiments. However, any simple modifications, equivalent variations, and modifications to the above embodiments that do not depart from the technical content of the present invention and are based on the technical essence of the present invention remain within the scope of protection of the present invention.
Claims
1. A difference-aware response generation method based on distant supervision and knowledge distillation, characterized by: The following steps are involved: Step A: Collect natural, open-domain conversations on social platforms, use a retrieval system to retrieve background knowledge related to the conversations from Wikipedia, and annotate the labels of the real responses to construct the training dataset DE; Step B: Use the training dataset DE to train a deep learning network model M based on distant supervision and knowledge distillation. This model selects the required background knowledge and generates responses based on the selected background knowledge. Step C: Input the conversation context and background knowledge base into the trained deep learning network model M to generate the corresponding response; The step B specifically comprises the following steps: Step B1: Initially encode all training samples in the training dataset DE to obtain the sentence representation vector of the current conversation. The sentence representation vector of the true response in this round The sentence representation vector of the candidate knowledge in this round Step B2: The sentence representation vector of the previous conversation obtained in step B1 is And the sentence representation vector of the real response in this round Get the dialogue history information representation through GRU encoding The sentence representation vector of candidate knowledge The vector representation r with inter-sentence relationship information is obtained by BiGRU encoding t ; Step B3: Represent the sentences of candidate knowledge selected by the previous M rounds of models The candidate knowledge vector representation r of the current round with the inter-sentence relationship information obtained in step B2 t Perform difference calculations and sum the difference information of different rounds according to the order of rounds through a weighted function based on time decay to obtain the difference information representation of candidate knowledge Step B4: Use the distant supervision method to obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge Step B5: Using the knowledge distillation method, the student knowledge selector uses the conversation history information of the previous round The sentence representation vector of the conversation above this round As the query vector, the real response vector is added to the query vector of the teacher knowledge selector, and then the sentence representation vector of the candidate knowledge of this round is The difference information obtained in step B3 is connected as the key vector of the teacher selector and the student selector, and the attention scores of the two are calculated respectively. The knowledge with the highest score is used as the knowledge selected by the two selectors, and the distribution of the student selector is trained to approximate the distribution of the teacher selector, and the knowledge selected by the student selector is used as the key vector of the teacher selector. As the knowledge of this round of selection; Step B6: Adopt a two-stage training strategy based on self-paced learning, and transform the knowledge selected in this round into or pseudo-true knowledge The information from the conversation is input into the decoder to generate the response for this round. Specifically, the pseudo-real knowledge obtained in step B4 is used in the pre-training phase. During the training, the self-paced learning strategy is used in the fine-tuning stage, and the pseudo-real knowledge is used according to the size of the scoring function. or knowledge selected in this round Input the selected knowledge and context information into the decoder to generate the response y of this round t ; Step B7: When the loss value change generated by each iteration of the deep learning network model is less than a given threshold or the maximum number of iterations is reached, the training process of the deep learning network model is terminated; The step B4 specifically includes the following steps: Step B41: Obtain the probability distribution of pseudo-true knowledge by calculating the F1 score between the candidate knowledge and the true response And take the knowledge with the highest probability as the pseudo-true knowledge The calculation process is as follows: The step B5 specifically includes the following steps: Step B51: The student knowledge selector uses the conversation history information obtained in step B21 And the conversation vector of this round obtained in step B12 Perform splicing as a query, use the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 as the key, and calculate the attention score to obtain the probability distribution of the selected knowledge The calculation process is as follows: Among them, tanh(·) is the activation function, W stuque , W stukey , v T is a trainable parameter; Step B52: Distribute the student knowledge selection obtained in step B51 Perform normalization operation and take the knowledge with the highest probability as the selected knowledge of this round of knowledge selector The calculation process is as follows: Among them, softmax() is a normalization function, and argmax() is a function that finds the independent variable corresponding to the maximum value of the function; Step B53: The teacher knowledge selector uses the conversation context information obtained in step B21 combined with the real response of this round As a query, the candidate knowledge vector obtained in step B14 and the difference information representation obtained in step B32 are used as keys, and the probability distribution of the selected knowledge is obtained by calculating the attention score. The calculation process is as follows: Among them, tanh(·) is the activation function, W teaque , W teakey , v T is a trainable parameter; Step B54: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The student knowledge selector is trained using cross entropy loss. The calculation process is as follows: in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the student’s knowledge selector; Step B55: Use the pseudo-true knowledge label obtained in step B41 and confidence weights The teacher knowledge selector is trained using cross entropy loss. The calculation process is as follows: in, represents the cross entropy loss, is the confidence weight of the pseudo-true knowledge label, represents the selection distribution of the teacher's knowledge selector; Step B56: The selection distribution of the student knowledge selector is trained by minimizing the distillation loss to fit the selection distribution of the teacher knowledge selector. The calculation process is as follows: in, KL divergence of the student selection distribution and the teacher selection distribution; Step B57: Add the student selector loss of step B54, the teacher selector loss of step B55, and the distillation loss of step B56 as the overall loss of the knowledge selector. The calculation process is as follows:
2. The difference-aware response generation method based on remote supervision and knowledge distillation according to claim 1 is characterized in that The step B1 specifically includes the following steps: Step B11: traverse the training dataset DE, perform word segmentation on the conversation content and knowledge, and remove special symbols and stop words. Each training sample in DE is represented as de = (x t ,y t ,k t ); where x t For the content of the previous dialogue, y t is x t The corresponding set of true responses, k t is the background knowledge set corresponding to this round of dialogue; The text content of the previous dialogue x t Expressed as: in, For the dialogue above x t The i-th word in , i=1,2,…,|x t |,|x t |For the previous conversation x t The number of words; True reply y t Expressed as: in, For true reply y t The i-th word in y, i=1,2,…,|y t |,|y t | is the real reply y t The number of words; Background knowledge set k t Expressed as: Among them, N represents the number of candidate knowledge in this round, and each candidate knowledge Expressed as: in, For each candidate knowledge The jth word in Candidate knowledge The number of words; Step B12: Get the dialogue context of step B11 Encode it through BERT and then use the average pooling layer to get the representation vector of the conversation above The calculation process is as follows: Among them, MeanPool(·) represents the average pooling function; Step B13: Get the dialogue context of step B11 Encoded by BERT, and then the sentence representation vector of the real response is obtained through the average pooling layer The calculation process is as follows: Among them, MeanPool(·) represents the average pooling function; Step B14: Background knowledge obtained in step B11 Encode each one through BERT, and then obtain the sentence representation vector of the candidate knowledge through the average pooling layer The calculation process is as follows: Among them, MeanPool(·) represents the average pooling function.
3. The difference-aware response generation method based on remote supervision and knowledge distillation according to claim 2 is characterized in that The step B2 specifically includes the following steps: Step B21: Vector representation of the conversation context through GRU and the vector representation of the true response Encode and get the dialogue history information representation The calculation process is as follows: Step B22: The sentence representation vector of the candidate knowledge obtained in step B14 is further encoded by BiGRU to obtain the candidate knowledge vector representation of the inter-sentence relationship perception The calculation process is as follows:
4. The difference-aware response generation method based on remote supervision and knowledge distillation according to claim 3 is characterized in that The step B3 specifically includes the following steps: Step B31: Calculate the weight λ of each round using the time decay function m , the calculation process is as follows: f(m)=e -αm Step B32: The knowledge selected by the past M rounds of models The difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 is calculated, and the result λ obtained in step B31 is used to calculate the difference between the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B22 and the candidate knowledge vector representation of the inter-sentence relationship perception obtained in step B31 is calculated. m Perform weighted summation of the difference information of different rounds to obtain the difference information representation of candidate knowledge The calculation results are as follows: Diff(a,b)=FullConnect([ab;a⊙b]) Among them, [;] represents the connection operation, FullConnect(·) is the fully connected layer activated by tanh, and α is the attenuation coefficient.
5. The difference-aware response generation method based on remote supervision and knowledge distillation according to claim 1 is characterized in that The step B6 specifically includes the following steps: Step B61: A two-stage training method based on a self-paced learning strategy is used, and pseudo-real knowledge is used in the pre-training stage. As the knowledge selected in this round, the fine-tuning stage adopts a self-paced learning strategy. The knowledge selected by the knowledge selector is regarded as a complex sample, and the pseudo-true knowledge is regarded as a simple sample. The loss of the student knowledge selector is used as the score of the self-paced learning. A weight V is set to indicate whether the complex sample should be used for response generation. V is calculated as follows: Step B62: Select the knowledge Dialogue above x t The concatenation is performed and the input is combined with the Transformer decoder with the replication mechanism to generate the response of this round. The process is as follows: Among them, [;] represents the connection operation, TransformerDecoder() represents the Transformer decoder, is the hidden vector of the nth word in this round of reply, MultHead() represents the multi-head attention mechanism, represents the vocabulary, is the final generated distribution; Step B63: Calculate the loss value based on the weight V obtained in step B61 And the confidence weight of the pseudo-true knowledge label obtained in step B41 The generation loss is weighted and calculated as follows: Step B64: Take the sum of the knowledge selection loss obtained in step B57 and the generation loss obtained in step B63 as the total loss, and use backpropagation to iteratively update the model parameters to minimize the loss function to train the model. The total loss is calculated as follows:
6. A difference perception response generation system using the method according to any one of claims 1 to 5, characterized in that: include: The data collection module is used to extract the conversation content and background knowledge of open-domain conversations on social platforms, annotate real responses, and construct a training set; The preprocessing module is used to preprocess the training samples in the training set, including word segmentation and stop word removal; The encoding module is used to find the word vectors of the pre-processed input content, response content, and background knowledge content in the pre-trained word vector matrix, and encode this information to obtain the representation vectors of the input content, response content, and background knowledge; The difference information construction module calculates the difference between the knowledge selected in the previous round and the candidate knowledge in the current round, and uses the time-decay weighting function to weight and sum the difference information of different rounds to obtain the difference information representation of the knowledge in this round; The network model training module is used to input the representation vector of the input dialogue, the representation vector of the response, the representation vector of the background knowledge, and the difference information representation into the deep learning network. It selects the background knowledge required for the current round of dialogue and inputs the selected knowledge and context into the decoder to generate the response for this round. The loss is calculated by comparing with the real responses in the training set. The entire deep learning network is trained with the goal of minimizing the loss, resulting in a deep learning network model for difference-aware response generation based on distant supervision and knowledge distillation. The reply generation module is used to generate replies. It uses a trained deep learning network model for difference-aware reply generation based on remote supervision and knowledge distillation to analyze and process the input conversation, select the knowledge for this round based on the context and difference information, and then generate a reply based on the selected knowledge.
Citation Information
Patent Citations
Natural language understanding method and device oriented to dialogue system
CN113297364A
Intelligence type retrieval dialogue method based on pre-training and attention interaction network
CN114817494A