Text sentiment classification method, model training method, device and equipment

By maximizing the pooling and cascade of aspect word hidden vectors for online comment texts, the problem of inaccurate emotional classification in the prior art is solved and higher accuracy is achieved.

CN120296163APending Publication Date: 2025-07-11CHENGDU TD TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311870477.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The prior art cannot accurately classify online comment texts emotionally, especially the emotional polarity of different words belonging to the same aspect may be different, resulting in inaccurate classification.

Method used

By processing the network comment text, the aspect word hidden vector collection is obtained and the maximum pooling and cascade is performed. Combined with the context hidden vector collection, the emotional polarity of each aspect word is output.

Benefits of technology

It improves the emotional classification accuracy of online comment texts and avoids classification errors caused by different emotions of words of the same aspect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120296163A_ABST
    Figure CN120296163A_ABST
Patent Text Reader

Abstract

The invention provides a text sentiment classification method, a model training method, devices and equipment, which can be used in the field of artificial intelligence. The method comprises the steps of obtaining a to-be-processed text; processing the to-be-processed text to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the to-be-processed text; performing maximum pooling processing on the aspect word hidden vector set to obtain a maximum pooling vector set corresponding to the aspect word hidden vector set; performing cascade processing on the maximum pooling vector set and the context hidden vector set to obtain a cascade vector set corresponding to the maximum pooling vector set; and outputting a classification result of the to-be-processed text according to the cascade vector set. According to the method, the accuracy of text sentiment classification can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular, to a method for sentiment classification of text, a method for model training, a device, and a device. Background Art

[0002] With the rapid development of the Internet, the number of online review texts has increased rapidly. The sentiment classification of online review texts has important practical value. For example, when a user purchases a commodity, it is necessary to classify the sentiment polarity of each online review text so that the user can judge the quality of the commodity to be purchased.

[0003] Therefore, there is an urgent need for an accurate method for sentiment classification of online review texts. Summary of the Invention

[0004] This application provides a method for sentiment classification of text, a method for model training, a device, and a device, which are used to solve the problem that the sentiment classification of online review texts cannot be accurately performed.

[0005] In a first aspect, this application provides a method for sentiment classification of text, and the method includes:

[0006] Obtain a text to be processed, where the text to be processed is an online review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; where the context hidden vector set includes an initial hidden vector corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed;

[0007] Perform max pooling processing on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set; where the max pooling vector set includes a max pooling vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector represents the semantic feature of the aspect word;

[0008] Perform concatenation processing on the max pooling vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the max pooling vector set; where the concatenated vector set includes a concatenated representation vector corresponding to each max pooling vector in the max pooling vector set, and the concatenated representation vector represents the sentiment feature of the aspect word;

[0009] Output a classification result of the text to be processed according to the concatenated vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0010] In one example, the maximum pooling vector set and the context hidden vector set are concatenated to obtain a concatenated vector set corresponding to the maximum pooling vector set, including:

[0011] The maximum pooling vector set and the context hidden vector set are input into the sentiment classification module of a preset model for concatenation processing to obtain a concatenated vector set corresponding to the maximum pooling vector set.

[0012] In one example, the maximum pooling vector set and the context hidden vector set are input into the sentiment classification module of a preset model for concatenation processing to obtain a concatenated vector set corresponding to the maximum pooling vector set, including:

[0013] The aspect word hidden vector set is input into the sentiment classification module for processing to determine the number of aspect words in the text to be processed;

[0014] According to the number, the context hidden vector set is copied to obtain N context hidden vector sets; where N is a positive integer greater than or equal to 1;

[0015] The context hidden vector set is subjected to average pooling processing to obtain an average pooling vector corresponding to the context hidden vector set; where the average pooling vector represents the context features of the text to be processed;

[0016] The maximum pooling vector and the average pooling vector are concatenated to obtain the concatenated representation vector.

[0017] In one example, the aspect word hidden vector set is subjected to maximum pooling processing to obtain a maximum pooling vector set corresponding to the aspect word hidden vector set, including:

[0018] The aspect word hidden vector set is input into the sentiment classification module of a preset model for maximum pooling processing to obtain the maximum pooling vector set.

[0019] In one example, the text to be processed is processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed, including:

[0020] The text to be processed is input into the aspect word extraction module of a preset model for encoding processing to obtain a context hidden vector set corresponding to the text to be processed;

[0021] Classify the set of context hidden vectors to obtain the label information corresponding to the text to be processed; wherein, the label information includes the label value of each word to be processed in the text to be processed, and the label value includes whether the word to be processed belongs to an aspect word.

[0022] According to the label information, determine the aspect word information corresponding to the text to be processed; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be processed.

[0023] Determine the word to be processed corresponding to the position information in the text to be processed as an aspect word; and determine the set of aspect word hidden vectors from the set of context hidden vectors.

[0024] In one example, the word to be processed includes at least one field; input the text to be processed into the aspect word extraction module of a preset model for encoding processing to obtain the set of context hidden vectors corresponding to the text to be processed, including:

[0025] Encode the word to be processed to obtain the set of field hidden vectors corresponding to the word to be processed; wherein, the set of field hidden vectors includes field hidden vectors corresponding to each character in the word to be processed, and the field hidden vector represents the semantic feature of the field.

[0026] Perform average pooling processing on the set of field hidden vectors to obtain the initial hidden vector.

[0027] In a second aspect, the present application provides a model training method for text sentiment classification, and the method includes:

[0028] Obtain the text to be trained, wherein the text to be trained is the network review text to be trained, and the text to be trained includes at least one word to be trained.

[0029] Input the text to be trained into the aspect word extraction module of the initial model for classification processing to obtain the set of context hidden vectors and the predicted label information corresponding to the text to be trained; wherein, the set of context hidden vectors includes the initial hidden vectors corresponding to each word to be trained in the text to be trained; the predicted label information includes the predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word.

[0030] Input the set of context hidden vectors and the predicted label information into the sentiment classification module of the initial model for processing to obtain the predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the sentiment polarity to which each aspect word in the predicted text to be trained belongs.

[0031] Train the initial model according to the predicted classification result and the predicted label information to obtain a preset model; wherein, the preset model is used to process the text to be processed described in any one of claims 1-6 to obtain a classification result, and the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0032] In one example, the text to be trained has actual label information and an actual classification result, the actual label information includes the actual label value of each word to be trained in the text to be trained, and the actual classification result includes the sentiment polarity to which each aspect word in the actual text to be trained belongs;

[0033] Training the initial model according to the predicted classification result and the predicted label information to obtain a preset model includes:

[0034] Train the initial model according to the predicted classification result, the actual classification result, the predicted label information, and the actual label information to obtain the preset model.

[0035] In one example, inputting the context hidden vector set and the predicted label information into the sentiment classification module of the initial model for processing to obtain the predicted classification result corresponding to the text to be trained, including:

[0036] Process the context hidden vector set and the predicted label information to obtain an aspect word hidden vector set corresponding to the text to be trained; wherein, the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be trained of the target described in the text to be trained;

[0037] Perform a concatenation process on the aspect word hidden vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the aspect word hidden vector set; wherein, the concatenated vector set includes concatenated representation vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the concatenated representation vector characterizes the sentiment feature of the aspect word;

[0038] Perform a classification process on the concatenated vector set to obtain the predicted classification result corresponding to the text to be trained.

[0039] In one example, processing the context hidden vector set and the predicted label information to obtain an aspect word hidden vector set corresponding to the text to be trained includes:

[0040] Determine the aspect word information corresponding to the text to be trained according to the predicted label information; wherein, the aspect word information includes position information, and the position information characterizes the position of each aspect word in the text to be trained;

[0041] Determine the word to be trained corresponding to the position information in the text to be trained as the aspect word; and determine the aspect word hidden vector set from the context hidden vector set.

