Training processing method, electronic device, and storage medium for dialogue emotion recognition model
By matching and screening the external knowledge in the dialogue emotion recognition model, removing mismatched knowledge and retaining matching knowledge, the problem of contradictions in the existing technology is solved, and the accuracy of dialogue emotion analysis is improved.
Patent Information
- Application Number
- CN202210821444.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-07-12
AI Technical Summary
In the existing dialogue emotion recognition technology, when the external knowledge-based model quotes a large amount of external knowledge, it is easy to introduce external knowledge that contradicts the current discourse emotions, resulting in a large difference between the analysis results and the real feelings, which reduces the recognition accuracy.
Make matching judgments by obtaining the current dialogue elements in the training sample and obtaining corresponding external knowledge from the external knowledge base. If it does not match, remove the mismatched external knowledge; if it is matched, retain the matching external knowledge, thereby filtering out the external knowledge that matches the conversation, and improving the accuracy of the sentiment analysis model.
By screening external knowledge that does not match the conversation, the accuracy of the dialogue sentiment analysis model is improved and the accuracy of the identification results is enhanced.
Smart Images

Figure CN115169365B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text emotion recognition, and in particular to a training and processing method, electronic device, and storage medium for a dialogue emotion recognition model. Background Art
[0002] With the development of society and the advancement of science and technology, emotion recognition technology for human-computer dialogue has gradually become the focus of intelligent technology. In the process of human-computer dialogue, how to judge the emotions contained in the dialogue and how to respond to the corresponding words according to the content of the dialogue are important problems.
[0003] In the current conversation emotion recognition technology, the conversation emotion recognition models based on external knowledge will introduce external knowledge that contradicts the current discourse emotion when citing a large amount of external knowledge, making the results analyzed by the conversation emotion analysis model have a large difference from the real emotion, thus playing a negative role. Summary of the invention
[0004] The main technical problem solved by this application is to provide a training and processing method, electronic device, and storage medium for a conversation emotion recognition model, which can improve the accuracy of the conversation emotion recognition model.
[0005] In order to solve the above technical problems, the present application provides a training and processing method for a dialogue emotion recognition model, which includes:
[0006] Get the current dialog element in the training sample.
[0007] The external knowledge corresponding to the current dialogue elements is obtained from the external knowledge base of the dialogue emotion recognition model.
[0008] Determine whether the current dialogue element matches the corresponding external knowledge.
[0009] If there is no match, the external knowledge in the external knowledge base that does not match the current dialogue element is removed.
[0010] If there is a match, the external knowledge in the external knowledge base that matches the current dialog element is retained.
[0011] In order to solve the above technical problems, the present application provides an electronic device, which includes: a processor, a memory and a human-computer interaction circuit, the memory and the human-computer interaction circuit are respectively coupled to the processor, the memory stores a computer program, and the processor is used to execute the computer program to implement the training processing method of the above-mentioned dialogue emotion recognition model.
[0012] In order to solve the above technical problems, the present application provides a computer-readable storage medium storing a computer program, which can be executed by a processor to implement the training and processing method of the dialogue emotion recognition model described in the present application.
[0013] The beneficial effect of the present application is: different from the prior art, the present application matches and compares the current dialogue elements with the corresponding external knowledge. If there is a mismatch, the external knowledge in the corresponding external knowledge base is eliminated. If there is a match, the external knowledge in the corresponding external knowledge base is retained. In this way, the external knowledge in the external knowledge base referenced by the dialogue emotion recognition model that does not match the dialogue can be screened, thereby improving the accuracy of the dialogue emotion analysis model. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a flowchart of the training and processing method of the conversation emotion recognition model of this application;
[0015] Figure 2 This is a flow chart of implementation method 1 of the training processing method of the conversation emotion recognition model of the present application;
[0016] Figure 3 This is another flowchart of the first implementation method of the training processing method of the conversation emotion recognition model of the present application;
[0017] Figure 4 This is another flowchart of the first implementation method of the training processing method of the conversation emotion recognition model of the present application;
[0018] Figure 5 This is another flowchart of the first implementation method of the training processing method of the conversation emotion recognition model of the present application;
[0019] Figure 6 This is another flowchart of the second implementation method of the training processing method of the conversation emotion recognition model of the present application;
[0020] Figure 7 This is another flowchart of Embodiment 2 of the training processing method for the conversation emotion recognition model of the present application;
[0021] Figure 8 This is another flowchart of the second implementation method of the training processing method of the conversation emotion recognition model of the present application;
[0022] Fig. 9 It is a schematic block diagram of the circuit structure of the electronic device of the present application;
[0023] Fig.10 It is a schematic block diagram of the circuit structure of the computer-readable medium of the present application. DETAILED DESCRIPTION
[0024] 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. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. 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.
[0025] After long-term research, the inventor of this application found that in the current conversation emotion recognition technology, the conversation emotion recognition model based on external knowledge will introduce external knowledge that does not match the current discourse when citing a large amount of external knowledge. If the conversation emotion recognition model is trained with the mismatched external knowledge, and the results analyzed by the conversation emotion recognition model with the assistance of the mismatched external knowledge are greatly different from the real emotions, it will play a negative role and reduce the recognition accuracy of the conversation emotion recognition model. Therefore, in order to improve the accuracy of the conversation emotion analysis model, this application proposes the following embodiments.
[0026] The following embodiment of the training processing method of the dialogue emotion recognition model of the present application provides an exemplary description of the training processing method of the dialogue emotion model.
[0027] like Figure 1 As shown, the training processing method of the dialogue emotion recognition model may include the following steps:
[0028] S100: Obtain the current dialogue element in the training sample.
[0029] The current dialogue element may include words of the current sentence, such as "animal", "apple" and the like.
[0030] The current dialogue element may include a current sentence, and the current sentence includes a plurality of words.
[0031] The current dialogue element may include the previous sentences of the current sentence, such as the first three sentences or five sentences of the current sentence.
[0032] Specifically, the user can specify the words of the current sentence, the current sentence, or the previous sentence of the current sentence in the required training sample according to his own needs. For example, the user can specify "animal", specify the sentence "my boss is very good", or specify the five sentences above this sentence.
[0033] S200: Acquire external knowledge corresponding to the current dialogue element from the external knowledge base of the dialogue emotion recognition model.
[0034] Among them, external knowledge includes conceptual knowledge. Conceptual knowledge is triple data retrieved from an external knowledge base (for example: SenticNet and ConceptNet, etc.), which can be in the form of a single word or in the form of a combination of multiple words. For example, "animal", "apple", etc. Specifically, the conceptual knowledge corresponding to the words of the current sentence obtained from the external knowledge base is associated with the words of the current sentence. For example, if the user specifies that the current dialogue element in the required training sample is "apple", then the current dialogue element in the training sample can be obtained as the word "apple". Then, the conceptual knowledge corresponding to the current dialogue element "apple" obtained from the external knowledge base of the dialogue emotion recognition model will have associated words such as "fruit", "red" or sentences composed of multiple words such as "apples grow on trees".
[0035] Among them, external knowledge also includes generative knowledge. Specifically, generative knowledge is common sense knowledge generated by generative models in external knowledge bases, such as the COMET model and its variants. Specifically, generative knowledge can be obtained from 9 types of relationship analysis of Atomic causal common sense. These 9 types of relationship analysis include 3 types of event-induced psychological state analysis, 5 types of event-induced event analysis, and 1 type of event-induced representational personality analysis. Event-induced psychological state includes: why you want to initiate this event, how you feel after this event, and how other people feel after this event. Event-induced events include what needs to be done to cause this event, the impact of this event on other events, what you want to do after this event, what other people want to do after this event, and the impact of this event on other people. Event-induced representational personality includes how others will view it.
[0036] For example, if the current sentence is "My boss is very good", then the generated knowledge corresponding to the current sentence can be obtained from the external knowledge base from the analysis of events leading to psychological states: "I feel proud", or from the analysis of events leading to events: "I got praise from my boss", or from the analysis of events leading to representational personality: "The customer is satisfied", and so on.
[0037] Specifically, the user can specify the external knowledge obtained from the external knowledge base as conceptual knowledge or generated knowledge according to needs.
[0038] S300: Determine whether the current dialog element matches the corresponding external knowledge.
[0039] Specifically, the current dialogue element and the corresponding external knowledge can be processed and analyzed using methods such as SenticNet sentiment dictionary and Embedding mapping method, and sentiment types or related data that can accurately reflect sentiment at the same latitude can be obtained, so as to determine whether the current dialogue element matches the corresponding external knowledge. Specifically, a preset value that can measure the relevance of the current dialogue element and the corresponding external knowledge can be set, and the similarity result obtained by comparing the sentiment of the current dialogue element with the sentiment of the corresponding external knowledge can be compared with the preset value.
[0040] S400: If there is no match, then the external knowledge in the external knowledge base that does not match the current dialog element is removed.
[0041] When the similarity result obtained by comparing the emotion of the current dialogue element with the emotion of the corresponding external knowledge is less than a preset value, the external knowledge is eliminated.
[0042] Specifically, the weight of the external knowledge that does not match the current dialogue element to be eliminated is set to 0, so that the mismatched external knowledge will not interfere with the results analyzed by the dialogue emotion recognition model.
[0043] S500: If there is a match, retain the external knowledge in the external knowledge base that matches the current dialog element.
[0044] Specifically, when the current dialogue element analyzed by the above processing is the same as the emotion type or related data of the corresponding external knowledge, or the similarity of the emotions of the two is greater than or equal to the preset value, the external knowledge is retained and a non-zero weight value is assigned to the external knowledge to facilitate model calculation processing. The weight value of the external knowledge obtained can be specified by the user, and if not specified, it defaults to 1.
[0045] By matching and comparing the current dialogue element with the corresponding external knowledge obtained from the external knowledge base, if there is a mismatch, the external knowledge in the corresponding external knowledge base is eliminated, and if there is a match, the external knowledge in the corresponding external knowledge base is retained. In this way, the external knowledge in the external knowledge base referenced by the dialogue emotion recognition model that does not match the dialogue elements can be screened, thereby improving the accuracy of the dialogue emotion analysis model and further improving the accuracy of the recognition results.
[0046] This embodiment can thus provide multiple implementations. The following is a first implementation that further describes the above steps from the word level, sentence level and context level when the external knowledge includes conceptual knowledge.
[0047] (1) Word level: The current dialogue elements include the words of the current sentence.
[0048] Furthermore, the external knowledge for obtaining the words of the current sentence is the corresponding conceptual knowledge. Figure 2 As shown, the specific steps may refer to the following steps included in step S200:
[0049] S210: Acquire various concept knowledge corresponding to the words of the current sentence from an external knowledge base.
[0050] Specifically, the conceptual knowledge corresponding to the words of the current sentence is obtained from the external knowledge base of the dialogue emotion recognition model. The dialogue emotion recognition model searches the external knowledge base based on the words of the current sentence to obtain the conceptual knowledge of a single word related to the words of the current sentence or the conceptual knowledge composed of multiple words. For example, if the current dialogue element in the training sample is the word "animal" in the current sentence, then the conceptual knowledge corresponding to "animal" such as "cat", "dog" and "human friend" can be obtained from the external knowledge base of the dialogue emotion recognition model.
[0051] After acquiring the concept knowledge corresponding to each word, the word-level matching can be started. For details, see the following steps included in step S300:
[0052] S311: Use the SenticNet sentiment dictionary to obtain the sentiment type of the words in the current sentence and the sentiment type of the conceptual knowledge in the form of a single word, and use the StanfordNLP toolkit to obtain the sentiment type of the conceptual knowledge in the form of a combination of multiple words.
[0053] Among them, SenticNet sentiment dictionary is a knowledge base that provides a set of 100,000 natural language concepts with semantic, sentiment, and polarity associations. At the same time, SenticNet, as a framework, includes a series of sentiment analysis tools and technologies that combine common sense reasoning, psychology, linguistics, and machine learning, and covers the latest findings in conceptual level sentiment analysis, thereby providing easy-to-use and state-of-the-art tools for large-scale social data analysis, which can realize automated tasks in different fields, languages, and forms, such as product positioning, trend discovery, and social media marketing. Using SenticNet sentiment dictionary to analyze the sentiment type of the words in the current sentence and the conceptual knowledge in the form of a single word can make the sentiment type recognition process more accurate and convenient.
[0054] The StanfordNLP toolkit provides a series of tools to process human natural language. It can restore stems, mark word parts of speech, identify named entities such as names of people, places, dates and times, and normalize them, as well as perform multiplication and dependency syntax analysis on sentences, including reference resolution, sentiment analysis and relation extraction. Therefore, the StanfordNLP toolkit can be used to perform stem sentiment analysis on more complex conceptual knowledge of multiple word combinations, and a more accurate sentiment type can be obtained.
[0055] In this embodiment, the sentiment types include negative, positive and neutral. The SenticNet sentiment dictionary and the StanfordNLP toolkit can be used to determine whether the sentiment type of each concept knowledge is negative, positive or neutral.
[0056] S312: Determine whether the sentiment type of the words in the current sentence is the same as the sentiment type of each conceptual knowledge, so as to determine whether the current dialogue element matches the corresponding external knowledge.
[0057] For example, if the sentiment type of the words in the current sentence obtained by using the SenticNet sentiment dictionary is negative, and the words in the current sentence and the corresponding concept knowledge are negative, then the sentiment type of the words in the current sentence and the sentiment type of each concept knowledge are the same, and it can be judged that the words in the current sentence match the corresponding concept knowledge. If the sentiment type of the words in the current sentence obtained by using the SenticNet sentiment dictionary is negative, and the words in the current sentence and the corresponding concept knowledge are positive, then the sentiment type of the words in the previous sentence and the sentiment type of each concept knowledge are different, and it can be judged that the words in the current sentence do not match the corresponding concept knowledge.
[0058] According to different judgment results of S312, how to specifically retain and eliminate the conceptual knowledge can refer to the following steps included in step S400 and step S500:
[0059] For mismatches:
[0060] S411: If the emotion type of the concept knowledge is different from the emotion type of the words in the current sentence, generate a random number corresponding to the concept knowledge, and determine whether the random number is less than a preset value.
[0061] The preset value can represent the correlation between the emotion type of the words in the current sentence and the emotion type of the corresponding concept knowledge. If the random number is less than the preset value, it means that the correlation between the emotion type of the words in the current sentence is low. If the random number is greater than the preset value, it means that the correlation between the emotion type of the words in the current sentence is high.
[0062] S412: If the random number is smaller than a preset value, the concept knowledge whose corresponding random number is smaller than the preset value in the external knowledge base is eliminated.
[0063] Specifically, the weight values of the concept knowledge in the external knowledge base whose corresponding random numbers are less than a preset value are set to 0, so that the unmatched concept knowledge will not affect the subsequent results.
[0064] For matching:
[0065] S510: If the sentiment type of the conceptual knowledge is the same as the sentiment type of the words in the current sentence, or if the random number is greater than or equal to the preset value, the conceptual knowledge in the external knowledge base whose sentiment type is the same as the words in the current sentence, as well as the conceptual knowledge whose corresponding random number is greater than or equal to the preset value, are retained.
[0066] Specifically, the weight values of the concept knowledge in the external knowledge base whose sentiment type is the same as the words in the current sentence, and the concept knowledge whose corresponding random number is greater than or equal to the preset value are all set to the first weight value. The first weight value is a non-zero value, which can be set by the user or retained as the original weight value of the knowledge.
[0067] The above steps enable the dialogue emotion recognition model to eliminate conceptual knowledge that is irrelevant to emotion at the word level, improve the emotional consistency between the conceptual knowledge at the word level in the dialogue emotion recognition model and the words in the current sentence, and improve the quality of the conceptual knowledge acquired in the dialogue emotion recognition model.
[0068] (2) Sentence level: The current dialogue element includes the current sentence.
[0069] After obtaining the concept knowledge corresponding to each word in the current sentence, the sentiment label of the current sentence can be compared with the sentiment label of the concept knowledge corresponding to each word in the current sentence to make corresponding matching judgments. Figure 3 For details, please refer to the following steps included in step S300:
[0070] S321: Calculate a first vector for representing the sentiment label of the current sentence and a second vector for representing each concept knowledge corresponding to each word of the current sentence through an Embedding mapping method.
[0071] The embedding mapping method is a method for continuousizing discrete data. It can map sentences from semantic space to vector space, while maintaining the relationship between the original samples in the semantic space as much as possible in the vector space. For example, the positions of two words with similar semantics in the vector space are also relatively close.
[0072] Specifically, the known sentiment label of the current sentence is vectorized to obtain a first vector using the Embedding mapping method. At the same time, each concept knowledge corresponding to each word of the current sentence is vectorized to obtain a second vector using the Embedding mapping method. This makes the current sentence and the vectors represented by each concept knowledge corresponding to each word of the current sentence in the same latitude, so as to judge whether the sentiments of the two match.
[0073] S322: Calculate a first cosine similarity between each second vector and the first vector.
[0074] Among them, cosine similarity, also known as cosine similarity, evaluates the similarity of two vectors by calculating the cosine value of the angle between them. Cosine similarity can be calculated by plotting vectors into vector space according to their coordinate values. Cosine similarity can measure the sentiment similarity between the current sentence and the conceptual knowledge corresponding to the current sentence more conveniently and accurately.
[0075] S323: Determine whether the first cosine similarity is less than a first preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge.
[0076] Furthermore, a first preset threshold is set, and the first preset threshold can characterize the sentiment relevance between the current sentence and each corresponding concept knowledge. It is determined whether the first cosine similarity is less than the first preset threshold to determine whether the current dialogue element matches the corresponding concept knowledge. Specifically, if the first cosine similarity is less than the first preset threshold, it can be determined that the current dialogue sentence does not match the corresponding concept knowledge. If the first cosine similarity is greater than or equal to the first preset threshold, it can be determined that the current dialogue sentence matches the corresponding concept knowledge.
[0077] According to different judgment results of S323, how to specifically retain and eliminate the conceptual knowledge can refer to the following steps included in S400 and S500:
[0078] For mismatches:
[0079] S420: If the first cosine similarity is less than a first preset threshold, remove the concept knowledge in the external knowledge base whose first cosine similarity is less than the first preset threshold.
[0080] Specifically, the weight value of the concept knowledge in the external knowledge base whose first cosine similarity is less than the first preset threshold is set to 0, so that the concept knowledge that does not match the current sentence does not affect the final recognition result.
[0081] For matching:
[0082] S520: If the first cosine similarity is greater than or equal to the first preset threshold, retain the concept knowledge in the external knowledge base whose first cosine similarity is greater than or equal to the first preset threshold.
[0083] Specifically, the weight value of the concept knowledge in the external knowledge base whose first cosine similarity is greater than or equal to the first preset threshold is set to a second weight value. The second weight value is a non-zero value, which can be set by the user or retained as the original weight value of the knowledge.
[0084] The above-mentioned sentence-level method steps realize the elimination of conceptual knowledge irrelevant to emotion at the sentence level of the dialogue emotion recognition model, improve the emotion consistency of the dialogue emotion recognition model at the sentence level, and improve the accuracy of emotion recognition by the dialogue emotion recognition model.
[0085] (3) Context level: The current dialogue element includes the context of the current sentence.
[0086] After obtaining the concept knowledge of the current sentence, the sentiment label of the previous sentence can be compared with the sentiment label of the concept knowledge corresponding to the current sentence to make corresponding matching judgments. Figure 4 For details, please refer to the following steps included in step S300:
[0087] S331: Calculate the vector of the sentiment label corresponding to each previous sentence and used to characterize the previous sentence through the Embedding mapping method, and perform weighted average on the vectors of all the previous sentences to obtain a third vector; add and average the first vector and the third vector to obtain a mean vector.
[0088] Specifically, the vector of the sentiment label corresponding to each previous sentence and used to characterize the previous sentence is calculated through the Embedding mapping method, and the vectors of all the previous sentences are weighted averaged to obtain a third vector for characterizing the sentiment labels of all the previous sentences.
[0089] Furthermore, the first vector and the third vector are added and averaged to obtain a mean vector. Specifically, the first vector used to characterize the emotion label of the current sentence and the third vector used to characterize the emotion label of the previous sentence are added and averaged, and the obtained mean vector can characterize the mixed emotion after the emotion label of the current sentence and the emotion label of the previous sentence are fused. For example, the previous sentence includes 2 previous sentences and 1 current sentence, and its emotions are "happy", "happy" and "uncomfortable", then the obtained mixed emotion is "very happy but a little uncomfortable", and the vector obtained by the Embedding mapping method for this mixed emotion is represented as a mean vector.
[0090] S332: Calculate the second cosine similarity between each second vector and the mean vector respectively.
[0091] Specifically, each concept knowledge corresponding to each word in the current sentence is vectorized to obtain a second vector, which is compared with the mean vector obtained by mixing the emotion label representing the current sentence with the emotion label of the previous sentence, and the second cosine similarity that can represent the similarity between the emotion of each corresponding concept knowledge and the emotion of the previous sentence is calculated.
[0092] S333: Determine whether the second cosine similarity is less than a second preset threshold value to determine whether the current dialogue element matches the corresponding external knowledge.
[0093] A second preset threshold is set to characterize the emotional relevance of the concept knowledge corresponding to the previous sentence and the current sentence, and it is determined whether the second cosine similarity is less than the second preset threshold to determine whether the current dialogue element matches the corresponding external knowledge. If the second cosine similarity is less than the second preset threshold, it means that the emotional relevance of the concept knowledge corresponding to the current sentence and the previous sentence is low, and it can be determined that the current dialogue element does not match the corresponding external knowledge. If the second cosine similarity is greater than or equal to the second preset threshold, it means that the emotional relevance of the concept knowledge corresponding to the current sentence and the previous sentence is high, and it can be determined that the current dialogue element matches the corresponding external knowledge.
[0094] For mismatches:
[0095] S430: If the second cosine similarity is less than the second preset threshold, remove the concept knowledge in the external knowledge base whose second cosine similarity is less than the second preset threshold.
[0096] Specifically, the weight value of the concept knowledge in the external knowledge base whose second cosine similarity is less than the second preset threshold is set to 0. In this way, the concept knowledge with a low relevance to the previous sentence will not affect the subsequent calculation.
[0097] For matching:
[0098] S530: If the second cosine similarity is greater than or equal to the second preset threshold, retain the concept knowledge in the external knowledge base whose second cosine similarity is greater than or equal to the second preset threshold.
[0099] Specifically, the weight value of the concept knowledge in the external knowledge base whose second cosine similarity is greater than or equal to the second preset threshold is set to a third weight value. The third weight value is a non-zero value and can be set by the user or retained as the original weight value of the knowledge.
[0100] In the above-mentioned method steps at the context level, only all the conceptual knowledge corresponding to each word of the current sentence is obtained from the external knowledge base, and the conceptual knowledge related to the previous sentence is not obtained. This can further improve the relevance of the conceptual knowledge to the current sentence dialogue, improve the accuracy of the dialogue emotion recognition model in identifying emotions, and will not be disturbed by words related to the previous sentence but irrelevant to the current dialogue. This setting enables the dialogue emotion recognition model to eliminate conceptual knowledge that is irrelevant to emotions at the context level, improve the emotional consistency of the dialogue emotion recognition model at the context level, further expand the calculation range of the dialogue emotion recognition model in identifying emotions, and improve the accuracy of the dialogue emotion recognition model.
[0101] The method steps after eliminating the conceptual knowledge at the word level, sentence level, and context level are as follows: Figure 5 As shown:
[0102] S610: Calculate a comprehensive weight value of the concept knowledge retained in the external knowledge base using the dialogue emotion model using the first weight value, the second weight value, and the third weight value.
[0103] Specifically, the product of the second weight value and the first coefficient and the product of the third weight value and the second coefficient are calculated, and the product of the first weight value and the third weight value is multiplied to obtain the comprehensive weight value. The sum of the first coefficient and the second coefficient is 1, that is:
[0104] ε=(a*β+b*Γ)*α(1)
[0105] In the above formula (1), ε is the comprehensive weight value, α is the first weight value, β is the second weight value, Γ is the third weight value, a is the first coefficient, and b is the second coefficient. Wherein, a+b=1. The values of the first coefficient a and the second coefficient b can be specified by the user. If not specified, the default values a=0.5 and b=0.5 can be set.
[0106] The comprehensive weight value combines the weights after eliminating the conceptual knowledge that contradicts the sentiment of the words in the current sentence, the current sentence, and the words in the previous sentence of the current sentence, so as to facilitate subsequent calculation and application.
[0107] Furthermore, the sentiment strength of mismatched conceptual knowledge is improved:
[0108] S711: Use the VAD dimensional sentiment model to calculate the fourth vector representing the sentiment intensity of the words in the current sentence in the VAD dimensional sentiment model, and calculate the fifth vector representing the sentiment intensity of the conceptual knowledge in the VAD dimensional sentiment model.
[0109] The VAD dimension emotion model is a three-dimensional continuous space model based on "Arousal Dimension - Valence Dimension - Control Dimension (AVD)". According to the emotion dimension representation theory, emotion can be defined as a coordinate point on the VAD dimension emotion model. Each VAD coordinate point can uniquely identify a discrete emotion type. By using the regression method to predict and estimate the continuous change of the VAD coordinate value of the emotion, the emotion recognition problem for discrete emotions is transformed into the emotion intensity estimation problem for continuous emotion changes, so as to achieve the purpose of tracking the continuous dynamic change of emotion intensity expression. The intensity of emotion expression can be represented as a vector in the three-dimensional continuous space model.
[0110] S712: Calculate the third cosine similarity between the fourth vector and the fifth vector.
[0111] Specifically, the fourth vector representing the sentiment intensity of the words in the current sentence is compared with the fifth vector representing the sentiment intensity of the corresponding conceptual knowledge, and the third cosine similarity used to represent the similarity of the sentiment intensity of the two is calculated.
[0112] S713: Calculate the final weight value of the concept knowledge using the third cosine similarity and the comprehensive weight value.
[0113] Specifically, the product of the sum of the third cosine similarity and a constant and the comprehensive weight value is calculated to obtain the final weight value, that is:
[0114] Q=(m+e)*ε(2)
[0115] In the above formula (2), Q is the final weight value, m is a constant greater than or equal to 1, e is the third cosine similarity, and ε is the comprehensive weight value.
[0116] The final weight value not only takes into account the sentiment differences at three levels: the words in the current sentence, the current sentence, and the previous sentence, but also takes into account the sentiment intensity characteristics of the words in the current sentence, further reducing the differences between the external knowledge and improving the quality of the external knowledge output by the dialogue emotion recognition model.
[0117] Furthermore, the results are further input into the model for training and parameter tuning:
[0118] S810: Input the final weight value into the conversation emotion recognition model for training and parameter tuning.
[0119] The Embedding mapping method is used to calculate the initial knowledge vector of each concept knowledge corresponding to each word in the current sentence, as well as the initial word vector of each word in the current sentence.
[0120] The initial knowledge vector of each concept knowledge corresponding to each word in the current sentence is calculated and weighted summed with the corresponding final weight value to obtain a weighted vector, and the ratio of the weighted vector to the total amount of concept knowledge corresponding to each word is calculated to obtain the concept knowledge vector of the current sentence.
[0121] The concept knowledge vector of each word in the current sentence is merged with the initial word vector, and then multiplied by the first mapping parameter to obtain the final word vector of each word, that is:
[0122]
[0123] In the above formula (3), s k W represents the final word vector of the kth word in the i-th sentence; x is the first mapping parameter in the model; The initial word vector of the kth word in the i-th sentence represented by; Represents the final weight value of the j-th knowledge corresponding to the k-th word; N represents the initial knowledge vector of the jth knowledge of the kth word; d Indicates the amount of knowledge corresponding to each word in the sentence, represents the weight vector, Represents a merge operation.
[0124] Furthermore, the final word vectors of all words in the current sentence are merged and then multiplied by the second mapping parameter to obtain the final sentence vector of the current sentence, that is:
[0125]
[0126] In the above formula (4), Represents the final sentence vector of the i-th sentence (i.e. the current sentence), W S is the second mapping parameter in the model. N w Indicates the number of words in the current sentence.
[0127] The final sentence vector of the current sentence is combined with the final sentence vector of the previous sentence of the current sentence, and then input into the dialogue emotion recognition model for calculation to output the emotion value of the current sentence, namely:
[0128]
[0129] In the above formula (5), y i represents the sentiment value of the outputted i-th sentence (i.e. the current sentence); M represents the sentiment analysis model without introducing external knowledge.
[0130] For example, the current sentence i has k words, and these k words correspond to Nd Concept knowledge can be obtained through the Embedding mapping method. d The initial knowledge vector of each concept knowledge is represented as The final weight value is obtained after knowledge elimination in the dialogue emotion recognition model The initial knowledge vector of the jth concept knowledge corresponding to the kth word in the current sentence and the corresponding final weight value Perform weighted summation to obtain the weighted vector of all concept knowledge Calculate the total number of concept knowledge N corresponding to the weighted vector and each word d The external knowledge vector of the current sentence is obtained, and then compared with the first mapping parameter W x Multiply them together to get the final word vector s for each word k Among them, the first mapping parameter W x It can be customized by the user and will be adjusted according to the model training prediction results. k Perform a merge operation and then multiply by the adjustable second mapping parameter W S , then the final sentence vector of the current sentence i can be obtained Furthermore, all previous sentences of the current sentence i and the current sentence i are merged and input into the model (ie, multiplied by M), and finally the sentiment value of the current sentence i is obtained.
[0131] Furthermore, a loss value between the sentiment value of the current sentence and the corresponding true sentiment value is calculated, and the loss value is used to adjust the first mapping parameter and / or the second mapping parameter.
[0132] The real emotion value is a representation of the real emotion in the training sample set in advance. The training sample is substituted into the model for training to predict the emotion value of each sentence, and the loss value between the emotion value and the corresponding real emotion value is calculated. The first mapping parameter and / or the second mapping parameter are adjusted according to the loss value to adjust the dialogue emotion recognition model by using the loss value, so that the emotion value predicted by the dialogue emotion recognition model is closer to the real emotion value.
[0133] This embodiment may provide another implementation mode. The second implementation mode based on external knowledge including generated knowledge is further described below to describe the above steps.
[0134] After obtaining the generated knowledge corresponding to the current sentence from the external knowledge base, the sentiment label of the current sentence can be compared with the sentiment label of the generated knowledge corresponding to the current sentence to make corresponding matching judgments. Figure 6 For details, please refer to the following steps included in step S300:
[0135] (1) Sentence level: The current dialogue element includes the current sentence.
[0136] S341: Calculate the first vector of the sentiment label for characterizing the current sentence through the Embedding mapping method, and obtain the sixth vector characterizing each generated knowledge output by the external knowledge base.
[0137] Among them, the process of calculating the first vector of the sentiment label used to characterize the current sentence by the Embedding mapping method is described in S322 and will not be repeated here. The sixth vector can be directly output by the external knowledge base. Specifically, the external knowledge base has a generation model such as the COMET model, and the generation model can directly represent the generation knowledge output corresponding to the current sentence retrieved as the sixth vector.
[0138] S342: Calculate the fourth cosine similarity between each sixth vector and the first vector.
[0139] Each first vector and the sixth vector are dimensionally transformed so that each first vector and the sixth vector after transformation have the same self-vector dimension, and the fourth cosine similarity between each sixth vector after transformation and the first vector is calculated. Specifically, the first vector and the sixth vector are dimensionally transformed using a linear layer, so as to obtain each first vector and the sixth vector having the same self-vector dimension.
[0140] S343: Determine whether the fourth cosine similarity is less than a third preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge.
[0141] The emotional relevance between the current sentence and each generated knowledge is determined based on the fourth cosine similarity calculated from the vectors of the same latitude. A third preset value is set to measure the emotional relevance between the current sentence and the corresponding generated knowledge, and it is determined whether the fourth cosine similarity is less than the third preset threshold value to determine whether the current dialogue element matches the corresponding generated knowledge. Specifically, if the fourth cosine similarity is less than the third preset threshold value, it is determined that the current dialogue element does not match the corresponding generated knowledge. If the fourth cosine similarity is greater than or equal to the third preset threshold value, it is determined that the current dialogue element matches the corresponding generated knowledge.
[0142] According to different judgment results of S343, how to specifically retain and eliminate the generated knowledge can refer to the following steps included in S400 and step S500:
[0143] For mismatches:
[0144] S440: If the fourth cosine similarity is less than the third preset threshold, the generated knowledge in the external knowledge base whose fourth cosine similarity is less than the third preset threshold is eliminated.
[0145] Eliminating the generated knowledge whose fourth cosine similarity in the external knowledge base is less than the third preset threshold is specifically performed by setting the weight value of the generated knowledge whose fourth cosine similarity in the external knowledge base is less than the third preset threshold to 0. In this way, the generated knowledge with low sentiment relevance to the current sentence will not affect the subsequent calculation.
[0146] For matching:
[0147] S540: If the fourth cosine similarity is greater than or equal to the third preset threshold, retain the generated knowledge in the external knowledge base whose fourth cosine similarity is greater than or equal to the third preset threshold.
[0148] Specifically, the weight value of the generated knowledge in the external knowledge base whose fourth cosine similarity is greater than or equal to the third preset threshold is set as the fourth weight value for subsequent calculation. The fourth weight value is a non-zero value and can be set by the user or retained as the original weight value of the knowledge.
[0149] (3) Context level: The current dialogue element includes the previous sentence of the current sentence.
[0150] After obtaining the generated knowledge of the current sentence, the sentiment label of the previous sentence can be compared with the sentiment label of the generated knowledge corresponding to the current sentence to make a corresponding matching judgment. For details, see the following steps included in step S300:
[0151] S351: Calculate the vector of the sentiment label corresponding to each previous sentence and used to characterize the previous sentence through the Embedding mapping method, and perform weighted average on the vectors of all the previous sentences to obtain a third vector; add and average the first vector and the third vector to obtain a mean vector.
[0152] This process is described in S322 and will not be repeated here.
[0153] S352: Calculate the fifth cosine similarity between each sixth vector and the mean vector respectively.
[0154] Specifically, the sixth vector representing each generated knowledge corresponding to the current sentence is compared with the mean vector obtained by merging the previous sentence and the current sentence. The fifth cosine similarity obtained represents the similarity between the sentiment of each generated knowledge corresponding to the current sentence and the sentiment combined of the previous sentence and the current sentence.
[0155] S353: Determine whether the fifth cosine similarity is less than a fourth preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge.
[0156] A fourth preset value is set to measure the emotional relevance between the previous sentence and the corresponding generated knowledge, and it is determined whether the fifth cosine similarity is less than the fourth preset threshold value to determine whether the current dialogue element matches the corresponding generated knowledge. Specifically, if the fifth cosine similarity is less than the fourth preset threshold value, it is determined that the previous sentence does not match the generated knowledge corresponding to the current sentence. If the fifth cosine similarity is greater than or equal to the fourth preset threshold value, it is determined that the previous sentence of the current sentence matches the generated knowledge corresponding to the current sentence.
[0157] According to different judgment results of S353, how to specifically retain and eliminate the generated knowledge can refer to the following steps included in S400 and step S500:
[0158] For mismatches:
[0159] S450: If the fifth cosine similarity is less than the fourth preset threshold, the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold is eliminated.
[0160] The specific manifestation of eliminating the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold is to set the weight value of the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold to 0, so that the generated knowledge with less similarity to the previous sentence will not affect the subsequent results.
[0161] For matching:
[0162] S550: If the fifth cosine similarity is greater than or equal to the fourth preset threshold, retaining the generated knowledge in the external knowledge base whose fifth cosine similarity is greater than or equal to the fifth preset threshold.
[0163] The weight value of the generated knowledge in the external knowledge base whose fifth cosine similarity is greater than or equal to the fourth preset threshold is set as the fifth weight value for subsequent calculation. The fifth weight value is a non-zero value and can be set by the user or retained as the original weight value of the knowledge.
[0164] The method steps after eliminating the conceptual knowledge at the word level, sentence level, and context level are as follows: Figure 8 As shown:
[0165] S620: Calculate the final weight value of the generated knowledge retained in the external knowledge base using the dialogue emotion recognition model using the fourth weight value and the fifth weight value.
[0166] Specifically, the product of the fourth weight value and the first coefficient and the product of the fifth weight value and the second coefficient are calculated, and the product of the first weight value is multiplied to obtain the final weight value. The sum of the first coefficient and the second coefficient is 1, that is:
[0167] Q=a*γ+b*δ(6)
[0168] In the above formula (6), Q is the final weight value, γ is the fourth weight value, δ is the fifth weight value, a is the first coefficient, and b is the second coefficient. Wherein, a+b=1, the values of a and b are specified by the user, and if not specified, the default values a=0.5 and b=0.5 can be set.
[0169] The final weight value combines the weights after eliminating the generated knowledge that contradicts the sentiment of the words in the current sentence and the sentence above the current sentence, so as to facilitate subsequent calculations and applications.
[0170] S820: Input the final weight value into the conversation emotion recognition model for training and parameter tuning.
[0171] The initial knowledge vector of each generated knowledge corresponding to each word of the current sentence output by the external knowledge base is obtained, and the initial word vector of each word of the current sentence is calculated by using the Embedding mapping method.
[0172] The initial word vectors of each word in the current sentence are merged and then multiplied by the first mapping parameter to obtain the initial sentence vector of the current sentence, that is:
[0173]
[0174] In the above formula (7), Represents the initial sentence vector of the i-th sentence (i.e. the current utterance), s k Represents the initial word vector of each word in the i-th sentence (current sentence), W S is represented as the first mapping parameter; N w Indicates the number of words in the current sentence.
[0175] Furthermore, the initial knowledge vectors of each generated knowledge corresponding to the current sentence are calculated and weighted summed with the corresponding final weight values to obtain a weighted vector, and the ratio of the weighted vector to the total number of generated knowledge corresponding to the current sentence is calculated to obtain the external knowledge vector of the current sentence. The initial sentence vector of the current sentence is merged with the external knowledge vector of the current sentence, and then multiplied by the second mapping parameter to obtain the final sentence vector of the current sentence, that is:
[0176]
[0177] In the above formula (8), u i Represents the final sentence vector of the i-th sentence (i.e., the current sentence), W x is represented as a two-mapping parameter, and Q (j) represents the final weight value of the jth knowledge corresponding to the i-th sentence; E(k (j)) represents the initial knowledge vector of the jth knowledge of the ith word; N d Indicates the amount of knowledge corresponding to each word in the sentence. Represents a merge operation. It is the ratio of the weighted vector to the total amount of conceptual knowledge corresponding to each word.
[0178] The final sentence vector of the current sentence is combined with the final sentence vector of the previous sentence of the current sentence, and then input into the dialogue emotion recognition model for calculation to output the emotion value of the current sentence, namely:
[0179]
[0180] In the above formula (9), y i represents the sentiment value of the outputted i-th sentence (i.e., the current sentence); M represents the dialogue sentiment recognition model without introducing external knowledge.
[0181] For example, the current sentence i has a corresponding N d words, and the initial word vector of each word is s k , the initial word vector of each word in the current sentence is merged and then combined with the first mapping parameter W S Multiply them together to get the initial sentence vector u for the current sentence i i The jth generated knowledge of the current sentence i is the initial knowledge vector E(k (j) ), multiplied by the final weight value Q of the jth generated knowledge corresponding to the current sentence i (j) , and perform weighted summation to obtain N for the current statement i d Generate knowledge weighted vectors and calculate the total number of generated knowledge N corresponding to the weighted vector and the current sentence i d The ratio of , to obtain the external knowledge vector u of the current sentence i i The external knowledge vectors of the current sentence i and the previous sentence of the current sentence i are merged and input into the dialogue emotion recognition model M to obtain the emotion value of the current sentence i.
[0182] Furthermore, a loss value between the sentiment value of the current sentence and the corresponding true sentiment value is calculated, and the loss value is used to adjust the first mapping parameter and / or the second mapping parameter.
[0183] Among them, the true emotion value is the true emotion value in the training sample set in advance. The training sample is substituted into the model for training to predict the emotion value of each sentence, and the loss value between the true emotion value and the corresponding true emotion value is calculated. The first mapping parameter and / or the second mapping parameter in the dialogue emotion recognition model is adjusted according to the loss value, so that the emotion value predicted by the dialogue emotion recognition model is closer to the true emotion value.
[0184] In summary, this application improves the quality of external knowledge output in the conversation emotion recognition model by comparing the specified dialogue elements with the external knowledge in the corresponding external knowledge base at the three levels of word level, sentence level, and context level. If there is a match, the corresponding external knowledge is retained, and if there is a mismatch, the external knowledge is removed. The weights of each external knowledge after eliminating the contradictory knowledge are merged, the weights of the external knowledge are improved accordingly, and finally input into the conversation emotion recognition model for training and parameter adjustment, so that the conversation emotion recognition model is optimized and the accuracy of the conversation emotion recognition model in predicting emotions is improved.
[0185] like Fig. 9 As shown, the electronic device 600 described in this embodiment includes a processor 610, a memory 620 and a human-computer interaction circuit 630. The memory 620 and the human-computer interaction circuit 630 are respectively coupled to the processor 610. The memory 620 stores a computer program. The processor 610 is used to execute the computer program to implement the training and processing method of the dialogue emotion recognition model described in this embodiment.
[0186] The processor 610 is used to control the operation of the electronic device 600. The processor 610 may also be referred to as a CPU (Central Processing Unit). The processor 610 may be an integrated circuit chip having signal processing capabilities. The processor 610 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor 610 may also be any conventional processor 610, etc.
[0187] The memory 620 may be a RAM, a ROM, or other types of storage devices. Specifically, the memory 620 may include one or more computer-readable storage media, which may be non-transitory. The memory 620 may also include a high-speed random access memory 620, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 620 is used to store at least one program code.
[0188] The human-machine interaction circuit 630 is used to realize information transmission between a person and the electronic device 600, and mainly includes two parts: information transmission from a person to the electronic device 600 and from the electronic device 600 to a person. Specifically, the human-machine interaction circuit 630 can realize the process of human-machine interaction through a driving chip.
[0189] The processor 610 is used to execute the computer program stored in the memory 620, and the information exchanged between the human-computer interaction circuit person and the electronic device 600 is transmitted to the processor 610, so that the electronic device 600 described in the present application implements the training and processing method of the dialogue emotion recognition model described in the embodiment of the present application.
[0190] In some embodiments, the electronic device 600 may further include: a peripheral device interface 640 and at least one peripheral device. The processor 610, the memory 620, the human-computer interaction circuit 630 and the peripheral device interface 640 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 640 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 650, a display screen 660, an audio circuit 670 and a power supply 680.
[0191] The peripheral device interface 640 may be used to connect at least one peripheral device related to I / O (Input / output) to the processor 610 and the memory 620. In some embodiments, the processor 610, the memory 620, and the peripheral device interface 640 are integrated on the same chip or circuit board; in some other implementations, any one or two of the processor 610, the memory 620, the human-computer interaction circuit 630, and the peripheral device interface 640 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0192] The radio frequency circuit 650 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 650 communicates with a communication network and other communication devices through electromagnetic signals, and can also be called a communication circuit. The radio frequency circuit 650 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 650 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 650 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 650 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0193] The display screen 660 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 660 is a touch display screen, the display screen 660 also has the ability to collect touch signals on the surface or above the surface of the display screen 660. The touch signal can be input to the processor 610 as a control signal for processing. At this time, the display screen 660 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 660 can be one, set on the front panel of the electronic device 600; in other embodiments, the display screen 660 can be at least two, respectively set on different surfaces of the electronic device 600 or in a folding design; in other embodiments, the display screen 660 can be a flexible display screen, set on the curved surface or folding surface of the electronic device 600. Even, the display screen 660 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 660 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).
[0194] The audio circuit 670 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 610 for processing, or input them into the radio frequency circuit 650 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the electronic device 600. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 610 or the radio frequency circuit 650 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 670 may also include a headphone jack.
[0195] The power supply 680 is used to power various components in the electronic device 600. The power supply 680 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 680 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged through a wired line, and a wireless rechargeable battery is a battery that is charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0196] In the several embodiments provided in the present application, it should be understood that the disclosed electronic device 600 and display processing method can be implemented in other ways. For example, the various embodiments of the electronic device 600 described above are only schematic. For example, the division of modules or units is a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0197] 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 present embodiment.
[0198] In addition, each functional unit in each embodiment of the present application 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.
[0199] Fig.10 It is a schematic block diagram of the circuit structure of the computer-readable storage medium of the present application. If the above-mentioned 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 computer-readable storage medium 700. Based on this understanding, the technical solution of the present application 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 / computer programs to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each embodiment of the present invention. The aforementioned storage medium includes: various media such as a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and electronic devices such as computers, mobile phones, laptops, tablet computers, cameras, etc. having the above-mentioned storage medium.
[0200] The description of the execution process of the program data in the computer-readable storage medium can refer to the description in the embodiment of the training and processing method of the dialogue emotion recognition model of the present application mentioned above, and will not be repeated here.
[0201] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A training method for a dialogue emotion recognition model, characterized in that: include: Get the current dialogue element in the training sample; The current dialogue elements include words of the current sentence; Acquire various external knowledge corresponding to the current dialogue element from the external knowledge base of the dialogue emotion recognition model; the external knowledge includes conceptual knowledge; The acquiring each external knowledge corresponding to the current dialogue element from the external knowledge base of the dialogue emotion recognition model includes: acquiring each conceptual knowledge corresponding to the words of the current sentence from the external knowledge base; Determine whether the current dialogue element matches the corresponding external knowledge; the determining whether the current dialogue element matches the corresponding external knowledge includes: using the SenticNet sentiment dictionary to obtain the sentiment type of the words of the current sentence and the sentiment type of the concept knowledge in the form of a single word, and using the StanfordNLP toolkit to obtain the sentiment type of the concept knowledge in the form of a combination of multiple words; determine whether the sentiment type of the words of the current sentence is the same as the sentiment type of each of the concept knowledge, so as to determine whether the current dialogue element matches the corresponding external knowledge; If not matched, the external knowledge in the external knowledge base that does not match the current dialogue element is eliminated; if not matched, the external knowledge in the external knowledge base that does not match the current dialogue element includes: if the emotion type of the concept knowledge is different from the emotion type of the words of the current sentence, a random number corresponding to the concept knowledge is generated, and it is determined whether the random number is less than a preset value; if the random number is less than the preset value, the concept knowledge in the external knowledge base whose corresponding random number is less than the preset value is eliminated; If there is a match, the external knowledge in the external knowledge base that matches the current dialogue element is retained; if there is a match, the external knowledge in the external knowledge base that matches the current dialogue element is retained including: if the emotion type of the concept knowledge is the same as the emotion type of the words in the current sentence, or if the random number is greater than or equal to the preset value, then the concept knowledge in the external knowledge base whose emotion type is the same as the words in the current sentence, and the corresponding concept knowledge whose random number is greater than or equal to the preset value are retained.
2. The method according to claim 1, characterized in that: The step of eliminating the concept knowledge in the external knowledge base whose corresponding random number is smaller than the preset value includes: The weight values of the concept knowledge whose corresponding random numbers in the external knowledge base are smaller than the preset value are set to 0; The retaining of the concept knowledge in the external knowledge base having the same sentiment type as the words in the current sentence, and the corresponding concept knowledge having the random number greater than or equal to the preset value, includes: The weight values of the concept knowledge in the external knowledge base whose sentiment type is the same as the words in the current sentence, and the concept knowledge whose corresponding random number is greater than or equal to the preset value are both set to the first weight value.
3. The method according to claim 2, characterized in that The determining whether the current dialog element matches the corresponding external knowledge includes: Calculate a first vector for representing the sentiment label of the current sentence and a second vector for representing each of the concept knowledge corresponding to each word of the current sentence by an embedding mapping method; Calculating a first cosine similarity between each of the second vectors and the first vector; Determining whether the first cosine similarity is less than a first preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge; If there is no match, then removing the external knowledge in the external knowledge base that does not match the current dialog element includes: If the first cosine similarity is less than the first preset threshold, the concept knowledge in the external knowledge base whose first cosine similarity is less than the first preset threshold is eliminated; If there is a match, retaining the external knowledge in the external knowledge base that matches the current dialog element comprises: If the first cosine similarity is greater than or equal to the first preset threshold, retaining the concept knowledge in the external knowledge base whose first cosine similarity is greater than or equal to the first preset threshold; The step of removing the external knowledge in the external knowledge base that does not match the current dialog element includes: Setting the weight value of the concept knowledge in the external knowledge base whose first cosine similarity is less than a first preset threshold to 0; The retaining the external knowledge in the external knowledge base that matches the current dialog element comprises: The weight value of the concept knowledge in the external knowledge base whose first cosine similarity is greater than or equal to the first preset threshold is set as a second weight value.
4. The method according to claim 3, characterized in that The current dialogue element also includes the previous sentence of the current sentence; The determining whether the current dialog element matches the corresponding external knowledge further includes: Calculate the vector corresponding to each of the above sentences and used to characterize the sentiment label of each of the above sentences by the Embedding mapping method, and perform weighted averaging on the vectors corresponding to all of the above sentences to obtain a third vector; Adding the first vector and the third vector and calculating the average thereof to obtain a mean vector; respectively calculating the second cosine similarity between each of the second vectors and the mean vector; Determining whether the second cosine similarity is less than a second preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge; If there is no match, then removing the external knowledge in the external knowledge base that does not match the current dialog element includes: If the second cosine similarity is less than the second preset threshold, the concept knowledge in the external knowledge base whose second cosine similarity is less than the second preset threshold is eliminated; If there is a match, retaining the external knowledge in the external knowledge base that matches the current dialog element comprises: If the second cosine similarity is greater than or equal to the second preset threshold, retaining the concept knowledge in the external knowledge base whose second cosine similarity is greater than or equal to the second preset threshold; The step of eliminating the concept knowledge in the external knowledge base whose second cosine similarity is less than the second preset threshold comprises: Setting the weight value of the concept knowledge in the external knowledge base whose second cosine similarity is less than the second preset threshold to 0; The retaining the concept knowledge in the external knowledge base whose second cosine similarity is greater than or equal to the second preset threshold comprises: The weight value of the concept knowledge in the external knowledge base whose second cosine similarity is greater than or equal to the second preset threshold is set as a third weight value.
5. The method according to claim 4, characterized in that The method further comprises: Calculate the sum of the product of the second weight value and the first coefficient and the product of the third weight value and the second coefficient, and multiply the sum of the product and the first weight value to obtain a comprehensive weight value; wherein the sum of the first coefficient and the second coefficient is 1; After acquiring each of the concept knowledge corresponding to the words of the current sentence from the external knowledge base, the method includes: Using the VAD dimension emotion model, a fourth vector representing the emotion intensity of the words of the current sentence in the VAD dimension emotion model is calculated, and a fifth vector representing the emotion intensity of the concept knowledge in the VAD dimension emotion model is calculated; Calculating a third cosine similarity between the fourth vector and the fifth vector; Calculate the product of the sum of the third cosine similarity and a constant and the comprehensive weight value to obtain a final weight value; Calculate the initial knowledge vector of each concept knowledge corresponding to each word of the current sentence and the initial word vector of each word of the current sentence by using the Embedding mapping method; Calculate the initial knowledge vector of each of the concept knowledge of the current sentence and the corresponding final weight value to obtain a weighted vector, and calculate the ratio of the weighted vector to the total amount of the concept knowledge corresponding to each of the words to obtain the concept knowledge vector of the current sentence; Merging the concept knowledge vector of each word in the current sentence with the initial word vector, and then multiplying the result with the first mapping parameter to obtain a final word vector for each word; Merging the final word vectors of all words in the current sentence, and then multiplying them by the second mapping parameter to obtain a final sentence vector of the current sentence; Merging the final sentence vector of the current sentence and the final sentence vector of the sentence before the current sentence, and inputting the result into the dialogue emotion recognition model for calculation to output the emotion value of the current sentence; Calculate a loss value between the sentiment value of the current sentence and the corresponding true sentiment value, and use the loss value to adjust the first mapping parameter and / or the second mapping parameter.
6. The method according to claim 1, characterized in that The current dialogue element includes a current sentence; The acquiring each external knowledge corresponding to the current dialogue element from the external knowledge base of the dialogue emotion recognition model includes: Acquire each generated knowledge corresponding to the current sentence from the external knowledge base; The determining whether the current dialog element matches the corresponding external knowledge includes: Calculate a first vector of the sentiment label for characterizing the current sentence by an Embedding mapping method; Acquire a sixth vector representing each of the generated knowledge output by the external knowledge base; Performing dimension conversion on each of the first vectors and the sixth vector so that each of the first vectors and the sixth vectors after conversion has the same self-vector dimension, and calculating the fourth cosine similarity between each of the sixth vectors after conversion and the first vector; Determining whether the fourth cosine similarity is less than a third preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge; If there is no match, then removing the external knowledge in the external knowledge base that does not match the current dialog element includes: If the fourth cosine similarity is less than the third preset threshold, the generated knowledge in the external knowledge base whose fourth cosine similarity is less than the third preset threshold is eliminated; If there is a match, retaining the external knowledge in the external knowledge base that matches the current dialog element comprises: If the fourth cosine similarity is greater than or equal to the third preset threshold, retaining the generated knowledge in the external knowledge base whose fourth cosine similarity is greater than or equal to the third preset threshold; The removing the generated knowledge in the external knowledge base whose fourth cosine similarity is less than the third preset threshold comprises: Setting the weight value of the generated knowledge in the external knowledge base whose fourth cosine similarity is less than the third preset threshold to 0; The retaining the generated knowledge in the external knowledge base whose fourth cosine similarity is greater than or equal to the third preset threshold comprises: The weight value of the generated knowledge in the external knowledge base whose fourth cosine similarity is greater than or equal to the third preset threshold is set as a fourth weight value.
7. The method according to claim 6, characterized in that The current dialogue element also includes the previous sentence of the current sentence; The determining whether the current dialog element matches the corresponding external knowledge further includes: Calculate the vector of the sentiment label corresponding to each of the above sentences and used to characterize the above sentences by the Embedding mapping method, and perform weighted average on the vectors of all the above sentences to obtain a third vector; Adding the first vector and the third vector and calculating the average thereof to obtain a mean vector; respectively calculating the fifth cosine similarity between each of the sixth vectors and the mean vector; Determining whether the fifth cosine similarity is less than a fourth preset threshold value, so as to determine whether the current dialogue element matches the corresponding external knowledge; If there is no match, then removing the external knowledge in the external knowledge base that does not match the current dialog element includes: If the fifth cosine similarity is less than the fourth preset threshold, the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold is eliminated; If there is a match, retaining the external knowledge in the external knowledge base that matches the current dialog element comprises: If the fifth cosine similarity is greater than or equal to the fourth preset threshold, retaining the generated knowledge in the external knowledge base whose fifth cosine similarity is greater than or equal to the fifth preset threshold; The removing the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold comprises: Setting the weight value of the generated knowledge in the external knowledge base whose fifth cosine similarity is less than the fourth preset threshold to 0; The retaining the generated knowledge in the external knowledge base whose fifth cosine similarity is greater than or equal to the fourth preset threshold comprises: The weight value of the generated knowledge in the external knowledge base whose fifth cosine similarity is greater than or equal to the fourth preset threshold is set as a fifth weight value.
8. The method according to claim 7, characterized in that The method further comprises: Calculating a final weight value of the generated knowledge retained in the external knowledge base using the conversation emotion recognition model by using the fourth weight value and the fifth weight value; Obtaining the initial knowledge vector of each generated knowledge corresponding to each word of the current sentence output by the external knowledge base, and calculating the initial word vector of each word of the current sentence by using the Embedding mapping method; Merging the initial word vectors of each word of the current sentence, and then multiplying the initial word vectors by the first mapping parameter to obtain the initial sentence vector of the current sentence; Calculate the initial knowledge vector of each generated knowledge corresponding to the current sentence and the corresponding final weight value to obtain a weighted vector, and calculate the ratio of the weighted vector to the total amount of generated knowledge corresponding to the current sentence to obtain the external knowledge vector of the current sentence; Merging the initial sentence vector of the current sentence with the external knowledge vector of the current sentence, and then multiplying the result with the second mapping parameter to obtain a final sentence vector of the current sentence; Merging the final sentence vector of the current sentence with the final sentence vector of the sentence above the current sentence, and inputting the result into the emotion recognition model for calculation to output the emotion value of the current sentence; Calculate a loss value between the sentiment value of the current sentence and the corresponding true sentiment value, and use the loss value to adjust the first mapping parameter and / or the second mapping parameter.
9. An electronic device, characterized in that: It includes a processor, a memory and a human-computer interaction circuit, the memory and the human-computer interaction circuit are respectively coupled to the processor, the memory stores a computer program, and the processor is used to execute the computer program to implement the method as claimed in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Dialogue command understanding method based on knowledge graph
CN110147451A
Voice data processing method, voice data processing device and storage medium
CN111444322A