Dialogue generation method and system for expanding context into knowledge graph

By extending the context to the knowledge graph in dialogue generation technology and combining structured and unstructured information, the problem of consistency and insufficient information in dialogue generation is solved, and information-rich and logically consistent dialogue responses are achieved.

CN113742490BInactive Publication Date: 2024-09-24SHANDONG NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110920580.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-11
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing dialogue generation technology is difficult to maintain the consistency and logic of dialogue in open fields, and knowledge perception that relies on entity retrieval cannot fully capture the specific knowledge of the current dialogue, resulting in insufficient information generation and too many generic answers.

Method used

By expanding the context into the knowledge graph, building a knowledge sub-graph, filtering out important sentences and vocabulary in the context, combining structured knowledge and unstructured contextual information, generating response dialogue sentences, using technologies such as point mutual information algorithms and convolutional neural networks. , ensuring the accuracy of knowledge perception and the fluency of dialogue.

Benefits of technology

It achieves information richness and fluency in dialogue responses, improves diversity and logical consistency, is significantly better than traditional knowledge perception models, and generates responses that are more specific and relevant.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113742490B
    Figure CN113742490B
Patent Text Reader

Abstract

The present invention discloses a method and system for generating a dialogue by expanding context into a knowledge graph, obtaining a current sentence and several context sentences of the current sentence; constructing a knowledge subgraph of the current sentence according to the current sentence; screening several context sentences of the current sentence to screen out important context sentences; screening out important words from the knowledge subgraph of the current sentence according to the important context sentences of the current sentence; deleting non-important words in the knowledge subgraph of the current sentence to obtain an updated knowledge subgraph; connecting the words obtained after word segmentation of the important context sentences with the important words in the updated knowledge subgraph to obtain an expanded knowledge graph; generating a response dialogue sentence based on the current sentence and the expanded knowledge graph. Further generating an information-rich and fluent reply according to the context and knowledge perception.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of dialog generation technology, and in particular to a dialog generation method and system for expanding context into a knowledge graph. Background Art

[0002] The statements in this section merely mention background art related to the present invention and do not necessarily constitute prior art.

[0003] Human-computer dialogue involves two main subjects: humans and machines. As a direct manifestation of communication between the two, the dialogue system is committed to pursuing the fluency and naturalness of the dialogue. In recent years, many scholars have been rooted in the generation of dialogue responses in open fields, which involves a wide range of issues but has relatively single results. It is difficult to grasp the consistency of the dialogue when focusing on topic transfer, and it is difficult to generate richer information when focusing on the logic of the dialogue. It is difficult to balance the fluency of the dialogue when grasping the particularity of the characters. In general, dialogue involves many factors, and the key is that the machine can understand the knowledge behind the language and infer the concepts in a specific dialogue. However, it is difficult to achieve true semantic interaction by relying solely on dialogue data or simple entity retrieval without the help of background knowledge learning.

[0004] Recently, some studies have begun to promote dialogue generation in open domains by introducing additional knowledge. These models mainly play the role of background knowledge through unstructured knowledge or structured triples, and experiments show that this prior knowledge can enhance the generalization ability of knowledge selection models. In particular, knowledge triples or graph paths can effectively narrow the scope of candidate vertices and generate more diverse answers. However, since the participation generation is limited to a word or entity, only limited information can be captured from the surface text of the query message, so it may encounter information that cannot generate a response. Unlike structured triples, the text sentences in the context contain rich information about the current dialogue, so the participation of relevant context can provide specific contextual information for dialogue generation. The fusion of graph structure and relevant context may have a positive effect on knowledge perception and conversation generation, but there are few studies on this.

[0005] In view of the low information content and general answer tendency of the dialogue replies in chat systems, recent research has proposed the introduction of structured knowledge based on knowledge graph retrieval. Giving additional relevant knowledge to the dialogue can obviously enrich the dialogue generation, but the knowledge retrieval process is limited to the retrieval of entity words, ignoring the meaning of entities in the context, and cannot fully grasp the specific knowledge of the current dialogue. Summary of the invention

[0006] In order to solve the deficiencies of the prior art, the present invention provides a method and system for generating a dialogue by expanding the context into a knowledge graph;

[0007] In a first aspect, the present invention provides a method for generating a dialogue by expanding the context into a knowledge graph;

[0008] The dialogue generation method that expands the context into the knowledge graph includes:

[0009] Get the current statement and several context statements of the current statement;

[0010] According to the current sentence, construct the knowledge subgraph of the current sentence;

[0011] Filter several context sentences of the current sentence to select important context sentences;

[0012] According to the important sentences in the context of the current sentence, important words are filtered out from the knowledge subgraph of the current sentence;

