Method and apparatus for text sentiment recognition, computer storage medium, and electronic device

By entering the text to be identified into the emotional task model and determining the categories of attribute words and emotional words, the problems of low accuracy and incomplete content in the prior art text emotion recognition are solved, and high accuracy and comprehensive emotional recognition results are achieved.

WO2025077885A1PCT designated stage expired Publication Date: 2025-04-17CHINA TELECOM CORP LTD

Patent Information

Application Number
PCT/CN2024/124480
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-13
Filing Date
2024-10-12
Publication Date
2025-04-17

AI Technical Summary

Technical Problem

In the prior art, the accuracy of the recognition results obtained after emotional recognition of text is low and the content of the recognition results is incomplete.

Method used

By obtaining the text to be identified, the text includes at least attribute words and emotional words. The attribute words are the subject of the description of the emotional words. The text to be identified is input into the emotional task model to process it to obtain the emotional recognition results. The emotion task model is used to determine the attribute category to which the attribute word belongs and the emotional category to which the emotional word belongs, determine all permutations and combination results of the attribute word, emotion word, emotion category and attribute category, and determine the target permutations and combination results as the emotion recognition results.

Benefits of technology

It improves the accuracy of text emotion recognition, ensures that the content of the recognition results is comprehensive, and accurately predicts the emotional recognition results, and improves prediction efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024124480_17042025_PF_FP_ABST
    Figure CN2024124480_17042025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the field of natural language processing or other related fields, and discloses a method and apparatus for text sentiment recognition, a computer storage medium, and an electronic device. The method comprises: obtaining text to be recognized, wherein said text at least comprises an attribute word and an emotion word, and the attribute word refers to a subject that the emotion word describes; and inputting said text to a sentiment task model for processing to obtain a sentiment recognition result, wherein the sentiment task model is configured to determine an attribute category to which the attribute word belongs and an emotion category to which the emotion word belongs, determine all permutation and combination results of the attribute word, the emotion word, the emotion category, and the attribute category, and determine a target permutation and combination result among all the permutation and combination results as the sentiment recognition result. The present application solves problems in the related art that accuracy of recognition results of text sentiment recognition is low and content of the recognition results is incomplete.
Need to check novelty before this filing date? Find Prior Art

Description

Text emotion recognition method, device, computer storage medium and electronic device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on October 13, 2023, with application number 2023113331139 and application name “Text Emotion Recognition Method, Device, Computer Storage Medium and Electronic Device”, all contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of natural language processing or other related fields, and specifically, to a method, device, computer storage medium, and electronic device for text emotion recognition. Background Art

[0003] With the development of deep learning, emotion recognition methods have made great progress and have gradually been applied to various scenarios, such as social media analysis, sentiment analysis, user review analysis, intelligent customer service, etc. By using emotion recognition methods to extract features from text or speech, and performing emotion classification through multi-layer neural networks, rich and abstract features can be learned from a large amount of data, thereby improving the accuracy of emotion recognition, and then accurately understanding the user's emotional needs and attitudes, thereby providing more personalized services and products. Among them, emotion recognition refers to the detailed and specific emotion classification and recognition of emotions expressed in text or speech.

[0004] However, related technologies usually rely on traditional rule-based and machine learning methods, that is, by constructing a series of rules and features to judge the emotions in text or speech, and at the same time, multiple sub-models are needed to process the sub-tasks involved in emotion recognition, where the sub-tasks may include: AE (extracting all attribute words in a sentence), AC (predicting the classification of attribute words in a given sentence), OE (extracting all emotion words in a sentence), ALSC (predicting the emotion category of each attribute word in a given sentence), AOE (extracting the paired emotion words for each given attribute word in a sentence), AESC (extracting the corresponding emotion category while extracting the attribute word), Pair (extracting the corresponding emotion word while extracting the attribute word) and Triplet (extracting attribute words, emotion categories, and emotion words at the same time). However, this method usually requires human intervention and is often ineffective for complex emotional expressions. The machine learning-based method, on the other hand, is a model that learns to extract features from input text or speech and classify emotions by training a classifier. Compared with the rule-based method, this method is more automated and intelligent, but it still has problems such as the generated recognition order is immutable, attributes and emotion categories may not exist in the sentence, emotion categories are fixed and single, and recognition accuracy is low.

[0005] Currently, no effective solution has been proposed to address the problems of low accuracy and incomplete content of the recognition results obtained after performing emotion recognition on text in related technologies.

[0006] Summary of the Invention

[0007] The main purpose of this application is to provide a text emotion recognition method, device, computer storage medium and electronic device to solve the problems in the related art of low accuracy and incomplete content of the recognition results obtained after emotion recognition of text.

[0008] To achieve the above-mentioned objectives, according to one aspect of the present application, a method for emotion recognition in text is provided. The method comprises: obtaining a text to be recognized, wherein the text to be recognized includes at least attribute words and emotion words, wherein the attribute words refer to the descriptive body of the emotion words; inputting the text to be recognized into an emotion task model, processing the text to obtain an emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute words belong and the emotion category to which the emotion words belong, determine all permutations and combinations of the attribute words, emotion words, emotion categories, and attribute categories, and determine a target permutation and combination result among all the permutations and combination results as the emotion recognition result.

[0009] In some embodiments, the emotion task model is trained in the following manner: obtaining X sample texts and obtaining text data for each sample text to obtain X groups of text data, wherein each group of text data includes sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories, where X is a positive integer; for the X sample texts, determining a group of sample emotion recognition results for each sample text based on the text data to obtain X groups of sample emotion recognition results, wherein each group of sample emotion recognition results includes all permutations and combinations of sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories; using the X sample texts, X groups of text data, and X groups of sample emotion recognition results to train an initial emotion task model to obtain an emotion task model.

[0010] In some embodiments, an initial emotion task model is trained using X sample texts, X groups of text data, and X groups of sample emotion recognition results to obtain the emotion task model, including: inputting X sample texts into the initial emotion task model and processing them to obtain X predicted emotion recognition results; determining a sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text, and the loss function value of the initial emotion task model is constituted by the sub-loss function values ​​of the X sample texts; judging whether the loss function value meets a preset condition, and if the loss function value does not meet the preset condition, adjusting the model parameters of the initial emotion task model until the loss function value of the adjusted initial emotion task model meets the preset condition, thereby obtaining the emotion task model.

