Model training method, sentiment tendency prediction method and device

Through joint training of sample data from fine-grained to coarse-grained sample data, the problem of low accuracy in deep learning models in predicting emotional tendencies is solved, and more accurate prediction of corpus emotional tendencies is achieved.

CN114896365BActive Publication Date: 2024-12-20MASHANG CONSUMER FINANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210451687.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-27
Publication Date
2024-12-20
Estimated Expiration
2042-04-27

AI Technical Summary

Technical Problem

The emotional tendency prediction model trained based on deep learning technology has a low accuracy rate when predicting emotional tendency in new sentences and new articles. It is mainly because there are few sentences that are exactly the same as those in training, and one sentence is found in the sample data during training. Or the emotional tendencies in an article include both positive short words and negative short words, which is more likely to lead to a model's prediction error.

Method used

A model training method is adopted to initially train the emotional tendency prediction model based on fine-grained sample data (such as word granularity), and then further train based on coarse-grained sample data (such as short word granularity, sentence granularity), so as to achieve the following: Joint training of sample data from fine to coarseness improves the accuracy of predicting the emotional tendency of the model to the corpus.

Benefits of technology

Through joint training from fine-grained to coarse-grained, the model can more accurately understand the emotional tendency of the corpus, improve the accuracy of predicting emotional tendency, and overcome the problem of low prediction accuracy of existing models when facing new sentences and new articles. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114896365B_ABST
    Figure CN114896365B_ABST
Patent Text Reader

Abstract

The present application discloses a model training method, a sentiment tendency prediction method and a device for improving the prediction accuracy of sentiment tendency. The scheme includes: first training a sentiment tendency prediction model based on a plurality of first sample data and sentiment tendency labels corresponding to the plurality of sample data; after the first training, second training is performed on the sentiment tendency prediction model after the first training based on a plurality of second sample data and sentiment tendency labels corresponding to the plurality of second sample data, wherein the granularity of the second sample data is greater than the granularity of the first sample data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a model training method, a sentiment tendency prediction method and a device. Background Art

[0002] Sentiment analysis in Natural Language Processing (NLP) is also commonly called opinion mining. It is an analytical method that mines users' opinions, tendencies, emotions, attitudes and evaluations based on textual data about products, services, organizations, individuals, issues, events, topics and attributes. As deep learning technology has begun to be applied in the field of NLP, it has also begun to be widely used in sentiment analysis.

[0003] At present, the sentiment tendency prediction model trained based on deep learning technology often annotates a batch of sentence-level or article-level sample data with sentiment tendency, and usually only annotates one sentiment tendency label in a sentence, and then trains the sentiment tendency prediction model to learn the sentiment tendency of sentences and articles in the sample data, so as to predict the sentiment tendency of new input sentences. However, when the sentiment tendency prediction model trained by this method predicts the sentiment tendency of new sentences and new articles, it rarely encounters sentences that are exactly the same as those in the sample data during training, and the sentiment tendency in a sentence or an article may include both positive short words and negative short words. At this time, the model is more likely to make mistakes in the prediction process, that is, the prediction accuracy is often low. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a model training method, a sentiment tendency prediction method and a device to improve the prediction accuracy of the sentiment tendency prediction model.

[0005] In a first aspect, a model training method is provided, comprising:

[0006] Based on the plurality of first sample data and the sentiment tendency labels corresponding to the plurality of sample data, performing a first training on the sentiment tendency prediction model;

[0007] After the first training, the sentiment tendency prediction model after the first training is subjected to second training based on multiple second sample data and sentiment tendency labels corresponding to the multiple second sample data, wherein the granularity of the first sample data is greater than the granularity of the second sample data.

[0008] Secondly, a sentiment tendency prediction method is proposed, including:

[0009] Get the corpus to be predicted;

[0010] The corpus to be predicted is input into the sentiment tendency prediction model obtained by training in the first aspect, and the sentiment tendency of the corpus to be predicted is output.

[0011] In the third aspect, a model training device is proposed, comprising:

[0012] A first training module, configured to perform first training on a sentiment tendency prediction model based on a plurality of first sample data and sentiment tendency labels corresponding to the plurality of sample data; and

[0013] The second training module is used to perform a second training on the sentiment tendency prediction model after the first training based on multiple second sample data and the sentiment tendency labels corresponding to the multiple second sample data after the first training, wherein the granularity of the first sample data is greater than the granularity of the second sample data.

[0014] In the fourth aspect, a sentiment tendency prediction device is proposed, comprising:

[0015] A corpus acquisition module is used to acquire the corpus to be predicted;

[0016] The sentiment tendency prediction module is used to input the corpus to be predicted into the sentiment tendency prediction model obtained by training in the first aspect, and output the sentiment tendency in the corpus to be predicted.

