Emotional dialogue generation method and device, computer equipment and storage medium

By conducting semantic analysis and emotional label extraction on natural language text, combining emotional attributes and semantic analysis results, generating emotional labels and inputting the second model, the problem that large language models are difficult to understand emotions in chatbots is solved, and simplified operations and Methods to improve emotional processing effects.

CN118916466AActive Publication Date: 2024-11-08MIND WITH HEART ROBOTICS CO LTD

Patent Information

Application Number
CN202411173559.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-11-08
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

The existing large language models are difficult to understand and process emotional information in user conversations in the field of chat robots, lack empathy, and the existing technology requires users to input emotional tags and prompt words, which are complex in operation and poor in effect.

Method used

By obtaining natural language text, the first model is used for semantic analysis and emotional label extraction, combining emotional attributes and semantic analysis results, the emotional label is generated, and the natural language text, semantic analysis results and emotional labels are input to the second model to generate the same Response text of rationality.

Benefits of technology

It simplifies operation steps, reduces engineering difficulty, and can generate emotionally related response texts without requiring guiding prompt words, improving the effect of emotional processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916466A_ABST
    Figure CN118916466A_ABST
Patent Text Reader

Abstract

The invention discloses an emotional dialogue generation method and device, computer equipment and a storage medium. The method comprises the steps of obtaining a natural language text to be processed; inputting a to-be-processed natural language text into the first model for processing, and outputting to obtain a semantic analysis result and an emotion tag; and inputting the to-be-processed natural language text, the semantic analysis result and the emotion tag into a second model for processing, so as to output and obtain a final natural language text responding to the to-be-processed natural language text. When the method is applied, a user only needs to input a section of natural language text, a text data result which has the same principle and can respond to the input of the user in emotion can be finally output, and it is not needed that in the prior art, guiding prompt words or instructions need to be input to extract and excite existing emotion processing content in a model; compared with the prior art, the operation steps are effectively simplified, and the implementation difficulty in engineering is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and more specifically to an emotional dialogue generation method, device, computer equipment and storage medium. Background Art

[0002] Large language models are widely used in related fields of artificial intelligence. In the field of chatbots, large language models are used to analyze and understand the language conversation content of human users, and after a large amount of data processing, output human language conversation results containing specific useful content to users. So far, people have developed a variety of large language models for different scenarios, including medical, legal, and computer, but they all lack the ability to empathize with the emotions in user conversations, and it is difficult to generate empathetic results that can provide emotional support to users.

[0003] In order to enable the large language model to understand and process emotional information, it is generally necessary to input guiding prompt words or instructions into the existing large language model to extract and stimulate the existing emotional processing content in the model. The operation steps are relatively complicated and the workload is relatively large. In addition, due to the huge amount of data and rich content of the large language model itself, this method of using the large language model to partially understand the emotional information in the conversation content has a poor processing effect.

[0004] A Chinese patent, with the patent announcement number CN107943974A, discloses an automatic conversation method and system that takes emotions into consideration, by first obtaining the sentences and emotion tags input by the user at the same time; then determining the current semantics and emotions of the user; based on a preset conversation model, determining a reply that conforms to the user's current semantics and emotions according to the user's current semantics and emotions; and finally outputting the reply content. This solution requires the user to input both sentences and emotion tags at the same time, and the emotion tags input by the user will be used to directly input into the model for processing. Moreover, the reply sentences generated by the model include at least a first reply sentence, a second reply sentence, a third reply sentence, and multiple other sentences, and in its processing steps, these multiple reply sentences need to be used to be input into the model to process and analyze the emotions of the sentences.

