Robot chat method based on knowledge-enhanced empathetic reply
By constructing semantic and emotional context graphs and using graph neural networks to train chatbots, the problem of inaccurate recognition of user emotions and situations in existing technologies is solved, more humane and diverse responses are generated, and the user experience is improved.
Patent Information
- Application Number
- CN202310690707.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-12
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-06-12
AI Technical Summary
In existing technologies, chatbots find it difficult to effectively identify users' implicit emotions and fully understand their situations, resulting in inaccurate responses and poor diversity.
A knowledge-enhanced empathic reply generation method is adopted. By constructing a semantic context graph and an emotional context graph, relevant external semantic knowledge and emotional knowledge are introduced respectively, and graph neural networks are used for training to generate more accurate and diverse replies.
The chatbot's recognition accuracy of user emotions and situations has been improved, and the generated responses are more humane and diverse, improving the user experience.
Smart Images

Figure CN116737898B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a robot chat method based on knowledge-enhanced empathetic reply. BACKGROUND
[0002] In recent years, artificial neural networks have been proven to be effective in generating fluent and coherent replies, researchers have turned to try to improve the higher-level performance of neural dialogue systems, that is, to realize the neural dialogue system that can generate more humanized replies. Empathy, as one of the important features that distinguish humans from artificial intelligence, is expected to be embodied in humanized dialogue systems. In such a case, the generation of empathetic replies by artificial intelligence has become a hot spot in the research of artificial intelligence dialogue systems.
[0003] Empathy, which usually refers to the ability to perceive others' emotions and understand others' situations, involves both emotions and cognition. In people's happy conversations, empathy is indispensable, and it plays an important role in enhancing people's emotional connection in conversations. Similarly, empathy is also one of the important abilities that chat robots should have. Whether the reply generated by the chat robot takes into account the user's feelings will directly affect the user experience and determine the quality of the response, and a dialogue system that appears to empathize with the user is more attractive than an ordinary dialogue system.
[0004] Although existing research on empathetic reply generation has made certain achievements, there are still bottlenecks: dialogue models are difficult to effectively identify user implicit emotions and fully understand user situations from limited dialogue context. Most of the work does not consider trying to solve this problem, and in existing technologies, there are technical solutions that try to introduce external knowledge to understand user emotions, but their emotion knowledge screening strategy has problems, which will introduce knowledge with opposite emotional polarity or irrelevant content, affecting the judgment of user emotions and user situations; there are also technical solutions that consider understanding the user's situation, but the accuracy of the user situation inference generated by the common sense knowledge base they rely on is still low, and there is still a great possibility of introducing noise data, affecting the judgment of the user's situation. SUMMARY
[0005] In view of the deficiencies in the prior art, the present application proposes a robot chat method based on knowledge-enhanced empathetic reply to improve the user emotion recognition bias problem caused by the inability to effectively identify implicit emotions in the prior art; and the problem of the generated reply being general and lacking diversity caused by the inability to fully understand the user's situation.
[0006] The technical solution adopted by the present application is a robot chat method based on knowledge-enhanced empathetic reply, characterized by comprising:
[0007] performing dialogue context preprocessing;
[0008] replying to the preprocessed dialogue using the co-empathetic reply generation model;
[0009] The construction method of the co-empathetic reply generation model comprises: constructing and encoding dialogue context into a dialogue context graph to obtain a global semantic representation of a semantic context graph; constructing and encoding the dialogue context into an emotional context graph to obtain a global emotional representation of the emotional context graph; taking the dialogue context, the global semantic representation of the semantic context graph and the global emotional representation of the emotional context graph as inputs, and taking a word probability table probability distribution of each word of a predicted reply as an output, training a graph neural network to obtain the co-empathetic reply generation model.
[0010] Further, the dialogue context preprocessing comprises: connecting all utterances in the dialogue context to form a word sequence, inserting a special mark in front of the sequence to obtain a new dialogue context.
[0011] Further, the semantic context graph construction and encoding comprises:
[0012] Filtering and introducing semantic knowledge to obtain semantic concepts related to the new dialogue context;
[0013] Taking all words and special marks in the new dialogue context as initial nodes and taking related semantic concepts as candidate nodes, selecting the top-ranked candidate nodes associated with the new dialogue context as new nodes, connecting the nodes to construct a semantic context graph, and obtaining the semantic context graph.
[0014] Graph encoding is performed on the semantic context graph to obtain a global semantic representation of the semantic context graph.
[0015] Further, filtering and introducing semantic knowledge to obtain semantic concepts related to the new dialogue context comprises:
[0016] Traversing each non-stop word in the new dialogue context, retrieving all triples related to each non-stop word in the common sense knowledge base;
[0017] Performing relationship filtering on the retrieved triples to remove triples with relationships unrelated to semantics and emotions;
[0018] Calculating the association degree of each semantic concept with the new dialogue context from the triples after relationship filtering to obtain the related semantic concepts of each non-stop word.
[0019] Further, the graph encoding of the semantic context graph comprises:
[0020] Initializing the semantic vector representation of each node in the semantic context graph using word embedding, position embedding and node state embedding;
[0021] Apply multi-head graph attention mechanism, use residual connection, perform layer normalization operation, and update node representation using relevant semantic concepts;
[0022] Update node representation using global semantic information through the encoder layer of the graph neural network, and inject global semantic information for all nodes;
[0023] Use special marker node representation as global semantic representation of semantic context graph.
[0024] Further, perform sentiment context graph construction and encoding, including:
[0025] Filter and introduce sentiment knowledge to obtain new sentiment concepts related to the current dialogue context;
[0026] Connect all words and special markers in the new dialogue context as initial nodes, and connect relevant sentiment concepts as new nodes to construct a sentiment context graph, and obtain the sentiment context graph;
[0027] Perform graph encoding on the sentiment context graph to obtain the global sentiment representation of the sentiment context graph.
[0028] Further, filter and introduce sentiment knowledge to obtain new sentiment concepts related to the current dialogue context, including:
[0029] Retrieve each non-stop word in the new dialogue context and the vector of the relevant concept of each non-stop word after relationship filtering in the sentiment dictionary;
[0030] Calculate the sentiment intensity value of all relevant concepts of each non-stop word according to the vector;
[0031] Calculate the sentiment difference value between each non-stop word and each non-stop word concept according to the vector;
[0032] Sort the relevant concepts of each non-stop word according to the sentiment intensity value, and select the relevant concepts with the top sentiment intensity value and the sentiment difference value less than the set threshold as the relevant sentiment concepts.
[0033] Further, perform graph encoding on the sentiment context, including:
[0034] Initialize the sentiment vector representation of each node in the sentiment context graph using word embedding, position embedding, and node state embedding;
[0035] Apply multi-head graph attention mechanism, use residual connection, perform layer normalization operation, and update node representation using relevant sentiment concepts;
[0036] The global sentiment information is used to update the node representation through the encoder layer of the graph neural network, and the global sentiment information is injected into all nodes:
[0037] The special marked node representation is used as the global sentiment representation of the sentiment context graph.
[0038] Further, the modeling of the empathetic reply generation model includes:
[0039] The vector representation of each word in the dialogue context is initialized using word embedding, position embedding and state embedding, and sequence embedding is obtained;
[0040] The sequence embedding is sent into the encoder layer of the graph neural network to obtain the hidden representation of the dialogue context, and the special marked hidden representation is included in the hidden representation of the dialogue context;
[0041] The special marked hidden representation is used to represent the dialogue context sequence;
[0042] The special marked hidden representation is subjected to semantic linear transformation and sentiment linear transformation, respectively, to obtain the semantic representation and the sentiment representation of the dialogue context;
[0043] The global sentiment representation of the sentiment context graph is spliced with the sentiment representation of the dialogue context to obtain the fused sentiment representation;
[0044] The fused sentiment representation is passed through a linear layer and then through a classification operation to generate a sentiment category distribution;
[0045] The global semantic representation of the semantic context graph is spliced with the semantic representation of the dialogue context to obtain the fused semantic representation;
[0046] The fused semantic representation and the fused sentiment representation are spliced, and the spliced result is passed through a multilayer perceptron to obtain a combined empathetic representation;
[0047] The word embedding of the target reply and the combined empathetic representation are used as inputs of the decoder layer of the graph neural network, and the word probability table probability distribution of each word of the predicted reply is used as the output, the graph neural network is trained, and the empathetic reply generation model is obtained.
[0048] Further, the following is included: during the training of the graph neural network, cross entropy is used to minimize the sentiment prediction loss, and negative log likelihood is used to optimize the predicted reply; frequency-aware cross entropy is used as an additional loss to punish high-frequency words in the predicted reply.
[0049] From the above technical solutions, the beneficial technical effects of the present application are as follows:
[0050] The present application enhances the empathy reply generation method in the aspects of semantics and emotion, adopts two stages of semantic context graph construction and coding and emotional context graph construction and coding, respectively introduces external semantic knowledge with high content correlation and external emotional knowledge with high emotional intensity and similar emotional polarity, so as to respectively inject rich structure and semantic information and emotional information into the empathy reply generation method, help to accurately identify the implicit emotion of the user, help to fully understand the complex situation of the user, solve the emotional recognition deviation problem caused by the inability to effectively identify the implicit emotion in the prior art, and the problem that the generated reply is relatively general and has poor diversity caused by the inability to fully understand the situation of the user. BRIEF DESCRIPTION OF DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required to be used in the specific embodiments or prior art description will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual proportions.
[0052] Figure 1 A robot chat method based on knowledge-enhanced empathy reply of an embodiment of the present application;
[0053] Figure 2 A flowchart of semantic context graph construction and coding of an embodiment of the present application;
[0054] Figure 3 A flowchart of semantic knowledge screening and introduction of an embodiment of the present application;
[0055] Figure 4 A flowchart of semantic context graph construction of an embodiment of the present application;
[0056] Figure 5 A flowchart of semantic context graph coding of an embodiment of the present application;
[0057] Figure 6 A flowchart of emotional context graph construction and coding of an embodiment of the present application;
[0058] Figure 7 A flowchart of emotional knowledge screening and introduction of an embodiment of the present application;
[0059] Figure 8 A flowchart of emotional context graph construction of an embodiment of the present application;
[0060] Figure 9 A flowchart of emotional context graph coding of an embodiment of the present application;
[0061] Figure 10 A modeling flowchart of an empathy reply generation model of an embodiment of the present application;
[0062] Figure 11 A reply generation process schematic diagram of an embodiment of the empathetic reply generation model of the present application. DETAILED DESCRIPTION
[0063] The embodiments of the technical solutions of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and therefore only serve as examples, and cannot limit the protection scope of the present application.
[0064] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present application should be understood as the usual meaning understood by the skilled person in the field to which the present application belongs.
[0065] Embodiment
[0066] The present embodiment provides a robot chat method based on knowledge-enhanced empathetic reply, comprising the following steps:
[0067] 1. Dialogue context preprocessing
[0068] In this step, the preprocessed dialogue is the dialogue context C. Specifically, all utterances in the dialogue context C=[U1, U2, …, U M ] are connected and tiled into a word sequence, where the utterance U i is composed of m i words: A special mark CLS is inserted before the sequence to obtain a new dialogue context C′ is used as the new dialogue context.
[0069] 2. Using an empathetic reply generation model to reply to the preprocessed dialogue
[0070] The construction method of the empathetic reply generation model is as follows:
[0071] S1. Construct and encode the semantic context graph of the dialogue context to obtain the global semantic representation of the semantic context graph;
[0072] S2. Construct and encode the sentiment context graph of the dialogue context to obtain the global sentiment representation of the sentiment context graph;
[0073] S3. Take the dialogue context, the global semantic representation of the semantic context graph, and the global sentiment representation of the sentiment context graph as input, and take the word probability table probability distribution of the predicted reply as output, and train the graph neural network to obtain the empathetic reply generation model
[0074] In a specific embodiment, the steps S1 and S2 are performed in no particular order and can be performed synchronously. Each step is described in detail below.
[0075] S1, semantic context graph construction and coding of the dialogue context, see Figure 2 ; including:
[0076] S11, screening and introducing semantic knowledge to obtain new semantic concepts related to the dialogue context
[0077] See Figure 3 , screening and introducing semantic knowledge, as follows:
[0078] Traverse each non-stop word in the new dialogue context C', retrieve all triples (head, relation, tail) related to each non-stop word in the common sense knowledge base ConceptNet, where head is the head node, tail is the tail node, and relation is the relationship between the two nodes. When retrieving, each non-stop word is used as a starting node or an ending node, and the other node is a concept related to the word.
[0079] Screen the retrieved triples for relationships and remove triples with relationships unrelated to semantics and emotions, such as triples with "ExternalURL", "NotDesires", "NotHasProperty", "NotCapableOf", "dbpedia", "EtymologicallyDerivedFrom", etc. If there is only a one-way link between the non-stop word and the related semantic concept, add a reverse link, which is (tail, relation -1 , head).
[0080] Calculate the relevance of each semantic concept to the new dialogue context C' from the triples after relationship screening, obtain the related semantic concepts of each non-stop word, and use them as the semantic knowledge needed for constructing the semantic context graph. In a specific embodiment, the relevance is defined as the number of non-stop words in C' connected to the concept in the common sense knowledge base ConceptNet.
[0081] S12, all words and special marks in the new dialogue context are used as initial nodes, and related semantic concepts are used as candidate nodes. The top-ranked candidate nodes associated with the new dialogue context are selected as new nodes, and the nodes are connected to construct a semantic context graph, obtaining the semantic context graph.
[0082] See Figure 4 , semantic context graph construction, as follows:
[0083] All words and special tokens CLS in the new conversation context C′ are used as initial nodes of the semantic context graph. The relevant semantic concepts obtained in the semantic knowledge screening and introduction task are used as candidate nodes of the semantic context graph. Candidate nodes with a high correlation ranking with C′ (for example, ranked as the top K1, where K1 is a set value) are selected as new nodes in the semantic context graph. The following nodes in the semantic context graph are connected:
[0084] Two consecutive words in a conversational context;
[0085] words and related semantic concepts in the conversation context;
[0086] Specially mark each word in CLS and conversation context;
[0087] Thus forming the semantic context graph G sem =(V sem ,E sem ).
[0088] Specifically, in G sem The adjacency matrix A sem , set the edges between nodes to 1.
[0089] S13. Graph encoding is performed on the semantic context graph to obtain the global semantic representation of the semantic context graph. Figure 5 , perform graph encoding on the semantic context graph as follows:
[0090] Initialize each node in the semantic context graph using word embedding, position embedding, and node state embedding Semantic vector representation of
[0091]
[0092] Among them, word embedding Use pre-trained Glove vectors to initialize, position embedding The initialization method is consistent with that of the graph neural network Transformer, and the node state is embedded in E v Differentiate according to the node source (speaker, listener, concept), d model is the embedding dimension.
[0093] Apply multi-head graph attention mechanism, use residual connection, perform layer normalization operation, use relevant semantic concepts to update node representation, and transform each node Follow all its direct neighbors Update to get the new node representation
[0094]
[0095] where LayerNorm denotes a layer normalization operation, denotes a node, || denotes concatenation of H attention heads, is an adjacency matrix A sem in the direct neighbor of, is a linear transformation, is the dimension of each head.
[0096] is the attention mechanism of the nth attention head:
[0097]
[0098] where is a linear transformation, denotes a node.
[0099] In particular, when is the word node representation in the dialogue context, is the concept node representation related to the word, according to the TransE model, the concept node is updated before applying the multi-head graph attention mechanism, which combines the concept information and the relationship information between the two nodes, denoted as:
[0100]
[0101]
[0102] where φ(·) denotes a combination operation, denotes a relationship between a node and a node, is the relationship embedding between nodes and .
[0103] The node representation is updated by using the encoder layer of the graph neural network Transformer to inject global semantic information for all nodes:
[0104]
[0105] where, is the semantic representation of node , TRSEnc(·) denotes the encoder layer of the graph neural network Transformer, denotes the semantic representation of the node after injecting global information.
[0106] The special token CLS node representation is used as the global semantic representation of the semantic context graph.
[0107] S2, constructing and encoding the sentiment context graph of the dialogue context, referring to Figure 6 ; comprising:
[0108] S21, screening and introducing sentiment knowledge, obtaining new sentiment concepts related to the dialogue context
[0109] Referring to Figure 7 , the screening and introduction of sentiment knowledge is specifically:
[0110] Retrieving the VAD vector of each non-stop word and its related concept after relationship screening in the new dialogue context C' in the sentiment dictionary NRC_VAD. Specifically, relationship screening refers to removing relationships that are irrelevant to semantics and sentiment.
[0111] According to the VAD vector, the sentiment intensity value of each non-stop word and all related concepts is calculated. Let a related concept be c, the calculation formula of the sentiment intensity value EI(c) of c is as follows:
[0112]
[0113] Where, min-max(·) refers to min-max normalization operation, ‖·‖ represents L2 norm, V(c) and A(c) represent the values of valence and arousal dimensions in the VAD vector of the related sentiment concept c respectively. If the related sentiment concept c is not in NRC_VAD, set EI(c) to 0.
[0114] According to the VAD vector, the sentiment difference value between each non-stop word and its related concept is calculated. The calculation formula of the sentiment difference value EG(w,c) between the word w and the related concept c is as follows:
[0115]
[0116] Where, abs(·) refers to the absolute value operation, V(w) and A(w) represent the values of valence and arousal dimensions in the VAD vector of the word w respectively, V(c) and A(c) represent the values of valence and arousal dimensions in the VAD vector of the related concept c respectively.
[0117] According to the sentiment intensity value, the related concepts of each non-stop word are sorted, and the related concept with a small sentiment difference value (such as less than a certain threshold value (such as 0.5)) and a high sentiment intensity value (such as the top K2, K2 is a set value) is selected as the sentiment knowledge required for constructing the sentiment context graph.
[0118] S22, take all words and special tags in the new conversation context as initial nodes, take related emotional concepts as new nodes, connect each node to construct the emotional context graph, and obtain the emotional context graph
[0119] See also Figure 8 ,The emotional context graph is constructed as follows:
[0120] All words and special tokens CLS in the new conversation context C′ are used as the initial nodes of the emotional context graph. The relevant emotional concepts obtained in the emotional knowledge screening and introduction tasks are used as new nodes in the emotional context graph. The following nodes in the emotional context graph are connected:
[0121] Two consecutive words in a conversational context;
[0122] Words and related emotional concepts in the conversation context;
[0123] CLS tags each word with the conversation context;
[0124] Thus forming the emotional context graph G emo =(V emo ,E emo ).
[0125] In G emo The adjacency matrix A emo , set the edges between nodes to 1.
[0126] S23. Graph encoding is performed on the emotion context graph to obtain the global emotion representation of the emotion context graph.
[0127] See also Figure 9 , the emotional context graph encoding is specifically:
[0128] Initialize each node in the sentiment context graph using word embedding, position embedding, and node state embedding Sentiment vector representation The specific method is the same as the method of graph encoding using semantic context graph in the previous article.
[0129] Apply multi-head graph attention mechanism, use residual connection, perform layer normalization operation, use relevant situation concept to update node representation, so that each node Follow all its direct neighbors Update to get the new node representation The specific method is basically the same as the graph encoding method of the semantic context graph in the previous article, but the difference from the semantic context graph encoding task is that in the emotional context graph, there is no need to combine the concept information and the relationship information between the two nodes to update the concept node.
[0130] The global sentiment information is used to update the node representation through the encoder layer of the graph neural network Transformer, and the global sentiment information is injected into all nodes:
[0131]
[0132] wherein is the sentiment representation of the node , TRSEnc(·) represents the encoder layer of the graph neural network Transformer, represents the node sentiment representation after injecting global information.
[0133] The node representation using a special mark CLS is used as the global sentiment representation of the sentiment context graph.
[0134] S3, taking the dialogue context, the global semantic representation of the semantic context graph and the global sentiment representation of the sentiment context graph as input, and taking the word probability table probability distribution of predicting the reply as output, a co-empathic reply generation model is obtained by training the graph neural network
[0135] Referring to Figure 10 , the modeling process of the co-empathic reply generation model includes:
[0136] The vector representation of each word in the dialogue context C is initialized using word embedding, position embedding and state embedding, and the sequence embedding E is obtained C .
[0137] E C is sent into the encoder layer of the graph neural network Transformer to obtain the hidden representation H of the dialogue context:
[0138] H=TRSEnc(C)
[0139] The hidden representation of the dialogue context includes the hidden representation of the special mark CLS, and the hidden representation h of the special mark is used to represent the dialogue context sequence:
[0140] h=H[0]
[0141] The special mark hidden representation h is subjected to semantic linear transformation and sentiment linear transformation, respectively obtaining the semantic representation h sem and the sentiment representation h emo of the dialogue context:
[0142] h sem =W soc h
[0143] h emo =W eoc h
[0144] where, denotes the dialogue context semantic linear transformation; denotes the dialogue context sentiment linear transformation.
[0145] The global sentiment representation of the sentiment context graph is and the sentiment representation h of the dialogue context emo The fusion sentiment representation is obtained by concatenation for predicting the speaker sentiment state:
[0146]
[0147] where, denotes the concatenation operation,
[0148] The fusion sentiment representation is is passed through a linear layer, and then a Softmax function for classification operation to generate the sentiment class distribution q is the number of sentiment classes:
[0149]
[0150] where, is the sentiment linear transformation operation on the fusion sentiment representation. In the training process, the parameter learning is performed by minimizing the cross-entropy between the target sentiment label e * and the predicted label e, i.e. minimizing the sentiment loss:
[0151]
[0152] where is the sentiment loss.
[0153] The global semantic representation of the semantic context graph is and the semantic representation h of the dialogue context sem The fusion semantic representation is obtained by concatenation
[0154]
[0155] where,
[0156] The fusion semantic representation is concatenated and the fusion sentiment representation The concatenation result is passed through a multi-layer perceptron (MLP) with ReLU activation to obtain the combined co-emotion representation
[0157]
[0158]
[0159] wherein, ⊙ denotes a dot product operation.
[0160] The target reply R gold is input into the graph neural network Transformer decoder layer together with the word embedding E w (R gold ) and the combined co-emotion representation , and the graph neural network is trained to obtain a co-emotion reply generation model, which outputs a word probability table probability distribution of each word in the predicted reply:
[0161]
[0162] P resp = softmax(W o O)
[0163] p(R t |R <t ,G sem ,G emo ) = P resp [t]
[0164] wherein, l R is the length of the predicted reply, TRSDec represents the graph neural network Transformer decoder layer, |V| is the length of the vocabulary table, and p(R t |R <t ,G sem ,G emo ) is the vocabulary table probability distribution of each word in the predicted reply.
[0165] In some embodiments, to achieve better neural network training effect, during the training process, the negative log likelihood is used to optimize the predicted reply:
[0166]
[0167] The frequency-aware cross-entropy (FACE) is used as an additional loss to penalize high-frequency words in the predicted reply. Therefore, during the training process, the relative frequency RF i of each word word i in the training corpus is first calculated as follows:
[0168]
[0169] wherein, V represents the vocabulary. Therefore, the frequency-based weight w i is obtained as follows:
[0170] w i = a x RF i + 1
[0171] where a = -(max 1≤j≤V (RF j )) -1 is the frequency slope, plus 1 as a bias, so that w i falls in [0, 1]. Since more frequent words will have higher relative frequencies, the obtained weights ensure that these words have lower weights. Finally, w i is normalized so that its average value is 1. The calculation of the diversity loss is as follows:
[0172]
[0173] where c i is a candidate word in the vocabulary, δ t (c i ) is an indicator function that equals 1 if and only if c i = y t , and 0 otherwise.
[0174] The joint loss function is defined as follows:
[0175]
[0176] where γ1, γ2 and γ3 are hyperparameters that control the weights of the three losses. Set γ1 = γ2 = 1, γ3 = 1.5. All parameters are jointly trained in an end-to-end model.
[0177] The graph neural network trained by the above process can be used as an empathetic reply generation model to generate dialogue replies for robot chatting.
[0178] The empathetic reply generation method is enhanced in semantics and emotion aspects, two stages of semantic context graph construction and coding and emotional context graph construction and coding are adopted, external semantic knowledge with high content relevance and external emotional knowledge with high emotional intensity and similar emotional polarity are introduced respectively, so as to respectively inject rich structure and semantic information and emotional information for the empathetic reply generation method, help to accurately identify the implicit emotion of the user, help to fully understand the complex situation of the user, solve the problem of emotional recognition deviation caused by the inability to effectively identify the implicit emotion in the prior art, and the problem of the generated reply being relatively general and poor in diversity caused by the inability to fully understand the situation of the user.
[0179] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can still be modified, or some or all of the technical features can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should be covered in the scope of the claims and the specification of the present application.
Claims
1. A robot chat method based on knowledge-enhanced empathic response, characterized in that: include: Perform conversation context preprocessing; Use the empathy response generation model to respond to the pre-processed conversation context; The method for constructing the empathic response generation model includes: constructing and encoding a semantic context graph of the conversation context to obtain a global semantic representation of the semantic context graph; constructing and encoding the conversation context to obtain a global emotional representation of the emotional context graph; taking the conversation context, the global semantic representation of the semantic context graph, and the global emotional representation of the emotional context graph as input, and taking the probability distribution of a word probability table for each word in the predicted response as output, and obtaining the empathic response generation model by training a graph neural network; The emotional context graph is constructed and encoded, including: screening and introducing emotional knowledge, retrieving each non-stop word in the new dialogue context from the emotional dictionary, and the vectors of the related concepts of each non-stop word after relationship screening; calculating the emotional intensity value of all related concepts of each non-stop word based on the vector; calculating the emotional difference value between each non-stop word and each related concept of each non-stop word based on the vector; sorting the related concepts of each non-stop word according to the emotional intensity value, selecting the related concepts with the highest emotional intensity value and whose emotional difference value with the non-stop word is less than the set threshold as the related emotional concept, and obtaining the emotional concept related to the new dialogue context; All words and special tags in the new conversation context are used as initial nodes, and related emotional concepts are used as new nodes. The nodes are connected to construct an emotional context graph to obtain the emotional context graph; the emotional context graph is graph encoded, and the word embedding, position embedding and node state embedding are used to initialize the emotional vector representation of each node in the emotional context graph; a multi-head graph attention mechanism is applied, residual connections are used, layer normalization operations are performed, and node representations are updated using related emotional concepts; global emotional information is used to update node representations through the encoder layer of the graph neural network to inject global emotional information into all nodes: the node representation of the special tag is used as the global emotional representation of the emotional context graph to obtain the global emotional representation of the emotional context graph.
2. The robot chat method based on knowledge-enhanced empathic reply according to claim 1 is characterized in that: Perform conversation context preprocessing, including: connecting all utterances in the conversation context, flattening them into a word sequence, inserting a special marker before the sequence, and obtaining a new conversation context.
3. The robot chat method based on knowledge-enhanced empathy response according to claim 1 is characterized in that: Construct and encode the semantic context graph, including: Filter and introduce semantic knowledge to obtain new semantic concepts related to the conversation context; All words and special tokens in the new conversation context are used as initial nodes, and related semantic concepts are used as candidate nodes. Among the candidate nodes, the nodes with the highest relevance to the new conversation context are selected as new nodes. The semantic context graph is constructed by connecting the nodes to obtain the semantic context graph. The semantic context graph is graph encoded to obtain the global semantic representation of the semantic context graph.
4. The robot chat method based on knowledge-enhanced empathic reply according to claim 3 is characterized in that: Filter and introduce semantic knowledge to obtain new semantic concepts related to the conversation context, including: Traverse each non-stop word in the new dialogue context and retrieve all triples related to each non-stop word in the common sense knowledge base; Perform relationship screening on the retrieved triples and remove triples with relationships irrelevant to semantics and sentiment; Calculate the relevance of each semantic concept with the new conversation context from the triples after relationship filtering, and obtain the relevant semantic concepts of each non-stop word.
5. The robot chat method based on knowledge-enhanced empathic reply according to claim 3 is characterized in that: Graph encoding of the semantic context graph, including: Initialize the semantic vector representation of each node in the semantic context graph using word embedding, position embedding, and node state embedding; Apply a multi-head graph attention mechanism, use residual connections, perform layer normalization, and update node representations using relevant semantic concepts; Use global semantic information to update node representations through the encoder layer of the graph neural network, injecting global semantic information into all nodes; Special labeled nodes are used as the global semantic representation of the semantic context graph.
6. The robot chat method based on knowledge-enhanced empathic reply according to claim 1, characterized in that: Modeling of the empathic response generation model, including: Initialize the vector representation of each word in the conversation context using word embedding, position embedding, and state embedding to obtain sequence embedding; Feed the sequence embedding into the encoder layer of the graph neural network to obtain the hidden representation of the conversation context, which includes the hidden representation of the special token. Use special token hidden representation to represent the conversation context sequence; Perform semantic linear transformation and sentiment linear transformation on the hidden representation of special tags to obtain the semantic representation and sentiment representation of the conversation context respectively; The global emotion representation of the emotion context graph is concatenated with the emotion representation of the conversation context to obtain the fused emotion representation. Pass the fused sentiment representation through a linear layer and then perform a classification operation to generate the sentiment category distribution; The global semantic representation of the semantic context graph is concatenated with the semantic representation of the conversation context to obtain a fused semantic representation. Splice and fuse the semantic representation and the emotional representation, and pass the splicing result through a multi-layer perceptron to obtain a combined empathy representation; The word embedding of the target reply and the combined empathy representation are used as the input of the graph neural network decoder layer, and the probability distribution of the word probability table for each word in the predicted reply is used as the output. The graph neural network is trained to obtain an empathy reply generation model.
7. The robot chat method based on knowledge-enhanced empathic reply according to claim 6, characterized in that: include: In the process of training the graph neural network, cross entropy is used to minimize the sentiment prediction loss, and negative log-likelihood is used to optimize the predicted response; Frequency-aware cross entropy is used as an additional loss to penalize high-frequency words in the predicted responses.
Citation Information
Patent Citations
External knowledge-assisted multi-factor hierarchical modeling common-situation dialogue generation method
CN115795010A
Emotional dialogue generation method fusing emotional reasons and emotional intentions
CN116089588A
Cited By
Social robot continuous learning method and system based on emotion distribution embedding
CN121562663A