[0017] In the fifth aspect, an electronic device is proposed, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the training method of the emotion tendency prediction model described in the first aspect.

[0018] In a sixth aspect, a computer-readable storage medium is proposed, on which a computer program is stored. When the computer program is executed by a processor, the steps of the training method of the emotion tendency prediction model described in the first aspect are implemented.

[0019] In the seventh aspect, an electronic device is proposed, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the emotion tendency prediction method as described in the second aspect.

[0020] In an eighth aspect, a computer-readable storage medium is proposed, on which a computer program is stored. When the computer program is executed by a processor, the steps of the emotion tendency prediction method described in the second aspect are performed.

[0021] It can be seen that in the embodiments of the present application, the sentiment tendency prediction model can be first trained based on fine-grained sample data, and then the sentiment tendency prediction model can be further trained based on coarse-grained sample data, thereby realizing that the sentiment tendency prediction model is jointly trained from fine-grained to coarse-grained sample data. Therefore, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, thereby improving the accuracy of the sentiment tendency prediction of the corpus. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0023] Figure 1 It is a schematic diagram of an implementation flow of a model training method provided by an embodiment of the present application.

[0024] Figure 2 It is a flowchart of the application of a model training method provided by an embodiment of the present application in an actual scenario.

[0025] Figure 3 It is a schematic diagram of the training process of a model training method provided by an embodiment of the present application.

[0026] Figure 4 It is a schematic diagram of the implementation process of a method for predicting a sentiment tendency provided by an embodiment of the present application.

[0027] Figure 5 It is a structural schematic diagram of a model training device provided by an embodiment of the present application.

[0028] Figure 6 It is a structural diagram of an emotion tendency prediction device provided by an embodiment of the present application.

[0029] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. The numbering of the drawings in this application is only used to distinguish the various steps in the scheme, and is not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.

[0031] Based on the different granularities of the corpus, sentiment analysis can usually be subdivided into word level, sentence level, document level and aspect level. Among them, document-level sentiment analysis is often based on the entire document, but the premise of sentiment analysis on document-level corpus is that the document needs to have a clear attitude, that is, the point of view must be clear. Sentence-level sentiment analysis is to perform sentiment analysis on the sentences in the document separately. Aspect-level sentiment analysis is more granular than document-level and sentence-level sentiment analysis. Its task is to extract and summarize people's opinions on a certain entity and the characteristics of the entity (also called the target). For example, for a product review, the purpose of aspect-level sentiment analysis is to summarize the positive and negative opinions on different aspects of the product respectively. Although the overall sentiment towards the product may be positive or negative, there may be a situation where a certain aspect of the product is different from the overall sentiment tendency.

[0032] At present, the sentence length of sentence-level and document-level sentiment analysis is generally kept between 10-500 words or more than 500 words. The purpose is to annotate a batch of sentence-level and document-level corpus data with sentiment tendencies, and then train the deep learning model with sentiment-annotated data to learn the semantics of the sentence-level and document-level sentences, understand the sentiment tendencies of sentences and documents, and judge the sentiment tendencies of new input sentences and documents. However, there is a lack of characterization of fine-grained sentiment information in sentence-level and chapter-level training corpus. This is mainly manifested in that the annotated corpus is all sentence-level or chapter-level (i.e., the overall sentiment tendency of a sentence or the sentiment tendency of the entire article is annotated), and the fine-grained information tendency in a sentence or an article may include positive short words or negative short words. At this time, the model may use the sentence sentiment tendency label to understand the sentiment tendency of the short words contained in the sentence, or use the article sentiment tendency label to understand the sentiment tendency of the contained sentence, which leads to the problem that the model has low prediction accuracy in new prediction data.

[0033] To this end, an embodiment of the present application provides a model training method, which can first perform a first training on a sentiment tendency prediction model based on multiple sample data of a first granularity and the sentiment tendency labels corresponding to the multiple sample data of the first granularity, and then perform a second training on the sentiment tendency prediction model based on multiple sample data of a second granularity and the sentiment tendency labels corresponding to the multiple sample data of the second granularity. The second granularity is coarser than the granularity of the first granularity, thereby realizing that the sentiment tendency prediction model is jointly trained by sample data from fine-grained to coarse-grained. Therefore, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, thereby improving the accuracy of predicting the sentiment tendency of the corpus.

[0034] Figure 1 1 is a schematic diagram of an implementation flow of a model training method provided in an embodiment of the present application. The method is applied to electronic equipment, Figure 1 Methods may include:

[0035] S110, performing first training on a sentiment tendency prediction model based on the plurality of first sample data and the sentiment tendency labels corresponding to the plurality of first sample data.

[0036] Among them, one first sample data corresponds to one sentiment tendency label, and the sentiment tendency label is used to reflect the sentiment of the data tendency. For example, the sentiment tendency label includes a negative sentiment label, a neutral sentiment label, a positive sentiment label, etc.