[0005] The Chinese patent, with the patent announcement number CN108874972A, discloses a multi-round emotional dialogue method based on deep learning, which performs word segmentation on the text information input by the user and vectorizes the text through a pre-trained word vector model; uses a deep learning model to perform sentiment analysis on the text input by the user, and analyzes the conversation topic and background; retrieves the most likely dialogue response from the sentiment corpus based on a retrieval method; uses a generative adversarial network to generate natural dialogue responses based on the sentiment category of the user's dialogue, as well as the chat topic and background; selects a dialogue whose dialogue sentiment and topic background are most relevant to the user input and sends it to the user according to two different dialogue generation methods. In this scheme, the method of generating the reply text is to retrieve the most likely dialogue response from the sentiment corpus based on the processing result of the user's dialogue in a retrieval-based manner, and there are dialogues stored in advance in the corpus, and the existing dialogues in the corpus are indexed and annotated with emotions and subjects in advance. Summary of the invention

[0006] The purpose of the present invention is to overcome the deficiencies of the prior art and to provide a method, device, computer equipment and storage medium for generating emotional dialogue.

[0007] To achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present invention provides a method for generating an emotional dialogue, comprising: Obtaining natural language text to be processed; Inputting the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label; The natural language text to be processed, the semantic analysis results and the sentiment tags are input into the second model for processing to output a final natural language text that responds to the natural language text to be processed.

[0008] Furthermore, the step of inputting the natural language text to be processed into the first model for processing to output a semantic analysis result and a sentiment label includes: Perform sentiment analysis on the natural language text to be processed to obtain sentiment attribute results; Find words related to the emotional attribute results from the natural language text to be processed to obtain emotional keywords that can express emotions; Performing semantic analysis on the natural language text to be processed to obtain semantic analysis results; Combining the sentiment attribute results, sentiment keywords and semantic analysis results, sentiment labels are obtained.

[0009] Furthermore, the sentiment analysis process is performed on the natural language text to be processed to obtain a sentiment attribute result, including: Extract sentiment-related features from the natural language text to be processed; Perform sentiment attribute analysis on sentiment-related features to obtain sentiment attribute results.

[0010] Furthermore, searching for words related to the emotional attribute results from the natural language text to be processed to obtain emotional keywords that can express emotions includes: Perform multi-level analysis on the natural language text to be processed to identify keywords that may express emotions; Keywords related to emotional attribute results are selected from keywords that may express emotions as the final emotional keywords.

[0011] Furthermore, the semantic analysis of the natural language text to be processed to obtain a semantic analysis result includes: Perform word segmentation and grammatical analysis on the natural language text to be processed to identify the basic structure of the text; Analyze each word and its position in the text according to the basic structure of the text to obtain the position information of the word; The basic structure of the text and the position information of the words are analyzed and processed to obtain the semantic analysis results.

[0012] Furthermore, the combination of the emotion attribute results, emotion keywords and semantic analysis results to analyze and obtain emotion tags includes: Integrate the sentiment attribute results, sentiment keywords and semantic analysis results to obtain comprehensive sentiment description information; Identify emotional features based on comprehensive emotional description information; Match sentiment features with words from a built-in list of sentiment tags; According to the matching results, one or more emotion tags are selected from the emotion tag list.

[0013] Furthermore, the step of inputting the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing to output a final natural language text that responds to the natural language text to be processed includes: Set the starting point for text generation and construct the text word by word; Use emotional tags to adjust the emotional tone of each word generated; The generated text is checked based on the semantic analysis results to ensure that the generated text contains the core topics and intentions of the natural language text to be processed.

[0014] In a second aspect, the present invention further provides an emotional dialogue generating device, comprising: An acquisition unit, used for acquiring a natural language text to be processed; A first model processing unit, used for inputting the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label; The second model processing unit is used to input the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing, so as to output the final natural language text that responds to the natural language text to be processed.

[0015] In a third aspect, the present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for generating emotional dialogue when executing the computer program.

[0016] In a fourth aspect, the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the emotional dialogue generation method as described above.

