Dialogue generation method and device and electronic equipment

By identifying and understanding the types and reasons of emotions in the user's voice information, it generates a dialogue that is more in line with the user's expectations, solving the problem in the existing technology that the dialogue assistant cannot deeply perceive the user's emotions, and improving the user experience.

CN118626601APending Publication Date: 2024-09-10SHENZHEN HEYTAP TECHNOLOGY CO LTD

Patent Information

Application Number
CN202310266838.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-10
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing conversational assistants and digital employees are unable to deeply perceive user emotions, resulting in reply content that cannot meet user expectations and affect user experience.

Method used

By obtaining the voice information to be replied to, identifying its emotion type and the reasons for the emotion type, and generating a dialogue based on this information, it can further perceive the user's emotion more deeply and generate a dialogue that is more in line with the user's expectations.

Benefits of technology

It improves the user experience and generates dialogue content that is more in line with user expectations through in-depth perception and mining of user emotions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626601A
    Figure CN118626601A
Patent Text Reader

Abstract

The embodiment of the invention discloses a dialogue generation method and device and electronic equipment. The method comprises the following steps: acquiring voice information to be replied; based on the to-be-replied voice information, obtaining an emotion type of the to-be-replied voice information and a reason for generating the emotion type; and based on the to-be-replied voice information, the emotion type and the reason, generating a dialogue corresponding to the to-be-replied voice information. Through the above mode, the emotion type of the to-be-replied voice information and the reason for generating the emotion type can be obtained based on the to-be-replied voice information, and then the dialogue corresponding to the to-be-replied voice information is generated based on the to-be-replied voice information, the emotion type and the reason for generating the emotion type. By mining the reason for generating the corresponding emotion type by the user, the emotion of the user can be perceived more deeply, so that a dialogue more conforming to the expectation of the user can be generated based on the to-be-replied voice information, the emotion type and the reason for generating the emotion type, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a dialogue generation method, device and electronic device. Background Art

[0002] With the continuous development of artificial intelligence technology, conversation assistants, digital employees, etc. are widely used. In related methods, conversation assistants, digital employees, etc. can receive voice information from users and identify the emotion type of the user's voice information to generate chat replies with different emotional strategies based on the recognition results. However, in related methods, conversation assistants, digital employees, etc. cannot deeply perceive user emotions, so that the reply content cannot meet user expectations, thus affecting the user experience. Summary of the invention

[0003] In view of the above problems, the present application proposes a dialogue generation method, device and electronic device to improve the above problems.

[0004] In a first aspect, the present application provides a dialogue generation method, which is applied to an emotional dialogue engine, and the method includes: obtaining voice information to be replied; based on the voice information to be replied, obtaining the emotion type of the voice information to be replied and the reason for generating the emotion type; based on the voice information to be replied, the emotion type and the reason, generating a dialogue corresponding to the voice information to be replied.

[0005] In the second aspect, the present application provides a dialogue generation device that runs on an emotional dialogue engine, and the device includes: a voice information acquisition unit, used to acquire voice information to be replied; an emotion recognition unit, used to obtain the emotion type of the voice information to be replied and the reason for the emotion type based on the voice information to be replied; a dialogue generation unit, used to generate a dialogue corresponding to the voice information to be replied based on the voice information to be replied, the emotion type and the reason.

[0006] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.

[0007] In a fourth aspect, the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is run.

[0008] The present application provides a method, device, electronic device and storage medium for generating a dialogue. After obtaining a voice message to be replied, the method obtains the emotion type of the voice message to be replied and the reason for the emotion type based on the voice message to be replied, and generates a dialogue corresponding to the voice message to be replied based on the voice message to be replied, the emotion type and the reason. Through the above method, the emotion type of the voice message to be replied and the reason for the emotion type can be obtained based on the voice message to be replied, and then the dialogue corresponding to the voice message to be replied can be generated based on the voice message to be replied, the emotion type and the reason for the emotion type. By mining the reasons why the user generates the corresponding emotion type, the user's emotions can be more deeply perceived, so that a dialogue that better meets the user's expectations can be generated based on the voice message to be replied, the emotion type and the reason for the emotion type, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A schematic diagram of an emotional dialogue engine proposed in this application is shown;

[0011] Figure 2 A flow chart of a method for generating a dialogue proposed in an embodiment of the present application is shown;

[0012] Figure 3 Shows this application Figure 1 A flowchart of an implementation method proposed in S120;

[0013] Figure 4 A schematic diagram of an emotional reasoning process proposed in this application is shown;

[0014] Figure 5 A flowchart of a method for generating a dialogue according to another embodiment of the present application is shown;

[0015] Figure 6 A schematic diagram of a psychological emotional support framework proposed in this application is shown;

[0016] Figure 7 A structural block diagram of a dialogue generation device proposed in an embodiment of the present application is shown;

[0017] Figure 8 A structural block diagram of an electronic device proposed in this application is shown;

