A knowledge-driven multi-path screening and fusion dialogue generation method
By combining a multi-path knowledge filtering module with a bidirectional GRU neural network to generate dialogue, the problems of inaccurate knowledge filtering and insufficient fusion are solved, and higher-quality dialogue generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF INFORMATION SCI & TECH
- Filing Date
- 2022-04-22
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies in dialogue generation suffer from low accuracy in knowledge filtering and fail to effectively integrate knowledge and semantic information, resulting in poor quality of generated responses.
A multi-path knowledge filtering module is adopted to select knowledge relevant to the dialogue context, and a bidirectional GRU neural network is used to fuse knowledge information with semantic information. Knowledge filtering is optimized by cosine similarity and posterior knowledge distribution. A knowledge fusion module is designed to improve the accuracy of response generation.
It improves the accuracy of knowledge screening and the quality of response generation, enhances the diversity and relevance of dialogue generation, and improves the model's generalization ability.
Smart Images

Figure CN115422329B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of dialogue generation in natural language processing, and specifically relates to a knowledge-driven multi-path filtering and fusion dialogue generation method. Background Technology
[0002] The purpose of dialogue generation is to translate machine language into natural language that users can understand. The rapid proliferation of social media has led to a massive accumulation of dialogue data, and the rapid increase in computing power has sparked a surge in deep learning technology. Deep learning has achieved remarkable success in various fields of artificial intelligence in recent years. Utilizing deep learning to enable models to automatically learn language features from massive amounts of dialogue data and master language skills has become a popular research direction in dialogue generation technology. Deep learning-based dialogue generation methods do not require pre-prepared templates or corpora; instead, they automatically summarize dialogue information from a large amount of dialogue data and learn language skills to generate responses.
[0003] In recent years, many studies have focused on introducing external knowledge into dialogue systems to improve generation performance. This task is divided into two important sub-tasks: knowledge selection and response generation. Appropriate knowledge can promote response generation, while inappropriate knowledge can not only fail to improve the quality of response generation but may even have a negative impact. Therefore, selecting appropriate knowledge is a crucial step. In 2018, Zhou et al. proposed a graph attention mechanism that combines structured triple knowledge with a generative dialogue model. They enhanced the encoder's semantic vectors through static attention and improved the decoder's generation performance through dynamic attention. In 2019, Lian et al. proposed using posterior knowledge to guide the selection of appropriate knowledge. In 2019, Zhang et al. proposed a context-aware knowledge pre-selection model (CaKe), which introduces a dynamic bidirectional attention pre-selection process, using historical context as prior information to select the most relevant background material. In 2019, Liu et al. proposed a knowledge divergence network that selects knowledge through fact matching and fact divergence mechanisms.
[0004] The invention with patent number CN113656569A mentions a generative dialogue method based on contextual information reasoning. First, the acquired input information is cleaned and processed into the input format required by the subsequent model. Then, a self-attention mechanism is introduced to calculate attention weights for important words and sentences in the historical context, obtaining corresponding semantic vector representations. These semantic vector representations are then used to select external knowledge relevant to the historical context. During the decoding process, a two-step decoding process integrates the selected historical context information and the selected external knowledge into the response, resulting in a more accurate and high-quality response. However, this invention obtains external knowledge based on important words and sentences in the historical context, resulting in low accuracy in knowledge selection. Furthermore, it cannot directly integrate knowledge information with semantic information. Summary of the Invention
[0005] Technical problem solved: This invention proposes a knowledge-driven multi-path filtering and fusion dialogue generation method. By designing a multi-path knowledge filtering module, it selects knowledge that is more relevant to the dialogue context, so that the response contains more information. In addition, it uses bidirectional GRU to fuse knowledge information with semantic information, so as to generate the response in a more efficient way.
[0006] Technical solution:
[0007] A knowledge-driven multi-channel filtering and fusion dialogue generation method, the generation method comprising the following steps:
[0008] S10: Preprocess the current dialogue context, including word segmentation and word embedding, and then feed the preprocessed results into a discourse encoder composed of bidirectional GRUs to encode the context information and obtain the corresponding semantic vector {h}. i};i=1,2,…,n;
[0009] S20, based on a multi-path knowledge filtering mechanism, calculates the semantic vector information obtained in step S10 and the knowledge set {k}. i The similarity of each piece of knowledge in the set is used to select the knowledge information k most relevant to the current dialogue from the knowledge set. a and k b The filtered knowledge information k′ is obtained by fusion. i ;
[0010] S30, Construct a knowledge fusion module based on a bidirectional GRU neural network, and use the knowledge fusion module to process the knowledge information k′ obtained in step S20. i Semantic information of the context obtained in step S10 {h i The intermediate semantic vector c is obtained by fusion and calculation using an attention mechanism. t ;
[0011] S40, the intermediate semantic vector c obtained in step S30 t and the knowledge information k′ obtained in step S20 i They are then fed into the decoder to generate the response.
[0012] Further, in step S10, the corresponding semantic vector {h} is obtained. i The process includes the following steps:
[0013] S11, after segmenting the relevant data containing contextual information using the NLTK tool, it is converted into fixed-dimensional word vectors using GloVe.
[0014] S12, a source sentence encoder is constructed based on bidirectional GRU units. The transformation result of step S11 is fed into the source sentence encoder to encode the dialogue context into a fixed-dimensional vector. Each step of the encoding outputs the hidden state at that time step. The last time step is used to represent the semantic information of the context. The input context is encoded into a fixed-length semantic vector to obtain the hidden state h = {h1, h2, ..., h...} n}
[0015] Furthermore, in step S20, the knowledge information k most relevant to the current dialogue is selected from the knowledge set. a and k b The process includes the following steps:
[0016] S21, using cosine similarity, obtain the similarity score between the semantic vector corresponding to the context information and each piece of knowledge in the knowledge set, and denot the knowledge information with the highest score as k. a ;
[0017] S22, obtain the posterior knowledge distribution based on posterior knowledge information, and use the posterior knowledge distribution and prior knowledge distribution to filter knowledge; use KL divergence to narrow the distance between the prior knowledge distribution and the posterior distribution, making the prior distribution continuously approximate the posterior distribution, and obtain relevant knowledge with the help of the prior distribution, denoted as k. b The prior knowledge distribution and posterior knowledge distribution are obtained according to the following formulas:
[0018]
[0019]
[0020] Where, k i For each piece of knowledge in the knowledge set, x represents the input context information, y represents the actual response information in the dataset, and k... j This represents all the knowledge in the knowledge set, where j is the sequence number of the knowledge, and N represents the number of knowledge items in the knowledge set.
[0021] Further, in step S30, the intermediate semantic vector c is calculated. t The process includes the following steps:
[0022] S31, Based on the relevance coefficient of each piece of knowledge information, a weighted sum is obtained to obtain the final form of knowledge information expression;
[0023] S32, a bidirectional GRU neural network is used to process the knowledge information obtained in step S31 and the semantic information of the context obtained in step S10 {h i They jointly encode the filtered knowledge into a representation k′. i As the initial state of the bidirectional GRU neural network, the hidden state h at each time step is also used. i The final state of the bidirectional GRU is obtained as the intermediate semantic vector c, which is used as the input at each step of the bidirectional GRU neural network. t .
[0024] Further, in step S40, the intermediate semantic vector c obtained in step S30 is... t and the knowledge information k′ obtained in step S20 i The process of sending the data to the decoder to generate the response includes the following steps:
[0025] Based on knowledge semantic expression k′ i and intermediate semantic vector c t The decoding state at each time step is mapped to the dimension of the vocabulary size through a fully connected network, and the probability distribution of candidate response words is calculated using the softmax function. The word with the highest probability is selected as the response y for the current time step. t The predicted responses from all time steps are combined to obtain the final predicted response sequence Y.
[0026] Beneficial effects:
[0027] This invention presents a knowledge-driven, multi-path filtering and fusion dialogue generation method for background knowledge-based dialogue generation tasks, simultaneously considering knowledge filtering and response generation. Incorporating the actual knowledge used in real responses helps improve the accuracy of knowledge filtering. This invention addresses the exposure bias between prior and posterior knowledge distributions, utilizing cosine similarity to calculate the similarity between the source sentence and each knowledge sentence, thereby improving the model's generalization ability. Furthermore, to better utilize the selected knowledge information, both the selected knowledge information and the source sentence are co-encoded. This combination improves the accuracy of knowledge filtering and better utilizes the selected knowledge to generate high-quality responses. Attached Figure Description
[0028] Figure 1This is a flowchart of the knowledge-driven multi-path filtering and fusion dialogue generation method according to an embodiment of the present invention;
[0029] Figure 2 This is a diagram showing the overall architecture of the network model corresponding to the multi-path filtering and fusion dialogue generation method in this embodiment of the invention. Detailed Implementation
[0030] The following embodiments are provided to enable those skilled in the art to more fully understand the present invention, but do not limit the invention in any way.
[0031] Figure 1 This is a flowchart of a knowledge-driven multi-path filtering and fusion dialogue generation method according to an embodiment of the present invention. See also... Figure 1 The generation method includes the following steps:
[0032] S1 performs preprocessing on the current dialogue context, including word segmentation and word embedding. The preprocessing results are then fed into a discourse encoder composed of bidirectional GRUs to encode the context information and obtain the corresponding semantic vector {h}. i};i=1,2,…,n.
[0033] S2, based on a multi-path knowledge filtering mechanism, calculates the semantic vector information obtained in step S10 and the knowledge set {k}. i The similarity of each piece of knowledge in the set is used to select the knowledge information k most relevant to the current dialogue from the knowledge set. a and k b The filtered knowledge information k′ is obtained by fusion. i .
[0034] S3, Construct a knowledge fusion module based on a bidirectional GRU neural network, and use the knowledge fusion module to process the knowledge information k′ obtained in step S20. i Semantic information of the context obtained in step S10 {h i The intermediate semantic vector c is obtained by fusion and calculation using an attention mechanism. t .
[0035] S4, the intermediate semantic vector c obtained in step S30 t and the knowledge information k′ obtained in step S20 i They are then fed into the decoder to generate the response.
[0036] This implementation case considers the importance of both knowledge selection and response generation. It designs a knowledge selection module based on posterior knowledge distribution and an attention mechanism for knowledge selection. Furthermore, it designs a knowledge fusion module to better utilize the acquired knowledge for dialogue generation. For example... Figure 1 As shown, this method includes the following steps:
[0037] Step 1): According to the task requirements, the data is preprocessed, and the input context is encoded into a fixed-length semantic vector using an encoder composed of bidirectional GRU units.
[0038] After word segmentation of the dataset, stop words are removed, and word embeddings are obtained using BERT. These are then fed into a bidirectional GRU to encode the preprocessed context information, resulting in the hidden state h = {h1, h2, ..., h...}. n Specifically, it includes the following sub-steps:
[0039] Step 101): After segmenting the data using the NLTK tool, convert it into fixed-dimensional word vectors using GloVe.
[0040] Step 102): The dialogue context is encoded into a fixed-dimensional vector using a bidirectional encoder composed of GRUs. Each step of the encoding outputs the hidden state at that time step, and the last time step is used to represent the semantic information of the context.
[0041] Step 2): Based on the file access frequency obtained in the previous step, calculate the similarity between the contextual semantic information and each piece of knowledge information in the knowledge set.
[0042] In step 2), based on the semantic vector obtained in step 1), relevant knowledge is acquired through a multi-path filtering module. First, cosine similarity is used to obtain the similarity score between the context vector and each piece of knowledge in the knowledge set, and the knowledge information with the highest score is denoted as k. a Secondly, the posterior knowledge distribution is obtained using posterior knowledge information, and then the KL divergence is used to narrow the distance between the prior knowledge distribution and the posterior distribution, so that relevant knowledge can also be obtained in practical applications. This knowledge is denoted as k. b Specifically, it includes the following sub-steps:
[0043] Step 201) Use the posterior knowledge distribution and the prior knowledge distribution to filter knowledge. During the model training process, use KL divergence to make the prior distribution continuously approach the posterior distribution, so as to obtain appropriate knowledge information by means of the prior distribution in the training stage when the real response cannot be obtained.
[0044] Step 202) Calculate the similarity between the semantic vector obtained in step 1) and the knowledge information in the knowledge set using the attention mechanism, so as to make up for the exposure bias between the prior knowledge distribution and the posterior knowledge distribution and improve the accuracy of knowledge selection.
[0045] The prior knowledge distribution and the posterior knowledge distribution are obtained according to the following formula, where k i For each piece of knowledge in the knowledge set, x represents the input context information, and y represents the actual response information in the dataset;
[0046]
[0047]
[0048] Step 3): Based on the context-related knowledge information obtained in the previous step, the knowledge fusion module integrates the semantic knowledge into the context to generate a response.
[0049] Step 3) Based on the knowledge information obtained in Step 2), to better utilize the filtered knowledge, a more subtle approach is used to fuse the knowledge filtering and the source sentence, rather than directly concatenating two vectors. Specifically, a bidirectional GRU neural network is employed to jointly encode the knowledge information and the source sentence, representing the filtered knowledge as k. i As the initial state of the bidirectional GRU neural network, the hidden state h = {h1, h2, ..., h...} obtained from the source sentence encoder is also used. n The input to each step of the bidirectional GRU neural network is used to obtain the final state of the bidirectional GRU as an intermediate semantic vector c. t Specifically, it includes the following sub-steps:
[0050] Step 301): Based on the results obtained in the previous step, the final knowledge information expression form is obtained by weighted summation based on the relevance coefficient of each knowledge information.
[0051] Step 302): The result of step 301) is co-encoded with the contextual semantic information using an encoder composed of bidirectional GRUs. The knowledge semantic information is used as the initial state of the encoder, and the hidden state at each time step in step 1) is used as the input of the encoder at each step to obtain the final hidden state.
[0052] Step 4) Input the contextual semantic expression with knowledge information obtained in Step 3) into the decoder and use the attention mechanism to generate a response.
[0053] In step 4), the intermediate semantic vector c obtained in step 3) t and knowledge representation k i The decoding state at each time step is mapped to the dimension of the vocabulary size through a fully connected network, and the probability distribution of candidate response words is calculated using a softmax function. The word with the highest probability is selected as the response y for the current time step. t The predicted responses at all time steps are combined to form the final predicted response sequence Y. Specifically, this includes the following sub-steps:
[0054] Step 401): Design a knowledge-aware decoder to flexibly integrate knowledge information. The knowledge-aware GRU consists of two parts: the knowledge semantic representation, the output prediction vocabulary information of the previous time step, the hidden state, and the result of step 3) are used as the input of the GRU to obtain the hidden state S at the current time step. t .
[0055] Step 402): Map the decoding state of each time step to the dimension of the vocabulary size through a fully connected network, calculate the probability distribution of candidate response words using the softmax function, and select the word with the highest probability as the response y for the current time step. t The final predicted response sequence s is obtained by combining the predicted responses of all time steps.
[0056] For the dialogue generation method described above, see [link to relevant documentation]. Figure 2 This embodiment also discloses a knowledge-driven multi-path filtering fusion dialogue generation network model.
[0057] In this embodiment, knowledge-driven dialogue generation includes two important sub-tasks: 1. Selecting knowledge information relevant to the current dialogue context from the knowledge set, i.e., knowledge selection; 2. Generating responses that are consistent with the context and contain more information using the selected knowledge. For the first task, this embodiment proposes a multi-path knowledge filtering mechanism based on background knowledge to effectively and accurately select knowledge. For the second task, this embodiment designs a dynamic decoder that performs secondary filtering of knowledge during the decoding process, avoiding the uniformity of knowledge filtering and thus improving the diversity and relevance of generated responses. This embodiment can fully utilize the semantic information of the context, filter highly relevant background knowledge information, and integrate the filtered knowledge information into the dialogue generation process, thereby improving the quality of dialogue generation.
Claims
1. A knowledge-driven multi-path filtering and fusion dialogue generation method, characterized in that, The generation method includes the following steps: S10: Preprocess the current dialogue context, including word segmentation and word embedding, and then feed the preprocessed results into a discourse encoder composed of bidirectional GRUs to encode the context information and obtain the corresponding semantic vectors. ; ; S20, based on a multi-path knowledge filtering mechanism, calculates the semantic vector information and knowledge set obtained in step S10. The similarity of each piece of knowledge is used to select the most relevant knowledge information from the knowledge set for the current conversation. and The filtered knowledge information is then integrated. ; In step S20, select the knowledge information most relevant to the current dialogue from the knowledge set. and The process includes the following steps: S21, using cosine similarity, obtain the similarity score between the semantic vector corresponding to the context information and each piece of knowledge in the knowledge set, and denot the knowledge information with the highest score as... ; S22, obtain the posterior knowledge distribution based on the posterior knowledge information, and use the posterior knowledge distribution and prior knowledge distribution to filter knowledge; use KL divergence to narrow the distance between the prior knowledge distribution and the posterior distribution, making the prior distribution continuously approximate the posterior distribution, and use the prior distribution to obtain relevant knowledge, which is denoted as... The prior knowledge distribution and posterior knowledge distribution are obtained according to the following formulas: ; ; in, For each piece of knowledge in the knowledge set, x represents the input context information, and y represents the actual response information in the dataset. This represents all the knowledge in the knowledge set, where j is the sequence number of the knowledge and N represents the number of knowledge items in the knowledge set. S30, Construct a knowledge fusion module based on a bidirectional GRU neural network, and use the knowledge fusion module to process the knowledge information obtained in step S20. Semantic information of the context obtained in step S10 The intermediate semantic vector is obtained through fusion and by using an attention mechanism. ; S40, the intermediate semantic vector obtained in step S30 and the knowledge information obtained in step S20 They are then fed into the decoder to generate the response.
2. The knowledge-driven multi-path filtering and fusion dialogue generation method according to claim 1, characterized in that, In step S10, the corresponding semantic vector is obtained. The process includes the following steps: S11, after segmenting the relevant data containing contextual information using the NLTK tool, it is converted into fixed-dimensional word vectors using GloVe. S12, a source sentence encoder is constructed based on bidirectional GRU units. The transformation result of step S11 is fed into the source sentence encoder to encode the dialogue context into a fixed-dimensional vector. Each step of the encoding outputs the hidden state at that time step. The last time step is used to represent the semantic information of the context. The input context is encoded into a fixed-length semantic vector to obtain the hidden state h={h1,h2,…,h...}. n } 3. The knowledge-driven multi-path filtering and fusion dialogue generation method according to claim 1, characterized in that, In step S30, the intermediate semantic vector is calculated. The process includes the following steps: S31, Based on the relevance coefficient of each piece of knowledge information, a weighted sum is obtained to obtain the final form of knowledge information expression; S32, a bidirectional GRU neural network is used to process the knowledge information obtained in step S31 and the semantic information of the context obtained in step S10. They jointly encode the filtered knowledge. This serves as the initial state of the bidirectional GRU neural network, while also containing the hidden state at each time step. The final state of the bidirectional GRU is obtained as an intermediate semantic vector by using the input of each step of the bidirectional GRU neural network. .
4. The knowledge-driven multi-path filtering and fusion dialogue generation method according to claim 1, characterized in that, In step S40, the intermediate semantic vector obtained in step S30 is... and the knowledge information obtained in step S20 The process of sending the data to the decoder to generate the response includes the following steps: Based on knowledge semantic expression and intermediate semantic vectors The decoding state at each time step is mapped to the dimension of the vocabulary size through a fully connected network, and the probability distribution of candidate response words is calculated using the softmax function. The word with the highest probability is selected as the response y for the current time step. t The predicted responses from all time steps are combined to obtain the final predicted response sequence Y.