WO2022052484A1 - 文本情绪识别方法、装置、终端设备和存储介质 - Google Patents

文本情绪识别方法、装置、终端设备和存储介质 Download PDF

Info

Publication number
WO2022052484A1
WO2022052484A1 PCT/CN2021/091079 CN2021091079W WO2022052484A1 WO 2022052484 A1 WO2022052484 A1 WO 2022052484A1 CN 2021091079 W CN2021091079 W CN 2021091079W WO 2022052484 A1 WO2022052484 A1 WO 2022052484A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
target
category
model
scene
Prior art date
Application number
PCT/CN2021/091079
Other languages
English (en)
French (fr)
Inventor
毛宇兆
高维国
李炫�
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022052484A1 publication Critical patent/WO2022052484A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/247Thesauruses; Synonyms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present application belongs to the technical field of intelligent decision-making, and in particular relates to a text emotion recognition method, device, terminal device and storage medium.
  • One of the purposes of the embodiments of the present application is to provide a text emotion recognition method, device, terminal device and storage medium, aiming to solve the problem of accuracy when using an existing training model to recognize and classify text in a specific application scenario. Less technical issues.
  • a first aspect of the embodiments of the present application provides a text emotion recognition method, the method comprising:
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • a second aspect of the embodiments of the present application provides a text emotion recognition device, the device comprising:
  • an input module configured to input each target text under each target scene into an existing training model, and obtain the target prediction category corresponding to each target text
  • a first acquisition module configured to acquire the first text belonging to the target category in each target scene according to the target prediction category
  • a second obtaining module configured to obtain a second text, wherein the second text belongs to a non-target category and belongs to a text in a non-target scene;
  • the recognition module is used for inputting the first text and the second text into the 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.
  • a third aspect of the embodiments of the present application provides a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program When realized:
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement:
  • Each target text under each target scene is input into the existing training model, and the target prediction category corresponding to each target text is obtained;
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • a fifth aspect of the embodiments of the present application further provides a computer program product, when the computer program product is run on a terminal device, the terminal device can implement:
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • the embodiments of the present application include the following advantages:
  • the existing training model the first text in the target scene and belonging to the target category and the second text in the non-target scene and belonging to the non-target category are used as training data, and the existing training model is trained Adjustment makes the trained target model more adequate for different types of text recognition, improves the recognition performance and generalization ability of the target model, and can achieve the purpose of reducing the training time of the target model.
  • Fig. 1 is the realization flow chart of a kind of text emotion recognition method provided by the embodiment of the present application
  • Fig. 2 is the realization flow chart of a kind of text emotion recognition method provided by another embodiment of the present application.
  • FIG. 3 is a schematic diagram of an implementation manner of S203 of a text emotion recognition method provided by another embodiment of the present application.
  • FIG. 4 is a schematic diagram of an implementation manner of S102 of a text emotion recognition method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of another implementation manner of S102 of a text emotion recognition method provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of an implementation manner of S104 of a text emotion recognition method provided by an embodiment of the present application.
  • FIG. 7 is a structural block diagram of a text emotion recognition device provided by an embodiment of the present application.
  • FIG. 8 is a structural block diagram of a terminal device provided by an embodiment of the present application.
  • the text emotion recognition method involved in the embodiments of the present application may be executed by a control device or a terminal (hereinafter referred to as "terminal device").
  • FIG. 1 shows an implementation flowchart of a text emotion recognition method provided by an embodiment of the present application. The method includes the following steps:
  • each target text in the above target scenario may be a separate Chinese text, an English text, or a text in other languages, or may be a combination of any language, which is not limited.
  • the above target scene may be a specific scene under a specific application scene.
  • the specific application scenario may be an interview scenario, a game interaction scenario, or the like.
  • the scenario is usually a questioning and answering scenario of the questioner and the answerer.
  • the target scene may be specifically: in the interview scene, the questioner asks an interview question, and the answerer answers the interview question.
  • the content answered by all the corresponding respondents about the same interview question is regarded as each target text in the target scene.
  • it can be a word "right”, “wrong”, or a word "yes", "no", or a sentence, or a paragraph. Not limited.
  • the predicted categories can be divided into predicted positive categories, predicted negative categories and predicted neutral categories, and the label category of the text can show the sentiment of the respondents to a certain extent. For example, for a text containing words such as “like”, “happy”, “satisfied”, etc., it can be determined that the respondent is in a positive category emotion at this time. For texts containing words such as “hardship”, “difficulty”, “suffering”, etc., it can be determined that the respondent is in a negative category at this time.
  • the above-mentioned target prediction category specifically includes a predicted positive category and a predicted negative category in the predicted categories.
  • the above-mentioned existing training model may be a text emotion classification model commonly used in the prior art.
  • it can be a text sentiment classification model obtained by training big data, for example, the BERT model based on the Transformer mechanism, the model is obtained by training based on existing text big data, making full use of the attention mechanism, It has a significant effect in the field of natural language processing.
  • the classification of the target text according to the existing BERT model can specifically be: if the target text is "I am very happy today", the existing word vector library can be used to represent this sentence as a feature vector. .
  • each word can be assigned a number corresponding to a number in sequence in advance, so that all words correspond to fixed numbers 1, 2, 3, . . . , which is not limited. 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].
  • a word or a sentence can be represented by the word vector feature in the above manner.
  • the punctuation in the text needs to be cleaned to obtain the text corresponding to the processed test scene.
  • English can be converted into Chinese for word feature vector representation, This is not limited.
  • the above-mentioned target categories are specifically a positive category and a negative category. It can be seen that, obtaining the first text belonging to the target category in each target scene can specifically be based on the target prediction category of each target text in the target scene, and taking the text belonging to the positive category and the negative category in the target prediction category as the first text 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 acquired.
  • the above-mentioned first text is in the target scene, and the acquired text of the positive category and the text of the negative category belong to the first text. Therefore, it can be considered that the above-mentioned non-target categories are neutral categories and belong to texts in non-target scenarios. It can be understood as a public text that does not belong to a specific application scenario. For example, it can be the text of public microblogs, or the text of the comment dataset that has been publicized. In order to obtain the second text quickly, the above-mentioned published text can be input into an existing training model for classification, and the second text belonging to the neutral category can be obtained.
  • the second texts predicted to belong to the neutral category may be manually screened on this basis.
  • all the second texts can be manually selected and stored in the database according to the published texts in advance. When the second texts need to be obtained, they can be obtained directly from the database, which is not limited.
  • 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.
  • the purpose of inputting the first text and the second text into the existing training model is that the neutral text is derived from the text in a non-specific application scenario.
  • the above target model is a model obtained by training the text in the target scene. Therefore, when performing emotion recognition on the text to be recognized in the target scene, the recognition accuracy is higher.
  • the above-mentioned adjustment of the model parameters of the training model may specifically be: a learning parameter w and a bias vector b pre-trained by the existing training model, which are used to calculate the vector representation of the text in the feature space. Then, according to the calculated vector, the probability of predicting that the text belongs to each category can be expressed. According to this probability, the loss function of model training can be calculated, and the loss can be reduced through iterative training to improve the model effect.
  • W is the newly updated learning parameters
  • is the learning efficiency, which is the initial value set by the neural network model. During the iteration process, the learning efficiency remains unchanged, and then the learning parameters of each layer are calculated forward step by step.
  • the training model can calculate the training loss of all the training texts in the iterative training each time after the first text and the second text are iteratively trained, and adjust the model parameters once according to the training loss.
  • the training text input to the training model does not contain duplicate text.
  • the convergence of the above training loss can be: setting a fixed number of iterative training times, and stopping training when the number of iterations is reached; or setting the training to be stopped if the text classification effect of the model does not improve after several consecutive iterative trainings, which is not limited. . After that, end the model training, and use the current training model as the adjusted target model.
  • the existing training model is Adjustments are made to make the trained target model more adequate for different types of text recognition, improve the recognition performance and generalization ability of the target model, and reduce the training time of the target model.
  • each target text under each target scene is input into the existing training model, and before acquiring the target prediction category corresponding to each target text, the following steps S201-S203 are also included, which are described in detail as follows :
  • the above S101 has explained that the target scene can be a specific scene under a specific application scene, and there is an explanation for the specific application scene. It can be considered that the test scenario is the above-mentioned specific application scenario, which will not be described again.
  • the multiple texts under each test scene are respectively input into the existing training model, and the initial predicted categories of the multiple texts under each test scene are obtained.
  • the target prediction category corresponding to each target text can be obtained by inputting each target text in each target scene into the existing training model with reference to the above S101. This step is similar to the above-mentioned step S101, and will not be described again.
  • the screening can be performed specifically according to the number of the initial predicted category belonging to the target category. Specifically, by selecting 10,000 texts from each test scene and inputting them into the training model, 10,000 labels belonging to the positive, negative or neutral categories can be correspondingly obtained. Multiple test scenarios with the largest number are used as target scenarios.
  • each text is preliminarily classified through an existing training model, and the target scenarios are screened out according to the classification results.
  • each target text contained in the screened target scene can be better recognized by the training model, so that the trained target model can recognize the text more fully, and improve the recognition performance of the target model.
  • determining multiple target scenarios from multiple test scenarios may include the following sub-steps:
  • the initial prediction category respectively determine the number of texts belonging to the target prediction category in a plurality of texts under each test scenario, and determine the texts of the initial prediction category included in each test scenario The total number of.
  • S302 Calculate the proportion of the number of texts belonging to the target prediction category to the total number of texts of the initial prediction category corresponding to the test scenario.
  • the above 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 above preset number can be selected according to the actual situation, for example, three target scenarios are selected from all test scenarios. Wherein, the number of all texts for each test scene can be the same or different.
  • 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 objects belonging to the target prediction category, and the target corresponding to all test scenarios is classified.
  • the number of predicted categories, and the top three test scenarios are set as the target scenarios. If the total number of texts contained in each test scenario is different, the total number of predicted categories in each test scenario is the total number of texts, then the number of target predicted categories calculated and calculated is the same as the total number of predicted categories.
  • the proportion value of the number, the test scene with the top three proportion value is set as the target scene.
  • the texts in each test scenario are preliminarily classified by the existing training model, the number of texts belonging to the target prediction category in the multiple texts in each test scenario is determined, and each test scenario is determined The total number of texts contained in the lower part is selected, and the target scene is filtered out according to the ratio of the number of texts of the target prediction category to the total number of texts.
  • each target text contained in the screened target scene can be better recognized by the training model, so that the trained target model can recognize the text more fully, and improve the recognition performance of the target model.
  • the target prediction category includes a predicted positive category and a predicted negative category;
  • S102 according to the target predicted category, obtaining the first text belonging to the target category in each target scene may be It includes the following sub-steps S401-S403:
  • S402 Acquire the real category corresponding to each target text in the target text corresponding to each target scene; wherein, the real category includes a real positive category and a real negative category.
  • each target text in each of the above target scenarios will output the corresponding prediction category after inputting the existing training model. Therefore, the target text can be differentiated according to the predicted class.
  • the existing training model predicts and classifies each target text in the target scene
  • the existing training model has a certain error in recognizing the text classification in a specific application scenario, the classification accuracy is low, and there are Many texts where the predicted class differs from the true class. Therefore, after the existing training model predicts and classifies each target text in the target scene, the target text whose predicted classification result is a predicted positive category is used as the first predicted text.
  • the real category of each first predicted text the text whose real category is a positive category is used as the first target text.
  • the second target text is the prediction classification of the text by the existing training model as a predicted negative category, and the real category of the text is also a negative category.
  • the target text corresponding to each target scene is predicted according to the existing training model, and the text whose predicted target category is consistent with the real category is used for model training as the first text, so that the training model can be used for training.
  • the first text of the text can be better recognized by the training model, so that the target model obtained by training can more fully recognize different types of texts, and the recognition performance and generalization ability of the target model can be improved.
  • the above-mentioned positive category words include but are not limited to words such as "like", “happy” and "satisfied”.
  • the word-positioning search text takes the searched text as the third target text.
  • the searched text may contain words such as "dislike” and "displeased", which although contain positive category words, actually belong to negative category texts. Therefore, the searched text can also be compared with the real category, and then the text whose positive category vocabulary is consistent with the real category can be used as the third target text.
  • the texts searched above are all texts in the target scene, and in order to avoid the overlapping of the third target text and the first target text, the overlapping third target text can be eliminated, and the new text can be found again as the first target text.
  • Three target texts which are not limited.
  • the manner of acquiring the above-mentioned fourth target text is the same as the manner of acquiring the third target text, which will not be described in detail.
  • the obtaining method of the above-mentioned fourth target text is the same as the obtaining method of the third target text, which will not be described in detail.
  • the number of positive category texts to 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 may be 1:1.
  • the quantity of the first target text and the quantity of the second target text, and the quantity of the third target text and the quantity of the fourth target text may be the same or not, which are not limited.
  • the ratio of the quantity of the first text to the quantity of the second text may be 1:1, or 1:N (N is an integer greater than 1), which is not limited. That is, the number of the second text is N times the number of the first text.
  • the purpose is: the expression of neutral text is more diverse, while the expression of emotional text is relatively simple. Therefore, selecting neutral category texts in non-specific scenarios can expand the text diversity of neutral texts and fully express the characteristics of this category of neutral texts, which can better improve training when training the training model.
  • the role of the classification effect of the model is: the expression of neutral text is more diverse, while the expression of emotional text is relatively simple. Therefore, selecting neutral category texts in non-specific scenarios can expand the text diversity of neutral texts and fully express the characteristics of this category of neutral texts, which can better improve training when training the training model.
  • each text in each target scene can be queried according to the input positive category vocabulary and negative category vocabulary, and the corresponding third target text and fourth target text can be obtained. target text to reduce the time to acquire the first text for training.
  • S104 inputs the first text and the second text into the 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
  • the following sub-steps S601-S602 may be included:
  • 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.
  • the number of texts of the positive category and the number of texts of the negative category obtained in the target scene may be insufficient, that is, the number of the first texts used for model training is insufficient, so that the target model obtained by training has no effect on the text features. Poor recognition performance. 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 text enhancement model.
  • the process of text enhancement can be implemented based on Bert's data enhancement (Conditional BERT Contextual Augmentation). Text enhancement can be understood intuitively as the process of increasing the amount of training data by replacing the original text with synonyms, randomly inserting, and deleting words.
  • the text enhancement model can predict replaceable text words for the first text according to the real category of the first text, so that the expressions of the first text are more diverse and can be expanded into texts with different expressions but similar semantics. That is to say, 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.
  • positive category text "I'm happy today” can be replaced with texts such as “I'm happy today", “I'm happy today”, etc.
  • 80 positive category texts in the target scene can be obtained for data enhancement using the text enhancement model.
  • 49 positive category texts can be expanded, and 4000 positive category texts can be correspondingly obtained.
  • text enhancement can also be performed on negative category text using the above method, which will not be described again.
  • the text enhancement model by inputting the first text into the text enhancement model, according to the real category of the first text, the text enhancement model can be extended according to the real category, and a plurality of first texts with different expressions but similar semantics are obtained.
  • text using the second text and the enhanced first text as training data, and training the existing training model to obtain the target model. This makes the target model more adequate for text recognition.
  • the first text and the second text are input into the existing training model, the model parameters of the training model are adjusted to obtain a target model, and the text to be recognized is processed according to the target model.
  • emotion recognition it also includes:
  • the corresponding text emotion recognition scheme is obtained based on the terminal device.
  • 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 equipment can download the text emotion recognition scheme from the blockchain, so as to verify whether the text emotion recognition scheme has been tampered with.
  • the blockchain referred to in this example is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • FIG. 7 is a structural block diagram of a text emotion recognition apparatus provided by an embodiment of the present application.
  • each unit included in the mobile terminal is used to execute each step in the embodiment corresponding to FIG. 1 to FIG. 4 .
  • FIG. 1 to FIG. 6 and the related descriptions in the embodiments corresponding to FIG. 1 to FIG. 6 .
  • the text emotion recognition apparatus 700 includes: an input module 710, a first acquisition module 720, a second acquisition module 730, and a recognition module 740, wherein:
  • the input module 710 is configured to input each target text under each target scene into the existing training model, and obtain the target prediction category corresponding to each target text.
  • the first obtaining module 720 is configured to obtain the first text belonging to the target category in each target scene according to the target prediction category.
  • the second obtaining module 730 is configured to obtain a second text, wherein the second text belongs to a non-target category and belongs to a text in a non-target scene.
  • the recognition module 740 is used to input the first text and the second text into the 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 .
  • the text emotion recognition apparatus 700 further includes:
  • the third acquisition module is used to acquire multiple texts in each test scenario.
  • the input module is configured to input the plurality of texts under each test scene into the existing training model respectively, and obtain the initial predicted categories of the plurality of texts under each test scene.
  • a determination module configured to determine a plurality of target scenarios from a plurality of test scenarios according to the initial predicted category.
  • the determining module is also used for:
  • the initial prediction category respectively determine the number of texts belonging to the target prediction category in the plurality of texts under each test scenario, and determine the total number of texts of the initial prediction category included in each test scenario Calculate the number of texts belonging to the target prediction category, the proportion value of the total number of texts corresponding to the initial prediction category under the test scenario; select a preset number according to the proportion value corresponding to each test scene The target 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 first obtaining module 720 is further configured to:
  • each target text under each target scene obtain the first predicted text of the target text belonging to the predicted positive category, and the target text to belong to the predicted negative category of the second predicted text; obtain In the target text corresponding to each target scene, the real category corresponding to each target text; wherein, the real category includes a real positive category and a real negative category; in the first predicted text, the predicted positive category is The text that is consistent with the true positive category is regarded as the first target text, and the text that is consistent with the predicted negative category and the real negative category is regarded as the second target text; Two target texts are used as the first text belonging to the target category; wherein, the target category includes a positive category and a negative category.
  • the first obtaining module 720 is further configured to:
  • the identification module 740 is further configured to:
  • the text emotion recognition apparatus 700 further includes:
  • the uploading module is used for uploading the emotion recognition result of the text to be recognized to the blockchain.
  • each unit/module is used to execute each step in the embodiment corresponding to FIG. 1 to FIG.
  • the steps in the examples have been explained in detail in the above-mentioned embodiments.
  • FIG. 8 is a structural block diagram of a terminal device provided by another embodiment of the present application.
  • 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 text emotion recognition method program.
  • the processor 81 executes the computer program 83
  • the steps in each of the foregoing embodiments of the text emotion recognition methods are implemented, for example, S101 to S104 shown in FIG. 1 .
  • the processor 81 executes the computer program 83
  • the functions of the modules in the embodiment corresponding to FIG. 7 are implemented, for example, the functions of the modules 710 to 740 shown in FIG. 7 .
  • the functions of the modules in the embodiment corresponding to FIG. 7 are implemented, for example, the functions of the modules 710 to 740 shown in FIG. 7 . Specifically as follows:
  • a terminal device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, the processor implements when the processor executes the computer program:
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • the processor when the processor executes the computer program, it further implements:
  • a plurality of target scenarios are determined from a plurality of test scenarios based on the initial predicted class.
  • the processor when the processor executes the computer program, it further implements:
  • the initial prediction category respectively determine the number of texts belonging to the target prediction category in the plurality of texts under each test scene, and determine the total number of texts of the initial prediction category included in each test scene number;
  • a preset number of the target scenes is 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.
  • the target prediction category includes a predicted positive category and a predicted negative category; the processor further implements when executing the computer program:
  • each target text under each target scene respectively acquiring the first predicted text of the target text belonging to the positive prediction category, and the second predicted text of the target text belonging to the negative prediction category;
  • the real category includes a real positive category and a real negative category
  • the text whose predicted positive category is consistent with the real positive category is used as the first target text, and the predicted negative category is consistent with the real negative category. as the second target text;
  • the first target text and the second target text are regarded as the first text belonging to the target category; wherein, the target category includes a positive category and a negative category.
  • the processor when the processor executes the computer program, it further implements:
  • the processor when the processor executes the computer program, it further implements:
  • the processor when the processor executes the computer program, it further implements:
  • a computer-readable storage medium stores a computer program, and the computer program is implemented when executed by a processor:
  • the target prediction category obtain the first text belonging to the target category in each target scene
  • the second text belongs to a non-target category and belongs to a text in a non-target scene
  • the computer program when executed by the processor, further implements:
  • a plurality of target scenarios are determined from a plurality of test scenarios based on the initial predicted class.
  • the computer program when executed by the processor, further implements:
  • the initial prediction category respectively determine the number of texts belonging to the target prediction category in the plurality of texts under each test scene, and determine the total number of texts of the initial prediction category included in each test scene number;
  • a preset number of the target scenes is 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.
  • the target prediction category includes a predicted positive category and a predicted negative category; the computer program, when executed by the processor, further implements:
  • each target text under each target scene respectively acquiring the first predicted text of the target text belonging to the positive prediction category, and the second predicted text of the target text belonging to the negative prediction category;
  • the real category includes a real positive category and a real negative category
  • the text whose predicted positive category is consistent with the real positive category is used as the first target text, and the predicted negative category is consistent with the real negative category. as the second target text;
  • the first target text and the second target text are regarded as the first text belonging to the target category; wherein, the target category includes a positive category and a negative category.
  • the computer program when executed by the processor, further implements:
  • the computer program when executed by the processor, further implements:
  • the computer program when executed by the processor, further implements:
  • the computer program 83 may be divided into one or more units, and the one or more units 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 performing specific functions, and the instruction segments are used to describe the execution process of the computer program 83 in the terminal device 80 .
  • the computer program 83 can be divided into an input module, a first acquisition module, a first acquisition module and an identification module, and the specific functions of each module are as described above.
  • the terminal device may include, but is not limited to, a processor 81 and a memory 82 .
  • FIG. 8 is only an example of the terminal device 80 , and does not constitute a limitation on the terminal device 80 , and may include more or less components than shown, or combine some components, or different components
  • the terminal device may further include an input and output device, a network access device, a bus, and the like.
  • the so-called processor 81 can be a central processing unit, and can also be 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, and discrete hardware components. Wait.
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the memory 82 may be an internal storage unit of the terminal device 80 , such as a hard disk or a 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 . Further, the memory 82 may also include both an internal storage unit of the terminal device 80 and an external storage device.
  • the computer-readable storage medium may be an internal storage unit of the terminal device described in the foregoing embodiments, such as a hard disk or a memory of the terminal device.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium may also be an external storage device of the terminal device, such as a plug-in hard disk equipped on the terminal device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) ) card, Flash Card, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文本情绪识别方法、装置、终端设备和存储介质,涉及人工智能技术领域,该方法包括:将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别(S101);根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本(S102);获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本(S103);将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别(S104)。采用上述方法使用目标场景下的第一文本和非目标场景下的第二文本对已有的模型进行训练得到目标模型,在保证目标模型对文本进行情绪识别时准确率的前提下,减少模型的训练时间。