[0017] Compared with the prior art, the beneficial effects of the present invention are: an emotional dialogue generation method, comprising: obtaining a natural language text to be processed; inputting the natural language text to be processed into a first model for processing to output a semantic analysis result and an emotional tag; inputting the natural language text to be processed, the semantic analysis result and the emotional tag into a second model for processing to output a final natural language text that responds to the natural language text to be processed. When the present invention is applied, it only requires the user to input a natural language text, and it can finally output a text data result that is empathetic and can respond to the user's input emotionally. It does not need to input guiding prompt words or instructions to extract and stimulate the existing emotional processing content in the model as in the prior art. Compared with the prior art, it effectively simplifies the operation steps and reduces the difficulty of engineering implementation.

[0018] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0020] Figure 1A main flow chart of a method for generating emotional dialogue provided by a specific embodiment of the present invention; Figure 2 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 1 ; Figure 3 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 2 ; Figure 4 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 3 ; Figure 5 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 4 ; Figure 6 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 5 ; Figure 7 A sub-process of an emotional dialogue generation method provided by a specific embodiment of the present invention Figure 6 ; Figure 8 A schematic block diagram of an emotional dialogue generating device provided in a specific embodiment of the present invention; Fig. 9 A schematic block diagram of a computer device provided for a specific embodiment of the present invention. DETAILED DESCRIPTION

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

[0022] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0023] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0024] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0025] The technical terms related to the present invention are explained as follows: Deep learning: a branch of machine learning, which is an algorithm that uses a multi-layer artificial neural network as a framework to learn features of data; Machine learning: is a method to achieve artificial intelligence. Its main content is to design some algorithms that allow computers to automatically analyze and obtain patterns from data, and use the patterns to predict unknown data; Artificial neural network: referred to as neural network, in the field of machine learning, it is a mathematical model or computational model designed to imitate the structure and function of the neural network of an organism, used to implement an algorithm for estimating or approximating mathematical functions; Natural language: Natural language mainly refers to the language that humans usually use for communication. This term is generally used to distinguish it from computer language.

[0026] The present invention is described below by means of specific embodiments.

[0027] like Figure 1 As shown, the embodiment of the present invention provides a method for generating an emotional dialogue, comprising the following steps: S10-S30: S10, obtaining a natural language text to be processed; The natural language text to be processed is generally input by the user, for example, the user input: I tried to bake a sausage cheesecake last night, but it tasted terrible; S20, inputting the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label; A large language model refers to a deep learning model trained based on massive text data. It can process various natural language texts, deeply understand the meaning of the text, and generate natural language text as a result. The first model is a large language model, which can imitate human thinking to perform sequential reasoning. It can analyze the user's text input to obtain the emotion the user wants to express.

[0028] like Figure 2 As shown, in one embodiment, step S20 specifically includes the following steps: S201-S204: S201, performing sentiment analysis on the natural language text to be processed to obtain sentiment attribute results; For this step, the main goal is to perform sentiment analysis on the text data input by the user to determine the emotional attributes expressed by the text, that is, the positivity or negativity of the emotion. The principle of obtaining the emotional attribute result is that a large amount of text data is used to perform deep learning training on the first model before use. These data sets usually contain text samples with various different emotional labels, such as positive, negative or neutral text. The training results are saved in a neural network with a large number of parameters. The input text data is processed by the neural network and can output an emotional attribute result, which can represent the degree of positivity or negativity of the emotional attribute of the text data.