[0037] The first sample data includes sample data at word granularity.

[0038] Since the sentiment tendency prediction model is first trained using the first sample data of word granularity, the obtained sentiment tendency prediction model can predict the sentiment tendency of the corpus of word granularity.

[0039] As shown in Table 1, it is an example table of the correspondence between sample data of word granularity and sentiment tendency labels. Among them, the sentiment tendency label "0" is used to indicate negative sentiment, that is, relatively negative sentiment, which usually makes people feel bad, the sentiment tendency label "1" is used to indicate neutral sentiment, that is, neutral sentiment, which does not clearly express good or bad, and the sentiment tendency label "2" is used to indicate positive sentiment, that is, relatively positive sentiment, which usually makes people feel better. The sentiment tendency label of the word "smaller" can be marked as "1", the sentiment tendency label of the word "lazy" can be marked as "0", the sentiment tendency label of the word "first" can be marked as "2", the sentiment tendency label of the word "general" can be marked as "1", the sentiment tendency label of the word "larger" can be marked as "2", and the sentiment tendency label of the word "neat" can be marked as "2".

[0040] Table 1 Correspondence between sample data of word granularity and sentiment tendency labels

[0041] Sample data at word granularity Sentiment label Smaller 1 lazy 0 First 2 generally 1 Larger 2 tidy 2

[0042] As an example, the sentiment tendency prediction model can be a deep neural network model such as Transformer, BERT, etc.

[0043] The training of the sentiment tendency prediction model specifically includes: encoding the sample data of word granularity into digital data and inputting it into the sentiment tendency prediction model for training. The sentiment tendency prediction model can perform forward propagation based on the input data, and calculate layer by layer until the output of the last layer of the neural network is obtained. Finally, the loss value is calculated according to the loss function such as cross entropy, and back propagation is performed according to the loss value to update the network parameters of each network node in the trained sentiment tendency prediction model, so that the next time the sample data of word granularity is input into the sentiment tendency prediction model for forward propagation, the output sentiment tendency prediction structure can be closer to the real sentiment tendency label value of the sample data of word granularity. Among them, the output of the two-category deep neural network model is 0 or 1, and the output of the three-category neural network model is 0 or 1 or 2.

[0044] Among them, the sentiment tendency prediction model can be understood as a mapping function from input X to output Y, which can be expressed as f(X)=Y, and the coefficient of the function f(X) is the network parameter W to be trained in the model training process. The process of first training the sentiment tendency prediction model based on multiple first sample data and the sentiment tendency labels corresponding to the multiple first sample data so that the sentiment tendency prediction model can predict the sentiment tendency of the corpus of each word granularity can be understood as: continuously adjusting the network parameter W so that the actual output f(X) of the deep neural network model is as close as possible to the corresponding sentiment tendency label Y.

[0045] In order to achieve this goal, the embodiment of the present application first encodes the sample data of the word granularity into digital data, and inputs the multiple first sample data encoded as digital data into each layer of the network structure in the deep neural network model, and obtains the output value of each layer of the neural network in turn, wherein the output of each layer of the neural network depends on the output value of the previous layer of the neural network, and the output value of the last layer of the neural network finally obtained is the output value obtained by forward propagation. Similar to straight line fitting, the above training of the sentiment tendency prediction model also has an objective function, namely the loss function, which defines what kind of network parameters are considered a good set of parameters. In the back propagation training process, the network parameter W is continuously adjusted to minimize the loss value calculated by the loss function.

[0046] Among them, after the first training, the sentiment tendency prediction model is converged, that is, it can accurately predict the sentiment tendency of the corpus with word granularity.

[0047] S120, after the first training, performing a second training on the sentiment tendency prediction model based on the plurality of second sample data and the sentiment tendency labels corresponding to the plurality of second sample data.

[0048] Among them, one second sample data corresponds to one sentiment tendency label, and the sentiment tendency label is used to reflect the sentiment of the data tendency. For example, the sentiment tendency label includes a negative sentiment label, a neutral sentiment label, a positive sentiment label, etc.

[0049] The granularity of the second sample data is greater than the granularity of the first sample data.

[0050] The second sample data includes sample data of short word granularity.

[0051] Since the sentiment tendency prediction model is trained for the second time using the second sample data of short word granularity, the obtained sentiment tendency prediction model can predict the sentiment tendency of the corpus of short word granularity. That is, after the second training, the sentiment tendency prediction model is convergent, that is, it can accurately predict the sentiment tendency of not only the corpus of word granularity, but also the corpus of short word granularity.