Description

文本情绪识别方法、装置、终端设备和存储介质
本申请要求于2020年09月14日在中国专利局提交的、申请号为202010961758.7、发明名称为“文本情绪识别方法、装置、终端设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于智能决策技术领域,尤其涉及一种文本情绪识别方法、装置、终端设备和存储介质。
背景技术
现有技术中,为了减少人工处理的工作量,常常使用已有的训练模型对各类应用场景下的文本进行情绪识别及分类。然而,发明人意识到,由于各个应用场景下的文本,与当时训练模型的训练文本的语句、语料存在很大区别,使用预训练好的模型,对各个应用场景下的文本进行分类准确率较低。
技术问题
本申请实施例的目的之一在于:提供一种文本情绪识别方法、装置、终端设备和存储介质,旨在解决使用已有的训练模型对特定应用场景下的文本进行识别和分类时,准确率较低的技术问题。
技术解决方案
为解决上述技术问题,本申请实施例采用的技术方案是:
本申请实施例的第一方面提供了一种文本情绪识别方法,所述方法包括:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
本申请实施例的第二方面提供了一种文本情绪识别装置,所述装置包括:
输入模块,用于将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
第一获取模块,用于根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
第二获取模块,用于获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
识别模块,用于将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
本申请实施例的第三方面提供了一种终端设备,包括:存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
本申请实施例的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本 对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
本申请实施例的第五方面还提供了一种计算机程序产品,当所述计算机程序产品在终端设备上运行时,使得所述终端设备行时实现:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
有益效果
与现有技术相比,本申请实施例包括以下优点:
本申请实施例,根据已有的训练模型,使用目标场景下且属于目标类别的第一文本,以及非目标场景下且属于非目标类别的第二文本作为训练数据,对已有的训练模型进行调整,使得训练得到的目标模型对不同类别的文本识别更加充分,提升目标模型的识别性能和泛化能力,且可以达到减少目标模型的训练时间的目的。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或示范性技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。
图1是本申请实施例提供的一种文本情绪识别方法的实现流程图;
图2是本申请另一实施例提供的一种文本情绪识别方法的实现流程图;
图3是本申请另一实施例提供的一种文本情绪识别方法的S203的一种实现方式示意图;
图4是本申请一实施例提供的一种文本情绪识别方法的S102的一种实现方式示意图;
图5是本申请一实施例提供的一种文本情绪识别方法的S102的另一种实现方式示意图;
图6是本申请一实施例提供的一种文本情绪识别方法的S104的一种实现方式示意图;
图7是本申请实施例提供的一种文本情绪识别装置的结构框图;
图8是本申请实施例提供的一种终端设备的结构框图。
本发明的实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请实施例所涉及的文本情绪识别方法,可以由控制设备或终端(以下称“终端设备”)执行。
请参阅图1,图1示出了本申请实施例提供的一种文本情绪识别方法的实现流程图,该方法包括如下步骤:
S101、将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别。
在应用中,上述目标场景下的各个目标文本可以为单独的中文文本、英文文本或者其他语言的文本,也可以为任意语言结合的文本,对此不作限定。上述目标场景可以为特定 应用场景下的具体场景。具体的,特定应用场景可以为面试场景、游戏互动场景等。对于特定应用场景为面试场景时,该场景通常为提问者与回答者的提问与回答场景。此时,目标场景可具体为:在面试场景中,提问者提出一个面试问题,回答者回答面试问题的场景。而对应的所有回答者关于该同一个面试问题进行回答的内容,均作为是目标场景下的各个目标文本。其中,对于不同回答者的回答内容,其可以是一个字“对”、“错”,也可以是一个词“是的”、“不是的”,也可以是一句话,或者一段话,对此不作限定。
在应用中,预测类别具体可以分为预测积极类别、预测消极类别和预测中性类别,该文本的标签类别可以在一定程度上显示回答者的情绪。例如,对于包含“喜欢”、“开心”、“满意”等词的文本,则可以判定回答者此时处于积极类别情绪。若对于包含“辛苦”、“困难”、“难受”等词的文本,则可以判定回答者此时处于消极类别情绪。在本实施例中,上述目标预测类别具体包含预测类别中的预测积极类别和预测消极类别。
在应用中,上述已有的训练模型可以为现有技术中常用的文本情绪分类模型。示例性的,可以为通过对大数据进行训练得到的文本情绪分类模型,例如,基于Transformer机制的BERT模型,该模型是基于已有的文本大数据进行训练得出,充分利用了注意力机制,对于自然语言处理领域效果显著。
在具体应用中,对于根据已有的BERT模型对目标文本进行类别分类具体可为:若目标文本为“今天很高兴”,则可首先使用已有的词向量库对这句话进行特征向量表示。其中,词向量库中可预先按照顺序赋予每个字对应一个数字编号,让所有的文字都对应固定的编号1,2,3,....,对此不作限定。例如,词向量库中第一个字为“我”,则“我”字对应的词向量数据为“1”,则上述“今天很高兴”对应的词向量特征可以表示为[2、3、4、5、6]。若是要提取预设维度的词向量特征,而文本字数不足,则可对于不足字数的文本可用特殊向量进行表示,其中特殊向量可以为数字0、或者特殊字符等。之后将词向量特征输入至训练模型中进行处理输出结果,输出的结果为训练模型预测目标文本为积极类别、消极类别、中性类别的概率值。例如,其分别对应为“积极类别”的概率值(A)、“消极类别”的概率值(B)和“中性类别”的概率(C)。若A=0.8,B=0.1和C=0.1,则选取三个数值中的最大值对应的类别作为的该目标文本的目标预测类别,即判定当前目标文本为“积极类别”。
其中,对于一个词或一句话可按上述方式进行词向量特征表示,对于一段话,包含多句话,则需要对文本中的标点符号进行清洗,得到处理后的测试场景对应的文本。另外,对于文本中同时包含有多种语言的文本,例如,在使用中文语言回答问题时,用了某个单词、或某句英文进行回复,则可将英文转换成中文进行词特征向量表示,对此不作限定。
S102、根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本。
上述S101中已说明一个目标场景对应的所有文本为不同的回答者关于同一个问题的回答,因此,回答该问题时的情绪可能各有不同。另外,上述目标类别具体为积极类别和消极类别。可知,在每个目标场景中获取属于目标类别的第一文本,则具体可以为根据目标场景中各个目标文本的目标预测类别,将目标预测类别中属于积极类别和消极类别的文本,作为第一文本。即可认为上述中性类别属于非目标类别,属于非目标类别的文本则不进行获取。
S103、获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本。
上述第一文本为在目标场景下,获取的积极类别的文本、以及消极类别的文本均属于第一文本。因此,可认为上述非目标类别即为中性类别,且属于非目标场景下的文本。可以理解为不是属于特定应用场景下的公开文本。例如,可以是公开的微博文本,或者是已经公开的评论数据集的文本。为快速获取第二文本,可将上述已公开的文本输入至已有的训练模型中进行分类,获取属于中性类别的第二文本。另外,为保证获取的第二文本均属于中性类别,可在此基础上由人工对预测属于中性类别的第二文本进行筛选。或者,第二 文本可以全部为人工预先根据公开的文本,进行挑选并存储在数据库中的第二文本,在需要获取第二文本时,可直接从数据库中进行获取,对此不作限定。
S104、将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
在应用中,上述将第一文本和第二文本输入至已有的训练模型,目的在于中性文本来源于非特定应用场景下的文本,在对已有的训练模型进行模型训练时,可一定程度上的保证使用训练数据进行预测识别分类的准确性。
在应用中,上述目标模型为针对目标场景下的文本进行训练得到的模型,因此,对于属于目标场景下的待识别的文本进行情绪识别时,识别准确度更高。
在应用中,上述对训练模型的模型参数进行调整具体可为:已有的训练模型预先训练出的一种学习参数w和偏置向量b,作用是用来计算文本在特征空间的向量表示。而后根据该计算得到的向量来表示预测该文本属于每种类别的概率,根据这个概率可以计算模型训练的损失函数,通过迭代的训练减少损失,提升模型效果。
示例性的,对于输入的积极类别的文本,训练模型先获取该文本的词向量特征,而后将该词向量特征输入至神经网络训练后,输出关于“积极类别”的概率值(A)=0.8。之后与预先设置的当前文本属于积极类别的真实值(A1)=1进行计算平方差,得到训练损失,根据训练损失迭代更新训练模型中关于积极类别的的模型参数(学习参数w和偏置向量b)。其中,计算训练损失可以为losscls=(A1 i-A i) 2,其中,A1 i中为第i个积极文本的预测类别,A i为第i个积极文本的已知类别。其中,对于模型参数调整可以为:使用训练损失的损失值对神经网络模型的最后一层的学习参数进行求偏导步骤,并如
Figure PCTCN2021091079-appb-000001
W =W -η*c,其中c为根据学习参数和训练损失计算得到的偏导值,W 为神经网络模型网络中最后一层的学习参数,最后根据计算出的偏导值更新模型内部的学习参数,W 更新后的学习参数,η为学习效率,是神经网络模型设定的初始值,在迭代过程中学习效率保持不变,而后逐步前推计算每层学习参数。
在应用中,上述第一文本与第二文本均具有多个,将所有第一文本与第二文本同时输入到训练模型中进行训练,直到训练损失收敛得到最终的目标模型。其中,训练模型在每次对第一文本和第二文本进行迭代训练后,都可计算一次迭代训练中所有训练文本的训练损失,并根据训练损失对模型参数进行一次调整。此外,输入到训练模型中的训练文本不包含重复文本。上述训练损失收敛可以为,设定固定的迭代训练次数,达到该次数即停止训练;或设定若在连续几次的迭代训练后模型的文本分类效果未提升,则停止训练,对此不作限定。之后结束模型训练,并将当前的训练模型作为已调整后的目标模型。
在本实施例,通过根据已有的训练模型,使用目标场景下且属于目标类别的第一文本,以及非目标场景下且属于非目标类别的第二文本作为训练数据,对已有的训练模型进行调整,使得训练得到的目标模型对不同类别的文本识别更加充分,提升目标模型的识别性能和泛化能力,且可以达到减少目标模型的训练时间的目的。
请参阅图2,在S101将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别之前,还包括如下步骤S201-S203,详述如下:
S201、获取每个测试场景下的多个文本。
在应用中,上述S101已说明目标场景可以为特定应用场景下的具体场景,且对特定应 用场景具有解释。可认为该测试场景即为上述特定应用场景,对此不再进行说明。
S202、将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别。
S203、根据所述初始预测类别,从多个测试场景中确定多个目标场景。
在应用中,将每个测试场景下的多个文本分别输入至已有的训练模型中,得到每个测试场景下的多个文本的初始预测类别。具体的,可参照上述S101中将每个目标场景下的各个目标文本输入至已有的训练模型中,获取各个目标文本对应的目标预测类别。该步骤与上述S101步骤类似,对此不再进行说明。
在应用中,在获取到每个测试场景中各个文本的初始预测类别后,可具体根据初始预测类别中属于目标类别的个数进行筛选。具体的,从每个测试场景中挑选10000个文本输入至训练模型中,可对应得到10000个属于积极类别、消极类别或中性类别的标签分类,分别统计积极类别与消极类别的标签数量,挑选数量最多的多个测试场景作为目标场景。
在本实施例中,在面对多个测试场景时,先通过已有的训练模型对各个文本进行初步分类,根据分类结果筛选出目标场景。可使得筛选出的目标场景包含的各个目标文本相比于其余测试场景下的文本,可以更好的被训练模型识别,使训练得到的目标模型对文本识别更加充分,提升目标模型的识别性能和泛化能力。
参照图3,在一实施例中,S203所述根据所述初始预测类别,从多个测试场景中确定多个目标场景可以包括如下子步骤:
S301、根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数。
S302、计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值。
S303、根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
在应用中,上述目标预测类别包括积极类别和消极类别,若存在中性类别,则中性类别即为非目标标签类别。上述预设个数可以根据实际情况选择,例如,在所有测试场景中选择3个目标场景。其中,对于每个测试场景的所有文本的数量可以采用相同数量,也可以采用不同数量。
示例性的,对于每个测试场景下的文本的总数量若是相同,则在将文本输入至训练模型中进行标签分类时,只需统计属于目标预测类别的个数,将所有测试场景对应的目标预测类别的个数,排在前三的测试场景定为目标场景。若对于每个测试场景下包含的文本的总数量不同,则每个测试场景下的预测类别的总个数即为文本的总数量,则计算统计的目标预测类别的个数,与预测类别总个数的占比值,将占比值排在前三的测试场景定为目标场景。
在本实施例中,通过已有的训练模型分别对各个测试场景下的文本进行初步分类,确定每个测试场景下的多个文本中属于目标预测类别的文本个数,以及确定每个测试场景下包含的文本总个数,根据目标预测类别的文本个数与文本总个数的占比值的大小筛选出目标场景。可使得筛选出的目标场景包含的各个目标文本相比于其余测试场景下的文本,可以更好的被训练模型识别,使训练得到的目标模型对文本识别更加充分,提升目标模型的识别性能和泛化能力。
请参阅图4,在一实施例中,所述目标预测类别包括预测积极类别和预测消极类别;S102根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本可以包括如下子步骤S401-S403:
S401、在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本。
S402、获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别。
S403、在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
S404、将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
在应用中,上述每个目标场景下的各个目标文本在输入已有的训练模型后,均会输出对应的预测类别。因此,可根据预测类别对目标文本进行区分。然而,已有训练模型在对目标场景下的各个目标文本进行预测分类时,由于已有的训练模型对特定应用场景下的文本分类进行识别时具有一定的误差,分类的准确率较低,存在许多预测类别与真实类别存在差异的文本。因此,在已有的训练模型对该目标场景下的每个目标文本进行预测分类后,将预测分类结果为预测积极类别的目标文本作为第一预测文本。再根据每个第一预测文本的真实类别,将真实类别为积极类别的文本作为第一目标文本。同样的,第二目标文本为已有的训练模型对该文本的预测分类为预测消极类别,且该文本的真实类别同样为消极类别。
在本实施例中,通过根据已有的训练模型,对每个目标场景对应的目标文本进行预测,将预测目标类别和真实类别均一致的文本作为第一文本进行模型训练,以使得用于训练的第一文本可以更好的被训练模型进行识别,实现训练得到的目标模型对不同类别的文本识别更加充分的效果,提升目标模型的识别性能和泛化能力。
请参阅图5,在S404在将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本之后,还包括如下步骤S501-S504:
S501、接收用户输入的积极类别词汇与消极类别词汇。
S502、根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本。
在应用中,上述积极类别词汇包括但不限定“喜欢”,“开心”,“满意”等词,在接收到用户输入的关键词后,可对目标场景下的所有文本进行查询,并根据关键词定位搜索文本,将搜索的文本作为第三目标文本。为避免存在特殊情况,如搜索的文本可能包含“不喜欢”、“不高兴”等词,其虽然包含积极类别词汇,但实际属于消极类别文本。因此,可将搜索到的文本同样与真实类别进行比较,之后将积极类别词汇与真实类别均一致的文本作为第三目标文本。另外,上述搜索的文本为目标场景下的所有文本,而为了避免第三目标文本与第一目标文本出现重合的情况,可将出现重合的第三目标文本进行剔除,重新查找新的文本作为第三目标文本,对此不作限定。同样的,上述第四目标文本的获取方式与第三目标文本的获取方式一致,对此不再详细描述。
S503、根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
S504、将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
在应用中,上述第四目标文本的获取方式与第三目标文本的获取方式一致,对此不再详细描述。
在其他应用中,用于训练的积极类别文本的数量与消极类别文本的数量可以为1:1。即上述第一文本中的积极类别文本与上述第一文本中的消极类别文本的数量一致,其比例可为1:1。然而,对于第一目标文本的数量与第二目标文本的数量,以及第三目标文本的数量与第四目标文本的数量,其均可以一致,也可以不一致,对此不作限定。且第一文本的数量与第二文本的数量的比值可以为1:1,或者1:N(N为大于1的整数),对此不作限定。即第二文本的数量为第一文本数量的N倍。其目的在于:中性文本的表达方式较为 多样,而含有情绪的文本的表达方式相对较为单一。因此,选择非特定场景下的中性类别文本能够扩充中性文本的文本多样性,充分表达中性文本这一大类的特征,在对训练模型进行训练时,可更好的起到提升训练模型的分类效果的作用。
在本实施例中,为了更快速的获取到第一文本,可根据输入的积极类别词汇与消极类别词汇,对每个目标场景下的各个文本进行查询,获取相应的第三目标文本以及第四目标文本,以达到减少获取用于训练的第一文本的时间。
请参阅图6,S104将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别可以包括如下子步骤S601-S602:
S601、将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本。
S602、将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
在应用中,因目标场景下获取到的积极类别的文本数量,和与消极类别的文本数量可能不足,即用于模型训练的第一文本的数量不足,使得训练得到的目标模型对文本特征的识别性能差。因此,需通过上述文本增强模型增加积极类别的文本数量和消极类别的文本数量。具体的,文本增强的过程可基于Bert做数据增强(Conditional BERT Contextual Augmentation)实现的。文本增强可较为直观地理解为通过对原有文本进行同义词替换、随机插入、删除词语等增大训练数据量的过程。在文本增强模型中具体体现为:在第一文本输入的过程中,同时输入第一文本的真实类别。文本增强模型可根据第一文本的真实类别,可为第一文本预测可以替换的文本词,从而使得第一文本的表达方式更加多样,使其可扩充为不同表达但语义相近的文本。即可认为文本增强模型强化了第一文本的文本特征,增强了目标模型对第一文本的识别与认知。
示例性的,对于积极类别文本:“今天很高兴”,可以替换为“今天很开心”、“今天很欢乐”等文本。具体的,可获取目标场景下80个积极类别文本使用文本增强模型进行数据增强,在每个积极类别文本的基础上,再扩展出49个积极类别文本,可对应得到4000个包含积极类别文本。同理,使用上述方式可同样对消极类别文本进行文本增强,对此不再进行说明。
在本实施例中,通过将第一文本输入至文本增强模型中,根据第一文本的真实类别,使文本增强模型可以根据真实类别对其进行扩展,得到不同表达但语义相近的多个第一文本,将第二文本以及增强后的第一文本作为训练数据,训练已有的训练模型得到目标模型。使得目标模型对文本识别的更加充分。
在一实施例中,在S104将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别之后还包括:
将所述待识别的文本的情绪识别结果上传至区块链中。
在本申请的所有实施例中,基于终端设备得到对应的文本情绪识别方案,具体来说,文本情绪识别方案由终端设备进行处理得到。将文本情绪识别方案上传至区块链可保证其安全性和对用户的公正透明性。用户设备可以从区块链中下载得该文本情绪识别方案,以便查证文本情绪识别方案是否被篡改。本示例所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。
请参阅图7,图7是本申请实施例提供的一种文本情绪识别装置的结构框图。本实施例中该移动终端包括的各单元用于执行图1至图4对应的实施例中的各步骤。具体请参阅 图1至图6以及图1至图6所对应的实施例中的相关描述。为了便于说明,仅示出了与本实施例相关的部分。参见图7,文本情绪识别装置700包括:输入模块710、第一获取模块720、第二获取模块730和识别模块740,其中:
输入模块710,用于将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别。
第一获取模块720,用于根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本。
第二获取模块730,用于获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本。
识别模块740,用于将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
作为本申请一实施例,文本情绪识别装置700还包括:
第三获取模块,用于获取每个测试场景下的多个文本。
输入模块,用于将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别。
确定模块,用于根据所述初始预测类别,从多个测试场景中确定多个目标场景。
作为本申请一实施例,确定模块还用于:
根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
作为本申请一实施例,所述目标预测类别包括预测积极类别和预测消极类别;第一获取模块720还用于:
在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别;在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
作为本申请一实施例,第一获取模块720还用于:
接收用户输入的积极类别词汇与消极类别词汇;根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
作为本申请一实施例,识别模块740还用于:
将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
作为本申请一实施例,文本情绪识别装置700还包括:
上传模块,用于将所述待识别的文本的情绪识别结果上传至区块链中。
应当理解的是,图7示出的文本情绪识别装置的结构框图中,各单元/模块用于执行图1至图6对应的实施例中的各步骤,而对于图1至图6对应的实施例中的各步骤已在上述实施例中进行详细解释,具体请参阅图1至图6以及图1至图6所对应的实施例中的相关 描述,此处不再赘述。
图8是本申请另一实施例提供的一种终端设备的结构框图。如图8所示,该实施例的终端设备80包括:处理器81、存储器82以及存储在所述存储器82中并可在所述处理器81上运行的计算机程序83,例如文本情绪识别方法的程序。处理器81执行所述计算机程序83时实现上述各个文本情绪识别方法各实施例中的步骤,例如图1所示的S101至S104。或者,所述处理器81执行所述计算机程序83时实现上述图7对应的实施例中各模块的功能,例如,图7所示的模块710至740的功能。具体如下所述:
一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
在一个实施例中,所述处理器执行所述计算机程序时还实现:
获取每个测试场景下的多个文本;
将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别;
根据所述初始预测类别,从多个测试场景中确定多个目标场景。
在一个实施例中,所述处理器执行所述计算机程序时还实现:
根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;
计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;
根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
在一个实施例中,所述目标预测类别包括预测积极类别和预测消极类别;所述处理器执行所述计算机程序时还实现:
在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;
获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别;
在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
在一个实施例中,所述处理器执行所述计算机程序时还实现:
接收用户输入的积极类别词汇与消极类别词汇;
根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;
根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
在一个实施例中,所述处理器执行所述计算机程序时还实现:
将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;
将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
在一个实施例中,所述处理器执行所述计算机程序时还实现:
将所述待识别的文本的情绪识别结果上传至区块链中。
一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现:
将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
在一个实施例中,所述计算机程序被处理器执行时还实现:
获取每个测试场景下的多个文本;
将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别;
根据所述初始预测类别,从多个测试场景中确定多个目标场景。
在一个实施例中,所述计算机程序被处理器执行时还实现:
根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;
计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;
根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
在一个实施例中,所述目标预测类别包括预测积极类别和预测消极类别;所述计算机程序被处理器执行时还实现:
在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;
获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别;
在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
在一个实施例中,所述计算机程序被处理器执行时还实现:
接收用户输入的积极类别词汇与消极类别词汇;
根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;
根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
在一个实施例中,所述计算机程序被处理器执行时还实现:
将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;
将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
在一个实施例中,所述计算机程序被处理器执行时还实现:
将所述待识别的文本的情绪识别结果上传至区块链中。
示例性的,所述计算机程序83可以被分割成一个或多个单元,所述一个或者多个单元被存储在所述存储器82中,并由所述处理器81执行,以完成本申请。所述一个或多个单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序83在所述终端设备80中的执行过程。例如,所述计算机程序83可以被分割成输入模块、第一获取模块、第一获取模块以及识别模块,各模块具体功能如上所述。
所述终端设备可包括,但不仅限于,处理器81、存储器82。本领域技术人员可以理解,图8仅仅是终端设备80的示例,并不构成对终端设备80的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入输出设备、网络接入设备、总线等。
所称处理器81可以是中央处理单元,还可以是其他通用处理器、数字信号处理器、专用集成电路、现成可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器82可以是所述终端设备80的内部存储单元,例如终端设备80的硬盘或内存。所述存储器82也可以是所述终端设备80的外部存储设备,例如所述终端设备80上配备的插接式硬盘,智能存储卡,安全数字卡,闪存卡等。进一步地,所述存储器82还可以既包括所述终端设备80的内部存储单元也包括外部存储设备。
所述计算机可读存储介质可以是前述实施例所述的终端设备的内部存储单元,例如所述终端设备的硬盘或内存。所述计算机可读存储介质可以是非易失性,也可以是易失性。所述计算机可读存储介质也可以是所述终端设备的外部存储设备,例如所述终端设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种文本情绪识别方法,其中,所述方法包括:
    将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
    根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
    获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
    将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
  2. 如权利要求1所述的文本情绪识别方法,其中,在将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的预测类别之前,还包括:
    获取每个测试场景下的多个文本;
    将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别;
    根据所述初始预测类别,从多个测试场景中确定多个目标场景。
  3. 如权利要求2所述的文本情绪识别方法,其中,根据所述初始预测类别,从多个测试场景中确定多个目标场景,包括:
    根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;
    计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;
    根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
  4. 如权利要求1所述的文本情绪识别方法,其中,所述目标预测类别包括预测积极类别和预测消极类别;
    所述根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本,包括:
    在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;
    获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别;
    在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
    将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
  5. 如权利要求4所述的文本情绪识别方法,其中,在将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本之后,还包括:
    接收用户输入的积极类别词汇与消极类别词汇;
    根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;
    根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
    将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
  6. 如权利要求1-5任一所述的文本情绪识别方法,其中,所述将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别,包括:
    将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;
    将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
  7. 如权利要求6所述的文本情绪识别方法,其中,在将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别之后,还包括:
    将所述待识别的文本的情绪识别结果上传至区块链中。
  8. 一种文本情绪识别装置,其中,所述装置包括:
    输入模块,用于将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
    第一获取模块,用于根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
    第二获取模块,用于获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
    识别模块,用于将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
  9. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现:
    将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
    根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
    获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
    将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
  10. 根据权利要求9所述的终端设备,其中,所述处理器执行所述计算机程序时还实现:
    获取每个测试场景下的多个文本;
    将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别;
    根据所述初始预测类别,从多个测试场景中确定多个目标场景。
  11. 根据权利要求10所述的终端设备,其中,所述处理器执行所述计算机程序时还实现:
    根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;
    计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;
    根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
  12. 根据权利要求9所述的终端设备,其中,所述目标预测类别包括预测积极类别和预测消极类别;所述处理器执行所述计算机程序时还实现:
    在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;
    获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所 述真实类别包括真实积极类别和真实消极类别;
    在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
    将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
  13. 根据权利要求12所述的终端设备,其中,所述处理器执行所述计算机程序时还实现:
    接收用户输入的积极类别词汇与消极类别词汇;
    根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;
    根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
    将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
  14. 根据权利要求9-13任一所述的终端设备,其中,所述处理器执行所述计算机程序时还实现:
    将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;
    将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
  15. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中,所述计算机程序被处理器执行时实现:
    将每个目标场景下的各个目标文本输入至已有的训练模型中,获取所述各个目标文本对应的目标预测类别;
    根据所述目标预测类别,在所述每个目标场景中获取属于目标类别的第一文本;
    获取第二文本,其中,所述第二文本属于非目标类别,且属于非目标场景下的文本;
    将所述第一文本和第二文本输入至已有的训练模型中,对训练模型的模型参数进行调整得到目标模型,并根据所述目标模型对待识别的文本进行情绪识别。
  16. 根据权利要求15所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时还实现:
    获取每个测试场景下的多个文本;
    将所述每个测试场景下的多个文本分别输入至所述已有的训练模型中,得到所述每个测试场景下的多个文本的初始预测类别;
    根据所述初始预测类别,从多个测试场景中确定多个目标场景。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时还实现:
    根据所述初始预测类别,分别确定所述每个测试场景下的多个文本中属于所述目标预测类别的文本个数,以及确定所述每个测试场景下包含的初始预测类别的文本总个数;
    计算属于所述目标预测类别的文本个数,在对应所述测试场景下的初始预测类别的文本总个数的占比值;
    根据所述每个测试场景对应的占比值选取预设个数的所述目标场景,其中,所述目标场景对应的占比值高于其他测试场景对应的占比值。
  18. 根据权利要求15所述的计算机可读存储介质,其中,所述目标预测类别包括预测积极类别和预测消极类别;所述计算机程序被处理器执行时还实现:
    在所述每个目标场景下的各个目标文本中,分别获取所述目标文本属于所述预测积极 类别的第一预测文本,和所述目标文本属于所述预测消极类别的第二预测文本;
    获取所述每个目标场景对应的目标文本中,各个目标文本对应的真实类别;其中,所述真实类别包括真实积极类别和真实消极类别;
    在所述第一预测文本中,将所述预测积极类别与所述真实积极类别均一致的文本,作为第一目标文本,并将所述预测消极类别与所述真实消极类别均一致的文本,作为第二目标文本;
    将所述第一目标文本与第二目标文本作为属于所述目标类别的第一文本;其中,所述目标类别包括积极类别和消极类别。
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时还实现:
    接收用户输入的积极类别词汇与消极类别词汇;
    根据所述积极类别词汇,在所述每个目标场景下的各个目标文本中,查找包含所述积极类别词汇的第三目标文本;
    根据所述消极类别词汇,在所述每个目标场景下的各个文本中,查找包含所述消极类别词汇的第四目标文本;
    将所述第一目标文本与所述第三目标文本作为所述第一文本中的积极类别文本,并将所述第二目标文本与所述第四目标文本作为所述第一文本中的消极类别文本。
  20. 根据权利要求15-19任一所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时还实现:
    将所述每个目标场景对应的所述第一文本,输入至文本增强模型中进行文本数据增强,得到增强后的第一文本;
    将所述第二文本,以及所述增强后的第一文本输入至已有的训练模型中,对所述训练模型的模型参数进行调整得到目标模型。