[0029] like Figure 3 As shown, in one embodiment, step S201 specifically includes the following steps: S2011-S2012: S2011, extracting sentiment-related features from the natural language text to be processed; S2012, performing sentiment attribute analysis on the sentiment-related features to obtain sentiment attribute results; For steps S2011-S2012, when actually using it, the user inputs a natural language text, such as a paragraph or a sentence. This text is input into the first model that has been trained. The neural network of the first model will process this input text and extract the emotion-related features therein. After layer-by-layer processing by the neural network, the model will eventually output an emotion attribute result. This result is usually a probability distribution, indicating the tendency of the input text towards positive or negative emotions. For example, the model may output two numerical values, representing the probability of "positive" and the probability of "negative". If the probability of positive is higher, it means that the input text is more inclined to express positive emotions, and vice versa. The output emotion attribute result can be used directly in subsequent steps. For example, in the first model, this emotion attribute result will be passed to the next step (such as keyword extraction, semantic analysis, etc.) or used as one of the inputs for the subsequent generation of empathetic answers; S202, searching for words related to the emotional attribute result from the natural language text to be processed to obtain emotional keywords that can express emotions; For this step, the goal is to identify emotion-related keywords from the text input by the user. These keywords are usually important clues to express the user's emotional state, such as "like", "hate", "angry", etc. The principle of obtaining the emotional attribute results is: a large amount of text data is used to perform deep learning training on the first model, and the training results are saved in a neural network with a large number of parameters. The input text data is processed by the neural network, and the first model can find one or more keywords from the text data. The keyword is a word in the sentence that can express the emotion expressed by the user.

[0030] like Figure 4 As shown, step S202 specifically includes the following steps: S2021-S2022: S2021. Perform multi-level analysis on the natural language text to be processed to identify keywords that may express emotions; S2022, selecting keywords related to the emotional attribute results from the keywords that may express emotions as the final emotional keywords; For steps S2021-S2022, the first model searches each word in the input text to determine whether it is related to a certain emotion. If a word is considered by the model to be an emotional keyword (for example, "like" represents positive emotion and "hate" represents negative emotion), then the word will be extracted and recorded as the output result of this step. The extraction process of these keywords depends on the knowledge learned by the model during training. Through its neural network parameters, the model can associate certain words in the input text with specific emotion categories, thereby identifying these words as emotional keywords. The identified keywords will be passed as intermediate results to subsequent processing steps (for example, selection of emotion tags, further analysis of emotion attributes, etc.); S203, performing semantic analysis on the natural language text to be processed to obtain a semantic analysis result; For this step, the main task is to perform semantic analysis on the text input by the user, understand the deep meaning of the text, and especially accurately describe the emotions expressed in the text through context. Analyze the semantic analysis results from the words and sentence structures (the semantic analysis results are a natural language text), and record the semantic analysis results as the output results of this step. The principle of obtaining the semantic analysis results is: a large amount of text data was previously used to perform deep learning training on the first model, and the training results were saved in a neural network with a large number of parameters. The input text data is processed by the neural network, and the first model can analyze the semantics of the text data and generate another natural language text. The main content of this text is to combine the context of the input text to deeply describe the emotions expressed in the input text.

[0031] like Figure 5 As shown, step S203 specifically includes the following steps: S2031-S2033: S2031. Perform word segmentation and grammatical analysis on the natural language text to be processed to identify the basic structure of the text; S2032, analyzing each word and the position of each word in the text according to the basic structure of the text to obtain the position information of the word; S2033: Analyze and process the basic structure of the text and the position information of the words to obtain a semantic analysis result.

[0032] For steps S2031-S2033, When a user inputs a natural language text, the first model will first perform word segmentation and syntactic analysis on the text to identify the basic structure of the sentence, such as subject, predicate, object, etc. The model will further analyze each word in the text and its position in the sentence, especially focusing on the impact of the context on the meaning of these words. For example, a word may express different emotions or semantics in different contexts. By analyzing the context, the first model can understand the deeper meaning of the entire sentence, rather than just looking at each word in isolation. For example, the model can distinguish the semantic difference between "I like you" and "I don't like you", even though they both contain the word "like". The first model will comprehensively consider the semantics of the word and the effect of the context on its emotion modification, and generate a more accurate semantic analysis result. This result not only describes the surface meaning of the text, but also reflects the deep emotion expressed by the context. After completing the context analysis, the model will generate a natural language text, which is a further explanation and description of the semantics and emotion of the input text; S204: Combine the sentiment attribute results, sentiment keywords and semantic analysis results to obtain sentiment labels.

