A goal-oriented dialogue method and model based on knowledge graph bidirectional reasoning

By using graph representation learning and attention computing technology in intelligent dialogue systems, combined with external knowledge graphs, the problem of limitations of keyword extraction methods in goal-oriented dialogues is solved, and the accuracy and user satisfaction of the dialogue system are improved.

CN118657223BActive Publication Date: 2024-10-29TIANJIN UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411154467.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-10-29
Estimated Expiration
2044-08-22

AI Technical Summary

Technical Problem

Existing intelligent dialogue systems have limitations in keyword extraction methods in goal-oriented dialogues, resulting in inaccurate dialogues, low user satisfaction, and inability to effectively handle customer personalization issues.

Method used

Determine the search range of the external knowledge graph through the starting point and end point of the conversation, generate dialogue responses based on contextual semantics, use graph representation learning, graph data reconstruction and attention calculation to obtain keyword sets, and use the GPT model to generate dialogue responses.

Benefits of technology

The accuracy of keyword retrieval and extraction range is improved, and the accuracy and user satisfaction of the dialogue system are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657223B_ABST
    Figure CN118657223B_ABST
Patent Text Reader

Abstract

The present invention discloses a target-oriented dialogue method and model based on knowledge graph bidirectional reasoning, and relates to the technical field of human-computer dialogue. The dialogue context representation vector is obtained by using the dialogue start sentence and the end sentence; the tail node words of the external knowledge graph are searched based on the head node words of the start sentence and the end sentence; a first dialogue subgraph is created for storing the dialogue context representation vector of the start sentence, each head node word and each corresponding tail node word, and a second dialogue subgraph is created for storing the dialogue context representation vector of the end sentence, each head node word and each corresponding tail node word; the first dialogue subgraph and the second dialogue subgraph are reconstructed to obtain a reconstructed subgraph by graph data; the probability of each head node word and the tail node word is calculated, each head node word and the tail node word is selected to obtain a keyword set, and a dialogue reply is generated. The problem of inaccuracy of the target-oriented dialogue method and low user satisfaction is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of human-computer dialogue technology, and in particular to a goal-oriented dialogue method and model based on knowledge graph bidirectional reasoning. Background Art

[0002] With the rise of social media, the accumulation of massive data, the rapid increase in computing power and the enhancement of algorithm effectiveness, artificial intelligence has been widely used in many fields such as medicine, finance, and the Internet of Things to help people make better decisions, improve efficiency and eliminate repetitive work. Among them, the application of human-computer dialogue technology has obvious advantages, including reducing dependence on manual labor, reducing costs, improving efficiency, simplifying service processes, and providing services to users anytime and anywhere. As human-computer dialogue-related technologies emerge in the fields of dialogue recommendation of goods, educational knowledge, and psychotherapy, the concept of goal-oriented dialogue has been mentioned by more people, that is, the system needs to guide user dialogue through natural language interaction to achieve specific goals. This means that the dialogue system is no longer limited to passively completing tasks and meeting needs such as chat companionship, but is gradually shifting towards active and intelligent directions. The rise of goal-oriented dialogue has changed the scope of capabilities of traditional chatbots, which requires it to more agilely identify human intentions and have the subjective initiative of planning, perception and guidance. In the traditional human-computer dialogue process, most conversations are initiated by users and then passively responded by the machine. In today's human-computer dialogue, the human-computer interaction mode is quietly changing: first, human-computer interaction is no longer limited to traditional methods such as mouse touch and keyboard input, but is gradually shifting towards physical sensation, conversation and other methods; second, the human-computer dialogue system is no longer limited to passively receiving user information and then giving feedback, but has developed richer functions. If, during the dialogue process, the target is preset as a product or a movie, the robot will talk and mention the target without the user noticing and maintaining interest in the conversation, and the user will be more interested, which can greatly enhance the user's interactive experience and inject new business opportunities into the Internet; if the preset target is psychotherapy, the robot will communicate with the user with insight and empathy, provide advice or therapeutic training, which will help countless people. The emergence of scenarios such as the above-mentioned psychotherapy and dialogue recommendations has made people place higher expectations on intelligent dialogue systems, which requires the system to have the ability to complete goal-oriented dialogues.