[0018] Fig. 9 It is a storage unit of an embodiment of the present application for storing or carrying program code for implementing the dialogue generation method according to an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0020] With the continuous development of artificial intelligence technology, conversation emotion recognition has become a research hotspot. Conversation emotion recognition can be a classification task, the purpose of which is to classify the emotions of the discourse in a conversation. Conversation emotion recognition can be widely used in various conversation scenarios, such as sentiment analysis of comments in social media, sentiment analysis of customers in manual customer service, etc. In addition, conversation emotion recognition can also be applied to chatbots to analyze the user's emotional state in real time and generate responses driven by user emotions. In a related manner, the conversation emotion recognition task can receive voice information from the user and identify the emotion type of the user's voice information, so as to generate chat replies with different emotional strategies through the recognition results.

[0021] The inventors found in related research that, in related methods, conversation assistants, digital employees, etc. are still unable to deeply perceive user emotions, so that the reply content cannot meet user expectations, thus affecting the user experience.

[0022] Therefore, the inventor has proposed a dialogue generation method, device and electronic device in the present application. After obtaining the voice information to be replied, the emotion type of the voice information to be replied and the reason for the emotion type are obtained based on the voice information to be replied, and the dialogue corresponding to the voice information to be replied is generated based on the voice information to be replied, the emotion type and the reason. Through the above method, the emotion type of the voice information to be replied and the reason for the emotion type can be obtained based on the voice information to be replied, and then the dialogue corresponding to the voice information to be replied is generated based on the voice information to be replied, the emotion type and the reason for the emotion type. By mining the reasons why the user generates the corresponding emotion type, the user's emotions can be perceived more deeply, so that a dialogue that better meets the user's expectations can be generated based on the voice information to be replied, the emotion type and the reason for the emotion type, thereby improving the user experience.

[0023] In order to better understand the solution of the embodiment of the present application, the emotional dialogue engine involved in the embodiment of the present application is first introduced below.

[0024] like Figure 1 As shown, in Figure 1The emotional dialogue engine 10 shown includes a multimodal information input unit 100, an emotion recognition unit 200, an empathy response unit 300, a multimodal emotion output unit 400, an application driving unit 500, and an analysis component 600. The emotion recognition unit 200 includes a dialogue emotion recognition module 201 and a dialogue emotion extraction module 203, and the empathy response unit 300 includes an empathy strategy selection module 301 and an empathy response generation module 303. Among them, the multimodal information input unit 100 can be used to obtain voice information, dialogue status, etc.; the dialogue emotion recognition module 201 can be used to recognize the emotion of the input voice information; the dialogue emotion extraction module 203 can be used to extract the reasons for the corresponding emotions; the empathy strategy selection module 301 can be used to determine the dialogue strategy of the emotional dialogue engine; the empathy response generation module 303 can be used to generate empathy response information, which may include dialogue content, etc.; the multimodal emotion output unit 400 can be used to output the output results of the emotion recognition unit 200 and the empathy response unit 300, and the application driving unit 500 can perform subsequent tasks (such as generating dialogues, etc.) based on the content output by the multimodal emotion output unit 400; the analysis component 600 can be used to assist the emotion recognition unit 200, the empathy response unit 300 and the multimodal emotion output unit 400 in performing subsequent tasks.

[0025] It should be noted that the emotional dialogue engine can run on a variety of electronic devices, such as mobile phones, computers, tablets, robots, etc.

[0026] The embodiments of the present application will be described below with reference to the accompanying drawings.

[0027] See also Figure 2 The present application provides a method for generating a dialogue, which is applied to an emotional dialogue engine. The method comprises:

[0028] S110: Obtain the voice message to be replied.

[0029] The voice information to be replied to may refer to the content of the voice input by the user.

[0030] As a method, the user can input voice into the electronic device. After the electronic device receives the voice through an audio acquisition device (such as a microphone, etc.), it can convert the content of the voice into text information and input the text information into the emotional dialogue engine to obtain the voice information to be replied.

[0031] Optionally, the electronic device can also obtain the current dialogue state, which may refer to dialogue turns, user scene information, user gender, age and other information, and input the current dialogue state information into the emotional dialogue engine so that the emotional dialogue engine can generate a dialogue based on the voice information to be replied and the dialogue state information.

[0032] Optionally, the electronic device can identify the gender and age of the user through an image acquisition device (such as a camera, etc.).

[0033] As another way, the emotional dialogue engine can be directly equipped with an information collection device, which can be used to collect audio, image, video and other information. After the user can input voice into the electronic device, the emotional dialogue engine can directly convert the content of the voice into text information and collect it into the current dialogue status.

[0034] S120: Based on the voice information to be replied, obtain the emotion type of the voice information to be replied and the reason for generating the emotion type.

[0035] As a way, Figure 3 As shown, based on the voice information to be replied, obtaining the emotion type of the voice information to be replied includes:

[0036] S121: Input the voice information to be replied into a first emotion classification model to obtain a first output result, wherein the first emotion classification model is a model pre-trained based on a first training data set, and the first training data set includes a plurality of pre-collected voice information that does not contain emotions and a plurality of voice information that contains emotions.

[0037] In the embodiment of the present application, as shown in Table 1, emotion types can be divided into positive emotion types, negative emotion types, ambiguous emotion types (ambiguous emotion types may refer to emotion types that appear as positive emotions in some scenarios and as negative emotions in other scenarios, or emotion types with ambiguous attitudes) and neutral emotion types (neutral emotion types may refer to emotions that are neither negative nor positive), among which positive emotions, negative emotions, ambiguous emotions, and neutral emotions each correspond to at least one fine-grained emotion type.