[0042] In one example, perform a concatenation process on the aspect word hidden vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the aspect word hidden vector set, including:

[0043] Perform max pooling on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set; wherein, the max pooling vector set includes a max pooling vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector represents the semantic feature of the aspect word;

[0044] Perform average pooling on the context hidden vector set to obtain an average pooling vector corresponding to the context hidden vector set; wherein, the average pooling vector represents the context feature of the text to be trained;

[0045] Perform a concatenation process on the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

[0046] In one example, performing average pooling on the context hidden vector set to obtain an average pooling vector corresponding to the context hidden vector set includes:

[0047] Determine the number of aspect words in the text to be trained according to the aspect word hidden vector set;

[0048] According to the number, perform a replication process on the context hidden vector set to obtain M context hidden vector sets; wherein, M is a positive integer greater than or equal to 1;

[0049] Perform average pooling on the context hidden vector set to obtain the average pooling vector.

[0050] In one example, the word to be trained includes at least one field; inputting the text to be trained into the aspect word extraction module of the initial model for classification processing to obtain a context hidden vector set and prediction label information corresponding to the text to be trained, including:

[0051] Input the word to be trained into the aspect word extraction module of the initial model for encoding processing to obtain a field hidden vector set corresponding to the word to be trained; wherein, the field hidden vector set includes a field hidden vector corresponding to each character in the word to be trained, and the field hidden vector represents the semantic feature of the field;

[0052] Perform average pooling on the set of field hidden vectors to obtain the initial hidden vector;

[0053] Input each of the initial hidden vectors into the aspect word extraction module of the initial model for classification processing to obtain the predicted label information corresponding to the text to be trained.

[0054] Thirdly, the present application provides a text sentiment classification device, which includes:

[0055] A processing unit, configured to obtain a text to be processed, where the text to be processed is a network review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a set of context hidden vectors and a set of aspect word hidden vectors corresponding to the text to be processed; where the set of context hidden vectors includes an initial hidden vector corresponding to each word to be processed in the text to be processed; the set of aspect word hidden vectors includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed;

[0056] A pooling unit, configured to perform max pooling on the set of aspect word hidden vectors to obtain a set of max pooling vectors corresponding to the set of aspect word hidden vectors; where the set of max pooling vectors includes max pooling vectors corresponding to each aspect word hidden vector in the set of aspect word hidden vectors, and the max pooling vector characterizes the semantic features of the aspect word;

[0057] A concatenation unit, configured to perform concatenation processing on the set of max pooling vectors and the set of context hidden vectors to obtain a set of concatenated vectors corresponding to the set of max pooling vectors; where the set of concatenated vectors includes concatenated representation vectors corresponding to each max pooling vector in the set of max pooling vectors, and the concatenated representation vector characterizes the sentiment features of the aspect word;

[0058] A classification unit, configured to output a classification result of the text to be processed according to the set of concatenated vectors; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0059] Fourthly, the present application provides a model training device applied to text sentiment classification, which includes:

[0060] An acquisition unit, configured to acquire a text to be trained, where the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained;

[0061] The first classification unit is configured to input the text to be trained into the aspect word extraction module of the initial model for classification processing, so as to obtain a set of context hidden vectors corresponding to the text to be trained and prediction label information; wherein, the set of context hidden vectors includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the prediction label information includes a predicted label value of each word to be trained in the text to be trained, and the label value indicates whether the word to be trained belongs to an aspect word.

[0062] The second classification unit is configured to input the set of context hidden vectors and the prediction label information into the sentiment classification module of the initial model for processing, so as to obtain a predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the sentiment polarity to which each aspect word in the text to be trained belongs.

[0063] The training unit is configured to train the initial model according to the predicted classification result and the prediction label information to obtain a preset model; wherein, the preset model is configured to process the text to be processed in the third aspect to obtain a classification result, and the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0064] In a fifth aspect, the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0065] The memory stores computer-executable instructions;

[0066] The processor executes the computer-executable instructions stored in the memory to implement the method according to the first aspect or the second aspect.

[0067] In a sixth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to the first aspect or the second aspect.

[0068] In a seventh aspect, the present application provides a computer program product, including: a computer program, the computer program is stored in a readable storage medium, and when the computer program is executed by a processor, it is used to implement the method according to the first aspect or the second aspect.

[0069] The text sentiment classification method, model training method, device, and equipment provided by this application process each text to be processed to obtain the hidden vector of the aspect words in the text to be processed, and regards the hidden vector of each aspect word as a whole to perform max-pooling processing, concatenation processing, and classification processing on the hidden vector of each aspect word, so as to obtain an accurate sentiment classification result for each text to be processed, avoiding the problem that words belonging to the same aspect word have different sentiments, and improving the accuracy of text sentiment classification. Description of the Drawings

[0070] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments in line with this application, and are used together with the specification to explain the principles of this application.

[0071] Figure 1 Schematic diagram of an aspect-level sentiment analysis multi-task model provided for the prior art;

[0072] Figure 2 Schematic diagram of a joint learning model provided for the prior art;

[0073] Figure 3 Schematic diagram of a parallel multi-task learning model provided for the prior art;

[0074] Figure 4 Schematic diagram of an application scenario provided by this application;

[0075] Figure 5 Schematic diagram of the process of a text sentiment classification method provided by an embodiment of this application;

[0076] Figure 6 Schematic diagram of the process of another text sentiment classification method provided by an embodiment of this application;

[0077] Figure 7 Schematic diagram of the process of a model training method applied to text sentiment classification provided by an embodiment of this application;

[0078] Figure 8 Schematic diagram of the process of another model training method applied to text sentiment classification provided by an embodiment of this application;

[0079] Figure 9 Schematic diagram of the structure of a multi-task model provided by an embodiment of this application;

[0080] Figure 10 Schematic diagram of the structure of a text sentiment classification device provided by an embodiment of this application;

[0081] Figure 11 Schematic diagram of the structure of a model training device applied to text sentiment classification provided by an embodiment of this application;

[0082] Figure 12 This is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

[0083] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Specific Embodiments

[0084] Here, exemplary embodiments will be described in detail, and their examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numerals in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0085] With the rapid development of the Internet, the number of online review texts has increased rapidly. The sentiment classification of online review texts has important practical value. For example, when users purchase goods, they need to classify the sentiment polarity of each online review text to help users judge the quality of the goods they purchase.

[0086] In one example, based on the Aspect Based Sentiment Analysis (ABSA) task, it can be divided into two subtasks: Aspect Term Extraction (ATE) and Aspect-Level Sentiment Classification (APC); the ATE task predicts the BIO tag value of each word (B represents the start of the aspect term, I represents the middle part of the aspect term, and O represents that the word is not an aspect term) to obtain the aspect terms in the sentence (the aspect term is the target described by the sentence); the APC task is used to determine the sentiment polarity of the aspect terms in the sentence. Figure 1 This is a schematic diagram of a multi-task model for aspect-level sentiment analysis provided by the prior art, such as Figure 1As shown in the figure, both the ATE task and the APC task are converted into word-level classification tasks. The ATE task is performed using a bidirectional long short-term memory network (Bi-LSTM), and a convolutional neural network (CNN) is used to model the local semantic information of the network review text, and sentiment classification is performed on each extracted word.

[0087] In another example, Figure 2 is a schematic diagram of a joint learning model provided by the prior art. As Figure 2 shown, the BIO tags of the ATE task and the sentiment tags of the APC task are combined into joint tags, and a single joint learning model is constructed. For the sentiment three-classification task, they use the Bi-LSTM and conditional random field (CRF) methods to determine the joint tags (including B-positive, B-neutral, B-negative, I-positive, I-neutral, I-negative, O) of each word in the network review text.