[0003] The existing intelligent dialogue business points are complicated, and the input of internal users has the characteristics of colloquialism and diversity. Traditional customer service systems face pain points such as inaccurate intelligent responses, poor search perception, scattered and unintegrated knowledge, and uncontrollable quality of complaint tickets. Therefore, they still rely mainly on manual services and manual editing of knowledge for self-service, and cannot provide intelligent processing and solutions according to customers' changing demands at any time. At present, intelligent dialogue systems also use some intelligent service methods to increase service efficiency, such as using intelligent robots + knowledge bases to query and feedback customers with pre-sorted knowledge through correlation analysis and fuzzy search. On the one hand, for the ever-changing operation and maintenance problems, manual sorting takes a long time and knowledge updates slowly, resulting in the inability to accurately hit customer problems. On the one hand, the information in massive text data (work orders, online customer service) cannot be fully extracted, and many personalized questions of customers cannot be answered, resulting in a large amount of information waste. Because knowledge points are independent and scattered, traditional retrieval methods such as keywords and correlation analysis are inefficient.

[0004] Public literature (TodBR: Target-Oriented Dialog with Bidirectional Reasoning on Knowledge

[0005] Graph, APPLIED SCIENCES-BASEL, 2024, 14(1): Article Number: 459) provides a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, which mainly includes three main parts: an encoder and two decoders. The first part is the dialogue encoder, which uses the Transformer encoder to encode the source and target utterances into embedding vectors; the second part is the bidirectional reasoning decoder. The graph neural network encodes the dialogue subgraph constructed in the data preprocessing stage, inputs the dialogue embedding vector obtained from the dialogue encoder into the decoder, and applies the attention mechanism to focus on the dialogue subgraph and generate prompt keywords; the third part is the GPT-based response generator, which inputs the dialog context and prompt keywords to generate the final response. The document discloses a goal-oriented dialogue method based on knowledge graph bidirectional reasoning that combines the TF-IDF importance statistical method and Part-of-Speech part-of-speech tagging to extract the functional letters of keywords. The TF-IDF algorithm (Term Frequency–Inverse Document Frequency) is a commonly used weighting technology for information retrieval and text mining, and is often used by search engines as a measure or rating of the relevance between documents and user queries. However, since the above algorithm is limited to the retrieval and extraction scope of keywords, it is easy to miss or misdetect, resulting in low accuracy of the goal-oriented dialogue method and affecting user satisfaction.

[0006] Therefore, there is a need for a two-way reasoning dialogue method and model that can complete goal-oriented dialogue based on an external knowledge graph to solve the above problems. Summary of the invention

[0007] The technical problem to be solved by the present invention is that when combining an external knowledge graph to obtain guided content, the existing keyword extraction method is relatively limited, and there are problems such as inaccurate goal-oriented dialogue methods and low user satisfaction. The purpose is to provide a two-way reasoning dialogue method and model for completing goal-oriented dialogue based on an external knowledge graph, which can determine the search scope of the external knowledge graph through the starting point and end point of the dialogue, and generate dialogue reply text in combination with context semantics and search results, thereby improving the accuracy of keyword retrieval and extraction scope and solving the above technical problems.

[0008] The present invention is achieved through the following technical solutions:

[0009] A goal-oriented dialogue method based on knowledge graph bidirectional reasoning, comprising:

[0010] Using the starting sentence and the last sentence of the current conversation to perform graph representation learning, a context word vector matrix is ​​obtained, and the first row of character vectors of the context word vector matrix is ​​taken as the conversation context representation vector of the starting sentence or the last sentence;

[0011] Searching for tail node words of an external knowledge graph based on the head node words of the starting sentence and the ending sentence; creating a first conversation subgraph for storing the conversation context representation vector of the starting sentence, each head node word and each corresponding tail node word; creating a second conversation subgraph for storing the conversation context representation vector of the ending sentence, each head node word and each corresponding tail node word;

[0012] Reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain a reconstructed subgraph;