[0013] Delete the non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph;

[0014] Generate response dialogue sentences based on the current sentence and the expanded knowledge graph.

[0015] In a second aspect, the present invention provides a dialog generation system that expands context into a knowledge graph;

[0016] The conversation generation that expands the context into the knowledge graph is the same, including:

[0017] An acquisition module is configured to: acquire a current sentence and several context sentences of the current sentence;

[0018] A construction module is configured to: construct a knowledge subgraph of the current sentence according to the current sentence;

[0019] The important sentence screening module is configured to: screen several context sentences of the current sentence to screen out the important context sentences;

[0020] An important vocabulary screening module is configured to: screen out important vocabulary from the knowledge sub-graph of the current sentence according to the contextual important sentences of the current sentence;

[0021] An expansion module is configured to: delete non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph;

[0022] A generation module is configured to generate a response dialogue sentence based on the current sentence and the expanded knowledge graph.

[0023] In a third aspect, the present invention further provides an electronic device, comprising:

[0024] a memory for non-transitory storage of computer-readable instructions; and

[0025] a processor for executing the computer readable instructions,

[0026] When the computer-readable instructions are executed by the processor, the method described in the first aspect is executed.

[0027] In a fourth aspect, the present invention further provides a storage medium that non-temporarily stores computer-readable instructions, wherein when the non-temporary computer-readable instructions are executed by a computer, the instructions of the method described in the first aspect are executed.

[0028] Compared with the prior art, the present invention has the following beneficial effects:

[0029] In order to maintain the consistency of the conversation, the effective integration of the conversation context is as important as the introduction of relevant knowledge. To address the above issues, the present invention proposes a conversation generation model (ECKDG) that expands the context into the knowledge graph, focusing on the introduction of knowledge in the current conversation. On the one hand, the expansion of the knowledge graph is the connection of the context on the relevant appropriate knowledge. The appropriate knowledge is the identification of specific knowledge for the current conversation. On the other hand, the context is a context that is highly relevant to the current information. The integration of important context information can effectively ensure the logical consistency before and after the conversation.

[0030] Among them, the expanded knowledge graph received in the generation of dialogue responses contains both structured knowledge and unstructured contextual information. In order to maximize the effectiveness of both inputs, the decoding generation module applies a summary extraction model, which is committed to further generating information-rich and fluent responses based on context and knowledge perception. At the same time, from the perspective of experimental evaluations involving multiple angles, compared with other current knowledge-aware dialogue generation models, the responses generated under the model of the present invention have an advantage in diversity and fluency, and the overall performance is outstanding.

[0031] Advantages of additional aspects of the present invention will be partially given in the following description or learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0033] Figure 1 : An illustrative example of context-based knowledge retrieval;

[0034] Figure 2 : An illustrative example of context-based knowledge retrieval;

[0035] Figure 3 : A schematic diagram of the framework of the first embodiment of the present application;

[0036] Figure 4 : A flow chart of the method of Embodiment 1 of the present application;

[0037] Figure 5 : A structural diagram of the overall calculation model involved in the method of the present invention in Example 1 of the present application. DETAILED DESCRIPTION

[0038] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0039] It should be noted that the terms used herein are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention. 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 the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0040] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0041] In this embodiment, all data is obtained in compliance with laws and regulations and based on the user's consent, and is used legally.

[0042] The present invention is developed on the basis of the previous exploration results. Considering that structured knowledge is the result of human extraction, it has obvious advantages in both specific fields and open environments. However, entities that rely solely on knowledge retrieval still have the problem of insufficient information in conversation generation. In order to bridge the gap between knowledge selection and conversation generation, the present invention proposes a conversation generation model (EKADG) with knowledge graph perception of relevant context expansion, which is committed to giving full play to the role of relevant context and appropriate knowledge in conversation generation. The model of the present invention mainly includes three stages: appropriate knowledge identification, context expansion, and conversation generation. The first two stages incorporate context information related to the current information through the point mutual information algorithm, because appropriate knowledge is based on the retrieval and selection of important information of the current conversation on the weekly knowledge graph, and context expansion is the expansion of the most relevant sentences of the current information on the retrieved appropriate knowledge. Therefore, the three stages of the present invention integrate the framework of the current conversation and the selection of appropriate knowledge to make the EKADG model more interpretable. The interpretability of the model is particularly important in dialogue systems such as, for example, in business scenarios, staff should not make business decisions without sufficient reasons, and users also need to understand how the knowledge of the chatbot's response is connected with the dialogue information.

