A training method, device, equipment and medium for an emotion analysis model
By conducting multi-step training on the initial text set data and the training text set data with marked emotions, a trained sentiment analysis model is generated, which solves the problem of low accuracy of the sentiment analysis model in the existing technology, and achieves higher analysis accuracy.
Patent Information
- Application Number
- CN202210874048.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-07-21
AI Technical Summary
When performing sentiment analysis on sentences, the accuracy of the analysis results is not ideal.
By obtaining the initial text set data published by the user for preprocessing, the initial long text set data, the first initial text set data and the second initial text set data are generated, and inputting them into the initial sentiment analysis model for training, and the intermediate sentiment analysis model is obtained; then the training text set data of marked emotions is obtained for further training, and the trained sentiment analysis model is generated.
The accuracy of the sentiment analysis model is significantly improved, and the analysis effect of the model is improved by extracting key sentences for long texts and grouping text set data.
Smart Images

Figure CN115049018B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent decision-making, and particularly to a method, device, equipment and medium for training an emotion analysis model. Background Art
[0002] Nowadays, the network is developing and popularizing rapidly. More and more users use emoji emoticons in forums or communication software, and some users even write text content entirely with emoji emoticons. The generation of a large amount of data also generates a large number of data analysis requirements. Analyzing the emotions of user text is a very important part among them. For the existing emotion analysis models, when analyzing the emotions of sentences, the accuracy of the analysis results is not ideal. Summary of the Invention
[0003] In view of the above-mentioned disadvantages of the prior art, the purpose of the present invention is to provide a method, device, equipment and medium for training an emotion analysis model, which can improve the accuracy of the trained emotion analysis model.
[0004] To achieve the above object and other related objects, the present invention provides a method for training an emotion analysis model, including:
[0005] Obtaining initial text set data published by users, where the initial text set data includes a plurality of initial text data;
[0006] Processing the initial text set data to generate initial long text set data, first initial text set data and second initial text set data;
[0007] Inputting the initial long text set data, the first initial text set data and the second initial text set data into an initial emotion analysis model, and training the training parameters in the initial emotion analysis model to obtain an intermediate emotion analysis model;
[0008] Obtaining training text set data with labeled emotions, where the training text set data includes a plurality of training text data;
[0009] Processing the training text set data to generate first training text set data and second training text set data;
[0010] Inputting the first training text set data and the second training text set data into the intermediate emotion analysis model, and training the training parameters in the intermediate emotion analysis model to obtain a trained emotion analysis model.
[0011] In an embodiment of the present invention, the step of processing the initial text set data to generate initial long text set data, first initial text set data and second initial text set data includes:
[0012] Clear the links and website addresses in the initial text set data to generate intermediate text set data;
[0013] Determine whether the length of the initial text data is greater than a preset length threshold. If it is greater than the preset length threshold, the initial text data is represented as initial long text data. If it is not greater than the preset length threshold, the initial text data is represented as initial short text data;
[0014] Extract key sentences from the initial long text data to generate the initial key sentence data, and summarize the initial key sentence data to generate the first initial text set data;
[0015] Summarize the initial short text data to generate the second initial text set data.
[0016] In an embodiment of the present invention, the step of inputting the initial long text set data, the first initial text set data, and the second initial text set data into an initial sentiment analysis model and training the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model includes:
[0017] Input the initial long text set data, the first initial text set data, and the second initial text set data into an initial sentiment analysis model to obtain an embedding vector set;
[0018] Process the embedding vector set to generate a search vector set, a keyword vector set, and a value vector set;
[0019] According to the search vector set, the keyword vector set, and the value vector set, obtain the search vector score, the keyword vector score, and the value vector score in each initial text data;
[0020] Process the search vector score, the keyword vector score, and the value vector score to obtain an attention weighted vector;
[0021] Input the attention weighted vector into the initial sentiment analysis model and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model.
[0022] In an embodiment of the present invention, the step of processing the search vector score, the keyword vector score, and the value vector score to obtain an attention weighted vector includes:
[0023] Normalize the search vector score, the keyword vector score, and the value vector score to obtain normalized data;
[0024] Perform activation processing on the normalized data to obtain importance data;
[0025] Process the importance set data to obtain an attention weighted vector.
[0026] In an embodiment of the present invention, the attention weighted vector M is expressed as: Wherein,
[0027] Q is expressed as a search vector,
[0028] K is expressed as a keyword vector,
[0029] V is expressed as a value vector,
[0030] T is expressed as a transpose,
[0031] d k Represents the matrix dimension.
[0032] In an embodiment of the present invention, the step of processing the training text set data to generate the first training text set data and the second training text set data includes:
[0033] Judge whether the length of the training text data is greater than a preset length threshold. If it is greater than the preset length threshold, the training text data is expressed as training long text data. If it is not greater than the preset length threshold, the training text data is expressed as training short text data;
[0034] Perform key sentence extraction processing on the training long text data to generate training key sentence data, and perform summarization processing on the training key sentence data to generate the first training text set data;
[0035] Perform summarization processing on the training short text data to generate the second training text set data.
[0036] In an embodiment of the present invention, the step of inputting the first training text set data and the second training text set data into the intermediate sentiment analysis model and training the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model includes:
[0037] Input the first training text set data and the second training text set data into the intermediate sentiment analysis model to obtain a first training text set vector and a second training text set vector;
[0038] Perform summarization processing on part of the first training text vectors and part of the second training text vectors to generate training set data, and perform summarization processing on the remaining first training text vectors and the remaining second training text vectors to generate validation set data;
[0039] Input the training set data and the validation set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
[0040] The present invention also provides a training device for a sentiment analysis model, including:
[0041] An initial text set data acquisition module, configured to acquire initial text set data published by a user, where the initial text set data includes a plurality of initial text data;
[0042] An initial text set data processing module, configured to process the initial text set data to generate initial long text set data, first initial text set data, and second initial text set data;
[0043] A first training module, configured to input the initial long text set data, the first initial text set data, and the second initial text set data into an initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model;
[0044] A training text set data acquisition module, configured to acquire training text set data with labeled emotions, where the training text set data includes a plurality of training text data;
[0045] A training text set data processing module, configured to process the training text set data to generate first training text set data and second training text set data; and
[0046] A second training module, configured to input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
[0047] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned training method for the sentiment analysis model are implemented.
[0048] The present invention also provides a computer-readable storage medium, storing a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned training method for the sentiment analysis model are implemented.
[0049] As described above, the present invention provides a training method for a sentiment analysis model, which can first perform preliminary training on the sentiment analysis model through initial text set data, and then perform further training on the sentiment analysis model through training text set data with labeled emotions, and can effectively improve the accuracy of the trained sentiment analysis model. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0051] Figure 1 It shows a flowchart of a method for training an emotion analysis model of the present invention.
[0052] Figure 2 Shown as Figure 1 The flowchart of step S20 in
[0053] Figure 3 Shown as Figure 1 The flowchart of step S30 in
[0054] Figure 4 Shown as Figure 3 The flowchart of step S34 in
[0055] Figure 5 Shown as Figure 1 The flowchart of step S50 in
[0056] Figure 6 Shown as Figure 1 The flowchart of step S60 in
[0057] Figure 7 It shows a schematic structural diagram of a device for training an emotion analysis model of the present invention.
[0058] Figure 8 It is a schematic structural diagram of a computer device in an embodiment of the present invention.
[0059] Figure 9 It is another schematic structural diagram of a computer device in an embodiment of the present invention.
[0060] Description of component numbers:
[0061] 10. Initial text set data acquisition module;
[0062] 20. Initial text set data processing module;
[0063] 30. First training module;
[0064] 40. Training text set data acquisition module;
[0065] 50. Training text set data processing module;
[0066] 60. Second training module. Detailed implementation manners
[0067] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0068] Please refer to Figure 1 As shown, the embodiment of the present invention provides a training method for an emotion analysis model, which can train the emotion analysis model to obtain a trained emotion analysis model. Specifically, the initial text set data published by users can be obtained first, and after processing the initial text set data, the initial emotion analysis model can be trained to obtain an intermediate emotion analysis model. Then, the training text set data with labeled emotions can be obtained, and after processing the training text set data, the intermediate emotion analysis model can be trained to obtain a trained emotion analysis model. Specifically, the steps of the training method for the emotion analysis model may include:
[0069] S10. Obtain the initial text set data published by users, where the initial text set data includes multiple initial text data.
[0070] In an embodiment of the present invention, specifically, when performing step S10, the message information and comment information of different users on the website or app can be obtained. For example, when users comment on forums, Weibo, Xiaohongshu, Douyin, etc., the text information of different users can be obtained. Each piece of text information can generate an initial text data, and by summarizing the text information of all users, the initial text set data published by users can be obtained.
[0071] S20. Process the initial text set data to generate an initial long text set data, a first initial text set data, and a second initial text set data.
[0072] Please refer to Figure 2 As shown, in an embodiment of the present invention, when performing step S20, that is, processing the initial text set data to generate an initial long text set data, a first initial text set data, and a second initial text set data. Specifically, the sub-steps of step S20 may include:
[0073] S21. Perform a cleaning process on the initial text set data to remove the links and website addresses in the initial text data and generate an intermediate text set data.
[0074] In an embodiment of the present invention, since there may be links or URLs in the user's message information and comment information, it is necessary to remove these links or URLs to prevent these additional information from affecting the text data. After processing all the initial text data, all the initial text set data after the cleaning process can be aggregated to generate intermediate text set data, and the intermediate text set data can include multiple initial text data after the cleaning process.
[0075] S22. Determine whether the length of the initial text data is greater than a preset length threshold. If it is greater than the preset length threshold, the initial text data is represented as initial long text data. If it is not greater than the preset length threshold, the initial text data is represented as initial short text data.
[0076] In an embodiment of the present invention, since the user's message information and comment information may be a single sentence or a paragraph, it is necessary to divide the initial text data into initial long text data and initial short text data so as to be able to process the initial text data of different lengths subsequently and improve the training effect of the sentiment analysis model. In this embodiment, a preset length threshold can be set, and the size of the preset length threshold can be unrestricted. The preset length threshold can be 50 bytes, 100 bytes, 150 bytes, 200 bytes, etc. Multiple initial text data can be compared with the preset length threshold in turn to determine whether the length of the initial text data is greater than the preset length threshold. If the length of the initial text data is greater than the preset length threshold, the initial text data can be represented as initial long text data. If the length of the initial text data is not greater than the preset length threshold, the initial text data can be represented as initial short text data.
[0077] S23. Aggregate multiple initial long text data to generate initial long text set data, extract key sentences from the initial long text data to generate initial key sentence data, and aggregate the initial key sentence data to generate the first initial text set data.
[0078] S24. Aggregate the initial short text data to generate the second initial text set data.
[0079] In an embodiment of the present invention, since the initial long text data contains a large amount of information, directly using it as a parameter to input into the sentiment analysis model for training may result in poor training results. In order to improve the accuracy of the sentiment analysis model, it is necessary to extract and process the initial long text data, extract key sentences, keywords, etc. contained in the initial long text data, and generate corresponding initial key sentence data. Each piece of initial long text data corresponds to an initial key sentence data. After extracting the key sentences from all the initial long text data, the generated multiple initial key sentence data can be aggregated to obtain the first initial text set data. For the initial short text data, since the initial short text data contains less information, it can be directly used as a parameter to input into the sentiment analysis model for training. Therefore, all the initial short text data can be aggregated to generate the second initial text set data. In order to further improve the accuracy of the sentiment analysis model, the multiple initial long text data can also be aggregated to generate the initial long text set data. The sentiment analysis model can be trained according to the initial long text set data, the first initial text set data, and the second initial text set data, and the initial long text set data is corresponded with the first initial text set data to improve the accuracy of the sentiment analysis model.
[0080] S30. Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model.
[0081] Please refer to Figure 3 As shown, in an embodiment of the present invention, when performing step S30, that is, inputting the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and training the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model. Specifically, the sub-steps of step S30 may include:
[0082] S31. Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model to obtain an initial long text set vector, a first initial text set vector, and a second initial text set vector. The initial long text set vector includes multiple initial long text vectors, the first initial text set vector includes multiple first initial text vectors, and the second initial text set vector includes multiple second initial text vectors. Aggregate the initial long text set vector, the first initial text set vector, and the second initial text set vector to obtain an embedding vector set, and the embedding vector set may include multiple embedding vectors X.
[0083] In one embodiment of the present invention, after generating the initial long text set data, the first initial text set data, and the second initial text set data, they can be input into the initial sentiment analysis model to extract the corresponding feature vectors. Specifically, since the initial long text set data contains multiple initial long text data, each initial long text data can be separately processed for feature vector extraction to generate the corresponding initial long text vectors. Since the first initial text set data contains multiple first initial text data, each first initial text data can be separately processed for feature vector extraction to generate the corresponding first initial text vectors. Since the second initial text set data contains multiple second initial text data, each second initial text data can be separately processed for feature vector extraction to generate the corresponding second initial text vectors. After generating multiple initial long text vectors, multiple first initial text vectors, and multiple second initial text vectors, they can be respectively summarized to obtain the initial long text set vector, the first initial text set vector, and the second initial text set vector. The initial long text set vector can include multiple initial long text vectors, the first initial text set vector can include multiple first initial text vectors, and the second initial text set vector can include multiple second initial text vectors. Then, the initial long text set vector, the first initial text set vector, and the second initial text set vector can be summarized to obtain an embedding vector set, and the embedding vector set can include multiple embedding vectors X.
[0084] S32. Process the embedding vector set to generate the corresponding search vector set, keyword vector set, and value vector set. The search vector set includes multiple search vectors Q, the keyword vector set includes multiple keyword vectors K, and the value vector set includes multiple value vectors V.
[0085] In one embodiment of the present invention, after obtaining the embedding vector set, corresponding search vectors Q, keyword vectors K, and value vectors V can be generated according to each embedding vector X in the embedding vector set. The multiple search vectors Q are summarized to obtain the search vector set. The multiple keyword vectors K are summarized to obtain the keyword vector set. The multiple value vectors V are summarized to obtain the value vector set.
[0086] S33. According to the search vector set, keyword vector set, and value vector set, obtain the search vector scores, keyword vector scores, and value vector scores within each initial text data.
[0087] In one embodiment of the present invention, after obtaining the search vector set, the keyword vector set, and the value vector set, since each initial text data can contain multiple word vectors, for example, it can contain multiple search vectors Q, multiple keyword vectors K, and multiple value vectors V, the search vector scores, keyword vector scores, and value vector scores within each initial text data can be calculated respectively to facilitate the subsequent calculation of the attention degree among the multiple word vectors within each initial text data.
[0088] S34. Process the multiple search vector scores, multiple keyword vector scores, and multiple value vector scores to obtain the attention degree weighted vector M, expressed as: where T represents transpose, and d k represents the matrix dimension.
[0089] Please refer to Figure 4 As shown, in one embodiment of the present invention, when step S34 is executed, that is, the search vector scores, keyword vector scores, and value vector scores are processed to obtain the attention degree weighted vector. Specifically, the sub-steps of step S34 may include:
[0090] S341. Perform normalization processing on the multiple search vector scores, multiple keyword vector scores, and multiple value vector scores to obtain multiple normalized data.
[0091] S342. Perform activation processing on the multiple normalized data to obtain multiple importance data.
[0092] S343. Process the multiple importance set data to obtain multiple attention degree weighted vectors M, expressed as: where T represents transpose, and d k represents the matrix dimension.
[0093] S35. Use the multiple attention degree weighted vectors as parameters and input them into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain the intermediate sentiment analysis model.
[0094] In one embodiment of the present invention, after obtaining multiple search vector scores, multiple keyword vector scores, and multiple value vector scores, they can be normalized to obtain corresponding multiple normalized data. At this time, a stable gradient can be maintained while increasing the gradient change amplitude. Then, the normalized data can be processed by an activation function to obtain multiple importance data, converting the importance degree of the word vectors in the initial text data corresponding to the normalized data into a number between 0 and 1. The larger the value, the higher the importance degree. The importance set data is weighted to generate an attention weighted vector. Finally, multiple attention weighted vectors are used as parameters and input into the initial sentiment analysis model, and the training parameters in the initial sentiment analysis model are trained to obtain an intermediate sentiment analysis model.
[0095] S40. Obtain a training text set data with labeled emotions. The training text set data includes multiple training text data, and negative emotions or non - negative emotions are labeled on the training text data.
[0096] In one embodiment of the present invention, specifically, when performing step S10, message information and comment information of different users on a website or an app can be obtained. For example, when users comment on a forum, Weibo, Xiaohongshu, Douyin, etc., text information of different users can be obtained. Each text information can generate a training text data. All the training text data can be pre - labeled with emotions, and different training text data are labeled as negative emotions and non - negative emotions. Then, the training text data after emotion labeling can be summarized to generate a training text set data with labeled emotions.
[0097] S50. Process the training text set data to generate a first training text set data and a second training text set data.
[0098] Please refer to Figure 5 As shown, in one embodiment of the present invention, when performing step S50, that is, processing the training text set data to generate a first training text set data and a second training text set data. Specifically, the sub - steps of step S50 may include:
[0099] S51. Determine whether the length of the training text data is greater than a preset length threshold. If it is greater than the preset length threshold, the training text data is represented as training long text data. If it is not greater than the preset length threshold, the training text data is represented as training short text data.
[0100] S52. Perform key sentence extraction processing on the training long text data to generate training key sentence data, and summarize the training key sentence data to generate a first training text set data.
[0101] S53. Summarize the training short text data to generate a second training text set data.
[0102] In one embodiment of the present invention, since the user's message information and comment information may be a single sentence or a paragraph, it is necessary to divide the initial text data into initial long text data and initial short text data, so as to be able to process the initial text data of different lengths subsequently and improve the training effect of the sentiment analysis model. In this embodiment, a preset length threshold can be set. The size of the preset length threshold can be unrestricted. The preset length threshold can be 50 bytes, 100 bytes, 150 bytes, 200 bytes, etc. Different training text data can be divided into training short text data and training long text data. Then, key sentence extraction processing can be performed on the training long text data to generate training key sentence data. Summarizing multiple training key sentence data can generate the first training text set data. Summarizing multiple training short text data can generate the second training text set data.
[0103] S60. Input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
[0104] Please refer to Figure 6 As shown, in one embodiment of the present invention, when step S60 is executed, that is, input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model. Specifically, the sub-steps of step S60 may include:
[0105] S61. Input the first training text set data and the second training text set data into the intermediate sentiment analysis model to obtain a first training text set vector and a second training text set vector. The first training text set vector includes multiple first training text vectors, and the second training text set vector includes multiple second training text vectors.
[0106] In one embodiment of the present invention, after the first training text set data and the second training text set data are obtained, they can be used as parameters and input into the intermediate sentiment analysis model to generate a first training text set vector and a second training text set vector. The first training text set vector includes multiple first training text vectors, and the second training text set vector includes multiple second training text vectors. Each training key sentence data can generate a first training text vector, and each training short text data can generate a second training text vector.
[0107] S62. Summarize and process some of the first training text vectors and some of the second training text vectors to generate training set data, and summarize and process the remaining first training text vectors and the remaining second training text vectors to generate validation set data. Among them, the ratio of the training text data labeled as negative emotion to the training text data not labeled as negative emotion in the training set data is a, and the ratio of the training text data labeled as negative emotion to the training text data not labeled as negative emotion in the validation set data is b. Both a and b are within the preset ratio range.
[0108] In an embodiment of the present invention, all the first training text vectors and all the second training text vectors can be split into training set data and validation set data according to a certain distribution and ratio. Among them, the training set data can include some of the first training text vectors and some of the second training text vectors, and the validation set data can include the remaining first training text vectors and the remaining second training text vectors. In this embodiment, the ratio of the training text data labeled as negative emotion to the training text data not labeled as negative emotion in the training set data can be a, and the ratio of the training text data labeled as negative emotion to the training text data not labeled as negative emotion in the validation set data can be b. Both a and b are within the preset ratio range. The preset range can be 0.3 - 0.7, or can be 0.4 - 0.6. The preset range can be set according to actual needs.
[0109] S63. Input the training set data and the validation set data into the intermediate emotion analysis model, and train the training parameters in the intermediate emotion analysis model to obtain a trained emotion analysis model.
[0110] It can be seen that in the above solution, for the training process of the emotion analysis model, the emotion analysis model can be initially trained through the initial text set data, and then further trained through the trained text set data with labeled emotions, which can effectively improve the accuracy of the trained emotion analysis model. At the same time, in the analysis process, by dividing the text into long text and short text and extracting key sentences from the long text, the training effect can be further improved.
[0111] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0112] Please refer to Figure 7As shown in the figure, the present invention also provides a training device for an emotion analysis model, which corresponds one-to-one with the training method in the above embodiment. The training device may include: an initial text set data acquisition module 10, an initial text set data processing module 20, a first training module 30, a training text set data acquisition module 40, a training text set data processing module 50, and a second training module 60. The detailed description of each functional module is as follows:
[0113] The initial text set data acquisition module 10 is used to acquire the initial text set data published by the user, and the initial text set data includes a plurality of initial text data;
[0114] The initial text set data processing module 20 is used to process the initial text set data to generate initial long text set data, first initial text set data, and second initial text set data;
[0115] The first training module 30 is used to input the initial long text set data, the first initial text set data, and the second initial text set data into the initial emotion analysis model, and train the training parameters in the initial emotion analysis model to obtain an intermediate emotion analysis model;
[0116] The training text set data acquisition module 40 is used to acquire the training text set data with labeled emotions. The training text set data includes a plurality of training text data, and negative emotions or non-negative emotions are labeled on the training text data;
[0117] The training text set data processing module 50 is used to process the training text set data to generate first training text set data and second training text set data;
[0118] The second training module 60 is used to input the first training text set data and the second training text set data into the intermediate emotion analysis model, and train the training parameters in the intermediate emotion analysis model to obtain a trained emotion analysis model.
[0119] In an embodiment of the present invention, the initial text set data processing module 20 is specifically used for:
[0120] Perform cleaning processing on the initial text set data, remove the links and website addresses in the initial text data, and generate intermediate text set data;
[0121] Judge whether the length of the initial text data is greater than a preset length threshold. If it is greater than the preset length threshold, the initial text data is represented as initial long text data. If it is not greater than the preset length threshold, the initial text data is represented as initial short text data;
[0122] Summarize multiple initial long text data to generate initial long text set data, extract key sentences from the initial long text data to generate initial key sentence data, and summarize the initial key sentence data to generate the first initial text set data;
[0123] Summarize the initial short text data to generate the second initial text set data.
[0124] In an embodiment of the present invention, the first training module 30 is specifically configured to:
[0125] Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model to obtain the initial long text set vector, the first initial text set vector, and the second initial text set vector. The initial long text set vector includes multiple initial long text vectors, the first initial text set vector includes multiple first initial text vectors, and the second initial text set vector includes multiple second initial text vectors. Summarize the initial long text set vector, the first initial text set vector, and the second initial text set vector to obtain an embedded vector set, which may include multiple embedded vectors X;
[0126] Process the embedded vector set to generate a corresponding search vector set, keyword vector set, and value vector set. The search vector set includes multiple search vectors Q, the keyword vector set includes multiple keyword vectors K, and the value vector set includes multiple value vectors V;
[0127] According to the search vector set, keyword vector set, and value vector set, obtain the search vector score, keyword vector score, and value vector score within each initial text data;
[0128] Normalize multiple search vector scores, multiple keyword vector scores, and multiple value vector scores to obtain multiple normalized data;
[0129] Activate multiple normalized data to obtain multiple importance data;
[0130] Process multiple importance set data to obtain multiple attention weighted vectors M, expressed as: where T represents transpose, and d k represents the matrix dimension;
[0131] Use multiple attention weighted vectors as parameters, input them into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model.
[0132] In an embodiment of the present invention, the training text set data processing module 50 is specifically configured to:
[0133] Determine whether the length of the training text data is greater than a preset length threshold. If it is greater than the preset length threshold, the training text data is represented as training long text data. If it is not greater than the preset length threshold, the training text data is represented as training short text data;
[0134] Perform key sentence extraction processing on the training long text data to generate training key sentence data, and perform summarization processing on the training key sentence data to generate the first training text set data;
[0135] Perform summarization processing on the training short text data to generate the second training text set data.
[0136] In an embodiment of the present invention, the second training module 60 is specifically used for:
[0137] Input the first training text set data and the second training text set data into the intermediate emotion analysis model to obtain the first training text set vector and the second training text set vector. The first training text set vector includes multiple first training text vectors, and the second training text set vector includes multiple second training text vectors;
[0138] Extract some of the first training text vectors and some of the second training text vectors for summarization processing to generate the training set data, and perform summarization processing on the remaining first training text vectors and the remaining second training text vectors to generate the validation set data. Among them, the ratio of the training text data labeled with negative emotions to the training text data with non - negative emotions in the training set data is a, and the ratio of the training text data labeled with negative emotions to the training text data with non - negative emotions in the validation set data is b. Both a and b are within the preset ratio range;
[0139] Input the training set data and the validation set data into the intermediate emotion analysis model to train the training parameters in the intermediate emotion analysis model, and obtain the trained emotion analysis model.
[0140] The present invention provides a training device for an emotion analysis model. For the training process of the emotion analysis model, the emotion analysis model can be initially trained through the initial text set data, and then further trained through the training text set data with labeled emotions, which can effectively improve the accuracy of the trained emotion analysis model. At the same time, during the analysis process, by dividing the text into long text and short text and performing key sentence extraction on the long text, the training effect can be further improved.
[0141] For the specific limitations of the training device, reference can be made to the limitations of the training method in the above text, which will not be elaborated here. Each module in the above training device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0142] Please refer to Figure 8 As shown, the present invention also provides a computer device, which can be a server. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it realizes the functions or steps of a method for training an emotion analysis model.
[0143] Please refer to Figure 9 As shown, the present invention also provides another computer device, which can be a client. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it realizes the functions or steps of a method for training an emotion analysis model.
[0144] In an embodiment of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0145] Obtain the initial text set data published by the user, and the initial text set data includes a plurality of initial text data;
[0146] Process the initial text set data to generate initial long text set data, first initial text set data, and second initial text set data;
[0147] Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model;
[0148] Obtain the training text set data with labeled sentiment. The training text set data includes multiple training text data, and negative sentiment or non - negative sentiment is labeled on the training text data;
[0149] Process the training text set data to generate the first training text set data and the second training text set data;
[0150] Input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
[0151] In an embodiment of the present invention, a computer - readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0152] Obtain the initial text set data published by the user. The initial text set data includes multiple initial text data;
[0153] Process the initial text set data to generate the initial long text set data, the first initial text set data, and the second initial text set data;
[0154] Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model;
[0155] Obtain the training text set data with labeled sentiment. The training text set data includes multiple training text data, and negative sentiment or non - negative sentiment is labeled on the training text data;
[0156] Process the training text set data to generate the first training text set data and the second training text set data;
[0157] Input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
[0158] It should be noted that for the functions or steps that can be realized by the above - mentioned computer - readable storage medium or computer device, reference can be made to the corresponding method embodiments described above. To avoid repetition, they are not described one by one here.
[0159] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0160] In the description of this specification, the descriptions referring to the terms "this embodiment", "example", "specific example", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.
[0161] The embodiments of the present invention disclosed above are only used to help explain the present invention. The embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of this specification. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and utilize the present invention well. The present invention is only limited by the claims and their full scope and equivalents.
Claims
1. A training method for an emotion analysis model, characterized in that Including: Obtain the initial text set data published by the user, where the initial text set data includes multiple initial text data; The initial text data is classified into initial long text data and initial short text data, and the number of bytes of the initial long text data is greater than that of the initial short text data; Process the initial text set data to generate initial long text set data, first initial text set data, and second initial text set data; the initial long text set data includes all initial long text data; the first initial text set data includes multiple initial key sentence data, and the initial key sentence data represents the keywords in the initial long text data; the second initial text set data includes all initial short text data; Input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model; Obtain the training text set data with labeled sentiment, where the training text set data includes multiple training text data; the training text data is classified into training short text data and training long text data, and the number of bytes of the training long text data is greater than that of the training short text data; Process the training text set data to generate first training text set data and second training text set data; The first training text set data includes multiple training key sentence data, and the training key sentence data represents the keywords in the training long text data; The second training text set data includes all training short text data; Input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
2. The training method of the emotion analysis model according to claim 1, wherein The step of processing the initial text set data to generate initial long text set data, first initial text set data, and second initial text set data includes: Clear the links and website addresses in the initial text set data to generate intermediate text set data; Judge whether the length of the initial text data is greater than a preset length threshold: if it is greater than the preset length threshold, the initial text data is represented as initial long text data; if it is not greater than the preset length threshold, the initial text data is represented as initial short text data; Summarize multiple pieces of the initial long text data to generate initial long text set data; extract key sentences from the initial long text data to generate initial key sentence data, and summarize the initial key sentence data to generate first initial text set data; Summarize the initial short text data to generate second initial text set data.
3. The training method of the emotion analysis model according to claim 1, characterized in that The step of inputting the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and training the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model includes: Input the initial long text set data, the first initial text set data, and the second initial text set data into an initial sentiment analysis model to obtain an embedding vector set; Process the embedding vector set to generate a search vector set, a keyword vector set, and a value vector set; According to the search vector set, the keyword vector set, and the value vector set, obtain the search vector score, the keyword vector score, and the value vector score in each initial text data; Process the search vector score, the keyword vector score, and the value vector score to obtain an attention weighted vector; Input the attention weighted vector into the initial sentiment analysis model and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model.
4. The training method of the emotion analysis model according to claim 3, wherein The step of processing the search vector score, the keyword vector score, and the value vector score to obtain an attention weighted vector includes: Perform normalization processing on the search vector score, the keyword vector score, and the value vector score to obtain normalized data; Perform activation processing on the normalized data to obtain importance data; Process the importance data to obtain an attention weighted vector.
5. The training method of the emotion analysis model according to claim 4, characterized in that The attention weighted vector M is expressed as: Wherein, Q is represented as a search vector, K is represented as a keyword vector, V is represented as a value vector, T is represented as a transpose, d k Denoted as matrix dimension.
6. The training method of the emotion analysis model according to claim 1, characterized in that, The step of processing the training text set data to generate the first training text set data and the second training text set data includes: Determine whether the length of the training text data is greater than a preset length threshold. If it is greater than the preset length threshold, the training text data is represented as training long text data. If it is not greater than the preset length threshold, the training text data is represented as training short text data; Perform key sentence extraction processing on the training long text data to generate training key sentence data, and perform summarization processing on the training key sentence data to generate the first training text set data; Perform summarization processing on the training short text data to generate the second training text set data.
7. The training method of the emotion analysis model according to claim 1, characterized in that The step of inputting the first training text set data and the second training text set data into the intermediate sentiment analysis model and training the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model includes: Input the first training text set data and the second training text set data into the intermediate sentiment analysis model to obtain a first training text set vector and a second training text set vector; the first training text set vector includes multiple first training text vectors, and the second training text set vector includes multiple second training text vectors; Perform summarization processing on some of the first training text vectors and some of the second training text vectors to generate training set data, and perform summarization processing on the remaining first training text vectors and the remaining second training text vectors to generate validation set data; Input the training set data and the validation set data into the intermediate sentiment analysis model to train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
8. A training device for an emotion analysis model, characterized in that Includes: The initial text set data acquisition module is used to acquire the initial text set data published by the user, and the initial text set data includes a plurality of initial text data; The initial text data is divided into initial long text data and initial short text data, and the number of bytes of the initial long text data is greater than that of the initial short text data; The initial text set data processing module is used to process the initial text set data to generate an initial long text set data, a first initial text set data, and a second initial text set data; the initial long text set data includes all the initial long text data; the first initial text set data includes a plurality of initial key sentence data, and the initial key sentence data represents the keywords in the initial long text data; the second initial text set data includes all the initial short text data; The first training module is used to input the initial long text set data, the first initial text set data, and the second initial text set data into the initial sentiment analysis model, and train the training parameters in the initial sentiment analysis model to obtain an intermediate sentiment analysis model; The training text set data acquisition module is used to acquire the training text set data with labeled sentiment, and the training text set data includes a plurality of training text data; the training text data is divided into training short text data and training long text data, and the number of bytes of the training long text data is greater than that of the training short text data; The training text set data processing module is used to process the training text set data to generate a first training text set data and a second training text set data; The first training text set data includes a plurality of training key sentence data, and the training key sentence data represents the keywords in the training long text data; The second training text set data includes all the training short text data; and The second training module is used to input the first training text set data and the second training text set data into the intermediate sentiment analysis model, and train the training parameters in the intermediate sentiment analysis model to obtain a trained sentiment analysis model.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the training method of the sentiment analysis model according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the training method of the sentiment analysis model according to any one of claims 1 to 7.
Citation Information
Patent Citations
Segment vector model based micro-blog text emotion classification method and classification system
CN106777361A
Text emotion analysis method and device and storage medium
CN108717406A