[0088] In yet another example, Figure 3 is a schematic diagram of a parallel multi-task learning model provided by the prior art. As Figure 3 shown, the ATE task and the APC task are combined into a parallel multi-task learning model. This model is based on a pre-trained bidirectional encoder representations from transformers (BERT) encoder, a self-attention mechanism, and a local context focusing mechanism. In the source code implementation of this model, the two sub-tasks share the encoding layer and then perform their respective tasks independently to perform sentiment classification on the network review text.

[0089] However, in the above methods, the aspect words in the network review text are not regarded as a whole, and only the sentiment polarity of each word in the network review text is predicted, which increases the difficulty of sentiment classification processing of the text. Moreover, the sentiment polarities of different words belonging to the same aspect word may be different. As a result, the sentiment classification of the text is inaccurate.

[0090] The sentiment classification method, model training method, device, and equipment provided by this application aim to solve the above technical problems of the prior art.

[0091] Figure 4 is a schematic diagram of an application scenario provided by this application. As Figure 4As shown in the figure, this scenario includes an electronic device 101 and a user 102. The user 102 can view network review texts through the electronic device 101. The electronic device 101 performs sentiment classification on the viewed network review texts and outputs the sentiment classification results of the network review texts to the user 101.

[0092] The following uses specific embodiments to elaborate in detail on the technical solutions of this application and how the technical solutions of this application solve the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0093] Figure 5 It is a schematic flowchart of a method for sentiment classification of a text provided by an embodiment of this application. As Figure 5 shown, this method includes:

[0094] 201. Obtain the text to be processed. Among them, the text to be processed is the network review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; among them, the context hidden vector set includes initial hidden vectors corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed.

[0095] Exemplarily, the execution subject of this embodiment can be an electronic device. Based on the user's viewing operation, the electronic device obtains each text to be processed, that is, the network review text to be processed, and performs word segmentation processing on each text to be processed, so that each text to be processed includes one or more words to be processed. For each text to be processed, the electronic device processes each word to be processed in the text to be processed to obtain initial hidden vectors corresponding to each word to be processed in the text to be processed to form a context hidden vector set, and at the same time obtains aspect word hidden vectors of one or more aspect words in the text to be processed to form an aspect word hidden vector set, where each aspect word is a word to be processed belonging to the target described in the text to be processed, that is, the theme content described in the text to be processed.

[0096] 202. Perform max-pooling processing on the aspect word hidden vector set to obtain a max-pooling vector set corresponding to the aspect word hidden vector set; among them, the max-pooling vector set includes max-pooling vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max-pooling vector characterizes the semantic features of the aspect word.

[0097] Exemplarily, based on a preset pooling processing algorithm, the electronic device performs max pooling processing on each aspect word hidden vector in the aspect word hidden vector set to obtain a max pooling vector corresponding to each aspect word hidden vector, so as to represent the semantic features of each aspect word, and then forms a max pooling vector set.

[0098] 203. Perform concatenation processing on the max pooling vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the max pooling vector set; wherein, the concatenated vector set includes a concatenated representation vector corresponding to each max pooling vector in the max pooling vector set, and the concatenated representation vector represents the sentiment feature of the aspect word.

[0099] Exemplarily, the electronic device concatenates each max pooling vector in the max pooling vector set with all the initial hidden vectors in the context hidden vector set, for example, performs splicing and combination processing on each max pooling vector and all the initial hidden vectors in the context hidden vector set, and then obtains a concatenated representation vector corresponding to each max pooling vector in the max pooling vector set to represent the sentiment feature of each aspect word, thereby obtaining a concatenated vector set.

[0100] 204. Output a classification result of the text to be processed according to the concatenated vector set; wherein, the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0101] Exemplarily, for each text to be processed, the electronic device performs classification processing on each concatenated representation vector in the concatenated vector set based on a preset classification rule or a preset classification processing algorithm, for example, calculates each concatenated representation vector by invoking the softmax algorithm of a preset model, and obtains and outputs the sentiment polarity to which each aspect word in each text to be processed belongs, that is, obtains an accurate classification result of each text to be processed.

[0102] In this embodiment, a method for text sentiment classification is provided. By processing each text to be processed, hidden vectors of aspect words in the text to be processed are obtained, and each hidden vector of an aspect word is regarded as a whole, so as to perform max pooling processing, concatenation processing, and classification processing on the hidden vectors of each aspect word, and obtain an accurate sentiment classification result of each text to be processed, avoiding the problem that words belonging to the same aspect word have different sentiments, and improving the accuracy of text sentiment classification.

[0103] Figure 6 For another flow chart of the method for text sentiment classification provided by the embodiment of the present application, as Figure 6 shown, the method includes:

[0104] 301. Obtain the text to be processed, where the text to be processed is the network review text to be processed, and the text to be processed includes at least one word to be processed.

[0105] Exemplarily, this step can refer to step 201 and will not be elaborated here.

[0106] 302. Input the text to be processed into the aspect word extraction module of the preset model for encoding processing to obtain the context hidden vector set corresponding to the text to be processed.

[0107] Exemplarily, the electronic device calls the trained preset model, such as the ABSA multi-task model, which includes an aspect word extraction module such as the ATE module. The electronic device inputs the text sequence corresponding to the text to be processed into the aspect word extraction module of the preset model, and based on the encoder in the aspect word extraction module, encodes the text to be processed to obtain the initial hidden vector corresponding to each word to be processed in the text to be processed, that is, to form the context hidden vector set.

[0108] In one example, the word to be processed includes at least one field; step 303 includes the following steps:

[0109] The first step of step 303: Encode the word to be processed to obtain the field hidden vector set corresponding to the word to be processed; where the field hidden vector set includes the field hidden vectors corresponding to each character in the word to be processed, and the field hidden vector represents the semantic feature of the field.

[0110] The second step of step 303: Perform average pooling processing on the field hidden vector set to obtain the initial hidden vector.

[0111] Exemplarily, each word to be processed includes one or more field tokens. The electronic device inputs each word to be processed into the aspect word extraction module of the preset model, and based on the encoder in the aspect word extraction module, encodes each character of each word to be processed. For example, each character of each word to be processed is input into the RoBERTa encoder to obtain the field hidden vector corresponding to each token, so as to represent the semantic feature of each field. Furthermore, the field hidden vector set corresponding to each word to be processed is obtained. Since there may not be a one-to-one correspondence between the word to be processed and the token, after obtaining the hidden vector of the token, if a word to be processed is divided into multiple tokens, it is also necessary to perform average pooling processing on the field hidden vector set corresponding to each word to be processed according to the relationship between each word to be processed and its corresponding token hidden vector, as the initial hidden vector of the word to be processed, and then the context hidden vector set corresponding to the text to be processed can be obtained.

[0112] 303. Classify the context hidden vector set to obtain the label information corresponding to the text to be processed; wherein, the label information includes the label value of each word to be processed in the text to be processed, and the label value includes whether the word to be processed belongs to an aspect word.

[0113] Exemplarily, for the context hidden vector set corresponding to each text to be processed, the aspect word extraction module in the preset model in the electronic device classifies the initial hidden vectors in each context hidden vector set. For example, a fully connected layer is used to map the context hidden vector set to the classification space, and softmax calculation is used to obtain the label value corresponding to the initial hidden vector in each context hidden vector set, so as to represent whether the word to be processed corresponding to each initial hidden vector belongs to an aspect word. For example, B represents the start of an aspect word, I represents the middle part of an aspect word, and O represents that the word is not an aspect word, thereby obtaining the label information corresponding to the text to be processed.

[0114] 304. Determine the aspect word information corresponding to the text to be processed according to the label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be processed.

[0115] Exemplarily, for the label information of each text to be processed, the electronic device can call the aspect word sentiment classification APC module in the preset model. Based on the APC module, according to the label value of the word to be processed corresponding to each initial hidden vector in the text to be processed, the aspect word information corresponding to the text to be processed can be determined, including the position of each aspect word in the text to be processed, that is, the position information, for further processing.