[0052] As shown in Table 2, it is an example table of the correspondence between sample data of short word granularity and sentiment tendency labels. Among them, the sentiment tendency label "0" is used to indicate negative sentiment, the sentiment tendency label "1" is used to indicate neutral sentiment, and the sentiment tendency label "2" is used to indicate positive sentiment. For example, the sentiment tendency label of the short word "small room" can be marked as "0", the sentiment tendency label of the short word "lazy to comment" can be marked as "0", the sentiment tendency label of the short word "ranked first in badness" can be marked as "0", the sentiment tendency label of the short word "general environment" can be marked as "1", the sentiment tendency label of the short word "large room" can be marked as "2", and the sentiment tendency label of the short word "tidy room" can be marked as "2".

[0053] Table 2 Correspondence between sample data of short word granularity and sentiment tendency labels

[0054] Sample data of short word granularity Sentiment label Small room 0 Too lazy to comment 0 The worst ranking 0 General environment 1 Larger room 2 Clean room 2

[0055] It should be noted that the specific implementation method of the first training of the sentiment tendency prediction model and the second training of the sentiment tendency prediction model are the same, except that the sample data input for the two trainings are different. The specific implementation method of the second training of the sentiment tendency prediction model is not described in detail here. For details, please refer to the above content.

[0056] Optionally, in order to improve the ability of the trained sentiment tendency prediction model to understand corpus with a coarser granularity and improve the prediction accuracy of the model, after the second training, the sentiment tendency prediction model after the second training can be trained using third sample data with a larger granularity than the second sample data. Specifically, the method provided in the embodiment of the present application also includes:

[0057] After the second training, the sentiment tendency prediction model is subjected to a third training based on the plurality of third sample data and the sentiment tendency labels corresponding to the plurality of third sample data, wherein the granularity of the third sample data is greater than the granularity of the second sample data.

[0058] Among them, one third sample data corresponds to one sentiment tendency label, and the sentiment tendency label is used to reflect the sentiment of the data tendency. For example, the sentiment tendency label includes a negative sentiment label, a neutral sentiment label, a positive sentiment label, etc.

[0059] Optionally, the third sample data includes sample data at a sentence granularity.

[0060] Since the sentiment tendency prediction model is trained for the third time using the third sample data of sentence granularity, the obtained sentiment tendency prediction model can predict the sentiment tendency of the corpus of sentence granularity. That is, after the third training, the sentiment tendency prediction model is convergent, that is, it can accurately predict the sentiment tendency of not only the corpus of word granularity and the corpus of short word granularity, but also the sentiment tendency of the corpus of sentence granularity.

[0061] As shown in Table 3, it is an example table of the correspondence between the sample data of sentence granularity and the sentiment tendency label. Among them, the sentiment tendency label "0" is used to indicate negative sentiment, the sentiment tendency label "1" is used to indicate neutral sentiment, and the sentiment tendency label "2" is used to indicate positive sentiment. The sentiment tendency label of the sentence "Convenient transportation; good environment; good service attitude, small room." can be marked as "1", the sentiment tendency label of the sentence "I bought a lot of books on Dangdang, but I am too lazy to comment. But this set of books is really good, and all three volumes are very exciting." is marked as "1", the sentiment tendency label of the sentence "The hotel's service is simply the worst! I stayed in 1702 on the first day, and the room was leaking." is marked as "0", the sentiment tendency label of the sentence "The environment of the hotel room, restaurant and bathroom is average." is marked as "1", the sentiment tendency label of the sentence "The hotel customer service attitude is good, and the hotel room is large." is marked as "2", and the sentiment tendency label of the sentence "The hotel service is considerate and the room is clean." is marked as "2".

[0062] Table 3 Correspondence between sample data of sentence granularity and sentiment tendency labels

[0063]

[0064] It should be noted that the specific implementation method of the first training of the sentiment tendency prediction model and the third training of the sentiment tendency prediction model are the same, except that the sample data input for the two trainings are different. The specific implementation method of the third training of the sentiment tendency prediction model is not described in detail here. For details, please refer to the above content.

[0065] Optionally, in order to improve the prediction accuracy of the trained sentiment tendency prediction model, the sentiment tendency prediction model after the third training can also be trained using randomly masked sample data after the third training, so that the model can better understand the sentiment tendency of the corpus. Specifically, the method provided in the embodiment of the present application also includes:

[0066] Obtaining a plurality of randomly masked fourth sample data and a plurality of sentiment tendency labels corresponding to the randomly masked fourth sample data, and a plurality of randomly masked fifth sample data and a plurality of sentiment tendency labels corresponding to the randomly masked fifth sample data;

[0067] After the third training, based on the plurality of randomly masked fifth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fifth sample data, performing a fourth training on the sentiment tendency prediction model; and

[0068] After the fourth training, the sentiment tendency prediction model is subjected to fifth training based on the plurality of randomly masked fourth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fourth sample data.