[0038] Table 1

[0039]

[0040]

[0041] In the embodiment of the present application, by constructing a fine-grained emotion labeling system covering more than 50 emotion types, a refined understanding of user emotions can be achieved.

[0042] As a method, the training method of the first emotion classification model can be: obtaining a first training data set, the first training data set can include multiple pre-collected voice information that does not contain emotions and multiple voice information that contains emotions; training the first emotion classification model to be trained based on the first training data set to obtain the first emotion classification model.

[0043] The speech information without emotion may refer to the speech information with neutral emotion (Query); the speech information with emotion may refer to the speech information with positive emotion, ambiguous emotion or negative emotion. The first emotion classification model to be trained may be a FastText model.

[0044] As a method, the emotion recognition unit in the emotional dialogue engine can input the voice information to be replied into the first emotion classification model to obtain a first output result, and the first output result can represent whether the voice information to be replied contains emotion.

[0045] S122: If the first classification result indicates that the voice information to be replied does not contain any emotion, determine that the emotion type is neutral.

[0046] As a method, if the first classification result indicates that the voice information to be replied does not contain any emotion, the emotion recognition unit may determine that the emotion type of the voice information to be replied is neutral.

[0047] S123: If the first classification result indicates that the voice information to be replied contains emotions, the voice information to be replied is input into the second emotion classification model to obtain a second output result, wherein the second emotion classification model is a model pre-trained based on a second training data set, and the second training data set includes multiple pre-collected voice information and emotion type labels corresponding to the multiple voice information.

[0048] The second output result may include the predicted emotion type and a confidence score corresponding to the predicted emotion type, and the confidence score may represent the probability that the emotion type of the voice information to be replied is the predicted emotion type.

[0049] As a method, if the first classification result represents that the voice information to be replied contains emotions, the emotion recognition unit in the emotional dialogue engine can input the voice information to be replied into the second emotion classification model to obtain a second output result, and the second output result can be the predicted emotion type of the voice to be replied.

[0050] In an embodiment of the present application, the training method of the second emotion classification model is: obtain a second training data set, which may include multiple pre-collected voice information and emotion type labels corresponding to the multiple voice information; obtain a pre-trained emotion classification model, which is pre-trained based on a target domain data set; perform data enhancement processing on the multiple voice information based on a prompt learning method to obtain processed training data; train the pre-trained emotion classification model based on the processed training data to obtain a second emotion classification model.

[0051] The second training data set may be a plurality of speech messages containing emotions in the first training data set, or may be speech messages with labels different from those of the first training data set, such as positive emotions, ambiguous emotions, or negative emotions. The target domain data set may refer to a data set with the same application scenario as the emotional dialogue engine, and the data set may contain speech messages with labels of positive emotions, ambiguous emotions, or negative emotions. The pre-trained emotion classification model may refer to a BERT model.

[0052] Optionally, voice data can be collected in the same application scenario as the emotional dialogue engine, and corresponding labels can be attached to the collected voice data through manual annotation or automatic annotation followed by manual calibration to obtain a target domain data set.

[0053] In an embodiment of the present application, prompt learning can convert the text classification task into a classification prediction task of constructing a mask in a prompt, use the pre-trained vector of the word to be predicted to initialize the classifier parameters, and make full use of the features and label text learned by the pre-trained language model, thereby reducing the sample size requirement. For example, the Prompt input can be: [CLS] I was praised by the teacher today [SEP] The emotion type is [MASK][MASK][SEP], and the model output can be: [CLS] Happy [SEP]. For another example, the Prompt input can be: [CLS] I was scolded by the teacher today [SEP] The emotion type is [MASK][MASK][SEP], and the model output can be: [CLS] Sad [SEP].

[0054] In the embodiment of the present application, the pre-trained emotion classification model is obtained through the target domain data set, which can improve the accuracy of the pre-trained emotion classification model in the corresponding application scenario of the dialogue generation method proposed in the present application. In addition, the pre-trained emotion classification model is re-trained by the prompt learning method, so that when a small amount of training data is used for model training, a higher accuracy can be achieved, thereby reducing the annotation cost and collection cost of the training data.

[0055] S124: Obtain the emotion type based on the second output result.

[0056] As a method, if the confidence score corresponding to the predicted emotion type is less than a preset value, the emotion recognition unit can input the voice information to be replied into the sentence recognition model and the implicit emotion reasoning model respectively to obtain a third output result and a fourth output result, the third output result can characterize the sentence type of the voice information to be replied, and the fourth output result can characterize whether there is indirect emotion expression in the voice information to be replied, wherein the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set may include multiple pre-collected voice information and sentence type labels corresponding to the multiple voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set may include multiple knowledge base data for describing events; based on the second output result, the third output result and the fourth output result, the emotion type is obtained; if the confidence score is greater than or equal to the preset value, the predicted emotion type is used as the emotion type.