[0116] 305. Determine the word to be processed corresponding to the position information in the text to be processed as an aspect word; and determine the aspect word hidden vector set from the context hidden vector set.

[0117] Exemplarily, for each text to be processed, the APC module in the preset model of the electronic device can extract the word to be processed corresponding to the position of each aspect word from the text to be processed according to the position of each aspect word in the text to be processed, and determine it as the aspect word of the text to be processed. Then, according to each aspect word in the text to be processed, the initial hidden vector corresponding to each aspect word is determined from the context hidden vector set as the aspect word hidden vector of each aspect word, that is, the aspect word hidden vector set is obtained.

[0118] 306. Input the aspect word hidden vector set into the sentiment classification module of the preset model for max-pooling processing to obtain the max-pooling vector set.

[0119] Exemplarily, for each set of aspect word hidden vectors, the electronic device retrieves the APC module in the preset model, and inputs the set of aspect word hidden vectors into the sentiment classification module of the preset model to perform max pooling processing on each aspect word hidden vector in the set of aspect word hidden vectors, obtaining the max pooling vector corresponding to each aspect word hidden vector to represent the semantic features of each aspect word, and then forming a max pooling vector set.

[0120] 307. Input the max pooling vector set and the context hidden vector set into the sentiment classification module of the preset model for concatenation processing, obtaining the concatenated vector set corresponding to the max pooling vector set.

[0121] Exemplarily, the electronic device retrieves the preset model, inputs the max pooling vector set and the context hidden vector set into the sentiment classification module of the preset model, and based on the sentiment classification module of the preset model, performs concatenation processing on each max pooling vector in the max pooling vector set and the context hidden vector set, obtaining the concatenated representation vector, that is, obtaining the concatenated vector set corresponding to the max pooling vector set.

[0122] In one example, step 307 includes the following steps:

[0123] The first step of step 307: Input the set of aspect word hidden vectors into the sentiment classification module for processing to determine the number of aspect words in the text to be processed.

[0124] The second step of step 307: According to the number, perform replication processing on the context hidden vector set to obtain N context hidden vector sets; where N is a positive integer greater than or equal to 1.

[0125] The third step of step 307: Perform average pooling processing on the context hidden vector set to obtain the average pooling vector corresponding to the context hidden vector set; where the average pooling vector represents the context features of the text to be processed.

[0126] The fourth step of step 307: Perform concatenation processing on the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

[0127] Exemplarily, the electronic device retrieves a preset model, inputs the aspect word hidden vector set into the sentiment classification module of the preset model, and based on the sentiment classification module, processes the aspect word hidden vector set to determine the number of aspect words in the text to be processed. For example, if the aspect word hidden vector set contains 3 aspect word hidden vectors, that is, the number of aspect words in the text to be processed is 3. For each text to be processed, based on the sentiment classification module of the preset model of the electronic device, according to the number of aspect words in each text to be processed, the context hidden vector set is copied to obtain N context hidden vector sets; where N is a positive integer greater than or equal to 1. For example, if the ATE task of the preset model extracts t aspect words from a certain text to be processed, then the context hidden vectors of this sentence are copied (t - 1) times, that is, t context hidden vector sets are obtained. For each of the N context hidden vector sets, based on the sentiment classification module, average pooling is performed on the initial hidden vectors in each context hidden vector set to obtain an average pooling vector corresponding to each context hidden vector set, so as to represent the context features of each text to be processed, that is, N context hidden vector sets to obtain the corresponding N average pooling vectors for further processing. In order to improve the accuracy of the sentiment classification of aspect words, for the N average pooling vectors of each text to be processed and the maximum pooling vector set of each text to be processed, based on the sentiment classification module, each maximum pooling vector in the maximum pooling vector set is cascaded with each average pooling vector, such as vector splicing or vector fusion processing methods, to obtain a cascaded representation vector corresponding to each aspect word in the text to be processed, so as to represent the sentiment features of each aspect word; furthermore, according to the number of aspect words predicted in the ATE task, the size of the processing batch is dynamically increased so that each aspect word matches a text to be processed.

[0128] 308. Output the classification result of the text to be processed according to the cascaded vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0129] Exemplarily, this step can refer to step 204 and will not be elaborated here.

[0130] In this embodiment, based on the above embodiment, on the one hand, by processing each text to be processed, a hidden vector of the aspect words in the text to be processed is obtained, and the hidden vector of each aspect word is regarded as a whole, so as to perform max-pooling processing, concatenation processing and classification processing on the hidden vector of each aspect word, and obtain an accurate sentiment classification result for each text to be processed, avoiding the problem that words belonging to the same aspect word have different sentiments; on the other hand, by copying the context hidden vector set according to the number of aspect words in the text to be processed, so that a text to be processed only predicts the sentiment polarity of one aspect word, thereby improving the accuracy of text sentiment classification.

[0131] Figure 7 FIG. is a schematic flowchart of a model training method for text sentiment classification provided by an embodiment of the present application, as Figure 7 shown, the method includes:

[0132] 401. Obtain a text to be trained, where the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained.

[0133] Exemplarily, the execution subject of this embodiment may be an electronic device. In order to perform sentiment classification on each network review text, it is necessary to obtain a training data set for model training and perform text sentiment classification processing. The electronic device obtains each text to be trained, that is, the network review text to be trained, and performs word segmentation processing on each text to be trained, so that each text to be trained includes one or more words to be trained.

[0134] 402. Input the text to be processed into the aspect word extraction module of the initial model for classification processing to obtain a context hidden vector set corresponding to the text to be trained and prediction label information; where the context hidden vector set includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the prediction label information includes the predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word.

[0135] Exemplarily, the electronic device calls an initial model, such as an ABSA multi-task model, which includes an aspect term extraction ATE module and an aspect term sentiment classification APC module. For each text to be trained, based on the ATE module of the initial model, each word to be trained in the text to be trained is processed to obtain an initial hidden vector corresponding to each word to be trained in the text to be trained, so as to form a context hidden vector set, and at the same time obtain the predicted label value of each word to be trained in the text to be trained to represent whether each word to be trained belongs to an aspect word, such as B indicating the start of an aspect word, I indicating the middle part of an aspect word, and O indicating that the word is not an aspect word, to obtain the prediction label information of the text to be trained.

[0136] 403. Input the context hidden vector set and the predicted label information into the sentiment classification module of the initial model for processing, and obtain the predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the sentiment polarity to which each aspect word in the text to be trained belongs.

[0137] Exemplarily, for each text to be trained, the electronic device inputs the context hidden vector set and the predicted label information corresponding to each text to be trained into the APC module of the initial model, so as to classify the initial hidden vector of each word to be trained in the context hidden vector set and the predicted label information and the predicted label value of each word to be trained in the predicted label information, and obtain the sentiment polarity to which each aspect word in the text to be trained belongs, that is, the predicted classification result corresponding to the text to be trained.

[0138] 404. Train the initial model according to the predicted classification result and the predicted label information to obtain a preset model; wherein, the preset model is used to process the text to be processed in the text sentiment classification method to obtain a classification result, and the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0139] Exemplarily, for each text to be trained, the electronic device trains the initial model according to the predicted classification result and the predicted label information corresponding to each text to be trained according to the preset number of training rounds to obtain a preset model, so as to process the text to be processed in the text sentiment classification method, and obtain the sentiment polarity to which each aspect word in the text to be processed belongs, that is, obtain the accurate classification result of each text to be trained, so as to improve the accuracy of text sentiment classification.

[0140] In this embodiment, a model training method applied to text sentiment classification is provided. Through the initial model, each text to be trained is classified to obtain the predicted label information and the predicted classification information, and the initial model is trained according to the predicted label information and the predicted classification information to obtain a preset model, so as to obtain the accurate classification result of each text to be processed, so as to improve the accuracy of text sentiment classification.