[0069] Among them, the randomly masked sample data refers to the data obtained after the data with emotional tendency is randomly masked.

[0070] Among them, data with sentiment tendency refers to the data expressing sentiment tendency, such as positive sentiment, neutral sentiment or negative sentiment. Taking positive sentiment as an example, words with positive sentiment tendency can be words such as "clean", "tidy", "good", "considerate" and other words that clearly express positive sentiment; taking negative sentiment as an example, words with negative sentiment tendency can be words such as "bad", "chaotic", "poor" and other words that clearly express negative sentiment; taking neutral sentiment as an example, words with neutral sentiment can be words such as "average", "ok", "ok" and other words that do not clearly express good or bad. By analogy, short words with sentiment tendency and sentences with sentiment tendency also express the user's positive, neutral or negative sentiment.

[0071] Optionally, the fourth sample data includes sample data at word granularity and sample data at short word granularity, and the fifth sample data includes sample data at sentence granularity.

[0072] Among them, the sentences with sentiment tendency in the sample data of random masked sentence granularity are masked. If the data of sentence granularity with sentiment tendency is "I bought a lot of books on Dangdang, all of them are good. Especially this set of books is really good, all three volumes are very wonderful.", it can be seen that the sentence with sentiment tendency in the data is "especially this set of books is really good, all three volumes are very wonderful", then the sample data of random masked sentence granularity obtained after the sentence is masked is "I bought a lot of books on Dangdang, all of them are good. _________".

[0073] In the sample data of the short word granularity of random masking, the short words with sentiment tendency are masked. If the data of the short word granularity with sentiment tendency is "I bought a lot of books on Dangdang, all of them are good. Especially this set of books is really good, all three volumes are very wonderful.", it can be seen that the short word with sentiment tendency in the data is "very wonderful", then the sample data of the short word granularity of random masking obtained after the short word is masked is "I bought a lot of books on Dangdang, all of them are good. Especially this set of books is really good, all three volumes are _____".

[0074] In the sample data of random masked word granularity, the words with sentiment tendency are masked. If the data of short word granularity with sentiment tendency is "I bought a lot of books on Dangdang, all of them are good. Especially this set of books is really good, all three volumes are very wonderful.", it can be seen that the words with sentiment tendency in the data are "very good" and "wonderful", then the sample data of random masked word granularity obtained after the word is masked is "I bought a lot of books on Dangdang, all of them are good. Especially this set of books is really __, all three volumes are very __.".

[0075] Since the sentiment tendency prediction model is trained for the fourth time using the fifth sample data of random masking, the sentiment tendency prediction model can predict the sentiment tendency of the masked sentence in combination with the context. That is, after the fourth training, the sentiment tendency prediction model is convergent, that is, it can not only accurately predict the sentiment tendency of the corpus of word granularity, the corpus of short word granularity and the corpus of sentence granularity, but also can predict the sentiment tendency of the masked sentence in combination with the context.

[0076] Among them, a fifth sample data corresponds to a sentiment tendency label, the sentiment tendency label is used to reflect the sentiment tendency of the masked information, and the sentiment tendency label is determined based on the masked information.

[0077] As shown in Table 4, it is an example table of the correspondence between sample data and sentiment labels of randomly masked sentence granularity. As shown in Table 4, the sample data is "The hotel is in a bad location and the transportation is extremely inconvenient. _____, at most three-star standard, and the surrounding environment is poor." The sentiment label of "_____" in the sample data is "small room".

[0078] Table 4 Correspondence between random masked sentence granularity sample data and sentiment tendency labels

[0079]

[0080] Specifically, the sample data of multiple randomly masked sentence granularities can be encoded as digital data and input into the sentiment tendency prediction model after the third training for training. The sentiment tendency prediction model can perform forward propagation based on the input sample data of the randomly masked sentence granularity, and calculate layer by layer until the output of the last layer of the neural network is obtained. Different from the model outputs of the first to third trainings, the model output of the fourth training is a predicted text sequence, which is a sequence prediction task. The loss is calculated based on the predicted text sequence and the real text sequence to obtain the loss value, and then the reverse calculation is continued to update the parameters of the sentiment tendency prediction model, so that the prediction result of the next sentiment tendency prediction model is closer to the real text sequence of the randomly masked sentences.

[0081] Since the sentiment tendency prediction model is trained for the fifth time using the fourth sample data of random masking, the sentiment tendency prediction model can predict the sentiment tendency of masked words and short words in combination with the context. That is, after the fifth training, the sentiment tendency prediction model is convergent, that is, it can not only accurately predict the sentiment tendency of the corpus of word granularity, the corpus of short word granularity and the corpus of sentence granularity, but also can predict the sentiment tendency of the masked sentence in combination with the context, and can also predict the sentiment tendency of the masked word granularity and short word granularity in combination with the context.