PCT/CN2021/091079 2020-09-14 2021-04-29 文本情绪识别方法、装置、终端设备和存储介质 WO2022052484A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010961758.7 2020-09-14
CN202010961758.7A CN112101042A (zh) 2020-09-14 2020-09-14 文本情绪识别方法、装置、终端设备和存储介质

Publications (1)

Publication Number Publication Date
WO2022052484A1 true WO2022052484A1 (zh) 2022-03-17

Family

ID=73752421

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/091079 WO2022052484A1 (zh) 2020-09-14 2021-04-29 文本情绪识别方法、装置、终端设备和存储介质

Country Status (2)

Country Link
CN (1) CN112101042A (zh)
WO (1) WO2022052484A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112101042A (zh) * 2020-09-14 2020-12-18 平安科技(深圳)有限公司 文本情绪识别方法、装置、终端设备和存储介质
CN112732910B (zh) * 2020-12-29 2024-04-16 华南理工大学 跨任务文本情绪状态评估方法、系统、装置及介质
CN113705678B (zh) * 2021-08-28 2023-04-28 重庆理工大学 利用词屏蔽数据增强与对抗学习的特定目标情感分析方法
CN113792146A (zh) * 2021-09-17 2021-12-14 平安科技(深圳)有限公司 基于人工智能的文本分类方法、装置、电子设备及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108922564A (zh) * 2018-06-29 2018-11-30 北京百度网讯科技有限公司 情绪识别方法、装置、计算机设备及存储介质
CN109918642A (zh) * 2019-01-23 2019-06-21 重庆恢恢信息技术有限公司 基于委员会查询的主动学习框架的情感分析方法及系统
US20200034116A1 (en) * 2016-08-30 2020-01-30 Google Llc Using user input to adapt search results provided for presentation to the user
CN112101042A (zh) * 2020-09-14 2020-12-18 平安科技(深圳)有限公司 文本情绪识别方法、装置、终端设备和存储介质

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106156766B (zh) * 2015-03-25 2020-02-18 阿里巴巴集团控股有限公司 文本行分类器的生成方法及装置
CN110019770A (zh) * 2017-07-24 2019-07-16 华为技术有限公司 训练分类模型的方法与装置
CN108334605B (zh) * 2018-02-01 2020-06-16 腾讯科技(深圳)有限公司 文本分类方法、装置、计算机设备及存储介质
CN109471938B (zh) * 2018-10-11 2023-06-16 平安科技(深圳)有限公司 一种文本分类方法及终端
CN109684478B (zh) * 2018-12-18 2023-04-07 腾讯科技(深圳)有限公司 分类模型训练方法、分类方法及装置、设备和介质
CN110162627B (zh) * 2019-04-28 2022-04-15 平安科技(深圳)有限公司 数据增量方法、装置、计算机设备及存储介质
CN110288019A (zh) * 2019-06-21 2019-09-27 北京百度网讯科技有限公司 图像标注方法、装置和存储介质
CN110413788B (zh) * 2019-07-30 2023-01-31 携程计算机技术(上海)有限公司 会话文本的场景类别的预测方法、系统、设备和存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200034116A1 (en) * 2016-08-30 2020-01-30 Google Llc Using user input to adapt search results provided for presentation to the user
CN108922564A (zh) * 2018-06-29 2018-11-30 北京百度网讯科技有限公司 情绪识别方法、装置、计算机设备及存储介质
CN109918642A (zh) * 2019-01-23 2019-06-21 重庆恢恢信息技术有限公司 基于委员会查询的主动学习框架的情感分析方法及系统
CN112101042A (zh) * 2020-09-14 2020-12-18 平安科技(深圳)有限公司 文本情绪识别方法、装置、终端设备和存储介质