[0013] The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word; the head and tail node words exceeding the preset probability threshold are selected to obtain the keyword set;

[0014] A dialogue response is generated according to the starting sentence and the keyword set.

[0015] The method of using the starting sentence and the last sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and taking the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the last sentence, includes: concatenating the starting sentence and the last sentence of the current conversation, adding numerical subscripts of each word, performing graph representation learning through an encoder to obtain a vector matrix, and taking the first row of character vectors of the vector matrix as the conversation context representation vector;

[0016] The reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain the reconstructed subgraph comprises: converting the first conversation subgraph and the second conversation subgraph into an index format of a digital subscript, and sending the format to a graph encoder to reconstruct the graph data to obtain the reconstructed subgraph.

[0017] The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word, including: inputting the reconstructed subgraph into a decoder for matrixing, using the attention matrix of the first layer of the decoder as the query matrix of the decoder, using the reconstructed subgraph as the key matrix and value matrix of the decoder, and obtaining the probability of each head and tail node word by multiplying the query matrix, the key matrix and the value matrix.

[0018] The step of selecting the head and tail node words exceeding a preset probability threshold to obtain a keyword set includes: performing multiple operations on the reconstructed subgraph through a fully connected layer and a Softmax layer, and obtaining the keyword set through the words with the highest probability calculated each time.

[0019] The generating of the dialogue response according to the starting sentence and the keyword set includes: splicing multiple keywords of the keyword set to form a guide sentence, splicing the starting sentence and the guide sentence and decoding them using a GPT model to obtain the dialogue response.

[0020] After generating a dialogue reply according to the starting sentence and the keyword set, the method includes:

[0021] Collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; pre-train the multiple groups of the dialogue training data to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply;

[0022] Comparing the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculating the loss of the dialogue response, and optimizing the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed;

[0023] The dialogue response of the dialogue to be detected is outputted through the dialogue training model.

[0024] A goal-oriented dialogue model based on knowledge graph bidirectional reasoning, including a semantic understanding module, a bidirectional reasoning decoding module, and a response generation module;

[0025] The semantic understanding module uses the starting sentence and the ending sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and takes the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the ending sentence;

[0026] The bidirectional reasoning decoding module includes a dialogue subgraph enhancement module, a subgraph embedding matrix module and a high-frequency word set analysis module; the dialogue subgraph enhancement module is used to search for tail node words of the external knowledge graph based on the head node words of the starting sentence and the last sentence; create a first dialogue subgraph for storing the dialogue context representation vector of the starting sentence, each head node word and the corresponding tail node words; create a second dialogue subgraph for storing the dialogue context representation vector of the last sentence, each head node word and the dialogue context representation vector of the corresponding tail node words; reconstruct the graph data of the first dialogue subgraph and the second dialogue subgraph to obtain a reconstructed subgraph; the subgraph embedding matrix module reconstructs the subgraph and obtains the probability of each head and tail node word by using attention calculation; the high-frequency word set analysis module selects each head and tail node word exceeding the preset probability threshold to obtain a keyword set;

[0027] The reply generation module is used to generate a dialogue reply according to the starting sentence and the keyword set.

[0028] The goal-oriented dialogue model based on knowledge graph bidirectional reasoning also includes a dialogue training module, a loss optimization module and a text generation module;

[0029] The dialogue training module is used to collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; multiple groups of the dialogue training data are pre-trained to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply;

[0030] The loss optimization module is used to compare the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculate the loss of the dialogue response, and optimize the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed;

[0031] The text generation module is used to output the dialogue response of the dialogue to be detected through the dialogue training model.

[0032] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0033] The present invention provides a goal-oriented dialogue method based on two-way reasoning of knowledge graph, which queries the external knowledge graph based on the starting sentence and the ending sentence of a dialogue, thereby obtaining multiple groups of head and tail node words, and adopts a two-way reasoning method to combine the context semantic vector, the extracted head node words and the tail node words of the external knowledge graph to obtain the reply text of the dialogue. The method solves the problem that the existing keyword extraction method is relatively limited, the goal-oriented dialogue method is inaccurate, and the user satisfaction is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:

[0035] Figure 1 This is a flowchart of a goal-oriented dialogue method based on knowledge graph bidirectional reasoning in Example 1 of the present application. DETAILED DESCRIPTION

[0036] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.

[0037] Example 1

[0038] like Figure 1 As shown, the embodiment of the present application provides a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, including:

[0039] Using the starting sentence and the last sentence of the current conversation to perform graph representation learning, a context word vector matrix is ​​obtained, and the first row of character vectors of the context word vector matrix is ​​taken as the conversation context representation vector of the starting sentence or the last sentence;

[0040] Searching for tail node words of an external knowledge graph based on the head node words of the starting sentence and the ending sentence; creating a first conversation subgraph for storing the conversation context representation vector of the starting sentence, each head node word and each corresponding tail node word; creating a second conversation subgraph for storing the conversation context representation vector of the ending sentence, each head node word and each corresponding tail node word;

[0041] Reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain a reconstructed subgraph;

[0042] The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word; the head and tail node words exceeding the preset probability threshold are selected to obtain the keyword set;

[0043] A dialogue response is generated according to the starting sentence and the keyword set.

[0044] For the external knowledge graph, you can select ConceptNet and version 15.7. For the dialogue context representation vector, you can refer to the pre-trained word vector Glove, which is pre-trained using 6K corpus and has a dimension of 300.

[0045] A conversation consists of multiple sentences, each of which can be expressed as:

[0046] ;

[0047] In the formula, ; Number the sentences; Indicates the first a sentence; the first sentence of a conversation For the first sentence, the last sentence For the final sentence, and One or more sentences in between are middle sentences; Indicates the words contained in each sentence A collection is used to select head node words from the starting sentence and the ending sentence.

[0048] The method of using the starting sentence and the last sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and taking the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the last sentence, includes: concatenating the starting sentence and the last sentence of the current conversation, adding numerical subscripts of each word, performing graph representation learning through an encoder to obtain a vector matrix, and taking the first row of character vectors of the vector matrix as the conversation context representation vector;

[0049] The reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain the reconstructed subgraph comprises: converting the first conversation subgraph and the second conversation subgraph into an index format of a digital subscript, and sending the format to a graph encoder to reconstruct the graph data to obtain the reconstructed subgraph.

[0050] Optionally, the conversation start sentence and the end sentence are concatenated into one sentence using a special marker [SEP] and the vocabulary subscript is encoded. Then, the vector matrix of the word count*dimension is sent to the Transformer encoder, and the character vector of the first row of the matrix is ​​finally taken as the conversation context representation vector , expressed as:

[0051] ;

[0052] in, Indicates different sentences; Indicates different words.

[0053] The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word, including: inputting the reconstructed subgraph into a decoder for matrixing, using the attention matrix of the first layer of the decoder as the query matrix of the decoder, using the reconstructed subgraph as the key matrix and value matrix of the decoder, and obtaining the probability of each head and tail node word by multiplying the query matrix, the key matrix and the value matrix.

[0054] The step of selecting the head and tail node words exceeding a preset probability threshold to obtain a keyword set includes: performing multiple operations on the reconstructed subgraph through a fully connected layer and a Softmax layer, and obtaining the keyword set through the words with the highest probability calculated each time.

[0055] Optionally, represent the conversation context vector As Input the attention matrix of the first layer of the Transformer decoder and use the dialogue context representation vector as the query matrix , using the reconstructed subgraph vector matrix represented by the graph nodes as the key matrix Sum Matrix ,and After multiplication, we get , and then Multiply to get , in order to stabilize the gradient, divide by Normalize, where For the embedding dimension, the matrixization process through the above attention operation is described as:

[0056] At this point, the dialogue context representation vector, the first dialogue subgraph, and the second dialogue subgraph complete information fusion, that is, the start and end information of the dialogue is synchronously introduced during decoding reasoning. Finally, the matrixed reconstructed subgraph is sent to the fully connected layer and Layer, get the probability of each head and tail node word, repeat the above operation and select the words with high probability as keywords each time, until encountering the preset stop symbol or up to 3 times, then get the keyword set Z.