[0011] In some embodiments, inputting X sample texts into an initial emotion task model and processing to obtain X predicted emotion recognition results includes: for one sample text, encoding a sample emotion category and a sample attribute category associated with the sample text to obtain an emotion vector and an attribute vector, and encoding the sample text to obtain a text vector; calculating a vector product of the text vector and the emotion vector to obtain a first vector product, calculating a vector product of the text vector and the attribute vector to obtain a second vector product; calculating a vector product of the first vector product and the second vector product to obtain a combined vector product, and decoding the combined vector product to obtain a predicted emotion recognition result of the sample text.

[0012] In some embodiments, determining whether the loss function value satisfies a preset condition includes: determining whether the loss function value is less than a preset threshold; when the loss function value is less than the preset threshold, determining whether the first function value and the second function value associated with each sub-loss function value satisfy the loss function condition, wherein the loss function condition refers to that the first function value associated with each sub-loss function value is less than the first loss threshold, and the second function value associated with each sub-loss function value is greater than the second loss threshold, the first function value is the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result, and the second function value is the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result; when the first function value and the second function value associated with all sub-loss function values ​​satisfy the loss function condition, determining that the loss function value satisfies the preset condition; when the loss function value is greater than or equal to the preset threshold, or when the first function value and the second function value associated with at least one sub-loss function value does not satisfy the loss function condition, determining that the loss function value does not satisfy the preset condition.

[0013] In some embodiments, a group of sample emotion recognition results for each sample text includes positive emotion recognition results and negative emotion recognition results, and determining the sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text includes: calculating the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result to obtain a first function value, and calculating the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result to obtain a second function value; obtaining the character length associated with the predicted emotion recognition result to obtain a first character length, and obtaining the character length associated with the positive emotion recognition result to obtain a second character length; calculating the mean square error loss function value of the first character length and the second character length to obtain a third function value; determining the sub-loss function value by the first function value, the second function value and the third function value.

[0014] In some embodiments, the positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following manner: calculating the fluency score of each emotion recognition result in each group of emotion recognition results to obtain Y fluency scores, and sorting the Y fluency scores in descending order to obtain a fluency arrangement, where Y is a positive integer; screening out a preset number of fluency scores at the top of the fluency arrangement, and using the emotion recognition results associated with the preset number of fluency scores as positive emotion recognition results, and using the emotion recognition results associated with the remaining fluency scores in the fluency arrangement as negative emotion recognition results.

[0015] In some embodiments, the positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following manner: a first result obtained by sequentially concatenating the sample attribute words, sample attribute categories, sample emotion words, and sample emotion categories; a second result obtained by sequentially concatenating the sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories; a third result obtained by sequentially concatenating the sample emotion words, sample emotion categories, sample attribute words, and sample attribute categories; and a fourth result obtained by sequentially concatenating the sample emotion words, sample attribute categories, sample attribute words, and sample emotion categories, and the first result, the second result, the third result, and the fourth result are determined as positive emotion recognition results; and the permutation and combination results other than the positive emotion recognition results in each group of sample emotion recognition results are determined as negative emotion recognition results.

[0016] To achieve the above-mentioned purpose, according to another aspect of the present application, a device for identifying emotions in text is provided. The device comprises: an acquisition unit for acquiring text to be identified, wherein the text to be identified includes at least attribute words and emotion words, and the attribute words refer to the descriptive body of the emotion words; an input unit for inputting the text to be identified into an emotion task model and processing it to obtain an emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute words belong and the emotion category to which the emotion words belong, determine all permutations and combinations of the attribute words, emotion words, emotion categories, and attribute categories, and determine a target permutation and combination result among all the permutations and combination results as the emotion recognition result.

[0017] According to another aspect of an embodiment of the present application, a computer storage medium is further provided, which is used to store a program, wherein when the program is run, the device where the computer storage medium is located is controlled to execute a text emotion recognition method.

[0018] According to another aspect of an embodiment of the present application, an electronic device is also provided, comprising one or more processors and a memory; the memory is used to store one or more programs, wherein, when the one or more programs are executed by one or more processors, the one or more processors implement a method for emotion recognition in text.

[0019] Through this application, the following steps are adopted: obtaining a text to be recognized, wherein the text to be recognized includes at least attribute words and sentiment words, and the attribute words refer to the descriptive subject of the sentiment words; inputting the text to be recognized into an emotion task model, and processing to obtain an emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute words belong and the sentiment category to which the sentiment words belong, determine all permutations and combinations of attribute words, sentiment words, sentiment categories and attribute categories, and determine the target permutation and combination results among all permutations and combination results as the emotion recognition result, thereby solving the problems of low accuracy and incomplete content of the recognition results obtained after emotion recognition of text in the related art. By inputting the text to be recognized into the emotion task model, the emotion task model determines the attribute category based on the attribute words and determines the sentiment category based on the sentiment words, thereby determining the emotion recognition result according to the attribute words, sentiment words, attribute categories and sentiment categories, thereby achieving the effect of accurately predicting the emotion recognition result and improving the prediction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0021] FIG1 is a flow chart of a method for identifying emotion in text according to an embodiment of the present application;

[0022] FIG2 is a schematic diagram of a training method for an emotion task model according to an embodiment of the present application;

[0023] FIG3 is a flowchart of obtaining predicted emotion recognition results according to an embodiment of the present application;

[0024] FIG4 is a schematic diagram of a method for determining a sub-loss function value according to an embodiment of the present application;

[0025] FIG5 is a schematic diagram of a text emotion recognition device provided according to an embodiment of the present application;