[0033] For this step, one or more emotional tags that best match the emotional attributes, keywords, and semantic analysis results generated in the previous steps are selected from the built-in emotional tag list. The principle of obtaining emotional tags is that a large amount of text data has been used to perform deep learning training on the first model, and the training results are stored in a neural network with a large number of parameters. When the emotional attribute results, keywords, and semantic analysis results generated in the previous three steps are input into the first model, the first model integrates these data and processes them through the neural network. The model can select several words from the built-in natural language vocabulary list as emotional tags. These emotional tags are the words in the vocabulary list that best reflect the emotions in the text data input by the user.

[0034] like Figure 6 As shown, step S204 specifically includes the following steps: S2041-S2044: S2041, integrating the sentiment attribute results, sentiment keywords and semantic analysis results to obtain comprehensive sentiment description information; S2042, identifying emotional features based on comprehensive emotional description information; S2043, matching the sentiment feature with words in the built-in sentiment tag list; S2044, selecting one or more emotion tags from the emotion tag list according to the matching result; For steps S2041-S2044, the first model receives the results from the previous three steps: emotional attributes (such as positive or negative probability distribution), keywords (such as "like", "angry", etc.), and semantic analysis results (description of the deep meaning of the text). The first model integrates these input data together to form a comprehensive emotional description. This integration helps the model better understand the emotional state of the user input because these results reflect the emotional information in the text from different angles. The integrated data is input into the neural network of the first model for further processing. The hierarchical structure of the neural network allows the model to analyze the complex relationships between these data in a high-dimensional space. Through these processes, the model is able to identify the features that best represent the user's input emotions and match these features with the vocabulary in the built-in emotional tag list. Based on the matching results, the model selects one or more emotional tags from the built-in emotional tag list that best match the analysis results of the previous steps. These tags may include "happy", "angry", "sad", etc., depending on the model's vocabulary and the emotional features of the user input. The selected emotional tags are output as the final result, indicating that the first model has completed the understanding and classification of the emotions of the user input text; S30, inputting the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing, so as to output a final natural language text that responds to the natural language text to be processed; The second model is a large language model that can perform sequential reasoning in the same way as human thinking. It can analyze the user's text input to get the emotion the user wants to express. The input data of natural language text to be processed, semantic analysis results, and selected sentiment labels contain the original information of the user's input text and the model's understanding of its sentiment. The second model will use this information to generate a suitable response. The principle of being able to finally obtain natural language text is that a large amount of text data and sentiment analysis data have been used to train the second model for deep learning. The training results are stored in a neural network with a large number of parameters. The input text data, semantic analysis results, sentiment labels and other data are processed by the neural network, and finally a natural language text can be output. This text can respond to the text data input by the user in terms of text content and emotion in an empathetic way.

[0035] like Figure 7 As shown, in one embodiment, step S30 specifically includes the following steps: S301-S303: S301, setting a starting point for text generation, and constructing a text in a word-by-word generation manner; S302, using the emotion tag to adjust the emotional tone of each word; S303: Check the generated text according to the semantic analysis result to ensure that the generated text contains the core theme and intention of the natural language text to be processed.

[0036] The second model generates text in a word-by-word manner. Each step generates a word, and the next word is determined based on the current generated word sequence and the input sentiment and semantic information. The second model continuously uses the previous context (i.e., the words that have been generated and the input information) to adjust the generation of the next word. This mechanism ensures that the generated text is coherent and consistent. In each generated word, the second model adjusts its output based on the sentiment label. For example, when dealing with positive sentiment labels, the second model may tend to choose more positive vocabulary and sentence patterns to ensure that the final generated text can convey the expected sentiment. The second model uses the results of semantic analysis to ensure that the generated text is logically and semantically consistent with the user input. It achieves this goal by checking whether the generated text contains the core theme and intent of the input text and whether it responds to these contents in an appropriate way. Semantic consistency helps the model generate text that is not only emotionally appropriate, but also content-related to the topic of the user's communication. After a series of iterations and adjustments, the model generates a complete natural language text. This text is output as a response to the user's input.