[0057] Among them, the analysis of the starting sentence and the final sentence , extract the starting sentence and the final sentence The verbs and nouns in the conversation graph are used as head node words to search for tail node words on the external knowledge graph. The tail node words can include the search results and the one-hop neighbor phrases of the search results. For example, based on the head node word "flowers", the tail node words such as "garden, outdoor" that are queried will help to learn the representation of the head node words in subsequent learning. The creation process of the first conversation subgraph and the second conversation subgraph specifically includes: creating a word index dictionary , add each group of head and tail node words to the word index dictionary in order, and obtain the correspondence between the word position and the numerical subscript. Store the word-level relationship between the head node words and the tail node words in the two-dimensional matrix E, and use the conversation context representation vector to represent the priority of the words in the conversation, and construct the conversation subgraph represented by the adjacency matrix .

[0058] The generating of the dialogue response according to the starting sentence and the keyword set includes: splicing multiple keywords of the keyword set to form a guide sentence, splicing the starting sentence and the guide sentence and decoding them using a GPT model to obtain the dialogue response.

[0059] The graph autoencoder GAE can be used. GAE consists of two parts: encoder and decoder. The original dialogue subgraph A is converted into a digital subscript index format. The encoder of the graph autoencoder encodes A into a low-dimensional vector. Then, the decoder reconstructs and decompresses the graph data to obtain the reconstructed subgraph. , and the mean square error loss function is used Perform training to obtain the optimized reconstructed sub-graph , used for subsequent training and prediction.

[0060] After generating a dialogue reply according to the starting sentence and the keyword set, the method includes:

[0061] Collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; pre-train the multiple groups of the dialogue training data to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply;

[0062] Comparing the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculating the loss of the dialogue response, and optimizing the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed;

[0063] The dialogue response of the dialogue to be detected is outputted through the dialogue training model.

[0064] When applied, the head and tail node words in the keyword set Z are concatenated using the special marker [SEP] to obtain the guide sentence, and the starting sentence in the conversation training data is used as the conversation context of the guide sentence, concatenated into a line and sent to the GPT model for decoding to generate a conversation reply, such as "[SEP] word 1 [SEP] word 2 [SEP] sentence 1 [SEP]". The calculation process of each decoding step of the GPT model is expressed as: ; That is, each decoding step Combined with the previous step's conversation context representation vector and head and tail node words Generate, where the decoding start state is , initialize all keyword sets Words The embedding forms a list .

[0065] Optionally, the dialogue response R generated by the starting sentence and each generated guide sentence is compared with the known standard reference response (answer) T one by one, where the negative log-likelihood loss function can be used Calculate the loss value. Determine whether the training is finished based on whether the preset number of training steps is reached or whether the loss value curve converges. If so, the training is finished. Otherwise, return to select a new dialogue to continue training.

[0066] Optionally, load the conversation data OTTers, which contains the starting sentence and the introduction sentence of a conversation, and distinguish the training, verification and test sets of the conversation training model, with the ratio of training, verification and test sets being 8:1:1; thereby using the conversation data to obtain multiple sets of conversation training data and standard reference responses. Optionally, each conversation has an average of 6.1 knowledge path connections and an average of 78.4 words. Optionally, use the Adam optimizer in the training phase, with an initial learning rate of 0.0001, and a learning rate reduction of 10 times after every 10,000 iterations, a momentum of 0.9, and a decay coefficient of 0.0005.

[0067] When the dialogue training model is tested, the starting sentence of the dialogue can be manually or randomly selected based on the predicted needs. and the final sentence , the starting sentence is like "The weather is nice today", the ending sentence is like "New mobile phones are on the market", and the expected model output sentence Used in the above opening sentence and the final sentence A transition between two topics. Concatenate the beginning and ending sentences into ,and , After being digitally encoded using the vocabulary subscript, they are sent to the Transformer encoder for encoded semantic representation, resulting in a vector matrix of number of characters * dimension. Finally, the first row of character vectors is taken as the conversation context representation vector.

[0068] Example 2

