Empathy dialogue method and system based on common sense adaptive selection
By adaptively selecting feature encoding of common sense graphs, the problem of context consistency in empathetic dialogue systems is solved, and the contextual understanding and user experience of the dialogue system are improved. It is suitable for unmanned systems and human-computer interaction scenarios.
Patent Information
- Application Number
- CN202211422630.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-11-14
AI Technical Summary
The existing technology fails to effectively utilize the common sense graph of adaptive selection to perform empathy in the context, and it is difficult to achieve context-consistent empathic responses in the empathy dialogue system.
Through a common sense adaptive selection method, using a pre-trained common sense graph generation model and a parameterized encoder, combined with a sentiment classification loss function, we adaptively select the feature encoding of the common sense graph to generate empathetic dialogue response text that is emotionally consistent with historical dialogue text data.
It achieves empathetic dialogue with consistent context, improves the contextual understanding ability and user experience of the dialogue system, enhances communication efficiency, and is suitable for various unmanned systems and human-computer interaction scenarios.
Smart Images

Figure CN115905485B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer applications, and in particular relates to an empathy dialogue method and system based on common sense adaptive selection. Background Art
[0002] Empathy is the human ability to understand the emotions of others, enabling us to experience their emotions and understand their mental states through various emotional stimuli. If a dialogue system possesses empathy and can identify the speaker's emotions, it can provide more targeted responses. In the field of natural language processing, current dialogue systems focus on the rationality of word and sentence structure, but overlook the role of empathy in sustainable chat systems. Empathy is a fundamental human cognitive ability that, combined with a speaker's common sense, enables a better understanding of the other person's emotional state. Therefore, recently emerging dialogue systems utilize common sense graphs to achieve the goal of perceiving human emotions in human-computer interaction. However, common sense is complex and diverse, and unselected common sense can disrupt the dialogue system's response generation.
[0003] Current research has not yet explored adaptively filtering common sense graphs to understand human emotions and assist dialogue systems in generating empathetic responses. The challenge of this system lies in unifying the dialogue system's emotional understanding of the common sense graph with the conversational context to achieve contextually consistent empathetic responses. Summary of the Invention
[0004] To solve the above problems, a method and system for empathic dialogue that can achieve consistent context is provided. The present invention adopts the following technical solutions:
[0005] The present invention provides an empathy dialogue method based on common sense adaptive selection, which is characterized by comprising the following steps: step S1, inputting historical dialogue text data and a predefined common sense relationship set into a pre-trained common sense graph generation model to obtain a predicted context-related common sense inference result set; step S2, based on a parameterized common sense graph encoder, inputting a common sense inference result set and a sentiment classification loss function to obtain a feature coding set of the corresponding common sense graph and common sense graph sentiment recognition information; step S3, based on a parameterized context encoder, inputting historical dialogue text data and a sentiment classification loss function to obtain a feature coding vector of the context and context sentiment recognition information; step S4, in order to unify the common sense graph sentiment recognition information and the context sentiment recognition information, inputting the feature coding set of the common sense graph, the feature coding vector of the context and the sentiment classification loss function into a simulation workspace, and using an adaptive selection common sense feature coding algorithm to obtain the feature coding of the adaptively selected common sense graph; step S5, inputting the feature coding of the adaptively selected common sense graph, combined with the feature coding vector of the context, into a parameterized neural network decoder, thereby obtaining an empathy dialogue reply text that is sentimentally unified with the historical dialogue text data.
[0006] The empathic dialogue method based on common sense adaptive selection provided by the present invention may also have such a technical feature, wherein the elements of the predefined common sense relationship set include at least a dialogue demand relationship, a dialogue intention relationship and a dialogue influence relationship.
[0007] The empathy dialogue method based on common sense adaptive selection provided by the present invention may also have the following technical features, wherein step S4 includes the following sub-steps:
[0008] Step S4-1, using an adaptive selection common sense feature encoding algorithm to simulate a workspace mechanism;
[0009] Step S4-2: The feature encoding set Z of the common sense graph r , parameterized neural network g φ , the feature encoding vector Z of the context ctx And the sentiment classification loss function Input to simulation workspace;
[0010] Step S4-3, in the competition phase m, when the feature encoding set Z of the common sense graph r When the number of codes is greater than 1, the sentiment classification loss function is used Calculation through neural network g φ The encoded feature encoding vector and the context feature encoding vector z ctx The set f consists of:
[0011]
[0012] And record it as the feature encoding set Z of the common sense graph r The maximum loss of sequence number I:
[0013]
[0014] Step S4-4, calculate the gradient of the elements in the set f to form the matrix Gm:
[0015] Step S4-5, calculate the momentum δ of the features of the context aligned with the features of the common sense graph in the competition stage m by solving the Lagrange multiplier λ m :
[0016]
[0017]
[0018] After solving the quadratic programming problem using the above formula to obtain the Lagrange multiplier λ, calculate the momentum δ m :
[0019] δ m =-G m T λ;
[0020] Step S4-6, in the broadcast phase m, input the feature coding set Z of the common sense graph r , through the neural network g α After decoding, we get the knowledge representation h k =g α (Z r ), and output after momentum δ m Revised knowledge encoding
[0021]
[0022] Step S4-7, after the above steps S4-1 to S4-6 are processed, the Ith common sense graph code is removed from the feature code set of the common sense graph until only one common sense graph feature code remains in the feature code set, thereby obtaining the feature code of the common sense graph selected according to the emotion recognition information of the context; wherein, the competition phase m and the broadcast phase m are represented by m cycles in the WHILE loop, and in each cycle m, the feature code set Z of the common sense graph is removed. r The number I with the largest loss in represents the elimination of the knowledge representation that is least relevant to the context. This process is called the adaptive selection process.
[0023] The present invention also provides an empathy dialogue system based on common sense adaptive selection, which is characterized in that it includes: a media data acquisition module, a calculation module and a result display module. The media data acquisition module is used to obtain historical dialogue text data. The calculation module is used to encode and decode the historical dialogue text data and the pre-stored common sense graph, and then use the adaptive selection common sense feature encoding algorithm to obtain the feature encoding of the common sense graph that is consistent with the encoded emotion of the historical dialogue text data, thereby generating an empathy dialogue response text. The result display module is used to display the historical dialogue text data obtained by the media data acquisition module and the empathy dialogue response text output by the calculation module.
[0024] The empathy dialogue system based on common sense adaptive selection provided by the present invention may also have such technical features, wherein the computing module includes a perception module, a cognitive module, a workspace module and a generation module. The perception module is a text pre-training model, which is used to encode the input historical dialogue text data and output the corresponding historical dialogue code; the cognitive module has a pre-stored common sense graph and a common sense inference generation model, which is used to encode the input historical dialogue text data and output the corresponding common sense code; the workspace module adaptively selects the common sense code based on the adaptive selection common sense feature coding algorithm, selects the common sense code that is consistent with the emotion of the historical dialogue code as the feature code of the adaptively selected common sense graph and outputs it; the generation module is a text dialogue generation model, which is used to generate an emotionally unified empathy dialogue response text based on the feature code of the adaptively selected common sense graph and the input historical dialogue code.
[0025] Functions and effects of the invention
[0026] The empathic dialogue method and system based on adaptive common sense selection according to the present invention first utilizes the representational capabilities of neural networks to perceive the contextual emotion recognition information of the conversation and encode the contextual information of the historical conversation and the prior information of the common sense graph. The encoded feature information is then filtered through a workspace-based common sense feature encoding algorithm, adaptively unifying the emotion recognition information. This ensures consistency between the filtered common sense feature encoding and the contextual emotion recognition information of the historical conversation, and outputs empathic dialogue text that better reflects the user's experience. Compared to existing dialogue systems that focus solely on grammatical accuracy and aim to generate fluent and coherent sentences while ignoring the importance of emotional understanding, the present invention utilizes the emotional information in the conversation to assist in understanding the conversation's intent. This not only improves contextual understanding, but also allows users to feel that their emotional state is understood, thereby improving communication efficiency and enhancing the user experience. Furthermore, the present invention can be applied to various unmanned systems or human-computer interaction scenarios, offering the advantages of wide applicability and high practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a flow chart of an empathy dialogue method based on common sense adaptive selection in an embodiment of the present invention;
[0028] Figure 2 2 is a schematic diagram of the structure of an empathic dialogue system based on common sense adaptive selection in an embodiment of the present invention. DETAILED DESCRIPTION
[0029] To provide a technical solution for achieving contextually consistent empathetic dialogue, the present invention views dialogue as the decision-making outcome of a person's cognitive process. This dialogue system first understands the person's emotions and then responds to the dialogue in a targeted manner. Motivated by this, and drawing on the cognitive and decision-making activities of the human brain in a conscious state, the global workspace theory is applied. This theory is a cognitive model of human decision-making proposed by American psychologist Bernard Barrs and is suitable for explaining the human dialogue process. The theory assumes that a person's decision-making (dialogue) in a conscious state is associated with a workspace called a "broadcast system." This workspace is responsible for integrating the input perceptual information and outputting a response dialogue after unifying the context of each perceptual information.
[0030] Integrating the aforementioned theory, the present invention models an empathic dialogue framework that adheres to a global workspace mechanism. This framework uses the context of the current speech and common sense as input sources for perceptual information. After the perceptual information passes through the workspace, it adaptively selects common sense that aligns with the context, achieving emotional cognition consistency and then outputs a corresponding response. Furthermore, this technical solution provides feedback on the adaptive cognitive process of the dialogue system's responses after the conversation, assisting system developers in optimizing the dialogue system.
[0031] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the following is a detailed description of the empathy dialogue method and system based on common sense adaptive selection of the present invention in combination with embodiments and drawings.
[0032] <Example>
[0033] Figure 1 4 is a flow chart of an empathy dialogue method based on common sense adaptive selection in an embodiment of the present invention.
[0034] like Figure 1 As shown, the empathy dialogue method based on common sense adaptive selection in this implementation includes the following steps:
[0035] Step S1: Generate a model based on the pre-trained common sense graph Input historical conversation text data U for forward propagation, and obtain the predicted context-related common sense inference result set E according to the predefined common sense relationship set r∈{N,W,O,...}r .
[0036] In the predefined common sense relation set r∈{N, W, O, ...}, N represents the dialogue requirement relation, W represents the dialogue intention relation, O represents the dialogue impact relation, etc.
[0037] Step S2, based on parameterized common sense graph encoder Enc k , input common sense inference result set E r And the loss function L for sentiment classification emo , output the feature encoding set Z of the common sense graph r and common sense graph emotion recognition information Emo k ;
[0038] Step S3, based on parameterized context encoder Enc ctx , input historical conversation text data U and sentiment classification loss function L emo , obtain the feature encoding vector z of the context of historical conversation text data ctx and contextual emotion recognition information Emo ctx ;
[0039] Step S4 is to unify the common sense graph emotion recognition information Emo k and contextual emotion recognition information Emo ctx , the feature encoding set Z of the common sense graph r and the context feature encoding vector z ctx , input into the simulation workspace, and use the adaptive selection common sense feature encoding algorithm to obtain the feature encoding of the adaptively selected common sense graph.
[0040] The specific process of this step is as follows:
[0041] Step S4-1, using an adaptive selection common sense feature encoding algorithm to simulate a workspace mechanism;
[0042] Step S4-2: The feature encoding set Z of the common sense graph r , parameterized neural network g φ , context feature encoding vector z ctx And the sentiment classification loss function Input to simulation workspace;
[0043] Step S4-3, in the competition phase m, when the feature encoding set Z of the common sense graph r When the number of codes is greater than 1, the sentiment classification loss function is used Calculation through neural network g φ The encoded feature encoding vector and the context feature encoding vector z ctx The set f consists of:
[0044]
[0045] And record it as the feature encoding set Z of the common sense graph r The maximum loss of sequence number I:
[0046]
[0047] Step S4-4, calculate the gradient of the elements in the set f to form the matrix Gm:
[0048] Step S4-5, calculate the momentum δ of the features of the context aligned with the features of the common sense graph in the competition stage m by solving the Lagrange multiplier λ m :
[0049]
[0050]
[0051] After solving the quadratic programming problem using the above formula to obtain the Lagrange multiplier λ, calculate the momentum δ m :
[0052] δ m =-G m T λ;
[0053] Step S4-6, in the broadcast phase m, input the feature coding set Z of the common sense graph r , through the neural network g α After decoding, we get the knowledge representation h k =g α (Z r ), and output after momentum δ m Revised knowledge encoding
[0054]
[0055] Step S4-7, after processing the above steps S4-1 to S4-6, the Ith common sense graph code is removed from the feature code set of the common sense graph until only one common sense graph code remains in the feature code set, thereby obtaining the feature code of the common sense graph selected according to the emotional information of the context.
[0056] In the above process, the competition phase m and the broadcast phase m are represented as m cycles in the WHILE loop. And, in each cycle m, the feature encoding set Z of the common sense graph is eliminated. rThe maximum loss number I in the list indicates that the knowledge representation that is least relevant to the context is eliminated. This process is the adaptive selection process and can also be expressed as the feature encoding set Z in the common sense graph. r In order from high to low:
[0057] Step S5: Encode the features of the adaptively selected common sense graph Combined with the feature encoding vector z of historical dialogue ctx , input parameterized neural network decoder Dec c,k , thereby obtaining empathetic dialogue response text that is consistent with the sentiment of the historical dialogue text data:
[0058]
[0059] Figure 2 2 is a schematic diagram of the structure of an empathic dialogue system based on common sense adaptive selection in an embodiment of the present invention.
[0060] like Figure 2 As shown, the empathy dialogue system 100 based on common sense adaptive selection in this embodiment includes a media data acquisition module 10 , a calculation module 11 and a result display module 12 .
[0061] The media data acquisition module 10 is used to acquire historical conversation text data, which may be acquired from a speech-to-text program or device, or may be locally stored text data.
[0062] The computing module 11 is used to encode and decode the historical conversation text data obtained by the media data acquisition module 10 and the pre-stored common sense graph, and then use the adaptive common sense feature encoding algorithm to obtain the feature encoding of the common sense graph that is consistent with the encoded emotion of the historical conversation text data, thereby generating an empathetic conversation response text.
[0063] The computing module 11 includes a perception unit 111 , a recognition unit 112 , a workspace unit 113 , and a generation unit 114 .
[0064] Among them, the perception unit 111 is a text pre-training model, which is used to encode the input historical conversation text data and output the corresponding historical conversation code.
[0065] The cognitive unit 112 has a pre-stored common sense graph and a common sense inference generation model, which is used to encode the input historical dialogue text data and output the corresponding common sense code.
[0066] The workspace unit 113 adaptively selects common sense coding based on the adaptive common sense feature coding algorithm, selects common sense coding that is consistent with the emotion of the historical dialogue coding as the feature coding of the adaptively selected common sense graph and outputs it.
[0067] The generation unit 114 is a text dialogue generation model, which is used to generate an emotionally unified empathetic dialogue response text based on the feature coding of the adaptively selected common sense graph and the input historical dialogue coding.
[0068] The result display module 12 is used to display the historical conversation text data acquired by the media data acquisition module 10 and the empathy conversation reply text output by the calculation module 11. The result display module 12 can be a computer or a mobile device.
[0069] The above-mentioned empathic dialogue method and system based on adaptive selection in this embodiment can be applied to various unmanned systems or human-computer interaction scenarios, such as communication and interaction between robots and patients in nursing scenarios; voice questions and answers between drivers and cars during autonomous driving; or voice ordering interactions between customers and food delivery robots in unmanned restaurants, etc., and has the advantages of wide applicability and high use value.
[0070] Example Function and Effect
[0071] The adaptively selected empathic dialogue method and system provided in this embodiment first utilizes the representational capabilities of neural networks to perceive the contextual emotion recognition information of the conversation and encode the contextual information of the historical conversation and the prior information of the common sense graph. The encoded feature information is then filtered through a workspace-based common sense feature encoding algorithm, adaptively unifying the emotion recognition information. This ensures consistency between the filtered common sense feature encoding and the contextual emotion recognition information of the historical conversation, and outputs empathic dialogue text that better reflects the user's feelings. Compared to existing dialogue systems that focus solely on grammatical accuracy and aim to generate fluent and coherent sentences while ignoring the importance of emotional understanding, this embodiment utilizes the emotional information in the conversation to assist in understanding the conversation's intent. This not only improves contextual understanding but also allows users to feel that their emotional state is understood, thereby enhancing communication efficiency and user experience.
[0072] At the same time, the empathic dialogue system provided in this embodiment can also report the adaptive selection process in the workspace, thereby assisting developers in iterating and tuning the dialogue system and common sense graph.
[0073] The above embodiments are only used to illustrate specific implementations of the present invention, and the present invention is not limited to the description scope of the above embodiments.
Claims
1. An empathy dialogue method based on common sense adaptive selection, characterized by: The following steps are involved: Step S1: Input historical conversation text data and a predefined common sense relationship set into a pre-trained common sense graph generation model to obtain a predicted context-related common sense inference result set; Step S2: Based on the parameterized common sense graph encoder, the common sense inference result set and the sentiment classification loss function are input to obtain the corresponding common sense graph feature encoding set and common sense graph sentiment recognition information; Step S3, based on the parameterized context encoder, inputting the historical conversation text data and the sentiment classification loss function, obtaining the context feature encoding vector and context sentiment recognition information; Step S4: To unify the common sense graph emotion recognition information and the context emotion recognition information, the feature coding set of the common sense graph, the feature coding vector of the context, and the emotion classification loss function are input into the simulation workspace, and the feature coding of the adaptively selected common sense graph is obtained using the adaptive common sense feature coding algorithm; Wherein, the step S4 includes the following sub-steps: Step S4-1, using the adaptive selection common sense feature encoding algorithm to simulate the workspace mechanism; Step S4-2: The feature encoding set Z of the common sense graph r , parameterized neural network g φ , context feature encoding vector z ctx And the sentiment classification loss function input into the simulation workspace; Step S4-3, in the competition phase m, when the feature encoding set Z of the common sense graph r When the number of codes is greater than 1, the sentiment classification loss function is used Calculation through neural network g φ The encoded feature encoding vector and the context feature encoding vector z ctx The set f consists of: And record it as the feature encoding set Z of the common sense graph r The maximum loss of sequence number I: Step S4-4, calculate the gradient of the elements in the set f to form the matrix G m : Step S4-5, calculate the momentum δ of the features of the context aligned with the features of the common sense graph in the competition stage m by solving the Lagrange multiplier λ m : After solving the quadratic programming problem using the above formula to obtain the Lagrange multiplier λ, calculate the momentum δ m : d m =-G m T l; Step S4-6, in the broadcast phase m, input the feature coding set Z of the common sense graph r , through the neural network g α After decoding, we get the knowledge representation h k =g α (Z r ), and output after momentum δ m Revised knowledge encoding Step S4-7: After the above steps S4-1 to S4-6, the first common sense graph code is removed from the feature code set of the common sense graph until only one common sense graph feature code remains in the feature code set, thereby obtaining the feature code of the common sense graph selected according to the emotion recognition information of the context; Among them, the competition phase m and the broadcast phase m are represented by m cycles in the WHILE loop. In each cycle m, the feature encoding set Z of the common sense graph is eliminated. r The number I with the largest loss in represents the elimination of the knowledge representation that is least relevant to the context. This process is the adaptive selection process. In step S5, the feature encoding of the adaptively selected common sense graph is combined with the feature encoding vector of the context and input into a parameterized neural network decoder, thereby obtaining an empathetic dialogue response text that is emotionally consistent with the historical dialogue text data.
2. The empathy dialogue method based on common sense adaptive selection according to claim 1, characterized in that: in, The elements of the predefined common sense relationship set include at least a dialogue requirement relationship, a dialogue intention relationship, and a dialogue impact relationship.
3. An empathic dialogue system based on common sense adaptive selection using the method of claim 1, characterized in that: include: Media data acquisition module, calculation module and result display module, The media data acquisition module is used to acquire historical conversation text data. The computing module is used to encode and decode the historical conversation text data and the pre-stored common sense graph, and then use an adaptive common sense feature encoding algorithm to obtain feature encoding of the common sense graph that is consistent with the encoded emotion of the historical conversation text data, thereby generating an empathetic conversation reply text. The result display module is used to display the historical conversation text data acquired by the media data acquisition module and the empathy conversation reply text output by the calculation module.
4. The empathic dialogue system based on common sense adaptive selection according to claim 3, characterized in that: in, The computing module includes a perception module, a cognitive module, a workspace module and a generation module. The perception module is a text pre-training model, which is used to encode the input historical conversation text data and output the corresponding historical conversation code; The cognitive module has a pre-stored common sense map and a common sense inference generation model, which is used to encode the input historical conversation text data and output the corresponding common sense code; The workspace module adaptively selects the common sense code based on the adaptive common sense feature coding algorithm, selects the common sense code that is consistent with the emotion of the historical conversation code as the feature code of the adaptively selected common sense graph, and outputs the selected common sense code; The generation module is a text dialogue generation model, which is used to generate emotionally unified empathetic dialogue response text based on the feature encoding of the adaptively selected common sense graph and the input historical dialogue encoding.
Citation Information
Patent Citations
A method for understanding, questioning and answering image semantics based on a deep neural network
CN109740012A
Dialogue generation method and device and storage medium
CN115169367A