[0037] It is worth noting that both the first model and the second model in the present invention have the following characteristics: both are based on the Transformer architecture, but compared with the traditional Transformer architecture, the model in the present invention only retains the Decoder module, omits the Encoder module, and uses RoPE position encoding on the Query matrix and the Key matrix, which is conducive to better capturing the sequential position information of the text.

[0038] In the working process of the thought chain model and the reply model in the present invention, the user inputs text data, which is processed by the model and finally outputs the result. The principle of this process is as follows: First, the tokenizer splits the sentence (text) into corresponding integer sequences according to the token table. Then, the embedding layer converts the integer sequence into digital vectors, which store the position information of each token in the semantic space. Then, the RMSNorm (root mean square layer normalization) component is responsible for normalizing the input vector data. The vectors processed by RMSNorm have the same scale and distribution, which helps the model converge faster during training. Before the self-attention layer, the rotational position encoding (RoPE) is applied to the query matrix and the key matrix to better capture the position information in the sequence and improve the expressiveness of the model. Then, the data passes through the self-attention layer; self-attention means that the data itself is used as both a query vector and a key vector; then the attention weight is calculated by matrix dot multiplication, where the query vector, key vector and value vector are all learnable weights. The obtained attention weight matrix will be matrix dot multiplied with the value matrix, and a Softmax operation will be performed to ensure that the sum of the matrix weights is 1 and the value of each weight is between 0 and 1. Finally, the output of the self-attention layer is obtained. After calculating the output of the self-attention mechanism, the model makes a residual connection with the input and then passes it to a feedforward neural network (FFN) to calculate the output; the feedforward neural network consists of two layers of linear transformation and an activation function, in which the input vector first passes through a linear transformation, then applies an activation function (such as SwiGLU), and finally another linear transformation to generate the final output vector. Finally, the vector is Softmaxed to obtain the probability of the next possible word, and the sum of the probabilities is 1. And so on, the result of the next word is obtained until the results of all words are calculated.

[0039] The processing of the present invention is specifically described below using an example: User input: I tried to bake a sausage cheesecake last night, but it tasted terrible. The sentiment attribute obtained by the first model is "negative", the keyword is "terrible", the semantic analysis result is "tried a bad-tasting baked good", and the sentiment label is "disgusted, sad". The second model, based on the user input, the semantic analysis result and sentiment label obtained by the first model, finally outputs "This sounds terrible, but remember: failure is the mother of success."

[0040] From the above examples, it can be seen that, using the method of the present invention, when a user inputs a natural language text, the method can ultimately output empathetic text data results that can emotionally respond to the user input. Unlike the prior art, it is not necessary to input guiding prompt words or instructions to extract and stimulate the existing emotional processing content in the model. Compared with the existing technology, the operation steps are effectively simplified and the difficulty of engineering implementation is reduced.

[0041] The embodiment of the present invention also provides an emotional dialogue generation device, which is used to perform the steps in any embodiment of the emotional dialogue generation method described above. Figure 8 , Figure 8 A schematic block diagram of an emotional dialogue generating device 100 provided in an embodiment of the present application is shown, and the emotional dialogue generating device 100 specifically includes: An acquisition unit 110 is used to acquire a natural language text to be processed; The first model processing unit 120 is used to input the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label.

[0042] In one embodiment, the first model processing unit 120 includes: The sentiment analysis module is used to perform sentiment analysis on the natural language text to be processed to obtain sentiment attribute results. The keyword search module is used to find words related to the sentiment attribute results from the natural language text to be processed to obtain sentiment keywords that can express emotions. The semantic analysis module is used to perform semantic analysis on the natural language text to be processed to obtain semantic analysis results. The sentiment tag processing module is used to combine the sentiment attribute results, sentiment keywords and semantic analysis results to analyze and obtain sentiment tags.