[0026] FIG6 is a schematic diagram of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0027] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0028] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0031] In the field of product services, using fine-grained emotion recognition methods to classify and identify texts posted by users on social media has gradually become a necessary task for service providers before providing services and products. When using fine-grained emotion recognition methods, it is necessary to use multiple prediction models to identify multiple subtasks, and then extract relevant information in the text based on the recognition results of the subtasks to determine the user's emotional needs and attitudes, so as to personalize the product. However, when using this fine-grained emotion recognition method, it is usually necessary to use multiple prediction models for prediction. Different prediction models can easily affect the accuracy of the prediction, the predicted emotion categories are relatively single, and the generated answers are relatively solidified. Therefore, in order to solve the above problems, the embodiment of the present application provides a text emotion recognition method, which can obtain recognition results that are more in line with human thinking by constructing an emotion task model based on a thinking chain.

[0032] The present application is described below in conjunction with preferred implementation steps. FIG1 is a flow chart of a text emotion recognition method provided according to an embodiment of the present application. As shown in FIG1 , the method includes the following steps:

[0033] Step S101 : obtaining a text to be recognized, wherein the text to be recognized includes at least attribute words and sentiment words, and the attribute words refer to the description subject of the sentiment words.

[0034] It should be noted that since the text to be identified contains one or more attribute words and sentiment words, the emotion task model can be used for emotion recognition, and more accurate results can be obtained based on attribute words and sentiment words. Among them, attribute words refer to the main body in the text, and sentiment words refer to words that describe emotions in the text. For example, when the text is "chicken legs are not bad", the attribute word of the text is "chicken legs", and the sentiment word is "not bad". Each attribute word has an attribute category, and each sentiment word corresponds to an emotion category. For example, the attribute category of the attribute word "chicken legs" is food, and the emotion category corresponding to the emotion word "not bad" is satisfaction and dissatisfaction.

[0035] In step S102, the text to be recognized is input into the emotion task model, and the emotion recognition result is obtained by processing. The emotion task model is used to determine the attribute category to which the attribute word belongs and the emotion category to which the emotion word belongs, determine all permutations and combinations of the attribute word, emotion word, emotion category and attribute category, and determine the target permutation and combination result among all the permutations and combination results as the emotion recognition result.

[0036] It should be noted that the emotion task model is a learning model based on the thought chain, which can obtain recognition results that are more in line with human thinking. The thought chain refers to a series of natural language reasoning processes starting from the input problem with reference to the human problem-solving method, that is, breaking it down into some intermediate problems and then gradually solving them until the final output conclusion is obtained.

[0037] In some embodiments, when it is necessary to use an emotion task model to perform emotion recognition on the text to be recognized, the text to be recognized can be input into the emotion task model, and the emotion task model performs emotion prediction. That is, after obtaining the attribute words and emotion words in the text to be recognized, the attribute category to which the attribute words belong is determined based on the attribute words, and the emotion category to which the emotion words belong is determined based on the emotion words. The attribute words, emotion words, emotion categories and attribute categories are arranged and combined, and then a more reasonable arrangement and combination result is selected from multiple arrangement and combination results, that is, the target arrangement and combination result is selected as the emotion recognition result, and the emotion recognition result is output. For example, the target arrangement and combination result can be a result obtained by splicing attribute words, attribute categories, emotion words and emotion categories in order.

[0038] The text emotion recognition method provided by the embodiment of the present application obtains a text to be recognized, wherein the text to be recognized includes at least attribute words and emotion words, and the attribute words refer to the descriptive body of the emotion words; the text to be recognized is input into the emotion task model, and the emotion recognition result is obtained through processing, wherein the emotion task model is used to determine the attribute category to which the attribute words belong and the emotion category to which the emotion words belong, determine all permutations and combinations of attribute words, emotion words, emotion categories and attribute categories, and determine the target permutation and combination result among all the permutations and combination results as the emotion recognition result, thereby solving the problem of low accuracy and incomplete content of the recognition results obtained after emotion recognition of text in the related art, and inputting the text to be recognized into the emotion task model, and the emotion task model determines the attribute category based on the attribute words and determines the emotion category based on the emotion words, thereby determining the emotion recognition result according to the attribute words, emotion words, attribute categories and emotion categories, thereby achieving the effect of accurately predicting the emotion recognition result and improving the prediction efficiency.

[0039] Before using the emotion task model to identify the text to be identified, the emotion task model needs to be trained. In some embodiments, in the text emotion recognition method, the emotion task model is trained in the following manner: obtaining X sample texts and obtaining text data for each sample text to obtain X groups of text data, wherein each group of text data includes sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories, where X is a positive integer; for the X sample texts, determining a group of sample emotion recognition results for each sample text based on the text data to obtain X groups of sample emotion recognition results, wherein each group of sample emotion recognition results includes all permutations and combinations of sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories; using the X sample texts, X groups of text data, and X groups of sample emotion recognition results to train the initial emotion task model to obtain the emotion task model.

[0040] In some embodiments, before using the emotion task model to perform emotion recognition operations, the emotion task model needs to be trained. Figure 2 is a schematic diagram of the training method of the emotion task model provided in accordance with an embodiment of the present application. As shown in Figure 2, it is first necessary to construct a sample data set for training the emotion task model, that is, by obtaining multiple sample texts and text data of each sample text, and determining the sample emotion recognition result of each sample text based on the text data, these data constitute a sample training set, wherein the text data contains attribute words, emotion words, attribute categories and emotion category data of each sample text.

[0041] It should be noted that to better train the emotion task model, positive and negative samples can be set and used to train the initial emotion task model. A loss function value is calculated based on the model output, and the model is optimized using the loss function value to obtain the emotion task model. Positive samples include positive emotion recognition results, and negative samples include negative emotion recognition results. This embodiment trains the initial emotion task model using sample text, text data, and sample emotion recognition results, thereby obtaining a highly accurate emotion task model, laying the foundation for subsequent practical operations.

[0042] The emotion task model can be determined by adjusting the initial emotion task model based on the loss function value. In some embodiments, in a text emotion recognition method, the initial emotion task model is trained using X sample texts, X sets of text data, and X sets of sample emotion recognition results. Obtaining the emotion task model includes: inputting the X sample texts into the initial emotion task model and processing to obtain X predicted emotion recognition results; determining a sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text, and forming the loss function value of the initial emotion task model from the sub-loss function values ​​of the X sample texts; determining whether the loss function value meets a preset condition, and if the loss function value does not meet the preset condition, adjusting the model parameters of the initial emotion task model until the loss function value of the adjusted initial emotion task model meets the preset condition, thereby obtaining the emotion task model.