[0057] The sentence recognition model may be a transformer type model. As shown in Table 2, the sentence type labels corresponding to the third training data set may include negative sentences, affirmative sentences, declarative sentences, and interrogative sentences.

[0058] Table 2

[0059] Voice Message Sentence Type I'm not happy at all Negative Sentences I'm not thinking about you Negative Sentences I like you so much declarative sentence Do I like you? Questions

[0060] Among them, the implicit sentiment reasoning model can be a generative model, such as a GPT (Generative Pre-training Transformer) model, a GPT2 model, etc. The fourth training data set can be a ConceptNet data set and an ATOMIC data set. The ConceptNet data set and the ATOMIC data set are event graphs, which contain many event reasoning triples, for example, "If PersonX praises PersonY, then PersonY is likely to return PersonX's praise". The ConceptNet data set and the ATOMIC data set also contain reasoning that represents sentiment attributes, such as: "PersonX puts his arm on Y, then PersonX is expressing caring."

[0061] For example, Figure 4 As shown in the figure, the implicit emotion reasoning model can infer based on "I broke up with my girlfriend" that the breakup event usually occurs after "I went on a date with my girlfriend", and the person involved will also feel "sad" and want to "cry".

[0062] In an embodiment of the present application, by combining the knowledge graph and the generative pre-trained model to realize emotional reasoning of events, the user's feelings can be understood more deeply, thereby improving the user experience.

[0063] As shown in Table 3, the fourth output result may include whether the voice information to be replied is an explicit emotion or an implicit emotion, and the corresponding emotion label content.

[0064] Table 3

[0065] Semantic Information Emotional Type Emotional tags I'm so sad. I was late for school today. Explicit Emotion sadness I failed my driving test again. Negative implicit emotion sadness I got 95 points in the test Positive implicit emotion Happy, proud I didn't go shopping No emotions neutral

[0066] In an embodiment of the present application, when the second emotion recognition model cannot accurately identify the voice information to be replied, the emotion type can be obtained based on the second output result, the third output result and the fourth output result, thereby improving the accuracy of emotion recognition of the voice information to be replied. For example: the voice information to be replied is: "I failed the driving test again." The second output result obtained by the second classification emotion recognition model is: {predicted emotion type: anger, confidence score: 60%}, the preset value can be 80%, at this time the confidence score is less than the predicted value, then the voice information to be replied can be input into the sentence recognition model and the implicit emotion reasoning model respectively, and the third output result is a negative sentence, and the fourth output result is a negative implicit emotion: sadness, so that the emotion type can be obtained as sadness based on the second output result, the third output result and the fourth output result.

[0067] Optionally, the preset value may be obtained based on multiple test results.

[0068] As another way, the emotion recognition unit can input the voice information to be replied into the sentence recognition model and the implicit emotion reasoning model respectively to obtain a third output result and a fourth output result. The third output result can characterize the sentence type of the voice information to be replied, and the fourth output result can characterize whether there is indirect emotion expression in the voice information to be replied. Among them, the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set includes multiple pre-collected voice information and sentence type labels corresponding to the multiple voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set includes multiple knowledge base data for describing events; based on the second output result, the third output result and the fourth output result, the emotion type is obtained.

[0069] In an embodiment of the present application, the accuracy of emotion recognition of the voice information to be replied can be improved by combining the output results of multiple models to obtain the emotion type of the nursery store to be replied.

[0070] In an embodiment of the present application, in order to generate conversation content that meets the user's expectations, the emotion recognition unit may further explore the reasons why the user has the corresponding emotions.

[0071] As a method, the emotion recognition model can input the voice information to be replied into the relational extraction model to obtain the reasons for the corresponding emotions. The relational extraction model can be a model trained by the fifth training data set based on the UIE (Universal Information Extraction) framework. The fifth training data set can include multiple voice messages and the reasons for the emotions corresponding to the multiple voice messages.

[0072] Among them, the UIE framework can be used for unified modeling of tasks such as entity extraction, relationship extraction, event extraction, and sentiment analysis, and has good migration and generalization capabilities between different tasks. The UIE framework can output good recognition results with a small amount of training data, and has universality, effectiveness, and transferability. The relationship extraction model can be a generative model, such as the GPT model, the GPT2 model, etc. The fifth training data set can be shown in Table 4.

[0073] Table 4

[0074] Voice Message Emotional Type Reasons for the corresponding emotion type I'm so tired. I have too much homework. tired Too much homework I'm so sad because I'm heartbroken. sadness Broken Heart I miss my mom when I'm working away from home. miss Working outside I can't sleep after drinking coffee. I feel so depressed. sadness Drink coffee

[0075] For example, the voice to be replied may be “Oh, my stomach hurts so much”, and the output result of the relationship extraction model may be: “[{'negative emotion event trigger words':[{'text':'uncomfortable','start':8,'end':10,'probability':0.2875420006093634,'relations':{'body':[{'text':'stomach','start':4,'end':6,'probability':0.47138602957381437}],'organs':[{'text':'stomach','start':4,'end':6,'probability':0.6592295077851027}]}}]}]”, thereby obtaining the reason for the corresponding emotion type as stomach discomfort.