[0043] The appropriate knowledge identification stage usually retrieves entity words as candidate knowledge based on the current information, and then perceives and responds based on the candidate knowledge and the current information. This paradigm is indeed effective to a certain extent, but it still faces some challenges: (1) There are multiple meanings of entity words in the sentence, but there is only one concept involved in the current conversation. If this is not taken into account, the retrieved knowledge will inevitably contain noise knowledge that is irrelevant to the current conversation; (2) Although we make the right choice in the entity concept selection, the relevant knowledge of the entity contains multiple topics. Some knowledge is connected to the entity but irrelevant to the current conversation, which is naturally unhelpful for the current conversation generation.

[0044] As Figure 1 and Figure 2 As shown in the example, the search for the word "water" includes both the biological body composition and the exaggerated way of speaking. However, according to the contextual information, it is obvious that the "water" here refers to the essential component of the human body. Further searching for all knowledge about water as a substance (the circled entity in the figure), if the model also selects irrelevant topics in the concept, it will generate answers that are useless to the current information. For example, the circled entity "blood" in the example is meaningless to the generation of the current dialogue.

[0045] To address the above problems, the present invention applies an appropriate knowledge identification algorithm, firstly locates the knowledge scope based on the current information retrieval knowledge graph of the conversation, and then calculates the probability distribution of the retrieved knowledge by encoding the relevant context, so as to effectively filter out the knowledge that violates the current conversation. The algorithm is special in that it calculates the most relevant topic information to the current information through the correlation between the context and the current conversation, thereby selecting the relevant knowledge that is highly matched with the current conversation.

[0046] With the widespread application of end-to-end input-output models in open-domain dialogue systems, the drawbacks of generating single and universal responses have gradually emerged. In order to solve the problem of monotonous response generation in different scenarios, researchers have continuously tried new methods to improve the scientific nature of the model, such as strengthening decoding algorithms, latent variable methods, and the introduction of additional content in dialogue generation. In terms of method implementation, Zhu et al. used retrieved existing dialogues, and Xu et al. used word monads, but the background knowledge obtained in the end was limited and could not meet the needs of dialogue generation. And with the availability of a large amount of knowledge, some studies have modeled conversations based on unstructured texts, or constructed dialogue data about basic knowledge. Ghazviinejad et al. used unstructured text knowledge to enrich traditional neural network dialogue models, realizing the connection between data-driven dialogue systems and other knowledge. Furthermore, Zhou et al. found the drawback of treating triples in isolation in unstructured knowledge, and proposed to use structured, that is, interrelated triple knowledge to perceive knowledge. Wu et al. used document reasoning networks to model contexts, but they were not applied to knowledge selection, and the research based on structured knowledge perception was limited to word embedding to represent vertices, without involving text analysis. Compared with these current knowledge-aware models, the present invention combines context with structured knowledge in a graph-based representation, effectively expanding the structure of the knowledge graph and improving the knowability of the knowledge graph in the current conversation.

[0047] Reply generation should be generated under a specific dialogue. Therefore, whether it is a neural network output model or a pre-trained model based on fine-tuning, it faces the problem of how to combine context information. As a direct source of context information, dialogue context is the key to determining the quality of dialogue responses. Existing research has also begun to realize the importance of context information. Sordoni et al. uniformly encode the context and the current dialogue into a recurrent neural network for learning. This is the first manifestation of putting context into a neural network for learning. This study reflects the necessity of context awareness. At the same time, some scholars have proposed a dialogue system that perceives context. For example, Yan et al. used a method of directly connecting context sentences with the current question to generate answers containing context information. This method can be called a non-layered method; Serben et al. used a layered method to first capture the feature vector of each sentence in the context and then further connect all the vectors. The additional knowledge that serves the dialogue must not only ensure consistency with the entity meaning in the dialogue, but also have a positive effect on the current dialogue. Therefore, in the process of retrieving knowledge, in addition to paying attention to current information, we also regard important context information as a necessary prerequisite for retrieving relevant knowledge.

[0048] Embodiment 1

[0049] This embodiment provides a method for generating a conversation by expanding the context into a knowledge graph;

[0050] The dialogue generation method that expands the context into the knowledge graph includes:

[0051] S101: Obtain a current statement and several context statements of the current statement;

[0052] S102: construct a knowledge subgraph of the current sentence according to the current sentence;

[0053] S103: screening several context sentences of the current sentence to screen out important context sentences;

[0054] S104: Filter out important words from the knowledge subgraph of the current sentence according to the important sentences in the context of the current sentence;

[0055] S105: deleting non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connecting the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph;

[0056] S106: Generate a response dialogue statement based on the current sentence and the expanded knowledge graph.

[0057] Furthermore, the S101: obtains the current sentence and several context sentences of the current sentence; for example: the current sentence is: Can eating fruit replenish water?

