Text emotion recognition method, device, terminal device and storage medium

By adjusting the text in the target scene and the neutral text in the non-target scene in the training model, the problem of low accuracy of text emotion recognition in the existing technology is solved, the recognition performance and generalization ability are improved, and the model is reduced Training time.

CN112101042BActive Publication Date: 2024-09-17PING AN TECH (SHENZHEN) CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202010961758.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-14
Publication Date
2024-09-17
Estimated Expiration
2040-09-14

AI Technical Summary

Technical Problem

Existing training models have low text emotion recognition accuracy in specific application scenarios and cannot effectively adapt to text classification in different scenarios.

Method used

By inputting text in the target scene and neutral text in the non-target scene into the existing training model, the model parameters are adjusted to form a target model to improve recognition performance and generalization ability.

Benefits of technology

It improves the accuracy of text emotion recognition and the generalization ability of the model, and reduces the training time of the target model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112101042B
    Figure CN112101042B
Patent Text Reader

Abstract

The present application is applicable to the field of artificial intelligence technology, and provides a text emotion recognition method, apparatus, terminal device and storage medium, the method comprising: inputting each target text in each target scene into an existing training model, obtaining the target prediction category corresponding to each target text; obtaining a first text belonging to the target category in each target scene according to the target prediction category; obtaining a second text belonging to a non-target category and belonging to a non-target scene; inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model. The above method is used to train the existing model using the first text in the target scene and the second text in the non-target scene to obtain a target model, and the training time of the model is reduced while ensuring the accuracy of the target model in emotion recognition of the text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence technology, and in particular relates to a text emotion recognition method, apparatus, terminal device and storage medium. Background Art

[0002] In the prior art, in order to reduce the workload of manual processing, existing training models are often used to perform emotion recognition and classification on texts in various application scenarios. However, since the texts in various application scenarios are very different from the sentences and corpora of the training texts used to train the model at that time, the accuracy of classifying texts in various application scenarios using pre-trained models is low. Summary of the invention

[0003] The embodiments of the present application provide a text emotion recognition method, apparatus, terminal device and storage medium, which can solve the problem of low accuracy when using existing training models to recognize and classify text in specific application scenarios.

[0004] In a first aspect, an embodiment of the present application provides a text emotion recognition method, comprising:

[0005] Input each target text in each target scenario into the existing training model to obtain the target prediction category corresponding to each target text;

[0006] According to the target prediction category, obtaining a first text belonging to the target category in each target scene;

[0007] Acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario;

[0008] The first text and the second text are input into an existing training model, the model parameters of the training model are adjusted to obtain a target model, and emotion recognition is performed on the text to be recognized based on the target model.

[0009] In one embodiment, before inputting each target text in each target scenario into an existing training model to obtain a predicted category corresponding to each target text, the method further includes:

[0010] Get multiple texts for each test scenario;

[0011] Inputting the multiple texts in each test scenario into the existing training model respectively to obtain initial prediction categories of the multiple texts in each test scenario;

[0012] According to the initial prediction category, a plurality of target scenes are determined from a plurality of test scenes.

[0013] In one embodiment, according to the initial prediction category, a plurality of target scenarios are determined from a plurality of test scenarios, including:

[0014] According to the initial prediction category, respectively determine the number of texts belonging to the target prediction category in the multiple texts in each test scenario, and determine the total number of texts of the initial prediction category contained in each test scenario;

[0015] Calculate the number of texts belonging to the target prediction category and the percentage of the total number of texts of the initial prediction category corresponding to the test scenario;

[0016] A preset number of the target scenes are selected according to the proportion value corresponding to each test scene, wherein the proportion value corresponding to the target scene is higher than the proportion value corresponding to other test scenes.

[0017] In one embodiment, the target prediction category includes a predicted positive category and a predicted negative category;

[0018] The step of acquiring a first text belonging to a target category in each target scene according to the target prediction category includes:

[0019] In each target text in each target scenario, respectively obtain a first predicted text in which the target text belongs to the predicted positive category and a second predicted text in which the target text belongs to the predicted negative category;

[0020] Obtaining the true categories corresponding to each target text in the target text corresponding to each target scene; wherein the true categories include true positive categories and true negative categories;

[0021] In the first predicted text, the text in which the predicted positive category is consistent with the true positive category is used as the first target text, and the text in which the predicted negative category is consistent with the true negative category is used as the second target text;

[0022] The first target text and the second target text are used as first texts belonging to the target category; wherein the target category includes a positive category and a negative category.

[0023] In one embodiment, after taking the first target text and the second target text as first text belonging to the target category, the method further includes:

[0024] Receiving positive category words and negative category words input by a user;