[0082] Among them, a fourth sample data corresponds to a sentiment tendency label, the sentiment tendency label is used to reflect the sentiment tendency of the masked information, and the sentiment tendency label is determined based on the masked information.

[0083] As shown in Table 5, it is an example table of the correspondence between sample data and sentiment labels of randomly masked word granularity. As shown in Table 5, the sample data is "It doesn't look very business-like, it feels more plastic, the screen is _____, there is no mouse, I have my own 2000-50 Dong coupons and I'm not happy, everything else is OK", and the sentiment label of "_____" in the sample data is "small".

[0084] Table 5. Examples of correspondence between random masked sentence granularity sample data and sentiment tendency labels

[0085]

[0086] It should be noted that the specific implementation method of the fifth training of the sentiment tendency prediction model and the fourth training of the sentiment tendency prediction model are the same, except that the sample data input for the two trainings are different. The specific implementation method of the fifth training of the sentiment tendency prediction model is not described in detail here. For specific details, please refer to the above content.

[0087] Figure 2This is a flowchart of applying a training method for a sentiment tendency prediction model provided by an embodiment of the present application in an actual scenario, including:

[0088] Step 210: Perform a first training on the sentiment tendency prediction model based on multiple word-granularity sentiment tendency annotation data.

[0089] Step 220, after the first training, the sentiment tendency prediction model is subjected to a second training based on a plurality of short-word granularity sentiment tendency annotation data.

[0090] Step 230, after the second training, the sentiment tendency prediction model is subjected to a third training based on a plurality of sentence-granularity sentiment tendency annotation data.

[0091] Step 240, after the third training, the sentiment tendency prediction model is subjected to a fourth training based on a plurality of sample data with sentiment data sentences randomly masked and the corresponding sentiment tendency labels.

[0092] Step 250, after the fourth training, the sentiment tendency prediction model is subjected to a fifth training based on a plurality of sample data in which the sentiment data is randomly masked with short words and the corresponding sentiment tendency labels.

[0093] Figure 3 This is a schematic diagram of the training process of the training method of the sentiment tendency prediction model provided by an embodiment of the present application. The word-granularity sentiment tendency annotation data, the short-word-granularity sentiment tendency annotation data, the sentence-granularity sentiment tendency annotation data, the sample data of randomly masked sentiment sentences, and the sample data of randomly masked sentiment words are sequentially input into the sentiment tendency prediction model for training to optimize the network parameters of the sentiment tendency prediction model. First, after completing the training of the word-granularity sentiment tendency annotation data, the network parameters of the sentiment tendency prediction model remain unchanged, and then the short-word-granularity sentiment tendency annotation data is trained, and the network parameters of the obtained sentiment tendency prediction model remain unchanged, and then the sentence-granularity sentiment tendency annotation data is trained, and the network parameters of the obtained sentiment tendency prediction model remain unchanged, and then the sample data of randomly masked sentiment sentences are trained, and the network parameters of the obtained sentiment tendency prediction model remain unchanged, and finally the sample data of randomly masked sentiment words are trained to obtain the sentiment tendency prediction model.

[0094] By training the sentiment data at the word level, the sentiment data at the short word level, and the sentiment data at the sentence level, the sentiment prediction model can not only understand the sentiment expressed by the sentence, but also understand the sentiment of finer-grained words and short words, which helps the sentiment prediction model to have a deeper understanding of the sentiment of the sentence. On this basis, the sentiment prediction model is allowed to predict masked words or short words through masking, so that the sentiment prediction model can apply the sentiment words and short words it has learned to the actual fill-in-the-blank task, and the sentiment prediction model can have a deeper understanding of the text sentiment and semantics in the corpus.

[0095] In an embodiment of the present application, the sentiment tendency prediction model can be first trained based on fine-grained sample data, and then further trained based on coarse-grained sample data, thereby realizing that the sentiment tendency prediction model is jointly trained from fine-grained to coarse-grained sample data. Therefore, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, thereby improving the accuracy of the sentiment tendency prediction of the corpus.

[0096] Based on the above-mentioned model training method embodiment, the present application embodiment provides a sentiment tendency prediction method, see Figure 4 It is a schematic diagram of the implementation process of a method for predicting a sentiment tendency provided by an embodiment of the present application. Figure 4 The emotional tendency prediction method shown can be executed by an electronic device, specifically by a processor of the electronic device. The electronic device can be a terminal device, such as a smart phone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device, smart home appliance, smart watch, vehicle terminal, aircraft, etc.; or, the electronic device can also be a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; or, the emotional tendency prediction method can also be executed by a client that can implement the emotional tendency prediction method, such as a client of various shopping applications, a client of travel applications, etc. Specifically, Figure 4 The method may include the following steps:

[0097] S410, obtaining corpus to be predicted.