[0058] Several context statements of the current statement are:

[0059] A: I caught a cold again for unknown reasons;

[0060] B: Colds are usually caused by lack of water in the body, so drink more water;

[0061] A: But I don’t really like drinking water, it has no taste;

[0062] B: Then you can eat more fruits and vegetables.

[0063] Furthermore, the S102: constructing a knowledge subgraph of the current sentence according to the current sentence; specifically includes:

[0064] S1021: Perform word segmentation processing on the current sentence to obtain a number of words;

[0065] S1022: Match each word with an entity in the existing knowledge graph; if the current word successfully matches the entity in the existing knowledge graph, perform a multi-hop search to obtain a knowledge subgraph of the current sentence;

[0066] The multi-hop retrieval means that each word in the current sentence is matched in the existing knowledge graph, the successfully identified entity is used as the starting node, and multi-hop reasoning is performed along the path in the existing knowledge graph until the end node is reached. All skipped nodes and all skipped paths are recorded, and finally the knowledge subgraph of the current sentence is obtained.

[0067] Exemplarily, the existing knowledge graph is an existing structured knowledge graph and unstructured text knowledge in the industry.

[0068] It should be understood that the initial positioning of knowledge retrieval. Due to the changing characteristics of topics in multi-round dialogues, the current information of the dialogue as the latest trend of the current dialogue can indicate the direction of the dialogue development. Therefore, the first retrieval of the knowledge graph aims to complete the initial positioning of the current dialogue in the knowledge graph. Given the current information X, if x i ∈X matches the entity V in the knowledge graph G, then a multi-hop search will be performed, that is, the entity in X is identified in the knowledge graph G, and the identified entity is used as the starting node v x , further perform multi-hop reasoning according to the path in the knowledge graph until the end node v y , and finally obtain the knowledge subgraph closest to the current information X. Therefore, the adjacent nodes including the entity and the corresponding edge relationships will be retrieved as the retrieved knowledge g.

[0069] Furthermore, the step S103: screening several context sentences of the current sentence to screen out important context sentences; specifically includes:

[0070] Based on the point mutual information algorithm, the point mutual information value between each context sentence and the entity in the current sentence is calculated;

[0071] Based on the point mutual message value between entities, the relevance between the current context sentence and the current sentence is obtained;

[0072] Filter out several context sentences whose relevance exceeds a set threshold as important context sentences;

[0073] The selected important context sentences are encoded in chronological order to obtain the encoding vectors of the important context sentences.

[0074] Furthermore, the screened out several important context sentences are encoded in chronological order to obtain encoding vectors of the important context sentences, and a bidirectional GRU neural network is used to implement it. The screened out several important context sentences are input into the bidirectional GRU neural network, and the encoding vectors of the important context sentences are output.

[0075] Exemplarily, context-related information is encoded. The context in a multi-round conversation can provide us with many aspects of contextual information, but it also contains useless noise information for generating the current response. Calculating the relevance of each context to the current conversation is an important means to distinguish context information, and further encoding based on important information will pave the way for the selection of appropriate knowledge. Therefore, in order to more conveniently and effectively use the context to obtain the relevant knowledge graph of the current conversation, the present invention calculates the point mutual information between the limited context and the given information. Find the sentences in the context whose relevance index to the given information exceeds a certain threshold as the important participating information in the context. Then for a given multi-round conversation d l , S i ={z1,…,z n}∈S as the i-th context and the current information X={x1,…,x q The point mutual information calculation process of} is as follows:

[0076] First, the point mutual information between the context and the entity in the current information is calculated in sequence:

[0077]

[0078] Based on the point mutual information value between entities, the relevance of the sentence to the current information is obtained:

[0079]

[0080] In summary, by integrating the results of the calculation of the point-wise mutual information between sentences, we can get the important sentences in the context according to the principle of exceeding a certain threshold. At the level of encoding important information, considering the integrity and order of the sentence, a bidirectional GRU neural network is applied here. Simply put, when a vocabulary S is given, at time step t, the encoder will generate two states, forward and backward. Then the concatenation of the two Will be the final encoded state of vocabulary S:

[0081]

[0082]

[0083] Furthermore, the step S104: filtering out important words from the knowledge sub-graph of the current sentence according to the important sentences in the context of the current sentence; specifically includes:

[0084] Input the encoding vector of the important sentences in the context and the knowledge subgraph of the current sentence into the appropriate knowledge identifier, and output the weight of each word in the knowledge subgraph of the current sentence; filter out the words with weights higher than the set threshold as the important words filtered out from the knowledge subgraph of the current sentence;