[0025] According to the positive category vocabulary, searching for a third target text containing the positive category vocabulary in each target text in each target scenario;

[0026] According to the negative category vocabulary, searching for a fourth target text containing the negative category vocabulary in each text in each target scenario;

[0027] The first target text and the third target text are used as positive category texts in the first text, and the second target text and the fourth target text are used as negative category texts in the first text.

[0028] In one embodiment, the step of inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model includes:

[0029] Inputting the first text corresponding to each target scene into a text enhancement model to perform text data enhancement to obtain an enhanced first text;

[0030] The second text and the enhanced first text are input into an existing training model, and the model parameters of the training model are adjusted to obtain a target model.

[0031] In one embodiment, after inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model, the method further includes:

[0032] The emotion recognition result of the text to be recognized is uploaded to the blockchain.

[0033] In a second aspect, an embodiment of the present application provides a text emotion recognition device, comprising:

[0034] An input module is used to input each target text in each target scenario into the existing training model to obtain the target prediction category corresponding to each target text;

[0035] A first acquisition module, configured to acquire, in each target scene, a first text belonging to a target category according to the target prediction category;

[0036] A second acquisition module, configured to acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario;

[0037] The recognition module is used to input the first text and the second text into an existing training model, adjust the model parameters of the training model to obtain a target model, and perform emotion recognition on the text to be recognized based on the target model.

[0038] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a method as described in any one of the first aspects above when executing the computer program.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspects above is implemented.

[0040] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute any of the methods described in the first aspect above.

[0041] A text emotion recognition method provided in an embodiment of the present application uses a first text in a target scenario and belonging to a target category, and a second text in a non-target scenario and belonging to a non-target category as training data based on an existing training model, and adjusts the existing training model so that the trained target model can more fully recognize texts of different categories, thereby improving the recognition performance and generalization ability of the target model and achieving the purpose of reducing the training time of the target model. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 This is a flowchart of a text emotion recognition method provided by an embodiment of the present application;

[0044] Figure 2 is a flowchart of an implementation method of a text emotion recognition method provided by another embodiment of the present application;

[0045] Figure 3 This is a schematic diagram of an implementation method of S203 of a text emotion recognition method provided by another embodiment of the present application;

[0046] Figure 4 This is a schematic diagram of an implementation method of S102 of a text emotion recognition method provided in an embodiment of the present application;

[0047] Figure 5 This is a schematic diagram of another implementation method of S102 of a text emotion recognition method provided by an embodiment of the present application;

[0048] Figure 6 This is a schematic diagram of an implementation method of S104 of a text emotion recognition method provided in an embodiment of the present application;

[0049] Figure 7 It is a structural block diagram of a text emotion recognition device provided by an embodiment of the present application;

[0050] Figure 8 It is a structural block diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] The text emotion recognition method involved in the embodiment of the present application can be executed by a control device or a terminal (hereinafter referred to as a "terminal device").

[0053] See also Figure 1 , Figure 1 The following is a flowchart of a text emotion recognition method provided by an embodiment of the present application, wherein the method comprises the following steps:

[0054] S101: Input each target text in each target scene into an existing training model to obtain a target prediction category corresponding to each target text.

[0055] In the application, each target text in the above target scenario can be a separate Chinese text, English text or text in other languages, or a text in any language combination, without limitation. The above target scenario can be a specific scenario in a specific application scenario. Specifically, the specific application scenario can be an interview scenario, a game interaction scenario, etc. When the specific application scenario is an interview scenario, the scenario is usually a question and answer scenario between the questioner and the respondent. At this time, the target scenario can be specifically: in the interview scenario, the questioner asks an interview question and the respondent answers the interview question. The corresponding content of all the respondents' answers to the same interview question is regarded as each target text in the target scenario. Among them, for the answer content of different respondents, it can be a word "right" or "wrong", or a word "yes" or "no", or a sentence or a paragraph, without limitation.

[0056] In the application, the prediction category can be specifically divided into a prediction positive category, a prediction negative category, and a prediction neutral category. The label category of the text can show the emotions of the respondent to a certain extent. For example, for a text containing words such as "like", "happy", and "satisfied", it can be determined that the respondent is in a positive category emotion at this time. If the text contains words such as "hard work", "difficult", and "uncomfortable", it can be determined that the respondent is in a negative category emotion at this time. In this embodiment, the above-mentioned target prediction category specifically includes a prediction positive category and a prediction negative category in the prediction category.

[0057] In the application, the above-mentioned existing training model can be a text sentiment classification model commonly used in the prior art. For example, it can be a text sentiment classification model obtained by training big data, for example, the BERT model based on the Transformer mechanism, which is obtained by training based on existing text big data, makes full use of the attention mechanism, and has significant effects in the field of natural language processing.