[0043] In some embodiments, when training the initial emotion task model, the sample text and the text data corresponding to the sample text are first input into the initial emotion task model, and the initial emotion task model outputs the predicted emotion recognition result corresponding to each sample text. Furthermore, the output predicted emotion recognition result and the actual sample emotion recognition result are used to calculate the loss function value, and the sub-loss function value can be obtained by using a mean square error loss function.

[0044] Furthermore, a determination is made as to whether the loss function value formed by each sub-loss function value satisfies a preset condition, and the model parameters of the initial emotion task model are adjusted based on the determination result until the loss function value satisfies the preset condition. The preset condition may be that each predicted emotion recognition result differs little from the sample emotion recognition result in the positive sample, differs greatly from the sample emotion recognition result in the negative sample, and the predicted emotion recognition result is less than a set threshold. This embodiment utilizes a loss function to adjust the model parameters of the initial emotion task model, thereby obtaining an emotion task model with higher recognition accuracy.

[0045] Predicted emotion recognition results can be obtained based on the encoding model and the decoding model. In some embodiments, in a text emotion recognition method, X sample texts are input into an initial emotion task model, and processing to obtain X predicted emotion recognition results includes: for each sample text, encoding the sample emotion category and sample attribute category associated with the sample text to obtain an emotion vector and an attribute vector, and encoding the sample text to obtain a text vector; calculating the vector product of the text vector and the emotion vector to obtain a first vector product, calculating the vector product of the text vector and the attribute vector to obtain a second vector product; calculating the vector product of the first vector product and the second vector product to obtain a combined vector product, and decoding the combined vector product to obtain the predicted emotion recognition result of the sample text.

[0046] In some embodiments, in order to obtain the predicted emotion recognition results output by the initial emotion task model, Figure 3 is a flowchart for obtaining the predicted emotion recognition results provided according to an embodiment of the present application. As shown in Figure 3, the sample text and the attribute categories and emotion categories corresponding to the sample text can be input into the initial emotion task model, and each sample text, attribute category and emotion category can be encoded using the encoding model to obtain a text vector, an emotion vector and an attribute vector in turn.

[0047] In some embodiments, the text vector is respectively vector-producted with the sentiment vector and the attribute vector to obtain two vector product results, namely, a first vector product and a second vector product. The two vector product results are then vector-producted again to obtain a combined vector product, wherein the combined vector product is in the form of a vector matrix.

[0048] In some embodiments, the combined vector product is decoded using a decoding model to obtain a predicted emotion recognition result corresponding to each sample text, wherein the encoding model and the decoding model can be large-scale processing models such as gbt-3 (Gradient Boosting Tree-3, also known as the third-generation model based on the gradient boosting tree algorithm), T5 (Text-to-Text Transfer Transformer, also known as a neural network model based on Transformer), and BART (Bidirectional and Auto-Regressive Transformer, also known as a pre-trained model based on Transformer).

[0049] It should be noted that, since the user may omit attribute words or emotion words when outputting the sample text, the initial emotion task model cannot determine the attribute categories and emotion categories corresponding to the omitted attribute words and emotion words before outputting the predicted emotion recognition result. Therefore, in order to prevent the problem of inaccurate output predicted emotion recognition results, "no attribute category" and "no emotion category" can be added respectively when the attribute categories and emotion categories corresponding to the sample text are input into the initial emotion task model. That is, if the number of attribute categories and emotion categories corresponding to a certain sample text is m and n respectively, then when input into the initial emotion task model, the number of attribute categories input is m+1 and the number of emotion categories input is n+1. This embodiment uses the encoding model and the decoding model to encode and decode the sample text, attribute categories and emotion categories, thereby obtaining a more accurate predicted emotion recognition result and improving the model processing efficiency.

[0050] The emotion task model is obtained by adjusting the model parameters of the initial emotion task model according to the relationship between the loss function value and the preset condition. In some embodiments, in the text emotion recognition method, determining whether the loss function value meets the preset condition includes: determining whether the loss function value is less than a preset threshold; if the loss function value is less than the preset threshold, determining whether the first function value and the second function value associated with each sub-loss function value meet the loss function condition, wherein the loss function condition refers to that the first function value associated with each sub-loss function value is less than the first loss threshold, and the second function value associated with each sub-loss function value is greater than the second loss threshold, the first function value is the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result, and the second function value is the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result; if the first function value and the second function value associated with all sub-loss function values ​​meet the loss function condition, determining that the loss function value meets the preset condition; if the loss function value is greater than or equal to the preset threshold, or if the first function value and the second function value associated with at least one sub-loss function value does not meet the loss function condition, determining that the loss function value does not meet the preset condition.

[0051] It should be noted that when using the loss function to adjust the model parameters of the initial emotion task model, it is necessary to set the preset conditions of the loss function. The preset conditions can be that the predicted emotion recognition results need to meet the requirements of having a small difference from the sample emotion recognition results in the positive sample, a large difference from the sample emotion recognition results in the negative sample, and be less than the set threshold.

[0052] In some embodiments, it is first determined whether the loss function value composed of the sub-loss function values ​​determined by each predicted emotion recognition result and the sample emotion recognition result is less than a preset threshold, that is, it is necessary to determine whether the loss function value is small enough. When the loss function value is less than the preset threshold, it is determined whether each sub-loss function value in the loss function value satisfies the loss function condition, wherein each sub-loss function value may include a first function value calculated by the predicted emotion recognition result and the sample emotion recognition result in the positive sample (that is, the positive emotion recognition result), and may also include a first function value calculated by the predicted emotion recognition result and the sample emotion recognition result in the negative sample (that is, the negative emotion recognition result). The second loss function value is obtained, and the loss function condition means that the first loss function value needs to be small enough, that is, the first function value is less than the first loss threshold, and the second function value needs to be large enough, that is, the second function value is greater than the second loss threshold, wherein the loss function condition is determined based on the contrastive learning loss. The contrastive learning loss learns features by comparing the similarities between different samples, that is, each sample is divided into an anchor sample and several negative samples, and then the feature representation is learned by maximizing the similarity between the anchor sample and the positive sample and minimizing the similarity between the anchor sample and the negative sample. Its sample is a sample similar to it, and the negative sample is a sample dissimilar to it.