[0098] The corpus to be predicted can be any text or voice corpus whose sentiment tendency needs to be predicted. The corpus to be predicted is different in different application scenarios. For example, in product evaluation scenarios in various shopping applications, the corpus to be predicted can be the user's evaluation of the purchased product. In the scenario where the intelligent agent handles the user's telephone request, the corpus to be predicted can be the service evaluation content described by the user's voice.

[0099] S420, inputting the corpus to be predicted into the trained sentiment tendency prediction model to predict the sentiment tendency in the corpus to be predicted.

[0100] The sentiment tendency prediction model is based on Figure 1 The sentiment tendency prediction model is trained using the training method shown.

[0101] Figure 4 The specific implementation of the steps in the embodiment shown can be referred to Figure 1 to Figure 3 The specific implementation of the corresponding steps in the illustrated embodiments will not be described in detail in this application.

[0102] In the embodiment of the present application, since the sentiment tendency prediction model is obtained by joint training of fine-grained to coarse-grained sample data, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, so when the sentiment tendency prediction model is used to predict the sentiment tendency in the corpus, the accuracy of the sentiment tendency prediction of the corpus can be improved.

[0103] Figure 5 is a schematic diagram of a structure of a training device 500 for a sentiment tendency prediction model provided by an embodiment of the present application. Figure 5 In a software implementation, the training device 500 for the sentiment tendency prediction model may include:

[0104] A first training module 501 is used to perform a first training on a sentiment tendency prediction model based on a plurality of first sample data and sentiment tendency labels corresponding to the plurality of sample data;

[0105] A second training module 502 is used to perform a second training on the sentiment tendency prediction model after the first training based on a plurality of second sample data and sentiment tendency labels corresponding to the plurality of second sample data after the first training;

[0106] The granularity of the second sample data is greater than the granularity of the first sample data.

[0107] In an embodiment of the present application, the sentiment tendency prediction model can be first trained based on fine-grained sample data, and then further trained based on coarse-grained sample data, thereby realizing that the sentiment tendency prediction model is jointly trained from fine-grained to coarse-grained sample data. Therefore, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, thereby improving the accuracy of the sentiment tendency prediction of the corpus.

[0108] Optionally, in one embodiment, the device further comprises:

[0109] A third training module is used to perform a third training on the sentiment tendency prediction model after the second training based on multiple third sample data and the sentiment tendency labels corresponding to the multiple third sample data after the second training, wherein the granularity of the third sample data is greater than the granularity of the second sample data.

[0110] Optionally, in one embodiment, the device further comprises:

[0111] An acquisition module, used to acquire a plurality of randomly masked fourth sample data and sentiment tendency labels corresponding to the plurality of randomly masked fourth sample data; and to acquire a plurality of randomly masked fifth sample data and sentiment tendency labels corresponding to the plurality of randomly masked fifth sample data;

[0112] A fourth training module, configured to perform a fourth training on the sentiment tendency prediction model after the third training based on the plurality of randomly masked fifth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fifth sample data after the third training;

[0113] A fifth training module, configured to perform a fifth training on the sentiment tendency prediction model after the fourth training based on the plurality of randomly masked fourth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fourth sample data after the fourth training;

[0114] The granularity of the fourth sample data is smaller than that of the third sample data, and the granularity of the fifth sample data is larger than that of the fourth sample data.

[0115] Optionally, in one implementation, the granularity of the first sample data includes word granularity;

[0116] The granularity of the second sample data includes short word granularity;

[0117] The granularity of the third sample data includes sentence granularity.

[0118] Optionally, in one implementation, the fourth sample data includes sample data of short word granularity;

[0119] The fifth sample data includes sample data at a sentence granularity.

[0120] The training device 500 of the sentiment tendency prediction model can achieve Figure 1 For details, please refer to Figure 1 The training method of the sentiment tendency prediction model of the exemplary embodiment is not described in detail.

[0121] Figure 6This is a schematic diagram of the structure of an emotional tendency prediction device 600 provided by an embodiment of the present application. Figure 6 In a software implementation, the emotional tendency prediction device 600 may include:

[0122] Get the corpus to be predicted;

[0123] The corpus to be predicted is input into the trained sentiment tendency prediction model to predict the sentiment tendency in the corpus to be predicted.

[0124] The sentiment tendency prediction model is based on Figure 1 The sentiment tendency prediction model is trained using the training method shown.

[0125] In the embodiment of the present application, since the sentiment tendency prediction model is obtained by joint training of fine-grained to coarse-grained sample data, the trained sentiment tendency prediction model can understand the corpus from fine to coarse, so when the sentiment tendency prediction model is used to predict the sentiment tendency in the corpus, the accuracy of the sentiment tendency prediction of the corpus can be improved.