[0058] In a specific application, the target text can be classified according to the existing BERT model as follows: if the target text is "I am very happy today", the existing word vector library can be used to represent the sentence with a feature vector. In the word vector library, a digital number can be assigned to each word in order in advance, so that all words correspond to fixed numbers 1, 2, 3, ..., without limitation. For example, if the first word in the word vector library is "I", the word vector data corresponding to the word "I" is "1", and the word vector feature corresponding to the above "I am very happy today" can be expressed as [2, 3, 4, 5, 6]. If the word vector feature of the preset dimension is to be extracted, and the number of words in the text is insufficient, the text with insufficient words can be represented by a special vector, where the special vector can be the number 0, or a special character, etc. After that, the word vector feature is input into the training model for processing and output, and the output result is the probability value of the training model predicting that the target text is a positive category, a negative category, or a neutral category. For example, they correspond to the probability value of the "positive category" (A), the probability value of the "negative category" (B), and the probability of the "neutral category" (C). If A = 0.8, B = 0.1, and C = 0.1, the category corresponding to the maximum value of the three values ​​is selected as the target prediction category of the target text, that is, the current target text is determined to be the "positive category".

[0059] Among them, for a word or a sentence, the word vector feature representation can be performed in the above manner. For a paragraph containing multiple sentences, it is necessary to clean the punctuation marks in the text to obtain the processed text corresponding to the test scenario. In addition, for texts containing multiple languages ​​at the same time, for example, when answering questions in Chinese, a certain word or a certain sentence in English is used to reply, the English can be converted into Chinese for word feature vector representation, and there is no limitation on this.

[0060] S102: Acquire a first text belonging to a target category in each target scene according to the target prediction category.

[0061] It has been explained in the above S101 that all texts corresponding to a target scene are answers to the same question by different respondents, so the emotions when answering the question may be different. In addition, the above target categories are specifically positive categories and negative categories. It can be seen that in each target scene, the first text belonging to the target category is obtained, and specifically, according to the target prediction category of each target text in the target scene, the text belonging to the positive category and the negative category in the target prediction category is used as the first text. It can be considered that the above neutral category belongs to the non-target category, and the text belonging to the non-target category is not obtained.

[0062] S103: Acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario.

[0063] The first text is a text of a positive category and a text of a negative category obtained in a target scenario, both of which belong to the first text. Therefore, it can be considered that the non-target category is a neutral category and belongs to a text in a non-target scenario. It can be understood as a public text that does not belong to a specific application scenario. For example, it can be a public microblog text, or a text of a public comment data set. In order to quickly obtain the second text, the above-mentioned public text can be input into an existing training model for classification to obtain a second text belonging to a neutral category. In addition, in order to ensure that the second texts obtained all belong to the neutral category, the second texts predicted to belong to the neutral category can be manually screened on this basis. Alternatively, the second texts can all be second texts that are manually selected and stored in a database based on the public texts in advance. When the second text needs to be obtained, it can be directly obtained from the database, and there is no limitation on this.

[0064] S104: input the first text and the second text into an existing training model, adjust the model parameters of the training model to obtain a target model, and perform emotion recognition on the text to be recognized according to the target model.

[0065] In the application, the first text and the second text are input into the existing training model. The purpose is that the neutral text comes from the text in a non-specific application scenario. When training the existing training model, the accuracy of using the training data for predictive recognition and classification can be guaranteed to a certain extent.

[0066] In the application, the target model is a model trained for texts in a target scenario. Therefore, when emotion recognition is performed on the text to be recognized in the target scenario, the recognition accuracy is higher.

[0067] In the application, the above adjustment of the model parameters of the training model can be specifically: the existing training model pre-trains a learning parameter w and a bias vector b, which is used to calculate the vector representation of the text in the feature space. Then, the probability of predicting that the text belongs to each category is expressed based on the calculated vector. Based on this probability, the loss function of the model training can be calculated, and the loss can be reduced through iterative training to improve the model effect.

[0068] Exemplarily, for the input text of the positive category, the training model first obtains the word vector feature of the text, and then inputs the word vector feature into the neural network training, and outputs the probability value (A) = 0.8 for the "positive category". Then, the square difference is calculated with the true value (A1) = 1 that the current text belongs to the positive category, and the training loss is obtained. The model parameters (learning parameter w and bias vector b) for the positive category in the training model are iteratively updated according to the training loss. Among them, the calculation of the training loss can be losscls = (A1 i -A i ) 2 , where A1 i is the predicted category of the i-th positive text, A i is the known category of the i-th positive text. The model parameter adjustment can be: using the loss value of the training loss to perform a partial derivative step on the learning parameters of the last layer of the neural network model, and W 新 =W 旧 -η*c, where c is the partial derivative calculated based on the learning parameters and training loss, W 旧 is the learning parameter of the last layer in the neural network model. Finally, the learning parameter inside the model is updated according to the calculated partial derivative value. 新 The updated learning parameters, η, are the learning efficiency, which is the initial value set by the neural network model. The learning efficiency remains unchanged during the iteration process, and then the learning parameters of each layer are calculated step by step.