[0053] In some embodiments, when the first function value and the second function value satisfy the loss function condition, it is determined that the loss function value satisfies the preset condition. If the loss function value is greater than or equal to the preset threshold, the first function value is greater than or equal to the first loss threshold, or the second function value is less than or equal to the second loss threshold, it indicates that the loss function value does not satisfy the preset condition. In this case, the model parameters of the initial emotion task model need to be adjusted until the loss function value satisfies the preset condition. This embodiment adjusts the model parameters of the initial emotion task model by utilizing the relationship between the loss function value and the preset condition, thereby being able to more accurately obtain the emotion task model.

[0054] The sub-loss function value can be obtained by the loss function value of the positive emotion recognition result and the negative emotion recognition result. In some embodiments, in the emotion recognition method of text, a group of sample emotion recognition results of each sample text includes a positive emotion recognition result and a negative emotion recognition result, and determining the sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text includes: calculating the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result to obtain a first function value, and calculating the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result to obtain a second function value; obtaining the character length associated with the predicted emotion recognition result to obtain a first character length, and obtaining the character length associated with the positive emotion recognition result to obtain a second character length; calculating the mean square error loss function value of the first character length and the second character length to obtain a third function value; determining the sub-loss function value by the first function value, the second function value and the third function value.

[0055] It should be noted that Figure 4 is a schematic diagram of the method for determining the sub-loss function value provided according to an embodiment of the present application. As shown in Figure 4, when calculating the loss function value, it can be changed to calculating the minimum value of multiple mean square error loss functions on the basis of the mean square error loss function loss_mse, that is, determining the minimum loss function value of the predicted emotion recognition result and a positive emotion recognition result among multiple positive emotion recognition results.

[0056] In some embodiments, the sub-loss function value (Loss) can be calculated using the following formula: Loss = αL CE +(1-α)L head ;

[0057] Among them, α is the preset parameter, L CE It refers to the comparative learning loss function value obtained by calculating the predicted emotion recognition result and the positive emotion recognition result or the negative emotion recognition result. head It refers to the mean square error loss function value obtained based on the predicted emotion recognition results and the positive emotion recognition results.

[0058] And L CE It can be calculated by the following formula: L CE =InfoNCE(pred, answer+, answer-);

[0059] Among them, InfoNCE() refers to the contrastive learning loss function, pred refers to the predicted emotion recognition result, answer+ refers to the positive emotion recognition result, and answer- refers to the negative emotion recognition result.

[0060] L head It can be calculated by the following formula: L head=loss_mse(pred_start, answer+_start),

[0061] Here, loss_mse() refers to the mean square error loss function, pred_start can be determined by int(0.1*len(pred)), and answer+_start can be determined by int(0.1*len(answer+)). This embodiment uses the mean square error loss function and the contrastive learning loss function to calculate the sub-loss function values, thereby laying the foundation for determining the emotion task model.

[0062] There may be multiple methods for determining positive emotion recognition results and negative emotion recognition results. In some embodiments, in a text emotion recognition method, the positive emotion recognition results and negative emotion recognition results in each set of sample emotion recognition results are determined by: calculating the fluency score of each emotion recognition result in each set of current emotion recognition results to obtain Y fluency scores, and sorting the Y fluency scores in descending order to obtain a fluency ranking, where Y is a positive integer; screening out a preset number of fluency scores that are ranked at the top from the fluency ranking, and using the emotion recognition results associated with the preset number of fluency scores as positive emotion recognition results, and using the emotion recognition results associated with the remaining fluency scores in the fluency ranking as negative emotion recognition results.

[0063] It should be noted that before inputting the sample text, attribute type, and emotion type into the initial emotion task model, it is necessary to determine the positive emotion recognition results and the negative emotion recognition results, and the positive emotion recognition results and the negative emotion recognition results can be determined based on the fluency score.

[0064] In some embodiments, the emotion recognition results corresponding to each sample text are first scored for fluency, thereby obtaining multiple fluency scores. The fluency scores are then sorted in descending order to obtain a fluency ranking. A preset number of fluency scores at the top of the fluency ranking are screened out from the fluency ranking, and the emotion recognition results associated with the fluency scores are used as positive emotion recognition results, while the emotion recognition results associated with the remaining fluency scores in the fluency ranking are used as negative emotion recognition results. For example, a sample text is "chicken legs are not bad", and the two emotion recognition results corresponding to the sample text are: the attribute is "chicken legs", the opinion on "chicken legs" is "not bad", "not bad" is the degree of "satisfaction", and "chicken legs" belong to the "food" category; the attribute is "individual chicken legs", the opinion on "individual chicken legs" is "not yet", "not yet" is the degree of "satisfaction", and "individual chicken legs" belong to the "tool" category. After the two emotion recognition results are fluency scored, if the fluency score of the first emotion recognition result is higher than the fluency score of the second emotion recognition result, the first emotion recognition result is used as the positive emotion recognition result, and the second emotion recognition result is used as the negative emotion recognition result. This embodiment determines positive emotion recognition results and negative emotion recognition results by using fluency scores, thereby laying the foundation for training the initial emotion task model.

[0065] Positive emotion recognition results and negative emotion recognition results can also be determined in a variety of ways. In some embodiments, in the text emotion recognition method, the positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following ways: a first result obtained by sequentially splicing sample attribute words, sample attribute categories, sample emotion words, and sample emotion categories; a second result obtained by sequentially splicing sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories; a third result obtained by sequentially splicing sample emotion words, sample emotion categories, sample attribute words, and sample attribute categories; a fourth result obtained by sequentially splicing sample emotion words, sample attribute categories, sample attribute words, and sample emotion categories; and determining the first result, the second result, the third result, and the fourth result as positive emotion recognition results; and determining the permutation and combination results other than the positive emotion recognition results in each group of sample emotion recognition results as negative emotion recognition results.