[0141] Figure 8 The flowchart of another model training method applied to text sentiment classification provided by the embodiments of the present application is shown in Figure 8 As shown, the method includes:

[0142] 501. Obtain the text to be trained, wherein the text to be trained is the network review text to be trained, and the text to be trained includes at least one word to be trained.

[0143] Exemplarily, this step can refer to step 401 and will not be elaborated here.

[0144] 502. Input the word to be trained into the aspect word extraction module of the initial model for encoding processing to obtain a set of field hidden vectors corresponding to the word to be trained. Among them, the set of field hidden vectors includes field hidden vectors corresponding to each character in the word to be trained, and the field hidden vector represents the semantic feature of the field.

[0145] In one example, the word to be trained includes at least one field.

[0146] Exemplarily, each word to be trained includes one or more field tokens. The electronic device inputs each word to be trained into the ATE module of the initial model. Based on the encoder in the ATE module, each character of each word to be trained is encoded. For example, each character of each word to be trained is input into the RoBERTa encoder to obtain the field hidden vector corresponding to each token, so as to represent the semantic feature of each field. Furthermore, a set of field hidden vectors corresponding to each word to be trained is obtained.

[0147] 503. Perform average pooling processing on the set of field hidden vectors to obtain an initial hidden vector.

[0148] Exemplarily, since there may not be a one-to-one correspondence between the word to be trained and the token, after obtaining the hidden vector of the token, if a word to be trained is divided into multiple tokens, the electronic device also needs to perform average pooling processing on the set of field hidden vectors corresponding to each word to be trained according to the relationship between each word to be trained and its corresponding token hidden vector, as the initial hidden vector of the word to be trained, so as to obtain the set of context hidden vectors corresponding to the text to be trained.

[0149] 504. Input each initial hidden vector into the aspect word extraction module of the initial model for classification processing to obtain the predicted label information corresponding to the text to be trained.

[0150] Exemplarily, for each set of context hidden vectors corresponding to the text to be trained, the aspect word extraction module in the initial model in the electronic device performs classification processing on the initial hidden vectors in each set of context hidden vectors. For example, use a fully connected layer to map the set of context hidden vectors to the classification space, and use softmax calculation to obtain the label value corresponding to each word to be trained in each text to be trained, so as to represent whether each word to be trained belongs to the aspect word, and obtain the label information corresponding to the text to be trained.

[0151] 505. Process the set of context hidden vectors and the predicted label information to obtain a set of aspect word hidden vectors corresponding to the text to be trained. Among them, the set of aspect word hidden vectors includes aspect word hidden vectors of at least one aspect word, and the aspect word is the word to be trained for the target described in the text to be trained.

[0152] Exemplarily, for each text to be trained, in the initial model in the electronic device, the aspect word extraction module extracts, according to the label value corresponding to each word to be trained in the prediction label information of each text to be trained, the word to be trained of the target described in the text to be trained from the context hidden vector set, that is, the initial hidden vector corresponding to each aspect word, as the aspect word hidden vector of each aspect word, and obtains the aspect word hidden vector set corresponding to the text to be trained.

[0153] In one example, step 505 includes the following steps:

[0154] The first step of step 505 is to determine the aspect word information corresponding to the text to be trained according to the prediction label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be trained.

[0155] The second step of step 505 is to determine the word to be trained corresponding to the position information in the text to be trained as the aspect word; and determine the aspect word hidden vector set from the context hidden vector set.

[0156] Exemplarily, for the label information of each text to be trained, the electronic device can call the aspect word sentiment classification APC module in the initial model. Based on the APC module, according to the label value of the word to be trained corresponding to each initial hidden vector in the text to be trained, the aspect word information corresponding to the text to be trained can be determined, including the position of each aspect word in the text to be trained, that is, the position information. For each text to be trained, the APC module in the initial model of the electronic device can extract, according to the position of each aspect word in the text to be trained, the word to be trained corresponding to the position of each aspect word from the text to be trained, determine it as the aspect word of the text to be trained, and according to each aspect word of the text to be trained, determine the initial hidden vector corresponding to each aspect word from the context hidden vector set as the aspect word hidden vector of each aspect word, that is, obtain the aspect word hidden vector set.

[0157] 506. Perform a concatenation process on the aspect word hidden vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the aspect word hidden vector set; wherein, the concatenated vector set includes a concatenated representation vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the concatenated representation vector represents the sentiment feature of the aspect word.

[0158] Exemplarily, in order to improve the accuracy of the initial model in sentiment classification of aspect words, for the aspect word hidden vector set of each text to be trained and the context hidden vector set of each text to be trained, based on the sentiment classification module of the initial model, each aspect word hidden vector in the aspect word hidden vector set is concatenated with the context hidden vector set, such as vector concatenation or vector fusion processing methods, to obtain the concatenated representation vector corresponding to each aspect word in the text to be trained, so as to characterize the semantic features of each aspect word.

[0159] In one example, step 506 includes the following steps:

[0160] The first step of step 506 is to perform max pooling on the aspect word hidden vector set to obtain the max pooling vector set corresponding to the aspect word hidden vector set; wherein, the max pooling vector set includes the max pooling vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector characterizes the semantic features of the aspect word.

[0161] The second step of step 506 is to perform average pooling on the context hidden vector set to obtain the average pooling vector corresponding to the context hidden vector set; wherein, the average pooling vector characterizes the context features of the text to be trained.

[0162] The third step of step 506 is to concatenate the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

[0163] Exemplarily, for each aspect word hidden vector set, the electronic device retrieves the APC module in the initial model, inputs the aspect word hidden vector set into the sentiment classification module of the initial model, and based on the preset pooling algorithm in the initial model, performs max pooling on each aspect word hidden vector in the aspect word hidden vector set to obtain the max pooling vector corresponding to each aspect word hidden vector, so as to characterize the semantic features of each aspect word, and then forms the max pooling vector set. For each context hidden vector set in each context hidden vector set, based on the sentiment classification module, average pooling is performed on the initial hidden vectors in each context hidden vector set to obtain an average pooling vector corresponding to each context hidden vector set, so as to characterize the context features of each text to be trained. In order to improve the accuracy of the initial model in sentiment classification of aspect words, based on the sentiment classification module, each max pooling vector in the max pooling vector set is concatenated with each average pooling vector, such as vector concatenation or vector fusion processing methods, to obtain the concatenated representation vector corresponding to each aspect word in the text to be trained.

[0164] In one example, the second step of step 506 includes:

[0165] Step 1: Determine the number of aspect words in the text to be trained based on the aspect word hidden vector set.

[0166] Step 2: Copy the context hidden vector set according to the number to obtain M context hidden vector sets; where M is a positive integer greater than or equal to 1.

[0167] Step 3: Perform average pooling on the context hidden vector set to obtain an average pooling vector.

[0168] Specifically, for each aspect word hidden vector set corresponding to the text to be trained, the electronic device processes the aspect word hidden vector set to determine the number of aspect words in the text to be trained. For example, if the aspect word hidden vector set contains 4 aspect word hidden vectors, the number of aspect words in the text to be trained is 4. For each text to be trained, based on the sentiment classification module of the initial model of the electronic device, according to the number of aspect words in each text to be trained, the context hidden vector set is copied to obtain M context hidden vector sets; where M is a positive integer greater than or equal to 1. For example, if the ATE task of the initial model extracts t aspect words of a certain text to be trained, then the context hidden vectors of this sentence are copied (T - 1) times to obtain T context hidden vector sets. For each context hidden vector set among the M context hidden vector sets, based on the sentiment classification module, average pooling is performed on the context hidden vectors in each context hidden vector set to obtain an average pooling vector corresponding to each context hidden vector set, that is, M context hidden vector sets, and M corresponding average pooling vectors are obtained; according to the number of aspect words predicted in the ATE task, dynamically increase the size of the processing batch so that each aspect word matches a text to be trained.