[0085] Among them, the appropriate knowledge identifier is realized by using a convolutional neural network, and the convolutional neural network is trained using a training set to obtain the appropriate knowledge identifier after training; the training set includes: a known response sentence and an encoding vector of an important context sentence corresponding to the response sentence; during the training process, the encoding vector of the important context sentence and the knowledge subgraph of the current sentence are used as input values, and the known response sentence is used as an output value to train the convolutional neural network, and the trained convolutional neural network is the appropriate knowledge identifier.

[0086] Appropriate knowledge identification. Figure 1 As shown in the example, due to the differences in the meanings of entities in different contexts, the initially retrieved knowledge may violate the facts of the current conversation. In order to fully combine the current conversation context and integrate external knowledge from the current conversation, the present invention uses an appropriate knowledge identifier to select the knowledge that highly matches the current conversation from the retrieved knowledge. The identifier can read the important information encoding of the context and output the probability distribution of the retrieved knowledge g, so the retrieved knowledge g i Whether it is highly matched with the current dialogue depends on its probability distribution Z i In the model training implementation, the answers generated by humans are mainly used as a posteriori knowledge, and in the test, they are used as a priori for reasoning.

[0087]

[0088] Among them, g is the retrieval knowledge, W gt , W post , and W prior are all trainable parameters, μ and They are softmax and tanh activation functions respectively.

[0089] Finally, KL divergence (KLD) is applied to make the two distributions as close as possible. KL divergence (also called relative entropy) method is used to describe the approximation between the estimated probability distribution and the true probability distribution.

[0090] τ k =KLD(Z post , Z prior ) (7)

[0091] Further, the S105: deleting non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connecting the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph; specifically includes:

[0092] Delete the unimportant words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph;

[0093] The important words in the updated knowledge sub-graph are used as the backbone, and the words obtained after the segmentation of important sentences in the context are connected through entity mapping to obtain the expanded knowledge graph.

[0094] Among them, entity mapping means that if the knowledge sub-graph contains the word S, assuming that the words after the word segmentation of the important context sentence also contain the word S, then the entire sentence of the important context sentence is connected to the entity of the knowledge sub-graph;

[0095] If an important context sentence is connected to two entities at the same time, the entity with the larger number of connections between entities is preferentially selected for context connection. If the number of connections between entities is the same as that in multiple pieces of knowledge, a random algorithm is used to select the entity and connect it to the context sentence.

[0096] In order to combine the knowledge graph and context sentence information, the present invention uses appropriate knowledge as the knowledge graph backbone, and connects the context to the backbone through connections between entities, thereby expanding the relevant knowledge with the context while retaining the graph structure.

[0097] The knowledge graph of the present invention serves as additional knowledge to serve the current conversation, and is committed to generating reasonable and rich replies based on reasoning based on the knowledge graph. Then the referenced knowledge graph should first be based on the knowledge graph of the current conversation, that is, the identification of the appropriate knowledge in the above text. At the same time, in order to ensure the logical consistency of the conversation before and after and increase the semantics, the present invention expands the context as a sentence into the selected appropriate knowledge graph through the connection between entities. It should be noted that the present invention takes appropriate knowledge as the backbone, and divides the context in the conversation and connects it with the appropriate knowledge through entity mapping. Therefore, we expand the selected appropriate knowledge graph with context, while retaining the basic structural representation of the knowledge graph.

[0098] Furthermore, the S106: generating a response dialogue statement based on the current statement and the expanded knowledge graph; specifically includes:

[0099] Input the current sentence into the recurrent neural network to obtain the first encoding representation;

[0100] Input the expanded knowledge graph into the recurrent neural network to obtain the second encoding representation;

[0101] The first encoded representation and the second encoded representation are both input into the summary extraction model, and a response dialogue sentence is output.

[0102] In order to reasonably utilize context information, the present invention, on the one hand, implements screening on the retrieved knowledge through relevant context, effectively ensuring a high degree of match between the knowledge and the current conversation; on the other hand, expands the appropriate knowledge graph of the current conversation based on the relevant context, ensuring that the knowledge is perceived and integrated into the relevant context during the response generation process.

[0103] The knowledge graph after context expansion is a combination of structured knowledge and unstructured sentence information. Therefore, in order to better play the role of appropriate knowledge and relevant context in conversation generation, the present invention applies a summary extraction model to generate specific answers based on the knowledge graph after context expansion and current information.

[0104] In the study of question and answer, the fusion of knowledge graph and text corpus has been achieved through late or early fusion, which effectively solves the problem of low answer coverage in the knowledge graph model. In the present invention, this fusion is used for dialogue generation instead of the question and answer system, and the model of the present invention can generate answers based on contextual information, rather than being limited to knowledge perception.