[0076] Optionally, the emotion recognition unit may also input the voice information to be replied into the safe opinion discrimination model to obtain an emotion triplet, which may include the opinion object in the voice information to be replied, the emotional tendency towards the opinion object, and the emotional expression towards the opinion object.

[0077] Among them, the security opinion discrimination model can also be a generative model for information extraction based on the UIE framework.

[0078] For example, when the voice to be replied is: "I like Xiao Ming", the security opinion discrimination model can extract: {like, positive emotion, Xiao Ming}. For another example, when the voice to be replied is: "I like to eat watermelon, but don't like to eat durian", the security opinion discrimination model can extract: {like, positive emotion, watermelon} and {dislike, negative emotion, durian}.

[0079] In the embodiment of the present application, by extracting emotional triples from the reply speech, the user's preferences can be further understood, so that content that the user does not like to talk about can be avoided in subsequent conversations, thereby improving the user experience.

[0080] Optionally, after the emotional engine generates the dialogue, the dialogue can also be input into the safe opinion discrimination model. When the emotional triplet of the dialogue is an unsafe opinion (such as swearing, talking about content that the user is taboo, etc.), a new dialogue with safe opinions can be regenerated.

[0081] S130: Based on the voice message to be replied, the emotion type and the reason, a dialogue corresponding to the voice message to be replied is generated.

[0082] As one approach, the voice message to be replied, the emotion type of the voice message to be replied, and the reason for the corresponding emotion type may be input into the empathy response unit to generate a dialogue corresponding to the voice message to be replied.

[0083] As another way, when the emotional dialogue engine also obtains the current dialogue status, the voice information to be replied, the current dialogue status, the emotion type of the voice information to be replied and the reason for the corresponding emotion type can be input into the empathy response unit to generate a dialogue corresponding to the voice information to be replied.

[0084] As another way, when the emotion triplet is extracted from the voice to be replied, the voice information to be replied, the emotion type of the voice information to be replied, the reason for the corresponding emotion type and the emotion triplet can be input into the empathy response unit to generate a dialogue corresponding to the voice information to be replied.

[0085] The present embodiment provides a method for generating a dialogue. After obtaining a voice message to be replied, the method obtains the emotion type of the voice message to be replied and the reason for the emotion type based on the voice message to be replied, and generates a dialogue corresponding to the voice message to be replied based on the voice message to be replied, the emotion type and the reason. Through the above method, the emotion type of the voice message to be replied and the reason for the emotion type can be obtained based on the voice message to be replied, and then the dialogue corresponding to the voice message to be replied can be generated based on the voice message to be replied, the emotion type and the reason for the emotion type. By mining the reasons why the user generates the corresponding emotion type, the user's emotions can be more deeply perceived, so that a dialogue that better meets the user's expectations can be generated based on the voice message to be replied, the emotion type and the reason for the emotion type, thereby improving the user experience.

[0086] See also Figure 5 The present application provides a method for generating a dialogue, which is applied to an emotional dialogue engine. The method comprises:

[0087] S210: Acquire the voice message to be replied.

[0088] S220: Based on the voice information to be replied, obtain the emotion type of the voice information to be replied and the reason for generating the emotion type.

[0089] S230: Based on the emotion type, an empathy strategy type is obtained, where the empathy strategy type is any one of inquiry, recognition, suggestion, gratitude, disagreement, expression of opinion, encouragement and comfort, and self-disclosure.

[0090] In the embodiments of the present application, empathy can include two aspects. The first aspect can be affective empathy, that is, detecting and simulating user emotions; the second aspect is cognitive empathy, that is, understanding the user's situation and feelings. In order to deeply understand the user's emotions and the reasons behind them, such as Figure 6 As shown, the framework for emotional support in psychology is usually divided into exploration, understanding and comfort, and action and suggestion. Based on the three stages in psychology, this application sets up eight empathy strategies: inquiry, recognition, suggestion, gratitude, disagreement, expression of opinion, encouragement and comfort, and self-disclosure, so that the emotional dialogue engine can understand and perceive the user's situation and feelings, thereby greatly improving the user's dialogue experience and dialogue continuity, and creating a more deeply rooted emotional interactive experience. Especially in some negative emotional dialogue scenarios, it has the ability to respond with empathy and empathy, and can give deeply rooted soothing replies, which resonates with users.

[0091] As a method, the empathy response unit can determine the empathy strategy type based on a preset mapping relationship between the emotion type and the empathy strategy. For example, when the emotion type is sadness, an inquiry strategy can be adopted to ask why the person is sad.

[0092] As another approach, the empathy response unit can automatically generate corresponding empathy strategy types directly based on the emotion type. In this approach, the generation model can be trained based on a large amount of sample data that characterizes the mapping relationship between emotion types and empathy strategies, so that the empathy response unit has the ability to automatically generate corresponding empathy strategy types directly based on emotion types.

[0093] S240: Obtain empathy response information based on the voice information to be replied, the reason, and the empathy strategy type.

[0094] Among them, empathy response information can refer to the content and tone of the conversation.

[0095] As a method, the empathy response unit can obtain empathy response information based on the voice information to be replied, the reason and the empathy strategy type.