[0069] In the application, the first text and the second text are both multiple, and all the first texts and the second texts are simultaneously input into the training model for training until the training loss converges to obtain the final target model. Among them, after each iterative training of the first text and the second text, the training model can calculate the training loss of all training texts in one iterative training, and adjust the model parameters once according to the training loss. In addition, the training texts input into the training model do not contain duplicate texts. The above-mentioned training loss convergence can be to set a fixed number of iterative training times and stop training when the number is reached; or to set that if the text classification effect of the model is not improved after several consecutive iterative trainings, then stop training, and there is no limitation on this. After that, the model training is terminated, and the current training model is used as the adjusted target model.

[0070] In this embodiment, by using the first text in the target scenario and belonging to the target category, and the second text in the non-target scenario and belonging to the non-target category as training data according to the existing training model, the existing training model is adjusted so that the trained target model can more fully recognize texts of different categories, thereby improving the recognition performance and generalization ability of the target model and achieving the purpose of reducing the training time of the target model.

[0071] See also Figure 2 , before inputting each target text in each target scene into the existing training model in S101 and obtaining the target prediction category corresponding to each target text, the following steps S201-S203 are also included, which are described in detail as follows:

[0072] S201. Obtain multiple texts in each test scenario.

[0073] In the application, the above S101 has explained that the target scenario can be a specific scenario under a specific application scenario, and the specific application scenario has an explanation. It can be considered that the test scenario is the above specific application scenario, and no further explanation is given for this.

[0074] S202: Input the multiple texts in each test scenario into the existing training model respectively to obtain initial predicted categories of the multiple texts in each test scenario.

[0075] S203: Determine multiple target scenes from multiple test scenes according to the initial prediction category.

[0076] In the application, multiple texts in each test scenario are input into the existing training model to obtain the initial prediction categories of the multiple texts in each test scenario. Specifically, referring to the above S101, each target text in each target scenario is input into the existing training model to obtain the target prediction category corresponding to each target text. This step is similar to the above S101 step and will not be described again.

[0077] In the application, after obtaining the initial predicted categories of each text in each test scene, you can filter it according to the number of target categories in the initial predicted categories. Specifically, select 10,000 texts from each test scene and input them into the training model, and you can get 10,000 label categories belonging to positive categories, negative categories, or neutral categories. Count the number of labels in the positive category and the negative category respectively, and select the test scenes with the largest number as the target scenes.

[0078] In this embodiment, when facing multiple test scenarios, each text is preliminarily classified through the existing training model, and the target scenario is screened out according to the classification results. The target texts contained in the screened target scenario can be better recognized by the training model than the texts in the other test scenarios, so that the trained target model can recognize the text more fully, and improve the recognition performance and generalization ability of the target model.

[0079] Reference Figure 3 In one embodiment, the step of determining a plurality of target scenes from a plurality of test scenes according to the initial prediction category in S203 may include the following sub-steps:

[0080] S301. According to the initial prediction category, respectively determine the number of texts belonging to the target prediction category among the multiple texts in each test scenario, and determine the total number of texts of the initial prediction category contained in each test scenario.

[0081] S302: Calculate the number of texts belonging to the target prediction category and the percentage of the total number of texts of the initial prediction category in the test scenario.

[0082] S303: Select a preset number of the target scenes according to the proportion value corresponding to each test scene, wherein the proportion value corresponding to the target scene is higher than the proportion values ​​corresponding to other test scenes.

[0083] In the application, the target prediction categories include positive categories and negative categories. If there is a neutral category, the neutral category is the non-target label category. The preset number can be selected according to the actual situation. For example, 3 target scenes are selected from all test scenes. The number of all texts for each test scene can be the same or different.

[0084] For example, if the total number of texts in each test scenario is the same, when the text is input into the training model for label classification, it is only necessary to count the number of target prediction categories, and the test scenarios with the top three target prediction categories corresponding to all test scenarios are defined as target scenarios. If the total number of texts contained in each test scenario is different, the total number of prediction categories in each test scenario is the total number of texts, and the number of target prediction categories counted is calculated, and the ratio of the total number of prediction categories is calculated, and the test scenarios with the top three ratios are defined as target scenarios.