[0066] Specifically, the positive emotion recognition results and the negative emotion recognition results can also be determined by enumeration method. First, the sample attribute words, sample attribute categories, sample emotion words and sample emotion categories of each sample text are obtained, and then they are arranged and combined. For example, if the sample text is "chicken legs are not bad", and the sample attribute word of the sample text is "chicken legs", the sample emotion word is "not bad", the sample attribute category is "food", and the sample emotion categories are "satisfied" and "dissatisfied".

[0067] In some embodiments, the sample sentiment words and the sample attribute words are used as the beginning for arrangement and combination respectively. For example, when the sample sentiment words are used as the beginning, the result obtained is the result obtained by splicing the sample sentiment words, sample sentiment categories, sample attribute words and sample attribute categories in order: the opinion is "not bad", "not bad" is the degree of "satisfaction", "not bad" is the evaluation of "chicken legs", and "chicken legs" belong to the "food" category; and the result obtained by splicing the sample sentiment words, sample attribute categories, sample attribute words and sample sentiment categories in order: the opinion is "not bad", "not bad" is the evaluation of "chicken legs", "chicken legs" belong to the "food" category, and "not bad" is the degree of "satisfaction". Alternatively, we can start with a sample attribute word and obtain the following results by sequentially concatenating the sample attribute words, sample attribute categories, sample sentiment words, and sample sentiment categories: the attribute is "chicken leg," "chicken leg" belongs to the "food" category, the opinion about "chicken leg" is "not bad," and "not bad" is the degree of "satisfaction." Alternatively, we can obtain the following results by sequentially concatenating the sample attribute words, sample sentiment words, sample sentiment categories, and sample attribute categories: the attribute is "chicken leg," the opinion about "chicken leg" is "not bad," "not bad" is the degree of "satisfaction," and "chicken leg" belongs to the "food" category. These results are considered positive emotion recognition results. Furthermore, permutation and combination results other than the positive emotion recognition results in each set of sample emotion recognition results are determined as negative emotion recognition results. For example, when the attribute words are extracted incorrectly, a negative emotion recognition result can be obtained: the attribute is "a chicken leg," the opinion on "a chicken leg" is "not yet," "not yet" is the degree of "satisfaction," and "a chicken leg" belongs to the "tool" category. It can also be a result of an incorrect logical order of sample emotion words, sample emotion categories, sample attribute words, and sample attribute categories: "chicken legs" belongs to the "food" category, the opinion is "not bad," "not bad" is the degree of "satisfaction," and "not bad" is the evaluation of "chicken legs." This embodiment determines positive and negative emotion recognition results by using an enumeration method, thereby laying the foundation for training the initial emotion task model.

[0068] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0069] The present application also provides a text emotion recognition device. It should be noted that the text emotion recognition device of the present application embodiment can be used to execute the text emotion recognition method provided in the present application embodiment. The text emotion recognition device provided in the present application embodiment is introduced below.

[0070] FIG5 is a schematic diagram of a text emotion recognition device provided according to an embodiment of the present application. As shown in FIG5 , the device includes: an acquisition unit 50 and an input unit 51 .

[0071] The acquisition unit 50 is used to acquire the text to be recognized, wherein the text to be recognized includes at least attribute words and sentiment words, and the attribute words refer to the description subject of the sentiment words;

[0072] The input unit 51 is used to input the text to be recognized into the emotion task model, and process it to obtain the emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute word belongs and the emotion category to which the emotion word belongs, determine all permutations and combinations of the attribute words, emotion words, emotion categories and attribute categories, and determine the target permutation and combination result among all the permutations and combination results as the emotion recognition result.

[0073] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: the emotion task model is trained in the following manner: a first acquisition module, used to obtain X sample texts, and obtain text data of each sample text to obtain X groups of text data, wherein each group of text data includes sample attribute words, sample emotion words, sample emotion categories and sample attribute categories, wherein X is a positive integer; a first determination module, used to determine a group of sample emotion recognition results for each sample text according to the text data for the X sample texts, to obtain X groups of sample emotion recognition results, wherein each group of sample emotion recognition results includes all permutations and combinations of sample attribute words, sample emotion words, sample emotion categories and sample attribute categories; a training module, used to train the initial emotion task model using the X sample texts, X groups of text data and X groups of sample emotion recognition results to obtain the emotion task model.

[0074] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: an input module, used to input X sample texts into the initial emotion task model, and process them to obtain X predicted emotion recognition results; a second determination module, used to determine the sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text, and the loss function value of the initial emotion task model is constituted by the sub-loss function values ​​of the X sample texts; a judgment module, used to judge whether the loss function value meets the preset conditions, and if the loss function value does not meet the preset conditions, adjust the model parameters of the initial emotion task model until the loss function value of the adjusted initial emotion task model meets the preset conditions, thereby obtaining the emotion task model.

[0075] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: an encoding module, which is used to encode the sample sample emotion category and the sample sample attribute category associated with a sample text for a sample text to obtain an emotion vector and an attribute vector, and encode the sample text to obtain a text vector; a first calculation module, which is used to calculate the vector product of the text vector and the emotion vector to obtain a first vector product, and calculate the vector product of the text vector and the attribute vector to obtain a second vector product; a second calculation module, which is used to calculate the vector product of the first vector product and the second vector product to obtain a combined vector product, and decode the combined vector product to obtain a predicted emotion recognition result of the sample text.

[0076] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: a first judgment module, used to judge whether the loss function value is less than a preset threshold; a second judgment module, used to judge whether the first function value and the second function value associated with each sub-loss function value meet the loss function condition when the loss function value is less than the preset threshold, wherein the loss function condition means that the first function value associated with each sub-loss function value is less than the first loss threshold, and the second function value associated with each sub-loss function value is greater than the second loss threshold, the first function value is the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result, and the second function value is the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result; a third determination module, used to determine that the loss function value meets the preset condition when the first function value and the second function value associated with all sub-loss function values ​​meet the loss function condition; a fourth determination module, used to determine that the loss function value does not meet the preset condition when the loss function value is greater than or equal to the preset threshold, or when the first function value and the second function value associated with at least one sub-loss function value does not meet the loss function condition.