[0169] 507. Classify the cascaded vector set to obtain the predicted classification result corresponding to the text to be trained.

[0170] Exemplarily, for each text to be trained, the electronic device inputs the cascaded vector set corresponding to each text to be trained into the APC module of the initial model to classify each cascaded representation vector in the cascaded vector set, and obtain the sentiment polarity to which each aspect word in the text to be trained belongs, that is, the predicted classification result corresponding to the text to be trained.

[0171] 508. Train the initial model according to the predicted classification result, the actual classification result, the predicted label information, and the actual label information to obtain a preset model.

[0172] In one example, the text to be trained has actual label information and actual classification results. The actual label information includes the actual label values of each word to be trained in the text to be trained, and the actual classification results include the sentiment polarity to which each aspect word in the actual text to be trained belongs.

[0173] Exemplarily, Figure 9 FIG. is a schematic structural diagram of a multi-task model provided by an embodiment of the present application. As Figure 8 shown, the multi-task model includes an aspect term extraction ATE module and an aspect term sentiment classification APC module. Based on the encoder processing and classification processing of the text to be trained by the ATE module, predicted label information is obtained. Based on the APC module, the predicted label information and the text to be trained are processed to obtain predicted classification results. For each text to be trained, each text to be trained has actual label information and actual classification results. The actual label information includes the actual label values of each word to be trained in each text to be trained, and the actual classification results include the sentiment polarity to which each aspect word in each actual text to be trained belongs. An electronic device calculates and processes the predicted label information and the actual label information of each text to be trained through the formula to obtain a first loss function Loss ate , where is the i-th label value corresponding to the j-th word in the actual text to be trained, t ij is the i-th label value corresponding to the j-th word in the predicted text to be trained, λ1 is the weight of the L1 regularization term parameter, D is the number of predicted label values, P is the number of words to be trained in the text to be trained, P is an integer greater than or equal to 1, and D is an integer greater than or equal to 1; through the formula calculates and processes the predicted classification result and the actual classification result of each text to be trained to obtain a second loss function Loss apc , where represents the sentiment polarity of the aspect word in the actual text to be trained, y represents the sentiment polarity to which the i-th aspect word belongs in the prediction, λ2 is the weight of the L2 regularization term parameter, and C is the number of aspect words in the text to be trained; through the weighted sum formula Loss mutil =Loss ate +Loss apc ; the final loss function Loss mutil is calculated. Based on this loss function Loss mutil , the initial model is trained to obtain a preset model for sentiment classification processing of text, so as to obtain accurate classification results for each text to be processed and improve the accuracy of text sentiment classification.

[0174] In this embodiment, based on the above embodiment, on the one hand, through the initial model, each text to be trained is classified to obtain predicted label information and predicted classification information, and the initial model is trained according to the predicted label information and the predicted classification information to obtain a preset model for obtaining the classification result of each text to be processed accurately; on the other hand, through the initial model, the average pooling vector corresponding to each text to be trained and the maximum pooling vector corresponding to each aspect word are cascaded to be used as the sentiment feature of the aspect word, so as to obtain the accurate predicted classification information of each text to be trained. Furthermore, the initial model is trained based on the predicted classification information to obtain a preset model with accurate prediction, so as to improve the accuracy of text sentiment classification.

[0175] Figure 10 FIG. is a schematic structural diagram of a text sentiment classification device provided by an embodiment of the present application, as Figure 10 shown. The device includes:

[0176] A processing unit 601, configured to obtain a text to be processed, where the text to be processed is a network review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; where the context hidden vector set includes an initial hidden vector corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed.

[0177] A pooling unit 602, configured to perform max-pooling processing on the aspect word hidden vector set to obtain a max-pooling vector set corresponding to the aspect word hidden vector set; where the max-pooling vector set includes a max-pooling vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max-pooling vector represents the semantic feature of the aspect word.

[0178] A cascading unit 603, configured to perform cascading processing on the max-pooling vector set and the context hidden vector set to obtain a cascaded vector set corresponding to the max-pooling vector set; where the cascaded vector set includes a cascaded representation vector corresponding to each max-pooling vector in the max-pooling vector set, and the cascaded representation vector represents the sentiment feature of the aspect word.

[0179] A classification unit 604, configured to output a classification result of the text to be processed according to the cascaded vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0180] The device of this embodiment can execute the technical solutions in the above method, and the specific implementation process and technical principle are the same, which will not be elaborated here.

[0181] An embodiment of the present application further provides a text sentiment classification device, which includes:

[0182] A processing unit, configured to obtain a text to be processed, where the text to be processed is a network review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; where the context hidden vector set includes an initial hidden vector corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed.

[0183] A pooling unit, configured to perform max-pooling processing on the aspect word hidden vector set to obtain a max-pooling vector set corresponding to the aspect word hidden vector set; where the max-pooling vector set includes a max-pooling vector corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max-pooling vector represents the semantic feature of the aspect word.

[0184] A concatenation unit, configured to perform concatenation processing on the max-pooling vector set and the context hidden vector set to obtain a concatenation vector set corresponding to the max-pooling vector set; where the concatenation vector set includes a concatenation representation vector corresponding to each max-pooling vector in the max-pooling vector set, and the concatenation representation vector represents the sentiment feature of the aspect word.

[0185] A classification unit, configured to output a classification result of the text to be processed according to the concatenation vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0186] In one example, the concatenation unit 603 includes:

[0187] A concatenation module, configured to input the max-pooling vector set and the context hidden vector set into a sentiment classification module of a preset model for concatenation processing to obtain a concatenation vector set corresponding to the max-pooling vector set.

[0188] In one example, the concatenation module is specifically configured to:

[0189] Input the aspect word hidden vector set into the sentiment classification module for processing to determine the number of aspect words in the text to be processed.

[0190] According to the number, perform replication processing on the context hidden vector set to obtain N context hidden vector sets; where N is a positive integer greater than or equal to 1.

[0191] Perform average pooling on the context hidden vector set to obtain the average pooling vector corresponding to the context hidden vector set; wherein, the average pooling vector represents the context features of the text to be processed.

[0192] Perform concatenation processing on the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

[0193] In one example, the pooling unit 602 includes:

[0194] Input the aspect word hidden vector set into the sentiment classification module of the preset model for max pooling processing to obtain the max pooling vector set.

[0195] In one example, the processing unit 601 includes:

[0196] An encoding module, configured to input the text to be processed into the aspect word extraction module of the preset model for encoding processing to obtain the context hidden vector set corresponding to the text to be processed.

[0197] A classification module, configured to perform classification processing on the context hidden vector set to obtain the label information corresponding to the text to be processed; wherein, the label information includes the label value of each word to be processed in the text to be processed, and the label value includes whether the word to be processed belongs to an aspect word.

[0198] A first determination module, configured to determine the aspect word information corresponding to the text to be processed according to the label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be processed.

[0199] A second determination module, configured to determine that the word to be processed corresponding to the position information in the text to be processed is an aspect word; and determine the aspect word hidden vector set from the context hidden vector set.

[0200] In one example, the word to be processed includes at least one field; the encoding module is specifically configured to:

[0201] Perform encoding processing on the word to be processed to obtain the field hidden vector set corresponding to the word to be processed; wherein, the field hidden vector set includes the field hidden vectors corresponding to each character in the word to be processed, and the field hidden vector represents the semantic features of the field.

[0202] Perform average pooling on the field hidden vector set to obtain the initial hidden vector.

[0203] The device of this embodiment can execute the technical solutions in the above method, and its specific implementation process and technical principle are the same, which will not be elaborated here.

[0204] Figure 11The following is a schematic structural diagram of a model training device for text sentiment classification provided by an embodiment of the present application. As Figure 11 shown, the device includes:

[0205] An obtaining unit 701, configured to obtain a text to be trained, where the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained.

[0206] A first classification unit 702, configured to input the text to be trained into an aspect word extraction module of an initial model for classification processing, to obtain a context hidden vector set and prediction label information corresponding to the text to be trained; wherein, the context hidden vector set includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the prediction label information includes a predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word.

[0207] A second classification unit 703, configured to input the context hidden vector set and the prediction label information into an emotion classification module of the initial model for processing, to obtain a predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the emotion polarity to which each aspect word in the text to be trained belongs.

[0208] A training unit 704, configured to train the initial model according to the predicted classification result and the prediction label information, to obtain a preset model; wherein, the preset model is used to process a text to be processed in a text emotion classification device to obtain a classification result, and the classification result includes the emotion polarity to which each aspect word in the text to be processed belongs.

[0209] The device of this embodiment can execute the technical solutions in the above method, and the specific implementation process and technical principle are the same, which will not be elaborated here.

[0210] An embodiment of the present application further provides a model training device for text sentiment classification. The device includes:

[0211] An obtaining unit, configured to obtain a text to be trained, where the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained.

[0212] A first classification unit, configured to input the text to be trained into an aspect word extraction module of an initial model for classification processing, to obtain a context hidden vector set and prediction label information corresponding to the text to be trained; wherein, the context hidden vector set includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the prediction label information includes a predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word.

[0213] A second classification unit is configured to input a set of context hidden vectors and predicted label information into the sentiment classification module of the initial model for processing, and obtain a predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the sentiment polarity to which each aspect word in the text to be trained belongs.

[0214] A training unit is configured to train the initial model according to the predicted classification result and the predicted label information to obtain a preset model; wherein, the preset model is configured to process the text to be processed in the sentiment classification device of the text to obtain a classification result, and the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

[0215] In one example, the text to be trained has actual label information and an actual classification result. The actual label information includes the actual label value of each word to be trained in the text to be trained, and the actual classification result includes the sentiment polarity to which each aspect word in the actual text to be trained belongs.

[0216] The training unit 704 includes:

[0217] A training module is configured to train the initial model according to the predicted classification result, the actual classification result, the predicted label information, and the actual label information to obtain a preset model.

[0218] In one example, the second classification unit 703 includes:

[0219] A processing module is configured to process the set of context hidden vectors and the predicted label information to obtain a set of aspect word hidden vectors corresponding to the text to be trained; wherein, the set of aspect word hidden vectors includes the aspect word hidden vectors of at least one aspect word, and the aspect word is the word to be trained of the target described in the text to be trained.

[0220] A concatenation module is configured to perform concatenation processing on the set of aspect word hidden vectors and the set of context hidden vectors to obtain a set of concatenated vectors corresponding to the set of aspect word hidden vectors; wherein, the set of concatenated vectors includes the concatenated representation vectors corresponding to each aspect word hidden vector in the set of aspect word hidden vectors, and the concatenated representation vectors represent the sentiment features of the aspect words.

[0221] A first classification module is configured to perform classification processing on the set of concatenated vectors to obtain a predicted classification result corresponding to the text to be trained.

[0222] In one example, the processing module is specifically configured to:

[0223] Determine the aspect word information corresponding to the text to be trained according to the predicted label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be trained.

[0224] Determine the training words corresponding to the location information in the text to be trained as aspect words; and determine the aspect word hidden vector set from the context hidden vector set.

[0225] In one example, the cascade module includes:

[0226] Perform max pooling on the aspect word hidden vector set to obtain the max pooling vector set corresponding to the aspect word hidden vector set; where the max pooling vector set includes the max pooling vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector represents the semantic features of the aspect word.

[0227] Perform average pooling on the context hidden vector set to obtain the average pooling vector corresponding to the context hidden vector set; where the average pooling vector represents the context features of the text to be trained.

[0228] Cascade the max pooling vector and the average pooling vector to obtain the cascade representation vector.

[0229] In one example, the cascade module is specifically used for:

[0230] Determine the number of aspect words in the text to be trained according to the aspect word hidden vector set.

[0231] Copy the context hidden vector set according to the number to obtain M context hidden vector sets; where M is a positive integer greater than or equal to 1.

[0232] Perform average pooling on the context hidden vector set to obtain the average pooling vector.

[0233] In one example, the training word includes at least one field; the first classification unit 702 includes:

[0234] The encoding module is used to input the training word into the aspect word extraction module of the initial model for encoding processing to obtain the field hidden vector set corresponding to the training word; where the field hidden vector set includes the field hidden vectors corresponding to each character in the training word, and the field hidden vector represents the semantic features of the field.

[0235] The pooling module is used to perform average pooling on the field hidden vector set to obtain the initial hidden vector.

[0236] The second classification module is used to input each initial hidden vector into the aspect word extraction module of the initial model for classification processing to obtain the predicted label information corresponding to the text to be trained.

[0237] The device in this embodiment can execute the technical solutions in the above method, and its specific implementation process and technical principle are the same, which will not be elaborated here.

[0238] Figure 12 The following is a schematic structural diagram of an electronic device provided by an embodiment of the present application, as Figure 12 shown. The electronic device includes: a memory 801, a processor 802; the memory 801; a memory for storing executable instructions of the processor 802.

[0239] Among them, the processor 802 is configured to execute the method provided in the above embodiment.

[0240] The electronic device 800 further includes a receiver 803 and a transmitter 804. The receiver 803 is used to receive instructions and data sent by other devices, and the transmitter 804 is used to send instructions and data to external devices.

[0241] According to an embodiment of the present application, the present application also provides a non-transitory computer-readable storage medium including instructions, such as a memory including instructions. The above instructions can be executed by a processor of the electronic device to complete the solution provided in any of the above embodiments. For example, the non-transitory computer-readable storage medium may be a random access memory, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0242] According to an embodiment of the present application, the present application also provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a processor of the electronic device, the electronic device can execute the solution provided in any of the above embodiments.

[0243] According to an embodiment of the present application, the present application also provides a computer program product. The computer program product includes: a computer program. The computer program is stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided in any of the above embodiments.

[0244] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present application. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0245] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A method for sentiment classification of text, characterized in that The method includes: Obtain the text to be processed, where the text to be processed is a network review text to be processed, and the text to be processed includes at least one word to be processed; process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; where the context hidden vector set includes an initial hidden vector corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed. Perform max pooling processing on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set; where the max pooling vector set includes max pooling vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector represents the semantic feature of the aspect word. Perform concatenation processing on the max pooling vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the max pooling vector set; where the concatenated vector set includes concatenated representation vectors corresponding to each max pooling vector in the max pooling vector set, and the concatenated representation vector represents the sentiment feature of the aspect word. Output a classification result of the text to be processed according to the concatenated vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

2. The method according to claim 1, characterized in that, Performing concatenation processing on the max pooling vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the max pooling vector set includes: Input the max pooling vector set and the context hidden vector set into the sentiment classification module of a preset model for concatenation processing to obtain a concatenated vector set corresponding to the max pooling vector set.

3. The method according to claim 2, wherein Inputting the max pooling vector set and the context hidden vector set into the sentiment classification module of a preset model for concatenation processing to obtain a concatenated vector set corresponding to the max pooling vector set includes: Input the aspect word hidden vector set into the sentiment classification module for processing to determine the number of aspect words in the text to be processed. According to the number, perform replication processing on the context hidden vector set to obtain N context hidden vector sets; where N is a positive integer greater than or equal to 1. Perform average pooling processing on the context hidden vector set to obtain an average pooling vector corresponding to the context hidden vector set; where the average pooling vector represents the context feature of the text to be processed. Perform concatenation processing on the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