[0096] For example, the voice message to be replied may be "I am heartbroken", the reason may be heartbreak, the empathy strategy type may be inquiry, and the empathy response message may be in a questioning tone, and the content of the conversation may be "What's going on?" or "Did anything happen to you?".

[0097] Exemplarily, as shown in Table 5, the following dialogue content may also be generated.

[0098] Table 5

[0099] Empathy strategy types Example of conversation content ask What's going on? | What happened to you? Identification Well, what you said makes sense. suggestion If you are in a bad mood, going out for a walk may help. grateful Thank you! Disagree You can be sad, but you can't be like this forever Express your opinion I think... Encourage, comfort Come on, I believe you can do it. Self-disclosure I've had this experience before...

[0100] S250: Generate the dialogue based on the empathy response information.

[0101] As a way, the empathy response unit can output the empathy response unit information to the corresponding application driving unit to generate a dialogue.

[0102] Optionally, the empathy response unit may obtain target timbre information, and generate a dialogue based on the empathy response information and the target timbre.

[0103] Among them, the target timbre can be one of the timbre of a heartwarming female voice, a spirited girl, a clever male voice, a funny child's voice, etc.

[0104] Optionally, the target timbre may be predetermined by the user based on his or her own preferences, or may be a default setting by the emotional dialogue engine, or may be determined by the emotional dialogue engine based on empathy response information.

[0105] The present embodiment provides a method for generating a dialogue, which can first obtain the emotion type of the voice information to be replied and the reason for the emotion type based on the voice information to be replied, and then generate a dialogue corresponding to the voice information to be replied based on the voice information to be replied, the emotion type and the reason for the emotion type. By mining the reasons why the user generates the corresponding emotion type, the user's emotions can be more deeply perceived, so that a dialogue that better meets the user's expectations can be generated based on the voice information to be replied, the emotion type and the reason for the emotion type, thereby improving the user experience. In addition, in the present embodiment, empathy response information can be generated based on the voice information to be replied, the emotion type and the reason for the corresponding emotion type, and then a dialogue is generated based on the empathy response information, which can improve the user experience.

[0106] See also Figure 7 The present application provides a dialogue generation device 600, which runs on an emotional dialogue engine. The device 600 includes:

[0107] The voice information acquisition unit 610 is used to acquire the voice information to be replied.

[0108] The emotion recognition unit 620 is used to obtain the emotion type of the voice information to be replied and the reason for generating the emotion type based on the voice information to be replied.

[0109] The dialogue generation unit 630 is used to generate a dialogue corresponding to the voice information to be replied based on the voice information to be replied, the emotion type and the reason.

[0110] As a method, the emotion recognition unit 620 is specifically used to input the voice information to be replied into a first emotion classification model to obtain a first output result, wherein the first emotion classification model is a model pre-trained based on a first training data set, and the first training data set includes a plurality of pre-collected voice information that does not contain emotions and a plurality of pre-collected voice information that contains emotions; if the first classification result represents that the voice information to be replied does not contain emotions, the emotion type is determined to be neutral; if the first classification result represents that the voice information to be replied contains emotions, the voice information to be replied is input into the second emotion classification model to obtain a second output result, and the second emotion classification model is a model pre-trained based on a second training data set, and the second training data set includes a plurality of pre-collected voice information and emotion type labels corresponding to the plurality of voice information; the emotion type is obtained based on the second output result.

[0111] Among them, the second output result includes a predicted emotion type and a confidence score corresponding to the predicted emotion type, and the confidence score represents the probability that the emotion type of the voice information to be replied is the predicted emotion type. Optionally, the emotion recognition unit 620 is specifically used to input the voice information to be replied into a sentence recognition model and an implicit emotion reasoning model respectively if the confidence score is less than a preset value, to obtain a third output result and a fourth output result, and the third output result represents the sentence type of the voice information to be replied, and the fourth output result represents whether there is indirect emotion expression in the voice information to be replied, wherein the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set includes multiple pre-collected voice information and sentence type labels corresponding to the multiple voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set includes multiple knowledge base data for describing events; based on the second output result, the third output result and the fourth output result, the emotion type is obtained; if the confidence score is greater than or equal to the preset value, the predicted emotion type is used as the emotion type.

[0112] Optionally, the emotion recognition unit 620 is specifically used to input the voice information to be replied into a sentence recognition model and an implicit emotion reasoning model respectively to obtain a third output result and a fourth output result, wherein the third output result represents the sentence type of the voice information to be replied, and the fourth output result represents whether the voice information to be replied has indirect emotion expression, wherein the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set includes multiple pre-collected voice information and sentence type labels corresponding to the multiple voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set includes multiple knowledge base data for describing events; based on the second output result, the third output result and the fourth output result, the emotion type is obtained.

[0113] As a method, the emotion recognition unit 620 is specifically used to input the voice information to be replied into a relationship extraction model to obtain the reason. The relationship extraction model is a model obtained by training the fifth training data set based on the UIE framework. The fifth training data set includes multiple voice information and the reasons for generating emotions corresponding to the multiple voice information.