[0069] The embodiment of the present application provides a goal-oriented dialogue model based on knowledge graph bidirectional reasoning, including a semantic understanding module, a bidirectional reasoning decoding module and a reply generation module;

[0070] The semantic understanding module uses the starting sentence and the ending sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and takes the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the ending sentence;

[0071] The bidirectional reasoning decoding module includes a dialogue subgraph enhancement module, a subgraph embedding matrix module and a high-frequency word set analysis module; the dialogue subgraph enhancement module is used to search for tail node words of the external knowledge graph based on the head node words of the starting sentence and the last sentence; create a first dialogue subgraph for storing the dialogue context representation vector of the starting sentence, each head node word and the corresponding tail node words; create a second dialogue subgraph for storing the dialogue context representation vector of the last sentence, each head node word and the dialogue context representation vector of the corresponding tail node words; reconstruct the graph data of the first dialogue subgraph and the second dialogue subgraph to obtain a reconstructed subgraph; the subgraph embedding matrix module reconstructs the subgraph and obtains the probability of each head and tail node word by using attention calculation; the high-frequency word set analysis module selects each head and tail node word exceeding the preset probability threshold to obtain a keyword set;

[0072] The reply generation module is used to generate a dialogue reply according to the starting sentence and the keyword set.

[0073] The goal-oriented dialogue model based on knowledge graph bidirectional reasoning also includes a dialogue training module, a loss optimization module and a text generation module;

[0074] The dialogue training module is used to collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; multiple groups of the dialogue training data are pre-trained to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply;

[0075] The loss optimization module is used to compare the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculate the loss of the dialogue response, and optimize the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed;

[0076] The text generation module is used to output the dialogue response of the dialogue to be detected through the dialogue training model.

[0077] Specifically, this embodiment uses a hierarchical Transformer to encode the conversation context, aiming to capture the global semantic dependency between the starting point and the end point of the conversation. The Transformer converts the context into a hidden vector sequence. The bidirectional reasoning module can focus on the conversation context through the attention mechanism, that is, focus on the starting point and the end point of the conversation at the same time, and then learn from the external knowledge graph related to the context keywords. The decoding state of the Transformer decoder at each decoding step is used to assist in generating a keyword set. The reply generation module generates a natural and fluent reply text containing a keyword set for a given starting sentence.

[0078] The embodiments of the present application are proposed based on the method of Embodiment 1, and the principle thereof is basically the same as that of Embodiment 1, and a repetitive description is not made here.

[0079] In summary, the embodiment of the present application provides a goal-oriented dialogue method and model based on knowledge graph bidirectional reasoning: combining external knowledge graph to obtain guided content, comprehensively considering the dialogue context representation vector and the head and tail node words, thereby obtaining a keyword set, and generating dialogue responses to feedback to the user, so as to conduct a natural and smooth guided dialogue. The present invention solves the problem that the existing keyword extraction method is relatively limited, resulting in inaccurate goal-oriented dialogue methods and low user satisfaction.

[0080] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that include: Using the starting sentence and the last sentence of the current conversation to perform graph representation learning, a context word vector matrix is ​​obtained, and the first row of character vectors of the context word vector matrix is ​​taken as the conversation context representation vector of the starting sentence or the last sentence; Searching for tail node words in an external knowledge graph based on the head node words of the starting sentence and the ending sentence; creating a first conversation subgraph for storing a conversation context representation vector of the starting sentence, each head node word and each corresponding tail node word; Creating a second conversation subgraph for storing the conversation context representation vector of the last sentence, each head node word and the conversation context representation vector corresponding to each tail node word; Reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain a reconstructed subgraph; The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word; Select the head and tail node words that exceed the preset probability threshold to obtain a keyword set; A dialogue response is generated according to the starting sentence and the keyword set.

2. According to claim 1, a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that The method of using the starting sentence and the ending sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and taking the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the ending sentence, includes: After concatenating the start sentence and the end sentence of the current conversation, add numerical subscripts to each word, perform graph representation learning through an encoder to obtain a vector matrix, and use the character vectors in the first row of the vector matrix as the conversation context representation vector; The reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain a reconstructed subgraph includes: The first conversation subgraph and the second conversation subgraph are converted into an index format of digital subscripts, and sent to a graph encoder for graph data reconstruction to obtain the reconstructed subgraph.