[0105] In theory, the present invention first performs a preliminary search in the knowledge graph G based on the current information of the conversation, further identifies the appropriate knowledge f in the retrieved knowledge according to the encoding of important context information, and uses the appropriate knowledge f as the backbone to obtain the context-expanded knowledge graph by connecting it with the context entity. Therefore, when generating a reply, it is necessary to obtain the expanded knowledge graph based on the current conversation and the current information as the prerequisite for decoding generation.

[0106] The present invention relates to a knowledge graph in the form of: G = {V, E, L e}. V represents the vertex of the entity, E represents the edge between entities, and L e is the label of the current edge (such as attribute or category). So given the current information X = {x1, ..., x n} and the knowledge graph expanded by the context, the decoder is committed to outputting a reasonable response Y = {y1, ..., y m}.

[0107] Appropriate knowledge mechanism. The additional knowledge for the current dialogue state not only involves the retrieval of the current information in the knowledge graph, but also the identification of appropriate knowledge under specific context conditions. Therefore, the appropriate knowledge in the present invention is the identification of the retrieved knowledge range, and the knowledge closest to the current dialogue is selected according to the important information in the context.

[0108] Context-enhanced knowledge graph. Knowledge graph-aware conversation generation not only involves the combination of relevant knowledge, but also requires the connection of relevant context. In order to balance the integration of appropriate knowledge and relevant context in conversation generation, the present invention takes appropriate knowledge as the backbone of the knowledge graph and connects relevant context to it through entity relationships. This task plays a key role in relevant context while maintaining the original structure of the knowledge graph.

[0109] Improved reply generation model. In the decoding generation process, the present invention will simultaneously accept the encoded output of the extended knowledge graph and the current information for calculation. Considering that the extended knowledge graph contains both structured knowledge (appropriate knowledge) and unstructured text (relevant context), the present invention applies the summary extraction model for reply generation, that is, the decoder calculates the probability distribution of reply generation under the reception of extended knowledge and current information to output.

[0110] The overall calculation model structure diagram involved in the method of the present invention is as follows Figure 3 , Figure 4 and Figure 5 shown.

[0111] The overall computing model includes: a multi-hop retrieval module, a point mutual information calculation module, a bidirectional GRU neural network, a convolutional neural network, a word segmentation module, an entity mapping module, a first recurrent neural network, a second recurrent neural network and a summary extraction module;

[0112] The input end of the multi-hop retrieval module is used to input the current sentence, and the output end of the multi-hop retrieval module is used to output the knowledge sub-graph;

[0113] The output end of the multi-hop retrieval module is connected to the input end of the convolutional neural network;

[0114] The output end of the convolutional neural network is connected to the input end of the entity mapping module;

[0115] The input end of the point mutual information calculation module is used to input the current sentence and the context sentence of the current sentence; the output end of the point mutual information calculation module is used to output the important context sentence;

[0116] The output end of the point mutual information calculation module is connected to the input end of the bidirectional GRU neural network;

[0117] The output of the bidirectional GRU neural network is connected to the input of the convolutional neural network;

[0118] The output end of the point mutual information calculation module is connected to the input end of the word segmentation module;

[0119] The output end of the word segmentation module is connected to the input end of the entity mapping module;

[0120] An output end of the entity mapping module is connected to an input end of the second recurrent neural network;

[0121] The output end of the second recurrent neural network is connected to the input end of the summary extraction model;

[0122] The input end of the summary extraction model is also connected to the output end of the first recurrent neural network;

[0123] The input end of the first recurrent neural network is used to input the current sentence;

[0124] The output end of the summary extraction model is used to output the response sentence.

[0125] Furthermore, the training process of the overall computing model includes:

[0126] First, pre-train the bidirectional GRU neural network, convolutional neural network, first recurrent neural network, second recurrent neural network and summary extraction module;

[0127] The overall computing model is then trained as a whole; during the overall training process, the input values ​​of the overall computing model are the current sentence, the context sentence and the known knowledge graph (structured knowledge), and the output value of the overall computing model is the response sentence; the trained overall computing model is obtained;

[0128] The overall calculation model is then put into practical application: the input values ​​of the overall calculation model are the actual current sentence and the actual context sentence, and the output value of the overall calculation model is the predicted response sentence.