[0114] Optionally, the emotion recognition unit 620 is specifically used to input the voice information to be replied into the safety opinion discrimination model to obtain an emotion triplet, wherein the emotion triplet includes the opinion object in the voice information to be replied, the emotional tendency towards the opinion object, and the emotional expression towards the opinion object. The dialogue generation unit 630 is specifically used to generate the dialogue based on the voice information to be replied, the emotion type, the reason, and the emotion triplet.

[0115] As a method, the dialogue generation unit 630 is specifically used to obtain an empathy strategy type based on the emotion type, and the empathy strategy type is any one of inquiry, approval, suggestion, gratitude, disagreement, expression of opinion, encouragement and comfort, and self-disclosure; based on the voice information to be replied, the reason and the empathy strategy type, obtain empathy response information; based on the empathy response information, generate the dialogue.

[0116] Optionally, the dialogue generation unit 630 is specifically used to obtain target timbre information; and generate the dialogue based on the empathy response information and the target timbre information.

[0117] Wherein, the device further comprises:

[0118] The model training unit 640 is used to obtain a first training data set, wherein the first training data set includes a plurality of pre-collected voice information that does not contain emotions and a plurality of voice information that contains emotions; train a first emotion classification model to be trained based on the first training data set to obtain a first emotion classification model. A second training data set is obtained, wherein the second training data set includes a plurality of pre-collected voice information and emotion type labels corresponding to the plurality of voice information; obtain a pre-trained emotion classification model, wherein the pre-trained emotion classification model is pre-trained based on a target domain data set; perform data enhancement processing on the plurality of voice information based on a prompt learning method to obtain processed training data; train the pre-trained emotion classification model based on the processed training data to obtain a second emotion classification model.

[0119] Optionally, the emotion type is divided into a positive emotion type, a negative emotion type, a fuzzy emotion type and a neutral emotion type, wherein the positive emotion, the negative emotion, the fuzzy emotion and the neutral emotion each correspond to at least one fine-grained emotion type.

[0120] The following will be combined Figure 8 An electronic device provided by the present application is described.

[0121] See also Figure 8Based on the above-mentioned conversation generation method and device, the embodiment of the present application also provides another electronic device 100 that can execute the above-mentioned conversation generation method. The electronic device 100 includes a processor 102, a memory 104, and an audio acquisition device 106, wherein the memory 104 stores a program that can execute the content of the above-mentioned embodiment, and the processor 102 can execute the program stored in the memory 104.

[0122] Among them, the processor 102 may include one or more processing cores. The processor 102 uses various interfaces and lines to connect various parts within the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of a network processor (Neural network Processing Unit, NPU), a digital signal processing (Digital Signal Processing, DSP), a field programmable gate array (Field-Programmable Gate Array, FPGA), and a programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), a network processor (Neural network Processing Unit, NPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; the NPU is responsible for processing multimedia data such as video and images; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.

[0123] The memory 104 may include a random access memory (RAM), and may also include a read-only memory (RAM) and a double data rate synchronous dynamic random access memory (DDR). The memory 104 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the terminal 100 during use.

[0124] The audio collection device 106 is used to collect audio signals. Optionally, the audio collection device 106 includes a plurality of audio collection devices, which may be microphones.

[0125] Please refer to Fig. 9 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0126] The computer readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.

[0127] In summary, the present application provides a method, device and electronic device for generating a dialogue. After acquiring the voice information to be replied, the method, device and electronic device obtain the emotion type of the voice information to be replied and the reason for the emotion type based on the voice information to be replied, and generate a dialogue corresponding to the voice information to be replied based on the voice information to be replied, the emotion type and the reason. Through the above method, the emotion type of the voice information to be replied and the reason for the emotion type can be obtained based on the voice information to be replied, and then the dialogue corresponding to the voice information to be replied can be generated based on the voice information to be replied, the emotion type and the reason for the emotion type. By mining the reasons why the user generates the corresponding emotion type, the user's emotions can be perceived more deeply, so that a dialogue that better meets the user's expectations can be generated based on the voice information to be replied, the emotion type and the reason for the emotion type, thereby improving the user experience.