[0126] The emotional tendency prediction device 600 can achieve Figure 4 For details, please refer to Figure 4 The emotional tendency prediction method of the illustrated embodiment will not be described in detail.

[0127] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 7 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0128] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0129] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0130] In one embodiment, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a model training device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0131] Based on the plurality of first sample data and the sentiment tendency labels corresponding to the plurality of sample data, performing a first training on the sentiment tendency prediction model;

[0132] After the first training, based on a plurality of second sample data and the sentiment tendency labels corresponding to the plurality of second sample data, performing a second training on the sentiment tendency prediction model after the first training;

[0133] The granularity of the second sample data is greater than the granularity of the first sample data.

[0134] In another embodiment, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming an emotional tendency prediction device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0135] Get the corpus to be predicted;

[0136] The corpus to be predicted is input into the trained sentiment tendency prediction model, and the sentiment tendency in the corpus to be predicted is output.

[0137] The sentiment tendency prediction model is based on Figure 1 The sentiment tendency prediction model is trained using the training method shown.

[0138] The above application Figure 1 to Figure 4The method disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0139] The electronic device may also perform Figure 1-3 The method and implementation of the model training device are Figure 1-3 The functions of the embodiments shown, or the electronic device may also perform Figure 4 The method and the emotional tendency prediction device are implemented in Figure 4 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.

[0140] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1-Figure 4 The method of the illustrated embodiment.

[0141] Of course, in addition to software implementation, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0142] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0143] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0144] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

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

[0146] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0147] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

Claims

1. A model training method, characterized in that: include: Based on the plurality of first sample data and the sentiment tendency labels corresponding to the plurality of first sample data, performing a first training on the sentiment tendency prediction model; After the first training, based on a plurality of second sample data and the sentiment tendency labels corresponding to the plurality of second sample data, a second training is performed on the sentiment tendency prediction model after the first training, wherein the granularity of the second sample data is greater than the granularity of the first sample data, the granularity of the first sample data includes word granularity, and the granularity of the second sample data includes short word granularity; After the second training, the sentiment tendency prediction model after the second training is subjected to a third training based on multiple third sample data and sentiment tendency labels corresponding to the multiple third sample data, wherein the granularity of the third sample data is greater than the granularity of the second sample data, and the granularity of the third sample data includes sentence granularity.

2. The method according to claim 1, characterized in that The method further comprises: Acquire a plurality of randomly masked fourth sample data and sentiment tendency labels corresponding to the plurality of randomly masked fourth sample data; and acquire a plurality of randomly masked fifth sample data and sentiment tendency labels corresponding to the plurality of randomly masked fifth sample data; After the third training, based on the plurality of randomly masked fifth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fifth sample data, performing a fourth training on the sentiment tendency prediction model after the third training; After the fourth training, based on the plurality of randomly masked fourth sample data and the sentiment tendency labels corresponding to the plurality of randomly masked fourth sample data, performing a fifth training on the sentiment tendency prediction model after the fourth training; The granularity of the fourth sample data is smaller than that of the third sample data, and the granularity of the fifth sample data is larger than that of the fourth sample data.

3. The method according to claim 2, characterized in that The fourth sample data includes sample data of word granularity and sample data of short word granularity; The fifth sample data includes sample data at a sentence granularity.

4. A method for predicting sentiment tendency, characterized in that: include: Get the corpus to be predicted; The corpus to be predicted is input into the sentiment tendency prediction model trained by the method according to any one of claims 1 to 3, and the sentiment tendency in the corpus to be predicted is output.

5. A model training device, characterized in that: include: A first training module, configured to perform a first training on a sentiment tendency prediction model based on a plurality of first sample data and sentiment tendency labels corresponding to the plurality of first sample data; A second training module is used for performing a second training on the sentiment tendency prediction model after the first training based on a plurality of second sample data and sentiment tendency labels corresponding to the plurality of second sample data after the first training, wherein the granularity of the second sample data is greater than the granularity of the first sample data, the granularity of the first sample data includes word granularity, and the granularity of the second sample data includes short word granularity; A third training module is used to perform a third training on the sentiment tendency prediction model after the second training based on multiple third sample data and the sentiment tendency labels corresponding to the multiple third sample data after the second training, wherein the granularity of the third sample data is greater than the granularity of the second sample data, and the granularity of the third sample data includes sentence granularity.

6. A sentiment tendency prediction device, characterized in that: include: A corpus acquisition module is used to acquire the corpus to be predicted; The sentiment tendency prediction module is used to input the corpus to be predicted into the sentiment tendency prediction model trained by the method according to any one of claims 1 to 3, and output the sentiment tendency of the corpus to be predicted.

7. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 4 when executed by the processor.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Emotion analysis method and system for enterprise subjects in financial news

    CN110298403A

  • Fine-grained emotion analysis method and device, computer equipment and storage medium

    CN110516245A