[0077] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: a third calculation module, used to calculate the comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result to obtain a first function value, and calculate the comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result to obtain a second function value; a second acquisition module, used to obtain the character length associated with the predicted emotion recognition result to obtain a first character length, and obtain the character length associated with the positive emotion recognition result to obtain a second character length; a fourth calculation module, used to calculate the mean square error loss function value of the first character length and the second character length to obtain a third function value; a fifth determination module, used to determine the sub-loss function value based on the first function value, the second function value and the third function value.

[0078] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: the positive emotion recognition results and the negative emotion recognition results in each group of sample emotion recognition results are determined in the following manner: a fifth calculation module, used to calculate the fluency score of each emotion recognition result in each group of current emotion recognition results, obtain Y fluency scores, and sort the Y fluency scores in descending order to obtain a fluency arrangement, where Y is a positive integer; a screening module, used to screen out a preset number of fluency scores ranked at the top from the fluency arrangement, and use the emotion recognition results associated with the preset number of fluency scores as positive emotion recognition results, and use the emotion recognition results associated with the remaining fluency scores in the fluency arrangement as negative emotion recognition results.

[0079] In some embodiments, in the text emotion recognition device provided in the embodiments of the present application, the input unit 51 includes: the positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following manner: a splicing module, which is used to obtain a first result by splicing the sample attribute words, sample attribute categories, sample emotion words and sample emotion categories in sequence, a second result by splicing the sample attribute words, sample emotion words, sample emotion categories and sample attribute categories in sequence, a third result by splicing the sample emotion words, sample emotion categories, sample attribute words and sample attribute categories in sequence, and a fourth result by splicing the sample emotion words, sample attribute categories, sample attribute words and sample emotion categories in sequence, and determining the first result, the second result, the third result and the fourth result as positive emotion recognition results; a sixth determination module, which is used to determine the permutation and combination results other than the positive emotion recognition results in each group of sample emotion recognition results as negative emotion recognition results.

[0080] The emotion recognition device for text provided in the embodiment of the present application is used to obtain the text to be recognized through the acquisition unit 50, wherein the text to be recognized includes at least attribute words and emotion words, and the attribute words refer to the descriptive body of the emotion words; the input unit 51 is used to input the text to be recognized into the emotion task model, and process it to obtain the emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute words belong and the emotion category to which the emotion words belong, determine all permutations and combinations of attribute words, emotion words, emotion categories and attribute categories, and determine the target permutation and combination results among all permutations and combination results as the emotion recognition result, thereby solving the problems of low accuracy and incomplete content of the recognition results obtained after emotion recognition of text in the related art, by inputting the text to be recognized into the emotion task model, and the emotion task model determines the attribute category based on the attribute words and the emotion category based on the emotion words, thereby determining the emotion recognition result according to the attribute words, emotion words, attribute categories and emotion categories, thereby achieving the effect of accurately predicting the emotion recognition result and improving the prediction efficiency.

[0081] The text emotion recognition device includes a processor and a memory. The acquisition unit 50, input unit 51, etc. are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.

[0082] The processor includes a core, which retrieves the corresponding program unit from the memory. One or more cores can be configured, and kernel parameters can be adjusted to address the low accuracy and incompleteness of emotion recognition results obtained from text in related technologies.

[0083] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0084] An embodiment of the present application provides a computer storage medium having a program stored thereon, which implements a method for emotion recognition of text when the program is executed by a processor.

[0085] FIG6 is a schematic diagram of an electronic device according to an embodiment of the present application. As shown in FIG6 , an embodiment of the present application provides an electronic device. The electronic device 60 includes a processor, a memory, and a program stored in the memory and executable on the processor. The processor is configured to execute computer-readable instructions, wherein the computer-readable instructions, when executed, execute a method for recognizing emotions in text. The device herein may be a server, a PC, a PAD, a mobile phone, or the like.

[0086] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for performing a method for emotion recognition of text.

[0087] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0088] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.

[0089] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0091] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0092] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0093] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0094] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0095] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0096] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A text emotion recognition method, comprising: Acquire a text to be recognized, wherein the text to be recognized at least includes attribute words and sentiment words, and the attribute words refer to the description subject of the sentiment words; The text to be recognized is input into the emotion task model and processed to obtain an emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute word belongs and the emotion category to which the emotion word belongs, determine all permutations and combinations of the attribute word, the emotion word, the emotion category and the attribute category, and determine the target permutation and combination result among all the permutations and combination results as the emotion recognition result.

2. The method according to claim 1, wherein: The emotion task model is trained in the following way: Obtain X sample texts, and obtain text data of each sample text to obtain X groups of text data, wherein each group of text data includes sample attribute words, sample sentiment words, sample sentiment categories, and sample attribute categories, wherein X is a positive integer; For the X sample texts, determine a set of sample emotion recognition results for each sample text according to the text data, and obtain X sets of sample emotion recognition results, wherein each set of sample emotion recognition results includes all permutation and combination results of sample attribute words, sample emotion words, sample emotion categories, and sample attribute categories; The initial emotion task model is trained using the X sample texts, the X groups of text data, and the X groups of sample emotion recognition results to obtain the emotion task model.

3. The method according to claim 2, wherein: Using the X sample texts, the X groups of text data, and the X groups of sample emotion recognition results to train an initial emotion task model, the emotion task model includes: Inputting the X sample texts into the initial emotion task model, and processing them to obtain X predicted emotion recognition results; Determine a sub-loss function value based on the predicted emotion recognition result and the sample emotion recognition result of each sample text, and form the loss function value of the initial emotion task model by the sub-loss function values ​​of the X sample texts; Determine whether the loss function value meets the preset conditions, and if the loss function value does not meet the preset conditions, adjust the model parameters of the initial emotion task model until the loss function value of the adjusted initial emotion task model meets the preset conditions, thereby obtaining the emotion task model.