[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for generating a dialogue, characterized in that: Applied to an emotional dialogue engine, the method includes: Get the voice message to be replied; Based on the voice information to be replied, obtaining the emotion type of the voice information to be replied and the reason for generating the emotion type; Based on the voice information to be replied, the emotion type and the reason, a dialogue corresponding to the voice information to be replied is generated.

2. The method according to claim 1, characterized in that The obtaining, based on the voice information to be replied, the emotion type of the voice information to be replied, comprises: Inputting the voice information to be replied into a first emotion classification model to obtain a first output result, wherein the first emotion classification model is a model pre-trained based on a first training data set, and the first training data set includes a plurality of pre-collected voice information without emotions and a plurality of voice information containing emotions; If the first classification result indicates that the voice information to be replied does not contain any emotion, determining that the emotion type is neutral; If the first classification result indicates that the voice information to be replied contains emotion, inputting the voice information to be replied into the second emotion classification model to obtain a second output result, wherein the second emotion classification model is a model pre-trained based on a second training data set, and the second training data set includes a plurality of pre-collected voice information and emotion type labels corresponding to the plurality of voice information; The emotion type is obtained based on the second output result.

3. The method according to claim 2, characterized in that The second output result includes a predicted emotion type and a confidence score corresponding to the predicted emotion type, wherein the confidence score represents a probability that the emotion type of the voice information to be replied is the predicted emotion type, and obtaining the emotion type based on the second output result includes: If the confidence score is less than a preset value, the voice information to be replied is respectively input into a sentence recognition model and an implicit emotion reasoning model to obtain a third output result and a fourth output result, wherein the third output result represents the sentence type of the voice information to be replied, and the fourth output result represents whether there is indirect emotion expression in the voice information to be replied, wherein the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set includes a plurality of pre-collected voice information and sentence type labels corresponding to the plurality of voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set includes a plurality of knowledge base data for describing events; Based on the second output result, the third output result and the fourth output result, obtaining the emotion type; If the confidence score is greater than or equal to the preset value, the predicted emotion type is used as the emotion type.

4. The method according to claim 2, characterized in that: The obtaining the emotion type based on the second output result includes: The voice information to be replied is respectively input into a sentence recognition model and an implicit emotion reasoning model to obtain a third output result and a fourth output result, wherein the third output result represents the sentence type of the voice information to be replied, and the fourth output result represents whether there is indirect emotion expression in the voice information to be replied, wherein the sentence recognition model is a model pre-trained based on a third training data set, and the third training data set includes a plurality of pre-collected voice information and sentence type labels corresponding to the plurality of voice information; the implicit emotion reasoning model is a model pre-trained based on a fourth training data set, and the fourth training data set includes a plurality of knowledge base data for describing events; The emotion type is obtained based on the second output result, the third output result and the fourth output result.

5. The method according to claim 1, characterized in that The obtaining the reason for generating the emotion type based on the voice information to be replied includes: The voice information to be replied is input into a relation extraction model to obtain the reason. The relation extraction model is a model trained based on the UIE framework of the fifth training data set. The fifth training data set includes multiple voice messages and the reasons for generating emotions corresponding to the multiple voice messages.

6. The method according to claim 5, characterized in that The method further comprises: Inputting the voice information to be replied into a safe opinion discrimination model to obtain an emotion triplet, wherein the emotion triplet includes an opinion object in the voice information to be replied, an emotional tendency toward the opinion object, and an emotional expression toward the opinion object; The generating a dialogue corresponding to the voice message to be replied based on the voice message to be replied, the emotion type and the reason includes: The dialogue is generated based on the voice information to be replied, the emotion type, the reason and the emotion triplet.

7. The method according to claim 1, characterized in that The generating, based on the language information, the emotion type and the reason, a dialogue corresponding to the voice message to be replied includes: Based on the emotion type, an empathy strategy type is obtained, where the empathy strategy type is any one of inquiry, recognition, suggestion, gratitude, disagreement, expression of opinion, encouragement and comfort, and self-disclosure; Obtaining empathy response information based on the voice information to be replied, the reason and the empathy strategy type; Based on the empathy response information, the dialogue is generated.

8. The method according to claim 7, characterized in that Generating the dialogue based on the empathy response information further includes: Get target timbre information; The dialogue is generated based on the empathy response information and the target timbre information.

9. The method according to claim 1, characterized in that: Before obtaining the voice message to be replied, it also includes: Acquire a first training data set, wherein the first training data set includes a plurality of pre-collected voice information not containing emotions and a plurality of voice information containing emotions; The first emotion classification model to be trained is trained based on the first training data set to obtain a first emotion classification model. Acquire a second training data set, where the second training data set includes a plurality of pre-collected voice information and emotion type labels corresponding to the plurality of voice information; Obtaining a pre-trained emotion classification model, wherein the pre-trained emotion classification model is pre-trained based on a target domain dataset; Performing data enhancement processing on the plurality of voice information based on a prompt learning method to obtain processed training data; The pre-trained emotion classification model is trained based on the processed training data to obtain a second emotion classification model.

10. The method according to any one of claims 1 to 9, characterized in that: The emotion types are divided into positive emotion types, negative emotion types, ambiguous emotion types and neutral emotion types, wherein the positive emotion, the negative emotion, the ambiguous emotion and the neutral emotion each correspond to at least one fine-grained emotion type.

11. A dialogue generation device, characterized in that: Running on an emotional dialogue engine, the device includes: A voice information acquisition unit, used to acquire the voice information to be replied; An emotion recognition unit, used for obtaining the emotion type of the voice information to be replied and the reason for generating the emotion type based on the voice information to be replied; The dialogue generation unit is used to generate a dialogue corresponding to the voice information to be replied based on the voice information to be replied, the emotion type and the reason.

12. An electronic device, characterized in that: including one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is run, the method according to any one of claims 1 to 10 is executed.

Citation Information

Patent Citations

  • Speech synthesis method and related equipment

    CN108962217A

  • Providing a summary of a multimedia document in a session

    CN110325982A

  • Text-based emotion recognition method, terminal equipment and medium

    CN110377733A

  • Method for determining credibility of network information based on sentiment analysis

    CN111597796A

  • Voice generation method and device, storage medium and electronic equipment

    CN112185389A

Cited By

  • Dialogue processing method and apparatus, computing device, and storage medium

    WO2026194401A1