4. The method according to claim 1, characterized in that Performing max pooling processing on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set includes: Input the aspect word hidden vector set into the sentiment classification module of a preset model for max pooling processing to obtain the max pooling vector set.

5. The method according to any one of claims 1-4, characterized in that, Process the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed, including: Input the text to be processed into the aspect word extraction module of a preset model for encoding processing to obtain a context hidden vector set corresponding to the text to be processed; Perform classification processing on the context hidden vector set to obtain label information corresponding to the text to be processed; wherein, the label information includes the label value of each word to be processed in the text to be processed, and the label value includes whether the word to be processed belongs to an aspect word; Determine aspect word information corresponding to the text to be processed according to the label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be processed; Determine the word to be processed corresponding to the position information in the text to be processed as an aspect word; and determine the aspect word hidden vector set from the context hidden vector set.

6. The method according to claim 5, wherein The word to be processed includes at least one field; inputting the text to be processed into the aspect word extraction module of a preset model for encoding processing to obtain a context hidden vector set corresponding to the text to be processed, including: Perform encoding processing on the word to be processed to obtain a field hidden vector set corresponding to the word to be processed; wherein, the field hidden vector set includes a field hidden vector corresponding to each character in the word to be processed, and the field hidden vector represents the semantic feature of the field; Perform average pooling processing on the field hidden vector set to obtain the initial hidden vector.

7. A model training method applied to text sentiment classification, characterized in that, The method includes: Obtain a text to be trained, wherein the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained; Input the text to be trained into the aspect word extraction module of an initial model for classification processing to obtain a context hidden vector set and predicted label information corresponding to the text to be trained; wherein, the context hidden vector set includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the predicted label information includes the predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word; Input the context hidden vector set and the predicted label information into the sentiment classification module of the initial model for processing to obtain a predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the sentiment polarity to which each aspect word in the text to be trained belongs; Train the initial model according to the predicted classification result and the predicted label information to obtain a preset model; wherein, the preset model is used to process the text to be processed according to any one of claims 1-6 to obtain a classification result, and the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

8. The method according to claim 7, characterized in that, The text to be trained has actual label information and actual classification results. The actual label information includes the actual label values of each word to be trained in the text to be trained, and the actual classification results include the sentiment polarity to which each aspect word in the actual text to be trained belongs. Training the initial model according to the predicted classification results and the predicted label information to obtain a preset model, including: Training the initial model according to the predicted classification results, the actual classification results, the predicted label information, and the actual label information to obtain the preset model.

9. The method according to claim 7, wherein Inputting the context hidden vector set and the predicted label information into the sentiment classification module of the initial model for processing to obtain the predicted classification result corresponding to the text to be trained, including: Processing the context hidden vector set and the predicted label information to obtain an aspect word hidden vector set corresponding to the text to be trained; wherein, the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be trained of the target described in the text to be trained. Performing a concatenation process on the aspect word hidden vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the aspect word hidden vector set; wherein, the concatenated vector set includes concatenated representation vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the concatenated representation vectors represent the sentiment features of the aspect words. Performing a classification process on the concatenated vector set to obtain the predicted classification result corresponding to the text to be trained.

10. The method according to claim 9, wherein Processing the context hidden vector set and the predicted label information to obtain an aspect word hidden vector set corresponding to the text to be trained, including: Determining the aspect word information corresponding to the text to be trained according to the predicted label information; wherein, the aspect word information includes position information, and the position information represents the position of each aspect word in the text to be trained. Determining the word to be trained corresponding to the position information in the text to be trained as the aspect word; and determining the aspect word hidden vector set from the context hidden vector set.

11. The method according to claim 9, wherein Performing a concatenation process on the aspect word hidden vector set and the context hidden vector set to obtain a concatenated vector set corresponding to the aspect word hidden vector set, including: Performing a max pooling process on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set; wherein, the max pooling vector set includes max pooling vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vectors represent the semantic features of the aspect words. Performing an average pooling process on the context hidden vector set to obtain an average pooling vector corresponding to the context hidden vector set; wherein, the average pooling vector represents the context features of the text to be trained. Performing a concatenation process on the max pooling vector and the average pooling vector to obtain the concatenated representation vector.

12. The method according to claim 11, wherein Performing average pooling on the context hidden vector set to obtain the average pooling vector corresponding to the context hidden vector set, including: Determining the number of aspect words in the text to be trained according to the aspect word hidden vector set; Performing replication processing on the context hidden vector set according to the number to obtain M context hidden vector sets; where M is a positive integer greater than or equal to 1; Performing average pooling on the context hidden vector set to obtain the average pooling vector.

13. The method according to any one of claims 7-12, characterized in that, The word to be trained includes at least one field; inputting the text to be trained into the aspect word extraction module of the initial model for classification processing to obtain the context hidden vector set and prediction label information corresponding to the text to be trained, including: Inputting the word to be trained into the aspect word extraction module of the initial model for encoding processing to obtain the field hidden vector set corresponding to the word to be trained; where the field hidden vector set includes field hidden vectors corresponding to each character in the word to be trained, and the field hidden vector represents the semantic feature of the field; Performing average pooling on the field hidden vector set to obtain the initial hidden vector; Inputting each of the initial hidden vectors into the aspect word extraction module of the initial model for classification processing to obtain the prediction label information corresponding to the text to be trained.

14. An emotional classification device for text, characterized in that, The device includes: A processing unit, configured to obtain a text to be processed, where the text to be processed is a network review text to be processed, and the text to be processed includes at least one word to be processed; processing the text to be processed to obtain a context hidden vector set and an aspect word hidden vector set corresponding to the text to be processed; where the context hidden vector set includes initial hidden vectors corresponding to each word to be processed in the text to be processed; the aspect word hidden vector set includes aspect word hidden vectors of at least one aspect word, and the aspect word is a word to be processed belonging to the target described in the text to be processed; A pooling unit, configured to perform max pooling on the aspect word hidden vector set to obtain a max pooling vector set corresponding to the aspect word hidden vector set; where the max pooling vector set includes max pooling vectors corresponding to each aspect word hidden vector in the aspect word hidden vector set, and the max pooling vector represents the semantic feature of the aspect word; A concatenation unit, configured to perform concatenation processing on the max pooling vector set and the context hidden vector set to obtain a concatenation vector set corresponding to the max pooling vector set; where the concatenation vector set includes concatenation representation vectors corresponding to each max pooling vector in the max pooling vector set, and the concatenation representation vector represents the sentiment feature of the aspect word; A classification unit, configured to output a classification result of the text to be processed according to the concatenation vector set; where the classification result includes the sentiment polarity to which each aspect word in the text to be processed belongs.

15. A model training device applied to text sentiment classification, characterized in that, The device includes: An acquisition unit for acquiring a text to be trained, where the text to be trained is a network review text to be trained, and the text to be trained includes at least one word to be trained; A first classification unit for inputting the text to be trained into an aspect word extraction module of an initial model for classification processing to obtain a context hidden vector set corresponding to the text to be trained and prediction label information; wherein, the context hidden vector set includes an initial hidden vector corresponding to each word to be trained in the text to be trained; the prediction label information includes a predicted label value of each word to be trained in the text to be trained, and the label value includes whether the word to be trained belongs to an aspect word; A second classification unit for inputting the context hidden vector set and the prediction label information into an emotion classification module of the initial model for processing to obtain a predicted classification result corresponding to the text to be trained; wherein, the predicted classification result includes the emotion polarity to which each aspect word in the text to be trained belongs; A training unit for training the initial model according to the predicted classification result and the prediction label information to obtain a preset model; wherein, the preset model is used to process the text to be processed in claim 14 to obtain a classification result, and the classification result includes the emotion polarity to which each aspect word in the text to be processed belongs.

16. An electronic device, characterized in that, Comprising: A processor and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6 or claims 7 to 13.

17. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 6 or claims 7 to 13.