3. According to claim 1, a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that The reconstructed subgraph uses attention calculation to obtain the probability of each head and tail node word, including: The reconstructed subgraph is input into the decoder for matrixization, the attention matrix of the first layer of the decoder is used as the query matrix of the decoder, the reconstructed subgraph is used as the key matrix and value matrix of the decoder, and the probability of each head and tail node word is obtained by multiplying the query matrix, the key matrix and the value matrix.

4. According to claim 1, a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that The step of selecting the head and tail node words exceeding a preset probability threshold to obtain a keyword set includes: performing multiple operations on the reconstructed subgraph through a fully connected layer and a Softmax layer, and obtaining the keyword set through the words with the highest probability calculated each time.

5. According to claim 1, a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that The generating of the dialogue response according to the starting sentence and the keyword set includes: splicing multiple keywords of the keyword set to form a guide sentence, splicing the starting sentence and the guide sentence and decoding them using a GPT model to obtain the dialogue response.

6. According to claim 1, a goal-oriented dialogue method based on knowledge graph bidirectional reasoning, It is characterized in that After generating a dialogue reply according to the starting sentence and the keyword set, the method includes: Collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; pre-train the multiple groups of the dialogue training data to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply; Comparing the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculating the loss of the dialogue response, and optimizing the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed; The dialogue response of the dialogue to be detected is outputted through the dialogue training model.

7. A goal-oriented dialogue model based on knowledge graph bidirectional reasoning, It is characterized in that It includes a semantic understanding module, a bidirectional reasoning decoding module, and a response generation module; The semantic understanding module uses the starting sentence and the ending sentence of the current conversation to perform graph representation learning to obtain a context word vector matrix, and takes the first row of character vectors of the context word vector matrix as the conversation context representation vector of the starting sentence or the ending sentence; The bidirectional reasoning decoding module includes a dialogue subgraph enhancement module, a subgraph embedding matrix module and a high-frequency word set analysis module; the dialogue subgraph enhancement module is used to search for tail node words of the external knowledge graph based on the head node words of the starting sentence and the last sentence; and create a first dialogue subgraph for storing the dialogue context representation vector of the starting sentence, each head node word and each corresponding tail node word; Creating a second conversation subgraph for storing the conversation context representation vector of the last sentence, each head node word and the conversation context representation vector corresponding to each tail node word; Reconstructing the graph data of the first conversation subgraph and the second conversation subgraph to obtain a reconstructed subgraph; the subgraph embedding matrix module reconstructs the subgraph and obtains the probability of each head and tail node word by using attention calculation; the high-frequency word set analysis module selects each head and tail node word exceeding a preset probability threshold to obtain a keyword set; The reply generation module is used to generate a dialogue reply according to the starting sentence and the keyword set.

8. According to claim 7, a goal-oriented dialogue model based on knowledge graph bidirectional reasoning, It is characterized in that It also includes a dialogue training module, a loss optimization module, and a text generation module; The dialogue training module is used to collect multiple groups of dialogue training data of multiple dialogues; each group of the dialogue training data includes the starting sentence, the dialogue reply and the ending sentence of a dialogue; multiple groups of the dialogue training data are pre-trained to obtain a dialogue training model; wherein the input of the dialogue training model is the starting sentence and the ending sentence, and the output of the dialogue training model is the dialogue reply; The loss optimization module is used to compare the dialogue response of each dialogue segment with the standard reference response of the dialogue in turn, calculate the loss of the dialogue response, and optimize the dialogue training model according to the loss of the dialogue response until the training process of the dialogue training model is completed; The text generation module is used to output the dialogue response of the dialogue to be detected through the dialogue training model.

Citation Information

Patent Citations

  • Multi-round dialogue reply generation method based on dual-channel semantic enhancement and terminal equipment

    CN115495552A

  • Target-oriented dialogue method combining global planning of knowledge graph

    CN116361478A