[0129] In order to fundamentally make up for the singleness of dialogue generation and ensure the logic of the dialogue process, the present invention realizes dialogue generation based on the knowledge graph expanded by context. Therefore, the knowledge graph not only contains the association between entities in the appropriate knowledge, but also contains the expansion of long text. In order to balance the knowledge perception between entities and long texts, the present invention applies a text summary model to realize knowledge graph-aware dialogue generation. Different from the traditional text summary model, the decoder in the present invention simultaneously receives the encoded representation of recurrent neural networks RNN (Recurrent Neural Networks) on two levels ([expanded knowledge graph, current information]), one for the expression of the expanded knowledge graph, and the other for representing the current information. Finally, the decoder generates a response by calculating the probability distribution of words: 1) the probability that the next word should be generated or copied; 2) the probability distribution in the generated word; 3) the probability distribution in the copied word. Finally, the distribution of the three probabilities is combined to obtain P(y t |y <t , x, v y ).

[0130] The decoder calculates the probability that the next word should be generated or copied;

[0131] If the probability of copying is high, then the probability distribution of the input vocabulary is combined with the probability distribution of the copied word, and the vocabulary with high probability is selected for copying;

[0132] If the probability of the next word being generated is high, then the next word is generated based on the probability distribution of the generated words.

[0133] The copied vocabulary involved here is the vocabulary of the previous encoding input, because the encoding input not only contains the current sentence but also involves the relevant knowledge graph. The generated vocabulary is the vocabulary information generated by the decoder based on the input information.

[0134] Embodiment 2

[0135] This embodiment provides a dialog generation system that expands context into a knowledge graph;

[0136] The conversation generation that expands the context into the knowledge graph is the same, including:

[0137] An acquisition module is configured to: acquire a current sentence and several context sentences of the current sentence;

[0138] A construction module is configured to: construct a knowledge subgraph of the current sentence according to the current sentence;

[0139] The important sentence screening module is configured to: screen several context sentences of the current sentence to screen out the important context sentences;

[0140] An important vocabulary screening module is configured to: screen out important vocabulary from the knowledge sub-graph of the current sentence according to the contextual important sentences of the current sentence;

[0141] An expansion module is configured to: delete non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph;

[0142] A generation module is configured to generate a response dialogue sentence based on the current sentence and the expanded knowledge graph.

[0143] It should be noted that the acquisition module, construction module, important sentence screening module, important vocabulary screening module, expansion module and generation module described above correspond to steps S101 to S106 in Embodiment 1, and the examples and application scenarios implemented by the modules and corresponding steps are the same, but are not limited to the contents disclosed in Embodiment 1 described above. It should be noted that the modules described above as part of the system can be executed in a computer system such as a set of computer executable instructions.

[0144] The description of each embodiment in the above embodiments has different emphases. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0145] The proposed system can be implemented in other ways. For example, the system embodiment described above is only illustrative, and the division of the modules is only a logical function division. In actual implementation, there may be other division methods, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.

[0146] Embodiment 3

[0147] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory so that the electronic device executes the method described in the above embodiment one.

[0148] It should be understood that in this embodiment, the processor may be a central processing unit CPU, and the processor may also be other general-purpose processors, digital signal processors DSP, application-specific integrated circuits ASIC, off-the-shelf programmable gate arrays FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0149] The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.

[0150] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.

[0151] The method in the first embodiment can be directly embodied as a hardware processor, or a combination of hardware and software modules in the processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.

[0152] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0153] Embodiment 4

[0154] This embodiment further provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the method described in the first embodiment is completed.

[0155] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A dialogue generation method that expands the context into the knowledge graph, characterized by: include: Get the current statement and several context statements of the current statement; According to the current sentence, construct the knowledge subgraph of the current sentence; Filter several context sentences of the current sentence to select important context sentences; According to the important sentences in the context of the current sentence, important words are filtered out from the knowledge subgraph of the current sentence; Delete the non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph; Generate response dialogue sentences based on the current sentence and the expanded knowledge graph; Filter several context sentences of the current sentence to select important context sentences; Specifically include: Based on the point mutual information algorithm, the point mutual information value between each context sentence and the entity in the current sentence is calculated; Based on the point mutual message value between entities, the relevance between the current context sentence and the current sentence is obtained; Filter out several context sentences whose relevance exceeds a set threshold as important context sentences; Encode the selected important context sentences in chronological order to obtain the encoding vectors of the important context sentences; The knowledge recognition algorithm first retrieves the knowledge graph based on the current information of the conversation to preliminarily locate the knowledge scope, and then calculates the probability distribution of the retrieved knowledge by encoding the relevant context, so as to effectively screen out the knowledge that violates the current conversation; and calculates the topic information most relevant to the current information through the correlation between the context and the current conversation, so as to select the knowledge that is highly matched with the current conversation.