[0085] In this embodiment, the texts in each test scenario are preliminarily classified by using the existing training model, the number of texts belonging to the target prediction category among the multiple texts in each test scenario is determined, and the total number of texts contained in each test scenario is determined, and the target scenario is screened out according to the ratio of the number of texts in the target prediction category to the total number of texts. The target texts contained in the screened target scenario can be better recognized by the training model than the texts in the other test scenarios, so that the trained target model can recognize text more fully, and improve the recognition performance and generalization ability of the target model.

[0086] See also Figure 4 In one embodiment, the target prediction category includes a predicted positive category and a predicted negative category; S102, according to the target prediction category, obtaining the first text belonging to the target category in each target scene may include the following sub-steps S401-S403:

[0087] S401 . Obtain, from each target text in each target scenario, a first predicted text in which the target text belongs to the predicted positive category and a second predicted text in which the target text belongs to the predicted negative category.

[0088] S402, obtaining the real categories corresponding to each target text in the target text corresponding to each target scene; wherein the real categories include real positive categories and real negative categories.

[0089] S403, in the first predicted text, taking the text in which the predicted positive category is consistent with the true positive category as the first target text, and taking the text in which the predicted negative category is consistent with the true negative category as the second target text;

[0090] S404: Use the first target text and the second target text as first texts belonging to the target category; wherein the target category includes a positive category and a negative category.

[0091] In the application, each target text in each target scenario mentioned above will output the corresponding prediction category after being input into the existing training model. Therefore, the target text can be distinguished according to the prediction category. However, when the existing training model predicts and classifies each target text in the target scenario, the classification accuracy is low because the existing training model has certain errors when identifying the text classification in a specific application scenario, and there are many texts whose predicted categories are different from the true categories. Therefore, after the existing training model predicts and classifies each target text in the target scenario, the target text whose predicted classification result is a predicted positive category is taken as the first predicted text. Then, according to the true category of each first predicted text, the text whose true category is a positive category is taken as the first target text. Similarly, the second target text is the predicted classification of the text by the existing training model as a predicted negative category, and the true category of the text is also a negative category.

[0092] In this embodiment, the target text corresponding to each target scene is predicted based on the existing training model, and the text whose predicted target category and true category are consistent is used as the first text for model training, so that the first text used for training can be better recognized by the training model, so that the trained target model can more fully recognize texts of different categories, thereby improving the recognition performance and generalization ability of the target model.

[0093] See also Figure 5 After the first target text and the second target text are taken as the first text belonging to the target category in S404, the following steps S501-S504 are also included:

[0094] S501: receiving positive category words and negative category words input by a user.

[0095] S502: Search, according to the positive category vocabulary, for a third target text containing the positive category vocabulary in each target text in each target scenario.

[0096] In the application, the above-mentioned positive category vocabulary includes but is not limited to words such as "like", "happy", and "satisfied". After receiving the keywords input by the user, all texts in the target scene can be queried, and the search text can be located according to the keywords, and the searched text can be used as the third target text. In order to avoid special circumstances, such as the searched text may contain words such as "dislike" and "unhappy", although it contains positive category vocabulary, it actually belongs to the negative category text. Therefore, the searched text can also be compared with the real category, and then the text with the positive category vocabulary and the real category consistent can be used as the third target text. In addition, the above-mentioned searched text is all texts in the target scene, and in order to avoid the overlap of the third target text and the first target text, the overlapping third target text can be eliminated, and a new text can be found as the third target text, which is not limited. Similarly, the acquisition method of the above-mentioned fourth target text is consistent with the acquisition method of the third target text, and this will not be described in detail.

[0097] S503, searching, according to the negative category vocabulary, for a fourth target text containing the negative category vocabulary in each text in each target scenario;

[0098] S504: Use the first target text and the third target text as positive category texts in the first text, and use the second target text and the fourth target text as negative category texts in the first text.

[0099] In the application, the method for obtaining the fourth target text is consistent with the method for obtaining the third target text, and will not be described in detail.

[0100] In other applications, the number of positive category texts and the number of negative category texts used for training can be 1:1. That is, the number of positive category texts in the above-mentioned first text is consistent with the number of negative category texts in the above-mentioned first text, and the ratio can be 1:1. However, the number of the first target text and the number of the second target text, as well as the number of the third target text and the number of the fourth target text, can be consistent or inconsistent, and there is no limitation on this. And the ratio of the number of the first text to the number of the second text can be 1:1, or 1:N (N is an integer greater than 1), and there is no limitation on this. That is, the number of the second text is N times the number of the first text. Its purpose is that the expression of neutral text is more diverse, while the expression of text containing emotions is relatively single. Therefore, selecting neutral category texts in non-specific scenarios can expand the text diversity of neutral texts, fully express the characteristics of the large category of neutral texts, and better improve the classification effect of the training model when training the training model.