Also Published As

Publication number Publication date
CN112101042A (zh) 2020-12-18

Similar Documents

Publication Publication Date Title
WO2022052484A1 (zh) 文本情绪识别方法、装置、终端设备和存储介质
US20210232762A1 (en) Architectures for natural language processing
US11816439B2 (en) Multi-turn dialogue response generation with template generation
US11803758B2 (en) Adversarial pretraining of machine learning models
US20210019599A1 (en) Adaptive neural architecture search
US20200104102A1 (en) Automated content editor
WO2021051560A1 (zh) 文本分类方法和装置、电子设备、计算机非易失性可读存储介质
CN111506714A (zh) 基于知识图嵌入的问题回答
US20190347571A1 (en) Classifier training
CN114565104A (zh) 语言模型的预训练方法、结果推荐方法及相关装置
CN110390017B (zh) 基于注意力门控卷积网络的目标情感分析方法及系统
Lee et al. Query-efficient and scalable black-box adversarial attacks on discrete sequential data via bayesian optimization
US20220292329A1 (en) Neural architecture search with weight sharing
CN112749274B (zh) 基于注意力机制和干扰词删除的中文文本分类方法
WO2023197613A1 (zh) 一种小样本微调方法、系统及相关装置
CN111400458A (zh) 一种自动泛化方法及其装置
Wu et al. An effective approach of named entity recognition for cyber threat intelligence
CN110929532B (zh) 数据处理方法、装置、设备及存储介质
CN110969005B (zh) 一种确定实体语料之间的相似性的方法及装置
WO2024109597A1 (zh) 文本合并判断模型的训练方法和文本合并判断方法
US12013884B2 (en) Knowledge graph question answering with neural machine translation
Wang et al. Augmentation with projection: Towards an effective and efficient data augmentation paradigm for distillation
Gong et al. Improving extractive document summarization with sentence centrality
Jeon et al. Pet: Parameter-efficient knowledge distillation on transformer
Jung et al. Improving visual relationship detection using linguistic and spatial cues

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21865545

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21865545

Country of ref document: EP

Kind code of ref document: A1