[0043] In one embodiment, the sentiment analysis module includes: The extraction submodule is used to extract emotion-related features from the natural language text to be processed. The emotion attribute analysis submodule is used to perform emotion attribute analysis on the emotion-related features to obtain emotion attribute results.

[0044] In one embodiment, the keyword search module includes: The multi-level analysis submodule is used to perform multi-level analysis on the natural language text to be processed to identify keywords that may express emotions. The screening submodule is used to screen out keywords related to emotional attribute results from keywords that may express emotions as the final emotional keywords.

[0045] In one embodiment, the semantic analysis module includes: The first recognition submodule is used to perform word segmentation and grammatical analysis on the natural language text to be processed to identify the basic structure of the text. The first analysis submodule is used to analyze each word and the position of each word in the text according to the basic structure of the text to obtain the position information of the word. The second analysis submodule is used to perform analysis and processing according to the basic structure of the text and the position information of the words to obtain the semantic analysis result.

[0046] In one embodiment, the emotion tag processing module includes: The integration submodule is used to integrate the sentiment attribute results, sentiment keywords and semantic analysis results to obtain comprehensive sentiment description information. The second identification submodule is used to identify sentiment features based on the comprehensive sentiment description information. The matching submodule is used to match the sentiment features with the words in the built-in sentiment tag list. The selection submodule is used to select one or more sentiment tags from the sentiment tag list based on the matching results.

[0047] The second model processing unit 130 is used to input the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing, so as to output a final natural language text that responds to the natural language text to be processed.

[0048] In one embodiment, the second model processing unit 130 includes: The setting module is used to set the starting point of text generation and construct the text in a word-by-word manner. The adjustment module is used to use the sentiment tag to adjust the sentiment tone of each word. The detection module is used to check the generated text based on the semantic analysis results to ensure that the generated text contains the core theme and intention of the natural language text to be processed.

[0049] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the above-mentioned emotional dialogue generation device 100 and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0050] The above-mentioned emotional dialogue generating device can be implemented in the form of a computer program, and the computer program can be used in Fig. 9 Runs on the computer device shown.

[0051] See also Fig. 9 , Fig. 9 700 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 700 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.

[0052] like Fig. 9 As shown, the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the emotional dialogue generation method as described above are implemented.

[0053] The computer device 700 may be a terminal or a server. The computer device 700 includes a processor 720 , a memory, and a network interface 750 connected via a system bus 710 , wherein the memory may include a non-volatile storage medium 730 and an internal memory 740 .

[0054] The non-volatile storage medium 730 may store an operating system 731 and a computer program 732. When the computer program 732 is executed, the processor 720 may execute the emotional dialogue generation method.

[0055] The processor 720 is used to provide computing and control capabilities and support the operation of the entire computer device 700.

[0056] The internal memory 740 provides an environment for the operation of the computer program 732 in the non-volatile storage medium 730. When the computer program 732 is executed by the processor 720, the processor 720 can execute the emotional dialogue generation method.

[0057] The network interface 750 is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the present application scheme, and does not constitute a limitation on the computer device 700 to which the present application scheme is applied. The specific computer device 700 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. The processor 720 is used to run the program code stored in the memory to implement the steps of the emotional dialogue generation method.

[0058] Those skilled in the art will understand that Fig. 9 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Fig. 9 The embodiments shown are consistent and will not be described again here.

[0059] It should be understood that in the embodiment of the present application, the processor 720 may be a central processing unit (CPU), and the processor 720 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0060] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the emotional dialogue generation method disclosed in the embodiment of the present invention is implemented.

[0061] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0062] In the several embodiments provided by the present invention, it should be understood that the disclosed equipment, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. Units with the same function may also be combined into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.

[0063] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0064] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0065] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), disk or optical disk and other media that can store program codes.

