A knowledge-driven dialogue generation method and device
Through the deep neural network dialogue model combined with the characteristics of the knowledge graph entity relationship, dialogue reply with appropriate semantics and rich information is generated, which solves the problem of insufficient application of knowledge graphs in the existing technology and realizes the efficiency of dialogue generation.
Patent Information
- Application Number
- CN202110413536.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-16
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2041-04-16
AI Technical Summary
The existing knowledge-driven dialogue generation methods are difficult to effectively integrate large-scale knowledge graphs into dialogue generation, resulting in the generated dialogue reply semantics and insufficient information.
A deep neural network dialogue model is adopted, and dialogue replies with appropriate semantics and rich information are generated through bidirectional encoder, knowledge interpreter and decoder, combined with the characteristics of the entity relationship of the knowledge graph. The specific steps include: inputting the sequence of text to be replied to by a bidirectional encoder to obtain implicit feature representation, using a knowledge interpreter to determine the entity relationship feature representation, and generating the reply text sequence through the decoder.
It realizes the more efficient application of knowledge graphs to generate dialogue responses with appropriate semantics and rich information, and solves the problem of insufficient application of knowledge graphs in the prior art.
Smart Images

Figure CN113111190B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and in particular to a knowledge-driven dialogue generation method and device. Background Art
[0002] With the rapid development of society, we have entered the era of information explosion. People have a more urgent pursuit of efficient information processing methods. Among them, dialogue systems have attracted more and more attention from researchers, manufacturers and users, resulting in dialogue systems such as Siri, Google Assistant, and Xiao Ai. In the research of dialogue systems, generating dialogue responses with appropriate semantics and rich information has always been crucial to constructing a successful anthropomorphic dialogue system.
[0003] Since knowledge graphs describe the relationships between entities in the world, the amount of knowledge they contain is very huge. In order to generate conversation responses with appropriate semantics and rich information, some research works have attempted to introduce knowledge graphs into the conversation generation process. This type of work is called knowledge-driven conversation models. However, these research works all use pre-trained knowledge embedding representations, word vector representations, or adjacency matrices to model entities and relationships in knowledge graphs, which makes them no longer suitable for integrating large-scale knowledge graphs into conversation generation.
[0004] Therefore, how to better implement knowledge-driven dialogue systems has become a research focus in the industry. Summary of the invention
[0005] The present invention provides a knowledge-driven dialogue generation method and device to better realize a knowledge-driven dialogue system.
[0006] The present invention provides a knowledge-driven dialogue generation method, comprising:
[0007] Inputting the to-be-replied text sequence into the trained deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text;
[0008] Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships;
[0009] Among them, the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied that carries real reply text sequence labels and a feature representation data set of the knowledge graph entity relationship.
[0010] According to a knowledge-driven dialogue generation method provided by the present invention, before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes:
[0011] Inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain an implicit feature representation of the to-be-replied text sample sequence;
[0012] According to the head entity in the to-be-replied text sample sequence, a knowledge graph corresponding to the head entity is obtained, so as to determine the entity relationship feature representation of the head entity from a feature representation data set of the entity relationship stored in the knowledge graph;
[0013] Inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity;
[0014] The feature representation of the head entity, the feature representation of the tail entity corresponding to the head entity, and the feature representation of the common words in the pre-stored vocabulary are input into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence.
[0015] According to a knowledge-driven dialogue generation method provided by the present invention, the step of inputting a text sample sequence to be replied into a bidirectional encoder of a deep neural network dialogue model to obtain an implicit feature representation of the text sample sequence to be replied specifically includes:
[0016] Replacing the head entity in the to-be-replied text sample sequence with a placeholder to obtain a de-lexicalized to-be-replied text sample sequence;
[0017] According to the de-lexicalized text sample sequence to be replied, an implicit feature representation of the text sample sequence to be replied is obtained.
[0018] According to a knowledge-driven dialogue generation method provided by the present invention, the step of inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity specifically includes:
[0019] Obtaining a feature representation of the head entity according to the implicit feature representation of the sample sequence of the text to be replied;
[0020] According to the feature representation of the head entity and the feature representation of the entity relationship of the head entity, a feature representation of the tail entity corresponding to the head entity is obtained.
[0021] According to a knowledge-driven dialogue generation method provided by the present invention, after the step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence, the method further includes:
[0022] In the case that the knowledge graph corresponding to the entity in the to-be-replied text sample sequence cannot be retrieved, a first feature representation of any entity is obtained based on the entity relationship feature representation of any entity in the pre-stored knowledge graph and the implicit feature representation of the to-be-replied text sample sequence;
[0023] Obtaining a second feature representation of any entity according to the first feature representation of any entity;
[0024] The first feature representation of any entity, the second feature representation of any entity and the feature representation of common words in a pre-stored vocabulary are input into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence.
[0025] According to a knowledge-driven dialogue generation method provided by the present invention, before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes:
[0026] Taking a to-be-replied text sample sequence and a real reply text sequence label carried by the to-be-replied text sample sequence as a group of dialogue training samples, and obtaining multiple groups of dialogue training samples;
[0027] The deep neural network dialogue model is trained using the multiple groups of dialogue training samples.
[0028] According to a knowledge-driven dialogue generation method provided by the present invention, the steps of training a deep neural network dialogue model using the plurality of dialogue training samples and the stored feature representation dataset of knowledge graph entity relationships specifically include:
[0029] For any group of dialogue training samples, input the dialogue training samples into the deep neural network dialogue model, and output the predicted probability corresponding to the dialogue training samples;
[0030] Using a preset loss function, a loss value is calculated according to the predicted probability corresponding to the dialogue training sample and the real response text sequence label in the dialogue training sample;
[0031] If the loss value is less than a preset threshold, the training of the deep neural network dialogue model is completed.
[0032] The present invention also provides a knowledge-driven dialogue generation device, comprising:
[0033] A reply text generation module is used to input the to-be-replied text sequence into the trained deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text;
[0034] Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships;
[0035] Among them, the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied that carries real reply text sequence labels and a feature representation data set of the knowledge graph entity relationship.
[0036] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-described knowledge-driven dialogue generation methods are implemented.
[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described knowledge-driven dialog generation methods.
[0038] The present invention provides a knowledge-driven dialogue generation method and device, which calculates the entity representation in the knowledge graph based on the unstructured information in the text to be replied and the structured information of the knowledge graph, based on a trained deep neural network dialogue model, and can more efficiently apply the knowledge graph to generate dialogue replies with appropriate semantics and rich information. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 It is a flowchart of the knowledge-driven dialogue generation method provided by the present invention;
[0041] Figure 2 Schematic diagram of the overall framework of the knowledge-driven dialogue model provided by an embodiment of the present invention;
[0042] Figure 3 It is a schematic diagram of the structure of the knowledge-driven dialogue generation device provided by the present invention;
[0043] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] Figure 1 It is a flow chart of the speech recognition method provided by the present invention, such as Figure 1 As shown, including:
[0046] Step S1, inputting a text sequence to be replied into a trained deep neural network dialogue model to obtain a reply text sequence of the text to be replied;
[0047] Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships;
[0048] Among them, the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied that carries real reply text sequence labels and a feature representation data set of the knowledge graph entity relationship.
[0049] Specifically, the text sequence to be replied described in the present invention is a text sequence input by the user terminal and needs to be replied, which includes unstructured information in data forms such as characters, numbers, punctuation marks and various symbols.
[0050] The reply text sequence of the text to be replied described in the present invention refers to the corresponding reply text sequence obtained after the text sequence to be replied is input into the deep neural network dialogue model trained by the present invention.
[0051] The feature representation described in the present invention refers to the parameterized representation of entity and entity relationship features in the knowledge graph.
[0052] The feature representation data set of the knowledge graph entity relationship described in the present invention refers to a data set obtained by parameterizing the entity relationship features in the commonly used knowledge graph structured information.
[0053] In an embodiment of the present invention, a feature representation dataset of knowledge graph entity relationships is pre-stored in a deep neural network dialogue model to facilitate subsequent training of the model.
[0054] The trained deep neural network dialogue model described in the present invention is obtained after training based on training samples and feature representation data sets of knowledge graph entity relationships. It is used to recognize the text sequence to be replied input by the user end, learn the generalized representation of entities in the knowledge graph, and thus output a reply text sequence with appropriate semantics and rich information.
[0055] The training samples are composed of multiple groups of to-be-replied text sample sequences carrying real reply text sequence labels.
[0056] The real reply text sequence labels described in the present invention are predetermined according to the to-be-replied text sample sequence and correspond one-to-one with the to-be-replied text sample sequence. That is, each to-be-replied text sample sequence in the training sample is predetermined to carry a corresponding reply text sequence as a real label.
[0057] Through the method of the embodiment of the present invention, according to the unstructured information in the text to be replied and the structured information of the knowledge graph, based on the trained deep neural network dialogue model, the entity representation in the knowledge graph is calculated, and the knowledge graph can be more efficiently applied to generate dialogue replies with appropriate semantics and rich information.
[0058] Based on any of the above embodiments, before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes:
[0059] Inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain an implicit feature representation of the to-be-replied text sample sequence;
[0060] According to the head entity in the to-be-replied text sample sequence, a knowledge graph corresponding to the head entity is obtained, so as to determine the entity relationship feature representation of the head entity from a feature representation data set of the entity relationship stored in the knowledge graph;
[0061] Inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity;
[0062] The feature representation of the head entity, the feature representation of the tail entity corresponding to the head entity, and the feature representation of the common words in the pre-stored vocabulary are input into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence.
[0063] Specifically, the bidirectional encoder described in the present invention can encode the knowledge entity in two contextual directions according to the context content of the knowledge entity in the text sample sequence to be replied, which is conducive to improving the accuracy of modeling.
[0064] The knowledge interpreter described in the present invention can be used to infer the entity representation in the knowledge graph based on the encoding results of the text sample sequence to be replied and through the structured information of the knowledge graph.
[0065] The decoder described in the present invention can be used to decode the feature representations of entities and common words in a sample sequence of text to be replied to, and generate a reply text sequence.
[0066] In an embodiment of the present invention, implicit feature representation is semantic feature representation, which refers to the parameterized representation of semantic features of words in a sample sequence of text to be replied; the feature representation data set of stored knowledge graph entity relationships refers to the feature representation data set of knowledge graph entity relationships pre-stored in a deep neural network dialogue model; the feature representation of common words in a pre-stored vocabulary refers to the parameterized representation of common word features in a common vocabulary pre-stored in a deep neural network dialogue model.
[0067] Furthermore, the sample sequence of the text to be replied is set to X = (x1, x2, ..., x n ), the knowledge graph is G = {g1,g2,…,g |G|}, it can be seen that the model task goal is to generate a dialogue reply text sequence with appropriate semantics and knowledge as Y = (y1, y2, ..., y m ). In essence, the probability of generating a reply text sequence obtained by the deep neural network dialogue model is
[0068] In the embodiment of the present invention, the knowledge graph is retrieved from the knowledge base based on the words in the sample sequence of text to be replied as the query index. Each word in the sample sequence of text to be replied corresponds to a knowledge subgraph g in G. i , each knowledge subgraph consists of a set of knowledge triples, which can be expressed as Each knowledge triple consists of a head entity, a relation, and a tail entity, expressed as
[0069] Furthermore, the sample sequence of text to be replied is X = (x1, x2, ..., x n ) is input into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation H = (h1, h2, ..., h n ).
[0070] According to the sample sequence of text to be replied X=(x1,x2,…,xn ) in the entity word, i.e., the head entity To query the index, retrieve the corresponding knowledge graph g from the knowledge base i . Among them, each tail entity Through the relationship Connect with the central entity (head entity) of the knowledge graph. i , determine the head entity from the feature representation dataset of the stored knowledge graph entity relationship Entity relationship feature representation
[0071] Furthermore, the implicit feature representation of the above-obtained sequence of text samples to be replied is H = (h1, h2, ..., h n ) and the entity relationship feature representation of the head entity Input the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity The tail entity feature representation corresponding to the head entity
[0072] Furthermore, the feature representation of the head entity Feature representation of tail entity corresponding to head entity and the feature representation of common words in the pre-stored vocabulary, and input it into the decoder of the deep neural network dialogue model to obtain the reply text sequence Y = (y1, y2, ..., y m ).
[0073] In an embodiment of the present invention, the decoder g of the deep neural network dialogue model θ It is a unidirectional neural network that dynamically focuses on the implicit feature representation H of the sample sequence of text to be replied by adopting the attention mechanism. The decoding state calculation process is as follows:
[0074] s t =g θ (e(y t-1 ),s <t ,H);
[0075] Among them, s t represents the state vector of the decoder at step t, e(y t-1 ) represents the word vector of the word decoded in the previous step, s <t represents the state vector of the decoder t steps ago, and H represents the implicit feature representation of the sample sequence of the text to be replied.
[0076] Furthermore, in order to generate informative and knowledge-related dialogue responses, the decoder g θThe knowledge selector preset in the memory module can select related entities from the knowledge entities stored in the memory module or select vocabulary from the vocabulary during the decoding process. Avoid decoder g θ Generates duplicate entities. The formal definition of the decoding process is as follows:
[0077]
[0078] P g (y t =w g )=softmax(W g s t );
[0079]
[0080]
[0081]
[0082]
[0083] in, represents the model parameter vector, s t Indicates the current state of the decoder, w g represents the model parameter matrix for calculating the generation probability of common words in the pre-stored vocabulary, g t ∈(0,1) is a scalar used to balance the choice between entities and general words, W e represents the model parameter matrix for calculating the probability of related entity generation, Represents the intermediate variables in the calculation process, represents the coverage mechanism parameter network, P g represents the generation probability distribution of common words, P e represents the generation probability distribution of knowledge entities, P(y t ) is the final generated probability distribution, Indicates the special representation of the head entity, The special representation of the tail entity, e(w g ) represents the feature representation of common words.
[0084] It should be noted that the encoder, knowledge interpreter and decoder of the deep neural network dialogue model can all be implemented using a general deep neural network, without specific limitation here.
[0085] The method of the embodiment of the present invention inputs a text sample sequence to be replied into a deep neural network dialogue model, and sequentially passes through the model's encoder, knowledge interpreter, and decoder to obtain a reply text sequence for the text sample sequence to be replied, thereby training the deep neural network dialogue model.
[0086] Based on any of the above embodiments, the step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence specifically includes:
[0087] Replacing the head entity in the to-be-replied text sample sequence with a placeholder to obtain a de-lexicalized to-be-replied text sample sequence;
[0088] According to the de-lexicalized text sample sequence to be replied, an implicit feature representation of the text sample sequence to be replied is obtained.
[0089] Specifically, the de-lexicalization process described in the present invention refers to a processing method of using placeholders to replace entity words in the sample sequence of text to be replied. The purpose of this processing method is to allow the model to focus on the latest knowledge entities mentioned in the sample sequence of text to be replied, so as to facilitate the subsequent model to learn the generalized representation of entities in the knowledge graph.
[0090] Furthermore, for a text sample sequence to be replied X = (x1, x2, ..., x n ), de-lexicalize the text sample sequence to be replied, and use the placeholder [MASK-i] to replace the knowledge entities in the text sample sequence to be replied, where i represents the reverse order of the text sample sequence to be replied. In this way, the de-lexicalization process makes the implicit feature representation of the text sample sequence to be replied learned by the dialogue model independent of the parameterized representation of the knowledge entity, and the dialogue model can be extended to apply entities that have not appeared in the training process.
[0091] Furthermore, after the de-lexicalization step, the text sample sequence to be replied is input into a bidirectional encoder f of the deep neural network dialogue model. θ , and obtain the implicit feature representation H = (h1,h2,…,h n ) and h X , which is formally defined as follows:
[0092] H=f θ (X);
[0093] h X = pooling(H);
[0094] Among them, f θIt can be implemented by Transformer or Gated Recurrent Unit (GRU).
[0095] The method of the embodiment of the present invention obtains implicit feature representation of the text sample sequence to be replied by de-lexicalizing the text sample sequence to be replied and then using a bidirectional encoder based on a deep neural network dialogue model.
[0096] Based on any of the above embodiments, the step of inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity specifically includes:
[0097] Obtaining a feature representation of the head entity according to the implicit feature representation of the sample sequence of the text to be replied;
[0098] According to the feature representation of the head entity and the feature representation of the entity relationship of the head entity, a feature representation of the tail entity corresponding to the head entity is obtained.
[0099] Specifically, in order to ensure the generalization of entities in the learned knowledge graph, the present invention does not learn parameterized feature representations for each entity. Instead, it uses the implicit features of the sample sequence of text to be replied to through the MLP parameter network to represent the knowledge entities mentioned in the sample sequence of text to be replied, that is, to obtain the head entity The feature representation is calculated as follows:
[0100]
[0101] Furthermore, by using knowledge entities The retrieved knowledge graph g i The structural information of the head entity is inferred to obtain the tail entity corresponding to the head entity. The feature representation is calculated as follows:
[0102]
[0103]
[0104]
[0105] Among them, MLP represents multi-layer perceptron, GRU represents gated recurrent unit, and h X The implicit feature representation of the sample sequence of text to be replied, The feature representation of the head entity, Entity relation feature representation representing the head entity, Indicates the tail entity feature representation corresponding to the head entity, Represents intermediate variables in the calculation process.
[0106] The method of the embodiment of the present invention obtains the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity through the knowledge interpreter of the deep neural network dialogue model based on the implicit feature representation of the text sample sequence to be replied.
[0107] Based on any of the above embodiments, after the step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence, the method further includes:
[0108] In the case that the knowledge graph corresponding to the entity in the to-be-replied text sample sequence cannot be retrieved, a first feature representation of any entity is obtained based on the entity relationship feature representation of any entity in the pre-stored knowledge graph and the implicit feature representation of the to-be-replied text sample sequence;
[0109] Obtaining a second feature representation of any entity according to the first feature representation of any entity;
[0110] The first feature representation of any entity, the second feature representation of any entity and the feature representation of common words in a pre-stored vocabulary are input into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence.
[0111] Specifically, in an embodiment of the present invention, although the above-mentioned embodiment method can represent knowledge entities related to the text sample sequence to be replied, it cannot model entities in the knowledge graph that do not have any path connection with the entities mentioned in the text sample sequence to be replied, that is, the relevant knowledge subgraph cannot be retrieved from the knowledge graph in the knowledge base through the entity words mentioned in the text sample sequence to be replied.
[0112] Therefore, in the embodiment of the present invention, in order to be able to represent and apply such knowledge entities that cannot be associated with entities in the text sample sequence to be replied, the pre-stored knowledge graph is used to calculate the |g connected to entity i for any entity i. i | feature representation of the relationship, so as to represent the implicit feature of the sample sequence of the text to be replied h X , calculate the first feature representation of entity i
[0113] Furthermore, based on the first feature representation of entity i, the second feature representation of entity i is obtained through the MLP parameter network.
[0114] Among them, the entire entity representation calculation process is carried out through the attention mechanism, and its calculation process is as follows:
[0115]
[0116]
[0117]
[0118]
[0119] Among them, h X The implicit feature representation of the sample sequence of text to be replied, Indicates the |g connected to entity i i | feature representation of a relation n, represents the first feature representation of entity i, represents the second feature representation of entity i, MLP represents multi-layer perceptron, W h represents the model parameter matrix, α n and β n Represents an intermediate variable in the calculation process.
[0120] In an embodiment of the present invention, and are two feature representations of the same entity i, which will play different roles in the decoding process.
[0121] Furthermore, the first feature of entity i is represented as The second feature representation and the feature representations of common words in the pre-stored vocabulary are input into the decoder of the deep neural network dialogue model.
[0122] In an embodiment of the present invention, the decoder g θ It is a unidirectional neural network that dynamically focuses on the implicit feature representation H of the sample sequence of text to be replied by adopting the attention mechanism. The decoding state calculation process is as follows:
[0123] s t =g θ (e(y t-1 ),s <t ,H);
[0124] Among them, s t represents the state vector of the decoder at step t, e(y t-1 ) represents the word vector of the word decoded in the previous step, s <t represents the state vector of the decoder t steps ago, and H represents the implicit feature representation of the text sample sequence to be replied.
[0125] Furthermore, in order to generate informative and knowledge-related dialogue responses, the decoder g θ The knowledge selector preset in the memory module can select related entities from the knowledge entities stored in the memory module or select vocabulary from the vocabulary during the decoding process. Avoid decoder g θ Generates duplicate entities. The formal definition of the decoding process is as follows:
[0126]
[0127] P g (y t =w g )=softmax(W g s t );
[0128]
[0129]
[0130]
[0131]
[0132] in, represents the model parameter vector, s t Indicates the current state of the decoder, w g represents the model parameter matrix for calculating the generation probability of common words in the pre-stored vocabulary, g t ∈(0,1) is a scalar used to balance the choice between entities and general words, W e represents the model parameter matrix for calculating the probability of related entity generation, Represents the intermediate variables in the calculation process, represents the coverage mechanism parameter network, P g represents the generation probability distribution of common words, P e represents the generation probability distribution of knowledge entities, P(y t ) is the final generated probability distribution, represents the first feature representation of entity i, The second feature representation of entity i, e(w g ) represents the feature representation of common words.
[0133] Through the method of the embodiment of the present invention, according to the implicit feature representation of the text sample sequence to be replied and the entity relationship feature representation of any entity in the pre-stored knowledge graph, based on the deep neural network dialogue model, a reply text sequence of the text sample sequence to be replied is obtained, which solves the technical problem that the entity representation in the knowledge graph cannot be used when the corresponding knowledge graph cannot be retrieved from the entity in the text sequence to be replied.
[0134] Based on any of the above embodiments, before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes:
[0135] Taking a to-be-replied text sample sequence and a real reply text sequence label carried by the to-be-replied text sample sequence as a group of dialogue training samples, and obtaining multiple groups of dialogue training samples;
[0136] The deep neural network dialogue model is trained using the multiple groups of dialogue training samples.
[0137] Specifically, before inputting the text sequence to be replied into the trained deep neural network dialogue model, the deep neural network dialogue model needs to be trained. The specific training process is as follows:
[0138] The text sample sequence to be replied and the real reply text sequence label carried by the text sample sequence to be replied are taken as a group of dialogue training samples, that is, each text sample sequence to be replied with a real reply text sequence label is taken as a group of training samples, thereby obtaining multiple groups of training samples.
[0139] In the embodiment of the present invention, the to-be-replied text sample sequence and the real reply text sequence label carried by the to-be-replied text sample sequence are in one-to-one correspondence.
[0140] Then, after obtaining multiple groups of training samples, the multiple groups of training samples are input into the deep neural network dialogue model in sequence, that is, the to-be-replied text sample sequence and the real reply text sequence label in each group of training samples are simultaneously input into the deep neural network dialogue model, and according to each output result of the deep neural network dialogue model, the model parameters in the deep neural network are adjusted by calculating the loss function value, and finally the training process of the deep neural network dialogue model is completed.
[0141] Through the method of the embodiment of the present invention, the text sample sequence to be replied and the real reply text sequence label carried by the text sample sequence to be replied are used as a group of dialogue training samples, and the deep neural network dialogue model is trained using multiple groups of training samples.
[0142] Based on any of the above embodiments, the step of training the deep neural network dialogue model using the multiple groups of dialogue training samples and the stored feature representation data set of knowledge graph entity relationships specifically includes:
[0143] For any group of dialogue training samples, input the dialogue training samples into the deep neural network dialogue model, and output the predicted probability corresponding to the dialogue training samples;
[0144] Using a preset loss function, a loss value is calculated according to the predicted probability corresponding to the dialogue training sample and the real response text sequence label in the dialogue training sample;
[0145] If the loss value is less than a preset threshold, the training of the deep neural network dialogue model is completed.
[0146] Specifically, after obtaining multiple groups of training samples, for any group of training samples, the to-be-replied text sample sequence and the actual reply text sequence label in the training sample are simultaneously input into the deep neural network dialogue model, and the prediction probability corresponding to the training sample is output, where the prediction probability refers to the prediction probability corresponding to the training sample for different reply text sequences.
[0147] In an embodiment of the present invention, the preset loss function refers to a loss function pre-set in a deep neural network dialogue model, which is used for model evaluation; the preset threshold refers to a threshold pre-set by the model, which is used to obtain the minimum loss value and complete model training.
[0148] On this basis, the preset loss function is used to calculate the loss value according to the predicted probability corresponding to the training sample and the real reply text sequence label in the training sample. Among them, the preset loss function is the generation probability distribution P(y t ) and the probability distribution p of knowledge entities or common words in the true response text sequence t In addition, in order to guide the model to select the correct knowledge entity for generation, the present invention also adds additional supervisory signals to the knowledge selector.
[0149] Among them, the preset loss function is defined as:
[0150]
[0151] Among them, q t ∈{0,1} is the true label of the selected knowledge entity or common word in the real response text sequence Y, which is used to supervise the model to learn the probability of selecting knowledge entities or common words; α and β represent the number of entities and the number of common words in the training data respectively; m represents the sum of the number of knowledge entities and common words in the real response text sequence; p trepresents the probability distribution of knowledge entities or common words in the real response text sequence; P(y t ) represents the generation probability distribution of knowledge entities or common words predicted by the model in the training corpus; g t represents the probability of selecting knowledge entities or common words predicted by the model in the training corpus, and λ represents the manually set parameter for balancing the loss weights of entities and common words.
[0152] Furthermore, after the loss value is calculated, the training process ends, and the Stochastic Gradient Descent (SGD) algorithm is used to update the model parameters in the deep neural network dialogue model before the next training. During the training process, if the loss value calculated for a group of training samples is less than the preset threshold, the training of the deep neural network dialogue model is completed.
[0153] The method of the embodiment of the present invention controls the loss value of the deep neural network dialogue model within a preset range by training the deep neural network dialogue model, thereby facilitating improving the accuracy of the reply text output by the deep neural network dialogue model.
[0154] Figure 2 is a schematic diagram of the overall framework of the knowledge-driven dialogue model provided by an embodiment of the present invention, such as Figure 2 As shown, the knowledge-driven dialogue model of the present invention is mainly composed of three units: an encoder, a knowledge interpreter and a decoder.
[0155] like Figure 2 As shown in FIG. 1 , the text sequence X to be replied can be “What is the next book by ChuckPalahniuk after Pygmy?”. The text sequence X to be replied is input into the encoder of the deep neural network dialogue model. The text sequence to be replied is delexicalized. The placeholder [MASK1] is used to cover the first entity word Pygmy from the end of the sequence, and the placeholder [MASK2] is used to cover the second entity word ChuckPalahniuk from the end of the sequence. After bidirectional encoding of the delexicalized text sequence to be replied, the implicit feature representation H = (h1, h2, …, h 10 ) and h X .
[0156] Furthermore, through the head entity Chuck Palahniuk in the to-be-replied text sequence X, its corresponding knowledge subgraph can be retrieved from the knowledge base, such as Figure 2 As shown on the left side of . The implicit feature representation H = (h1,h2,…,h 10 ) and h XInput the knowledge interpreter of the deep neural network dialogue model, the implicit feature representation H = (h1,h2,…,h 10 ) After the MLP network in the knowledge interpreter, the feature representation of the head entity Chuck Palahniuk is calculated Then, according to the implicit feature representation h X Feature representation of relationships with pre-existing entities Through the MLP network, the tail entity feature representation corresponding to the head entity Chuck Palahniuk is calculated
[0157] According to the feature representation of the head entity Chuck Palahniuk The tail entity feature representation corresponding to the head entity ChuckPalahniuk The feature representation of common words in the pre-stored vocabulary is passed through the decoder Decoder in the deep neural network dialogue model, and the reply text sequence obtained is "The book is Tell-All".
[0158] Through the method of the embodiment of the present invention, a knowledge-driven dialogue model based on entity-agnostic representation learning (EARL) can be provided, which can learn the generalized representation of entities in the knowledge graph and generate dialogue responses with appropriate semantics and rich information.
[0159] Figure 3 is a schematic diagram of the structure of the knowledge-driven dialogue generation device provided by the present invention, such as Figure 3 As shown, including:
[0160] A reply text generation module 310 is used to input a text sequence to be replied to into a trained deep neural network dialogue model to obtain a reply text sequence of the text to be replied to;
[0161] Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships;
[0162] Among them, the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied that carries real reply text sequence labels and a feature representation data set of the knowledge graph entity relationship.
[0163] Through the knowledge-driven dialogue generation device of the present invention, according to the unstructured information in the text to be replied and the structured information of the knowledge graph, based on the trained deep neural network dialogue model, the entity representation in the knowledge graph is calculated, and the knowledge graph can be more efficiently applied to generate dialogue replies with appropriate semantics and rich information.
[0164] The knowledge-driven dialogue generation device described in this embodiment can be used to execute the above method embodiments. Its principles and technical effects are similar and will not be repeated here.
[0165] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the knowledge-driven dialogue generation method, which includes: inputting the text sequence to be replied into the trained deep neural network dialogue model to obtain the reply text sequence of the text to be replied; wherein the deep neural network dialogue model stores a feature representation data set of the knowledge graph entity relationship; wherein the trained deep neural network dialogue model is obtained after training based on the sample sequence of the text to be replied carrying the real reply text sequence label and the feature representation data set of the knowledge graph entity relationship.
[0166] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0167] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the knowledge-driven dialogue generation method provided by the above methods, and the method includes: inputting a text sequence to be replied into a trained deep neural network dialogue model to obtain a reply text sequence of the text to be replied; wherein the deep neural network dialogue model stores a feature representation data set of a knowledge graph entity relationship; wherein the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied carrying a real reply text sequence label and a feature representation data set of the knowledge graph entity relationship.
[0168] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the knowledge-driven dialogue generation method provided by the above-mentioned methods, the method comprising: inputting a text sequence to be replied into a trained deep neural network dialogue model to obtain a reply text sequence of the text to be replied; wherein the deep neural network dialogue model stores a feature representation data set of a knowledge graph entity relationship; wherein the trained deep neural network dialogue model is obtained after training based on a sample sequence of text to be replied carrying a real reply text sequence label and a feature representation data set of the knowledge graph entity relationship.
[0169] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0170] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0171] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A knowledge-driven dialogue generation method, characterized in that: include: Inputting the to-be-replied text sequence into the trained deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text; Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships; The trained deep neural network dialogue model is obtained by training based on a sample sequence of texts to be replied that carries a real reply text sequence label and a feature representation dataset of the entity relationship of the knowledge graph; Before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes: Inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain an implicit feature representation of the to-be-replied text sample sequence; According to the head entity in the to-be-replied text sample sequence, a knowledge graph corresponding to the head entity is obtained, so as to determine the entity relationship feature representation of the head entity from a feature representation data set of the entity relationship stored in the knowledge graph; Inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity; Inputting the feature representation of the head entity, the feature representation of the tail entity corresponding to the head entity, and the feature representation of the common words in the pre-stored vocabulary into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence; The step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence specifically includes: Replacing the head entity in the to-be-replied text sample sequence with a placeholder to obtain a de-lexicalized to-be-replied text sample sequence; Obtaining an implicit feature representation of the to-be-replied text sample sequence according to the de-lexicalized to-be-replied text sample sequence; The step of inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity specifically includes: Obtaining a feature representation of the head entity according to the implicit feature representation of the sample sequence of the text to be replied; According to the feature representation of the head entity and the feature representation of the entity relationship of the head entity, a feature representation of the tail entity corresponding to the head entity is obtained.
2. The knowledge-driven dialogue generation method according to claim 1, characterized in that: After the step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence, the method further comprises: In the case that the knowledge graph corresponding to the entity in the to-be-replied text sample sequence cannot be retrieved, a first feature representation of any entity is obtained based on the entity relationship feature representation of any entity in the pre-stored knowledge graph and the implicit feature representation of the to-be-replied text sample sequence; Obtaining a second feature representation of any entity according to the first feature representation of any entity; The first feature representation of any entity, the second feature representation of any entity and the feature representation of common words in a pre-stored vocabulary are input into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence.
3. The knowledge-driven dialogue generation method according to claim 1, characterized in that: Before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the method further includes: Taking a to-be-replied text sample sequence and a real reply text sequence label carried by the to-be-replied text sample sequence as a group of dialogue training samples, and obtaining multiple groups of dialogue training samples; The deep neural network dialogue model is trained using the multiple groups of dialogue training samples.
4. The knowledge-driven dialogue generation method according to claim 3, characterized in that: The step of training the deep neural network dialogue model using the multiple groups of dialogue training samples and the stored feature representation dataset of the knowledge graph entity relationship specifically includes: For any group of dialogue training samples, input the dialogue training samples into the deep neural network dialogue model, and output the predicted probability corresponding to the dialogue training samples; Using a preset loss function, a loss value is calculated according to the predicted probability corresponding to the dialogue training sample and the real response text sequence label in the dialogue training sample; If the loss value is less than a preset threshold, the training of the deep neural network dialogue model is completed.
5. A knowledge-driven dialogue generation device, characterized in that: include: A reply text generation module is used to input the to-be-replied text sequence into the trained deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text; Wherein, the deep neural network dialogue model stores a feature representation data set of knowledge graph entity relationships; The trained deep neural network dialogue model is obtained by training based on a sample sequence of texts to be replied that carries a real reply text sequence label and a feature representation dataset of the entity relationship of the knowledge graph; Before the step of inputting the to-be-replied text sequence into the trained deep neural network dialogue model, the following steps are also included: Inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain an implicit feature representation of the to-be-replied text sample sequence; According to the head entity in the to-be-replied text sample sequence, a knowledge graph corresponding to the head entity is obtained, so as to determine the entity relationship feature representation of the head entity from a feature representation data set of the entity relationship stored in the knowledge graph; Inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity; Inputting the feature representation of the head entity, the feature representation of the tail entity corresponding to the head entity, and the feature representation of the common words in the pre-stored vocabulary into the decoder of the deep neural network dialogue model to obtain a reply text sequence of the to-be-replied text sample sequence; The step of inputting the to-be-replied text sample sequence into the bidirectional encoder of the deep neural network dialogue model to obtain the implicit feature representation of the to-be-replied text sample sequence specifically includes: Replacing the head entity in the to-be-replied text sample sequence with a placeholder to obtain a de-lexicalized to-be-replied text sample sequence; Obtaining an implicit feature representation of the to-be-replied text sample sequence according to the de-lexicalized to-be-replied text sample sequence; The step of inputting the implicit feature representation of the to-be-replied text sample sequence and the entity relationship feature representation of the head entity into the knowledge interpreter of the deep neural network dialogue model to obtain the feature representation of the head entity and the feature representation of the tail entity corresponding to the head entity specifically includes: Obtaining a feature representation of the head entity according to the implicit feature representation of the sample sequence of the text to be replied; According to the feature representation of the head entity and the feature representation of the entity relationship of the head entity, a feature representation of the tail entity corresponding to the head entity is obtained.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the knowledge-driven dialogue generation method according to any one of claims 1 to 4 are implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the knowledge-driven dialogue generation method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Intention recognition method and device based on ordering dialogue text and electronic device
CN109857844A
Automatic reply generation method for open domain dialogue system
CN110334190A