[0101] In this embodiment, in order to obtain the first text more quickly, each text in each target scene can be queried based on the input positive category vocabulary and negative category vocabulary to obtain the corresponding third target text and fourth target text, so as to reduce the time for obtaining the first text for training.

[0102] See also Figure 6 S104 inputs the first text and the second text into an existing training model, adjusts the model parameters of the training model to obtain a target model, and performs emotion recognition on the text to be recognized according to the target model, which may include the following sub-steps S601-S602:

[0103] S601: Input the first text corresponding to each target scene into a text enhancement model to perform text data enhancement to obtain an enhanced first text.

[0104] S602: input the second text and the enhanced first text into an existing training model, and adjust the model parameters of the training model to obtain a target model.

[0105] In the application, the number of texts in the positive category and the number of texts in the negative category obtained in the target scene may be insufficient, that is, the number of the first text used for model training is insufficient, so that the target model obtained by training has poor recognition performance of text features. Therefore, it is necessary to increase the number of texts in the positive category and the number of texts in the negative category through the above-mentioned text enhancement model. Specifically, the process of text enhancement can be realized by data enhancement based on Bert (Conditional BERTContextual Augmentation). Text enhancement can be more intuitively understood as a process of increasing the amount of training data by replacing synonyms, randomly inserting, deleting words, etc. of the original text. In the text enhancement model, it is specifically embodied as: in the process of inputting the first text, the real category of the first text is input at the same time. The text enhancement model can predict the replaceable text words for the first text according to the real category of the first text, so that the expression of the first text is more diverse, so that it can be expanded into texts with different expressions but similar semantics. It can be considered that the text enhancement model strengthens the text features of the first text and enhances the recognition and cognition of the first text by the target model.

[0106] For example, for positive category text: "I am very happy today", it can be replaced with texts such as "I am very happy today" and "I am very happy today". Specifically, 80 positive category texts in the target scene can be obtained and data enhanced using the text enhancement model. On the basis of each positive category text, 49 positive category texts are expanded, and 4,000 positive category texts can be obtained. Similarly, the above method can also be used to enhance the text of negative category texts, which will not be explained again.

[0107] In this embodiment, by inputting the first text into the text enhancement model, the text enhancement model can expand the first text according to the real category, obtain multiple first texts with different expressions but similar semantics, and use the second text and the enhanced first text as training data to train the existing training model to obtain the target model, so that the target model can more fully recognize the text.

[0108] In one embodiment, after inputting the first text and the second text into an existing training model in S104, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model, the method further includes:

[0109] The emotion recognition result of the text to be recognized is uploaded to the blockchain.

[0110] In all embodiments of the present application, a corresponding text emotion recognition scheme is obtained based on a terminal device. Specifically, the text emotion recognition scheme is obtained by processing the terminal device. Uploading the text emotion recognition scheme to the blockchain can ensure its security and fairness and transparency to users. The user device can download the text emotion recognition scheme from the blockchain to verify whether the text emotion recognition scheme has been tampered with. The blockchain referred to in this example is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database. It is a string of data blocks generated by cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain may include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0111] See also Figure 7 , Figure 7 is a structural block diagram of a text emotion recognition device provided in an embodiment of the present application. In this embodiment, the mobile terminal includes various units for executing Figures 1 to 4 For details, please refer to the steps in the corresponding embodiment. Figures 1 to 6 as well as Figures 1 to 6For the convenience of explanation, only the parts related to this embodiment are shown. Figure 7 The text emotion recognition device 700 includes: an input module 710, a first acquisition module 720, a second acquisition module 730 and a recognition module 740, wherein:

[0112] The input module 710 is used to input each target text in each target scenario into the existing training model to obtain the target prediction category corresponding to each target text.

[0113] The first acquisition module 720 is used to acquire a first text belonging to a target category in each target scene according to the target prediction category.

[0114] The second acquisition module 730 is used to acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario.

[0115] The recognition module 740 is used to input the first text and the second text into an existing training model, adjust the model parameters of the training model to obtain a target model, and perform emotion recognition on the text to be recognized according to the target model.

[0116] As an embodiment of the present application, the text emotion recognition device 700 further includes:

[0117] The third acquisition module is used to acquire multiple texts in each test scenario.

[0118] An input module is used to input the multiple texts in each test scenario into the existing training model respectively to obtain initial predicted categories of the multiple texts in each test scenario.

[0119] A determination module is used to determine multiple target scenes from multiple test scenes according to the initial prediction category.

[0120] As an embodiment of the present application, the determination module is further used for:

[0121] According to the initial prediction category, respectively determine the number of texts belonging to the target prediction category in the multiple texts in each test scenario, and determine the total number of texts of the initial prediction category contained in each test scenario;

[0122] Calculate the number of texts belonging to the target prediction category and the percentage of the total number of texts of the initial prediction category corresponding to the test scenario;

[0123] A preset number of the target scenes are selected according to the proportion value corresponding to each test scene, wherein the proportion value corresponding to the target scene is higher than the proportion value corresponding to other test scenes.

[0124] As an embodiment of the present application, the target prediction category includes a predicted positive category and a predicted negative category; the first acquisition module 720 is further used to:

[0125] In each target text in each target scenario, respectively obtain a first predicted text in which the target text belongs to the predicted positive category and a second predicted text in which the target text belongs to the predicted negative category;

[0126] Obtaining the true categories corresponding to each target text in the target text corresponding to each target scene; wherein the true categories include true positive categories and true negative categories;

[0127] In the first predicted text, the text in which the predicted positive category is consistent with the true positive category is used as the first target text, and the text in which the predicted negative category is consistent with the true negative category is used as the second target text;

[0128] The first target text and the second target text are used as first texts belonging to the target category; wherein the target category includes a positive category and a negative category.

[0129] As an embodiment of the present application, the first acquisition module 720 is further configured to:

[0130] Receiving positive category words and negative category words input by a user;

[0131] According to the positive category vocabulary, searching for a third target text containing the positive category vocabulary in each target text in each target scenario;

[0132] According to the negative category vocabulary, searching for a fourth target text containing the negative category vocabulary in each text in each target scenario;

[0133] The first target text and the third target text are used as positive category texts in the first text, and the second target text and the fourth target text are used as negative category texts in the first text.

[0134] As an embodiment of the present application, the identification module 740 is further used for:

[0135] Inputting the first text corresponding to each target scene into a text enhancement model to perform text data enhancement to obtain an enhanced first text;

[0136] The second text and the enhanced first text are input into an existing training model, and the model parameters of the training model are adjusted to obtain a target model.

[0137] As an embodiment of the present application, the text emotion recognition device 700 further includes:

[0138] The uploading module is used to upload the emotion recognition result of the text to be recognized to the blockchain.

[0139] It should be understood that Figure 7 In the structural block diagram of the text emotion recognition device shown, each unit / module is used to execute Figures 1 to 6 The steps in the corresponding embodiments, and for Figures 1 to 6 Each step in the corresponding embodiment has been explained in detail in the above embodiment. Figures 1 to 6 as well as Figures 1 to 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0140] Figure 8 is a structural block diagram of a terminal device provided by another embodiment of the present application. Figure 8 As shown, the terminal device 80 of this embodiment includes: a processor 81, a memory 82, and a computer program 83 stored in the memory 82 and executable on the processor 81, such as a program of the text emotion recognition method. When the processor 81 executes the computer program 83, the steps in each embodiment of the above-mentioned text emotion recognition method are implemented, such as Figure 1 Alternatively, the processor 81 implements the above when executing the computer program 83 Figure 7 The functions of each unit in the corresponding embodiment are, for example, Figure 7 For details on the functions of the units 710 to 740 shown, please refer to Figure 7 Related description in the corresponding embodiment.

[0141] Exemplarily, the computer program 83 may be divided into one or more units, which are stored in the memory 82 and executed by the processor 81 to complete the present application. The one or more units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 83 in the terminal device 80. For example, the computer program 83 may be divided into an input unit, a first acquisition unit, a first acquisition unit, and a recognition unit, and the specific functions of each unit are as described above.

[0142] The terminal device may include, but is not limited to, a processor 81 and a memory 82. Those skilled in the art will appreciate that Figure 8It is only an example of the terminal device 80 and does not constitute a limitation of the terminal device 80. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0143] The processor 81 may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.

[0144] The memory 82 may be an internal storage unit of the terminal device 80, such as a hard disk or memory of the terminal device 80. The memory 82 may also be an external storage device of the terminal device 80, such as a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, etc. equipped on the terminal device 80. Furthermore, the memory 82 may also include both an internal storage unit of the terminal device 80 and an external storage device.