[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for generating emotional dialogue, characterized in that: include: Obtain natural language text to be processed; Inputting the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label; The natural language text to be processed, the semantic analysis results and the sentiment tags are input into the second model for processing to output a final natural language text that responds to the natural language text to be processed.

2. The method for generating emotional dialogue according to claim 1, characterized in that: The step of inputting the natural language text to be processed into the first model for processing to output a semantic analysis result and a sentiment label includes: Perform sentiment analysis on the natural language text to be processed to obtain sentiment attribute results; Find words related to the emotional attribute results from the natural language text to be processed to obtain emotional keywords that can express emotions; Performing semantic analysis on the natural language text to be processed to obtain semantic analysis results; Combining the sentiment attribute results, sentiment keywords and semantic analysis results, sentiment labels are obtained.

3. The method for generating emotional dialogue according to claim 2, characterized in that: The sentiment analysis process is performed on the natural language text to be processed to obtain the sentiment attribute result, including: Extract sentiment-related features from the natural language text to be processed; Perform sentiment attribute analysis on sentiment-related features to obtain sentiment attribute results.

4. The method for generating emotional dialogue according to claim 2, characterized in that: The step of searching for words related to the emotional attribute result from the natural language text to be processed to obtain emotional keywords that can express emotions includes: Perform multi-level analysis on the natural language text to be processed to identify keywords that may express emotions; Keywords related to emotional attribute results are selected from keywords that may express emotions as the final emotional keywords.

5. The method for generating emotional dialogue according to claim 2, characterized in that: The semantic analysis of the natural language text to be processed to obtain a semantic analysis result includes: Perform word segmentation and grammatical analysis on the natural language text to be processed to identify the basic structure of the text; Analyze each word and its position in the text according to the basic structure of the text to obtain the position information of the word; The basic structure of the text and the position information of the words are analyzed and processed to obtain the semantic analysis results.

6. The method for generating emotional dialogue according to claim 2, characterized in that: The emotional attribute results, emotional keywords and semantic analysis results are combined to obtain emotional tags, including: Integrate the sentiment attribute results, sentiment keywords and semantic analysis results to obtain comprehensive sentiment description information; Identify emotional features based on comprehensive emotional description information; Match sentiment features with words from a built-in list of sentiment tags; According to the matching results, one or more emotion tags are selected from the emotion tag list.

7. The method for generating emotional dialogue according to claim 1, characterized in that: The step of inputting the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing to output a final natural language text that responds to the natural language text to be processed comprises: Set the starting point for text generation and construct the text word by word; Use emotional tags to adjust the emotional tone of each word generated; The generated text is checked based on the semantic analysis results to ensure that the generated text contains the core topics and intentions of the natural language text to be processed.

8. An emotional dialogue generating device, characterized in that: include: An acquisition unit, used for acquiring a natural language text to be processed; A first model processing unit, used for inputting the natural language text to be processed into the first model for processing, so as to output a semantic analysis result and a sentiment label; The second model processing unit is used to input the natural language text to be processed, the semantic analysis result and the sentiment tag into the second model for processing, so as to output the final natural language text that responds to the natural language text to be processed.

9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the emotional dialogue generation method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the processor executes the emotional dialogue generation method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Intelligent question answering method, device and equipment based on emotion recognition and storage medium

    CN114999533A

  • Emotion recognition method and device, electronic equipment and storage medium

    CN115599894A

  • Chat scene matching system, method and equipment based on context and storage medium

    CN116881730A

  • Anthropomorphic dialogue method and device based on natural language model and electronic equipment

    CN117493529A

  • Digital human customer service method, system and device and storage medium

    CN117828065A

Cited By

  • Touch component, bionic structure and sensing feedback method thereof

    CN119200857A

  • A tactile component, a bionic structure and a perception feedback method thereof

    CN119200857B

  • AI-based sentiment analysis platform

    CN120874851A