4. The method according to claim 3, wherein: Inputting the X sample texts into the initial emotion task model, and processing to obtain X predicted emotion recognition results includes: For a sample text, a sample emotion category and a sample attribute category associated with the sample text are encoded to obtain an emotion vector and an attribute vector, and the sample text is encoded to obtain a text vector; Calculate the vector product of the text vector and the emotion vector to obtain a first vector product, and calculate the text vector The vector product of the quantity and the attribute vector is obtained to obtain a second vector product sum; The vector product of the first vector product and the second vector product is calculated to obtain a combined vector product, and the combined vector product is decoded to obtain a predicted emotion recognition result of the sample text.

5. The method according to claim 3, wherein: Determining whether the loss function value satisfies a preset condition includes: Determine whether the loss function value is less than a preset threshold; In the case where the loss function value is less than the preset threshold, determine whether the first function value and the second function value associated with each sub-loss function value meet the loss function condition, wherein the loss function condition means that the first function value associated with each sub-loss function value is less than the first loss threshold, and the second function value associated with each sub-loss function value is greater than the second loss threshold, the first function value is a comparative learning loss function value of the predicted emotion recognition result and the positive emotion recognition result, and the second function value is a comparative learning loss function value of the predicted emotion recognition result and the negative emotion recognition result; In the case where the first function values ​​and the second function values ​​associated with all the sub-loss function values ​​satisfy the loss function condition, determining that the loss function value satisfies the preset condition; When the loss function value is greater than or equal to the preset threshold, or the first function value and the second function value associated with at least one sub-loss function value do not satisfy the loss function condition, it is determined that the loss function value does not satisfy the preset condition.

6. The method according to claim 3, wherein: A set of sample emotion recognition results for each sample text includes a positive emotion recognition result and a negative emotion recognition result. The sub-loss function value is determined based on the predicted emotion recognition result and the sample emotion recognition result of each sample text, including: Calculating a comparative learning loss function value between the predicted emotion recognition result and the positive emotion recognition result to obtain a first function value, and calculating a comparative learning loss function value between the predicted emotion recognition result and the negative emotion recognition result to obtain a second function value; Obtaining the character length associated with the predicted emotion recognition result to obtain a first character length, and obtaining the character length associated with the positive emotion recognition result to obtain a second character length; Calculate the mean square error loss function value of the first character length and the second character length to obtain a third function value; The sub-loss function value is determined by the first function value, the second function value and the third function value.

7. The method according to claim 6, wherein: The positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following way: Calculate the fluency score of each emotion recognition result in each group of emotion recognition results to obtain Y fluency scores, and sort the Y fluency scores in descending order to obtain a fluency ranking, where Y is a positive integer; A preset number of fluency scores that are ranked at the top are selected from the fluency ranking, and the preset number of fluency scores are The emotion recognition results associated with the fluency scores of the selected sentences are taken as the positive emotion recognition results, and the emotion recognition results associated with the remaining fluency scores in the fluency arrangement are taken as the negative emotion recognition results.

8. The method according to claim 6, wherein: The positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined in the following way: a first result obtained by sequentially splicing the sample attribute words, the sample attribute categories, the sample emotion words, and the sample emotion categories, a second result obtained by sequentially splicing the sample attribute words, the sample emotion words, the sample emotion categories, and the sample attribute categories, a third result obtained by sequentially splicing the sample emotion words, the sample emotion categories, the sample attribute words, and the sample attribute categories, and a fourth result obtained by sequentially splicing the sample emotion words, the sample attribute categories, the sample attribute words, and the sample emotion categories, and determining the first result, the second result, the third result, and the fourth result as the positive emotion recognition result; The permutation and combination results other than the positive emotion recognition results in each group of sample emotion recognition results are determined as the negative emotion recognition results.

9. The method according to claim 6, wherein: The positive emotion recognition results and negative emotion recognition results in each group of sample emotion recognition results are determined by the following enumeration method: Obtaining sample attribute words, sample attribute categories, sample sentiment words, and sample sentiment categories of each sample text; Arrange and combine the sample attribute words, sample attribute categories, sample sentiment words and sample sentiment categories of each sample text; The permutation and combination results starting with the sample sentiment word and the sample attribute word are determined as the positive emotion recognition results, and the other permutation and combination results are determined as the negative emotion recognition results.

10. A text emotion recognition device, comprising: An acquisition unit, used for acquiring a text to be recognized, wherein the text to be recognized at least includes attribute words and sentiment words, and the attribute words refer to the description subject of the sentiment words; An input unit is used to input the text to be recognized into an emotion task model to process and obtain an emotion recognition result, wherein the emotion task model is used to determine the attribute category to which the attribute word belongs and the emotion category to which the emotion word belongs, determine all permutations and combinations of the attribute word, the emotion word, the emotion category and the attribute category, and determine a target permutation and combination result among all the permutations and combination results as the emotion recognition result.

11. A computer storage medium for storing a program, wherein: When the program is executed, the device where the computer storage medium is located is controlled to execute the text emotion recognition method described in any one of claims 1 to 9.

12. An electronic device comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein: When the one or more programs are executed by the one or more processors, the one or more processors implement the text emotion recognition method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Automobile comment text viewpoint mining method and device and storage medium

    CN112836052A

  • E-commerce comment analysis method and system and computer readable storage medium

    CN116011447A

  • Literature retrieval method, device and system and storage medium

    CN116431838A

  • Large language model distillation method based on thinking chain

    CN116739110A

  • Text emotion recognition method and device, computer storage medium and electronic equipment

    CN117370495A

Cited By

  • Transform-based gateway access threshold dynamic adjustment method and device

    CN120050334A

  • Intelligent screening method and system for student psychological state recognition

    CN120496846A

  • Training method of thinking type recognition model and bad thinking recognition method

    CN120687918A

  • Method for training thought type recognition model and method for recognizing undesirable thought

    CN120687918B

  • Emotion analysis method and system based on big language model reasoning chain generation

    CN121524357A