[0145] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A text emotion recognition method, characterized in that: include: Input each target text in each target scenario into the existing training model to obtain the target prediction category corresponding to each target text; According to the target prediction category, obtaining a first text belonging to the target category in each target scene; Acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario; Inputting the first text and the second text into an existing training model, adjusting model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model; Before inputting each target text in each target scenario into the existing training model to obtain the predicted category corresponding to each target text, the method further includes: Get multiple texts for each test scenario; Inputting the multiple texts in each test scenario into the existing training model respectively to obtain initial prediction categories of the multiple texts in each test scenario; Determining a plurality of target scenarios from a plurality of test scenarios according to the initial prediction category; According to the initial prediction category, a plurality of target scenarios are determined from a plurality of test scenarios, including: According to the initial prediction category, respectively determine the number of texts belonging to the target prediction category in the multiple texts in each test scenario, and determine the total number of texts of the initial prediction category contained in each test scenario; Calculate the number of texts belonging to the target prediction category and the percentage of the total number of texts of the initial prediction category corresponding to the test scenario; Selecting a preset number of the target scenes according to the proportion value corresponding to each test scene, wherein the proportion value corresponding to the target scene is higher than the proportion value corresponding to other test scenes; The target prediction category includes a predicted positive category and a predicted negative category; The step of acquiring a first text belonging to a target category in each target scene according to the target prediction category includes: In each target text in each target scenario, respectively obtain a first predicted text in which the target text belongs to the predicted positive category and a second predicted text in which the target text belongs to the predicted negative category; Obtaining the true categories corresponding to each target text in the target text corresponding to each target scene; wherein the true categories include true positive categories and true negative categories; In the first predicted text, the text in which the predicted positive category is consistent with the true positive category is used as the first target text, and the text in which the predicted negative category is consistent with the true negative category is used as the second target text; The first target text and the second target text are used as first texts belonging to the target category; wherein the target category includes a positive category and a negative category.

2. The text emotion recognition method according to claim 1, characterized in that: After taking the first target text and the second target text as first text belonging to the target category, the method further includes: Receiving positive category words and negative category words input by a user; According to the positive category vocabulary, searching for a third target text containing the positive category vocabulary in each target text in each target scenario; According to the negative category vocabulary, searching for a fourth target text containing the negative category vocabulary in each text in each target scenario; The first target text and the third target text are used as positive category texts in the first text, and the second target text and the fourth target text are used as negative category texts in the first text.

3. The text emotion recognition method according to claim 1 or 2, characterized in that: The step of inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model includes: Inputting the first text corresponding to each target scene into a text enhancement model to perform text data enhancement to obtain an enhanced first text; The second text and the enhanced first text are input into an existing training model, and the model parameters of the training model are adjusted to obtain a target model.

4. The text emotion recognition method according to claim 3, characterized in that: After inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model, the method further includes: The emotion recognition result of the text to be recognized is uploaded to the blockchain.

5. A text emotion recognition device, characterized in that: include: An input module, used to input each target text in each target scenario into an existing training model, and obtain a target prediction category corresponding to each target text, wherein the target prediction category includes a predicted positive category and a predicted negative category; A first acquisition module, configured to acquire, in each target scene, a first text belonging to a target category according to the target prediction category; A second acquisition module, configured to acquire a second text, wherein the second text belongs to a non-target category and is a text in a non-target scenario; A recognition module, used for inputting the first text and the second text into an existing training model, adjusting the model parameters of the training model to obtain a target model, and performing emotion recognition on the text to be recognized according to the target model; The text emotion recognition device also includes: The third acquisition module is used to acquire multiple texts in each test scenario; An input module, used to input the multiple texts in each test scenario into the existing training model respectively, to obtain the initial predicted categories of the multiple texts in each test scenario; A determination module, configured to determine a plurality of target scenes from a plurality of test scenes according to the initial prediction category; The determination module is used to determine the number of texts belonging to the target prediction category among the multiple texts in each test scenario according to the initial prediction category, and to determine the total number of texts of the initial prediction category contained in each test scenario; Calculate the number of texts belonging to the target prediction category and the percentage of the total number of texts of the initial prediction category corresponding to the test scenario; Selecting a preset number of the target scenes according to the proportion value corresponding to each test scene, wherein the proportion value corresponding to the target scene is higher than the proportion value corresponding to other test scenes; The first acquisition module is further used to respectively acquire, from each target text in each target scenario, a first predicted text in which the target text belongs to the predicted positive category and a second predicted text in which the target text belongs to the predicted negative category; Obtaining the true categories corresponding to each target text in the target text corresponding to each target scene; wherein the true categories include true positive categories and true negative categories; In the first predicted text, the text in which the predicted positive category is consistent with the true positive category is used as the first target text, and the text in which the predicted negative category is consistent with the true negative category is used as the second target text; The first target text and the second target text are used as first texts belonging to the target category; wherein the target category includes a positive category and a negative category.

6. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

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

    CN108922564A

  • An emotion analysis method and system of an active learning framework based on committee query

    CN109918642A

  • Data increment method and device, computer equipment and storage medium

    CN110162627A

  • Image labeling method and device and storage medium

    CN110288019A

  • Prediction method, system and device for scene category of session text and storage medium

    CN110413788A