2. The method for generating a dialog by expanding a context into a knowledge graph as claimed in claim 1, wherein: According to the current sentence, construct the knowledge subgraph of the current sentence; specifically including: Perform word segmentation on the current sentence to obtain several words; Match each word with an entity in the existing knowledge graph; if the current word successfully matches an entity in the existing knowledge graph, perform a multi-hop search to obtain the knowledge subgraph of the current sentence; The multi-hop retrieval means that each word in the current sentence is matched in the existing knowledge graph, the successfully identified entity is used as the starting node, and multi-hop reasoning is performed along the path in the existing knowledge graph until the end node is reached. All skipped nodes and all skipped paths are recorded, and finally the knowledge subgraph of the current sentence is obtained.

3. The method for generating a dialog by expanding a context into a knowledge graph as claimed in claim 1, wherein: The selected important context sentences are encoded in chronological order to obtain the encoding vectors of the important context sentences, which are: A bidirectional GRU neural network is used to implement this. Several selected context-important sentences are input into the bidirectional GRU neural network, and the encoding vectors of the context-important sentences are output.

4. The method for generating a dialog by expanding a context into a knowledge graph as claimed in claim 1, wherein: According to the important sentences in the context of the current sentence, important words are filtered out from the knowledge subgraph of the current sentence; specifically, the following are included: Input the encoding vector of the important sentences in the context and the knowledge subgraph of the current sentence into the appropriate knowledge identifier, and output the weight of each word in the knowledge subgraph of the current sentence; filter out the words with weights higher than the set threshold as the important words filtered out from the knowledge subgraph of the current sentence; Among them, the appropriate knowledge identifier is realized by using a convolutional neural network, and the convolutional neural network is trained using a training set to obtain the appropriate knowledge identifier after training; the training set includes: a known response sentence and an encoding vector of an important context sentence corresponding to the response sentence; during the training process, the encoding vector of the important context sentence and the knowledge subgraph of the current sentence are used as input values, and the known response sentence is used as an output value to train the convolutional neural network, and the trained convolutional neural network is the appropriate knowledge identifier.

5. The method for generating a dialog by expanding a context into a knowledge graph as claimed in claim 1, wherein: Delete the non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph; specifically include: Delete the unimportant words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; The important words in the updated knowledge sub-graph are used as the backbone, and the words obtained after the word segmentation of the important sentences in the context are connected through entity mapping to obtain the expanded knowledge graph.

6. The method for generating a dialog by expanding a context into a knowledge graph as claimed in claim 1, wherein: Generate response dialogue sentences based on the current sentence and the expanded knowledge graph; specifically include: Input the current sentence into the recurrent neural network to obtain the first encoding representation; Input the expanded knowledge graph into the recurrent neural network to obtain the second encoding representation; The first encoded representation and the second encoded representation are both input into the summary extraction model, and the response dialogue sentence is output.

7. A dialogue generation system that extends the context into a knowledge graph, characterized by: include: An acquisition module is configured to: acquire a current sentence and several context sentences of the current sentence; A construction module is configured to: construct a knowledge subgraph of the current sentence according to the current sentence; The important sentence screening module is configured to: screen several context sentences of the current sentence to screen out the important context sentences; An important vocabulary screening module is configured to: screen out important vocabulary from the knowledge sub-graph of the current sentence according to the contextual important sentences of the current sentence; An expansion module is configured to: delete non-important words in the knowledge sub-graph of the current sentence to obtain an updated knowledge sub-graph; connect the words obtained after the word segmentation of the important sentences in the context with the important words in the updated knowledge sub-graph to obtain an expanded knowledge graph; A generation module, configured to: generate a response dialogue sentence based on the current sentence and the expanded knowledge graph; Filter several context sentences of the current sentence to select important context sentences; Specifically include: Based on the point mutual information algorithm, the point mutual information value between each context sentence and the entity in the current sentence is calculated; Based on the point mutual message value between entities, the relevance between the current context sentence and the current sentence is obtained; Filter out several context sentences whose relevance exceeds a set threshold as important context sentences; Encode the selected important context sentences in chronological order to obtain the encoding vectors of the important context sentences; The knowledge recognition algorithm first retrieves the knowledge graph based on the current information of the conversation to preliminarily locate the knowledge scope, and then calculates the probability distribution of the retrieved knowledge by encoding the relevant context, so as to effectively screen out the knowledge that violates the current conversation; and calculates the topic information most relevant to the current information through the correlation between the context and the current conversation, so as to select the knowledge that is highly matched with the current conversation.

8. An electronic device, comprising: a memory for non-transitory storage of computer readable instructions; as well as a processor for executing the computer readable instructions, Wherein, when the computer-readable instructions are executed by the processor, the method described in any one of claims 1 to 6 is executed.

9. A storage medium, characterized in that: The computer-readable instructions are non-transitory stored, wherein when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method according to any one of claims 1 to 6 are executed.