Aspect-level sentiment classification method, device and equipment

By combining BERT, bidirectional long and short-term memory network and capsule network model, the problem of insufficient semantic features in aspect-level emotion classification is solved, and high accuracy classification is achieved when there are few training samples.

CN116484285BActive Publication Date: 2025-08-08ANHUI UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310517683.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-09
Publication Date
2025-08-08
Estimated Expiration
2043-05-09

AI Technical Summary

Technical Problem

In the prior art, the single neural network model in the aspect-level emotion classification task is not comprehensive enough to obtain semantic features, resulting in a low classification accuracy rate, especially when there are fewer training samples, and the aspect-level emotion classification labeling corpus resources are scarce.

Method used

A multi-layer neural network model consisting of BERT model, a two-way long and short-term memory network model and a capsule network model is used to obtain the position and local semantic characteristics of words through the BERT model. The two-way long and short-term memory network model captures the context semantic characteristics, and the capsule network model performs cluster analysis, and finally uses the output layer for emotional classification.

Benefits of technology

With fewer training samples, the classification accuracy of the aspect-level emotion classification model is improved, and rich semantic features are obtained through multi-layer neural network models. The capsule network model is suitable for tasks with fewer training samples, improving classification accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116484285B_ABST
    Figure CN116484285B_ABST
Patent Text Reader

Abstract

The embodiments of this specification disclose an aspect-level sentiment classification method, apparatus, and device. The solution may include: using a BERT model to receive text data to be classified at a target business location, and outputting first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business location; using a bidirectional long short-term memory network model to receive the first feature vector data, and then outputting second feature vector data; using a capsule network model, clustering and analyzing the second feature vector data to obtain third feature vector data; using an output layer, performing classification processing based on the third feature vector data to obtain a sentiment classification result corresponding to the aspect words. Based on the solution of the present invention, the classification accuracy of the aspect-level sentiment classification model can be improved when there are fewer training samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a method, apparatus, and device for aspect-level sentiment classification. Background Art

[0002] The booming development of e-commerce has generated a massive amount of product review data. This data can help businesses analyze market trends and determine user preferences. The emotional information contained in product reviews has a wide range of applications.

[0003] Aspect-level sentiment classification can determine the sentiment polarity of different aspects in a review, enabling fine-grained sentiment classification of text, and has strong application demand. Current research on aspect-level sentiment analysis focuses on using single neural network models for aspect-level sentiment classification, such as LSTM or BERT models, to perform aspect-level sentiment classification on user reviews. However, single neural network models often suffer from low classification accuracy due to insufficient semantic feature acquisition.

[0004] Furthermore, training a good sentiment classification model requires a large amount of annotated corpus. Aspect-level sentiment classification requires not only annotating the sentiment polarity of the text, as with traditional sentiment classification tasks, but also annotating the corresponding aspect terms. Currently, annotated corpus resources for aspect-level sentiment classification are very limited, primarily in English. Annotated corpus resources in other languages are even scarcer.

[0005] Based on this, how to improve the classification accuracy of aspect-level sentiment classification models with fewer training samples has become a technical problem that needs to be solved urgently. Summary of the Invention

[0006] In view of this, the embodiments of this specification provide an aspect-level sentiment classification method, apparatus, and device for improving the classification accuracy of an aspect-level sentiment classification model when there are fewer training samples.

[0007] To solve the above technical problems, the embodiments of this specification are implemented as follows:

[0008] An embodiment of this specification provides an aspect-level sentiment classification method, which uses an aspect-level sentiment classification model. The aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the method includes:

[0009] Using the BERT model to receive text data to be classified at a target business, and outputting first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified;

[0010] After receiving the first feature vector data using the bidirectional long short-term memory network model, outputting second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified;

[0011] Using the capsule network model, performing cluster analysis on the second feature vector data to obtain third feature vector data;

[0012] The output layer is used to perform classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0013] The embodiments of this specification provide a method for training an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the method includes:

[0014] Acquire a training sample set; wherein a training sample in the training sample set includes a first target sentence sample and a first aspect word sample of a target business; and the label data of the training sample is used to reflect the sentiment classification result of the first target sentence sample corresponding to the first aspect word sample;

[0015] The initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

[0016] An embodiment of this specification provides an aspect-level sentiment classification device, which uses an aspect-level sentiment classification model. The aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the device includes:

[0017] A first feature vector generation module is configured to receive text data to be classified at a target business using the BERT model and output first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is configured to reflect positional features and local semantic features of each word in the text data to be classified;

[0018] A second feature vector generating module is configured to receive the first feature vector data using the bidirectional long short-term memory network model and output second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified;

[0019] A third eigenvector generating module is configured to perform cluster analysis on the second eigenvector data using the capsule network model to obtain third eigenvector data;

[0020] An output module is used to utilize the output layer to perform classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0021] The embodiment of this specification provides an aspect-level sentiment classification model training device, wherein the aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the device includes:

[0022] A training sample acquisition module is used to acquire a training sample set; one training sample in the training sample set includes a target sentence sample and an aspect word sample of a target business; the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample;

[0023] The model training module is used to train the initial aspect-level sentiment classification model using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

[0024] The embodiment of this specification provides an aspect-level sentiment classification device, including:

[0025] at least one processor; and,

[0026] a memory communicatively connected to the at least one processor; wherein,

[0027] The memory stores an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the memory further stores instructions executable by the at least one processor, wherein the instructions are executed by the at least one processor to enable the at least one processor to:

[0028] Using the BERT model to receive text data to be classified at a target business, and outputting first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified;

[0029] After receiving the first feature vector data using the bidirectional long short-term memory network model, outputting second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified;

[0030] Using the capsule network model, performing cluster analysis on the second feature vector data to obtain third feature vector data;

[0031] The output layer is used to perform classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0032] The embodiments of this specification provide an aspect-level sentiment classification model training device, including:

[0033] at least one processor; and,

[0034] a memory communicatively connected to the at least one processor; wherein,

[0035] The memory stores an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the memory further stores instructions executable by the at least one processor, wherein the instructions are executed by the at least one processor to enable the at least one processor to:

[0036] Acquire a training sample set; wherein a training sample in the training sample set includes a target sentence sample and an aspect word sample of a target business; and the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample;

[0037] The initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

[0038] At least one embodiment provided in this specification can achieve the following beneficial effects:

[0039] In the solution of the present invention, the aspect-level sentiment classification model is a multi-layer neural network model composed of multiple single neural network models, such as the BERT model, the bidirectional long short-term memory network model, and the capsule network model. When performing aspect-level sentiment classification tasks, the multi-layer neural network model captures richer semantic features than single neural network models and achieves higher sentiment classification accuracy. Furthermore, the capsule network model is suitable for aspect-level sentiment classification tasks with fewer training samples. By introducing the capsule network model, the classification accuracy of the aspect-level sentiment classification model can be improved even with fewer training samples. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0041] Figure 1 A flowchart of an aspect-level sentiment classification method provided in an embodiment of this specification;

[0042] Figure 2 A schematic diagram of the structure of an aspect-level sentiment classification model provided in an embodiment of this specification;

[0043] Figure 3 A flowchart of a method for training an aspect-level sentiment classification model provided in an embodiment of this specification;

[0044] Figure 4 The embodiments of this specification provide corresponding Figure 1 A structural diagram of an aspect-level sentiment classification device;

[0045] Figure 5 The embodiments of this specification provide corresponding Figure 3A structural diagram of an aspect-level sentiment classification model training device;

[0046] Figure 6 The embodiments of this specification provide corresponding Figure 1 A structural diagram of an aspect-level sentiment classification device;

[0047] Figure 7 The embodiments of this specification provide corresponding Figure 3 A structural diagram of an aspect-level sentiment classification model training device; DETAILED DESCRIPTION

[0048] To make the purpose, technical solutions, and advantages of one or more embodiments of this specification more clear, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of one or more embodiments of this specification.

[0049] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0050] In existing technologies, single neural network models are often used to perform aspect-level sentiment classification tasks. However, due to insufficient semantic feature acquisition, single neural network models often suffer from low classification accuracy. This is especially true when training samples are limited.

[0051] In order to solve the defects in the prior art, this solution provides the following embodiments:

[0052] Figure 1 This is a flow chart of an aspect-level sentiment classification method provided in an embodiment of this specification. The method uses an aspect-level sentiment classification model to perform aspect-level sentiment classification on a target sentence.

[0053] Figure 2 This is a structural diagram of an aspect-level sentiment classification model provided in the embodiment of this specification, such as Figure 2As shown, the aspect-level sentiment classification model 201 includes: a BERT model 202, a bidirectional long short-term memory network model 203, a capsule network model 204, and an output layer 205; wherein, the BERT model 202 is connected to the bidirectional long short-term memory network model 203, the bidirectional long short-term memory network model 203 is connected to the capsule network model 204, and the capsule network model 204 is connected to the output layer 205.

[0054] like Figure 1 As shown, the process may include the following steps:

[0055] Step 102: Use the BERT model to receive the text data to be classified at the target business and output first feature vector data; the text data to be classified is generated based on the target sentence and aspect words of the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified.

[0056] In the embodiments of this specification, the BERT (full name: Bidirectional Encoder Representations from Transformers) model is a pre-trained language model (PLM). The BERT model can process the text data input into the BERT model and convert the text data into feature vector data, wherein the BERT model can use position embedding to reflect the position of the word in the sentence; the BERT model can use segment embedding to distinguish which sentence a word belongs to in a sentence pair; the BERT model can use token embedding to convert each word into a feature vector of fixed dimension. The BERT model can use the Masked Language Model (MLM) as one of the pre-training tasks, which allows the model to learn the possibility distribution of masked words, thereby enhancing the understanding of the local semantic relationship between each word in the sentence.

[0057] In the embodiments of this specification, the target business can be an online shopping business, a telecommunications service business, or other businesses involving user reviews. As long as the business involves user reviews, it can be used as a target business, and there is no specific limitation on this. The text data to be classified at the target business can be the user review text (target sentence) data related to the target business, which can be input into the BERT model after preliminary data processing. Since the data processing part before inputting the BERT model will be described in detail later, it will not be repeated here.

[0058] In the embodiment of this specification, since the BERT model can use position embedding to reflect the position of a word in a sentence, after the BERT model processes the text data to be classified at the target business, the first feature vector data outputted can reflect the positional features of each word in the text data to be classified; since the BERT model can use the Masked Language Model (MLM) to enhance the understanding of the local semantic relationship of each word in a sentence, after the BERT model processes the text data to be classified at the target business, the first feature vector data outputted can reflect the local semantic features of each word in the text data to be classified. For example, for the sentence "I sit on a chair and eat an apple", the BERT model can determine that the two words "chair" and "apple" in this sentence are in different positions in the sentence, and the semantic meanings of the two words are also different.

[0059] Step 104: After receiving the first feature vector data using a bidirectional long short-term memory network model, output second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified.

[0060] In the embodiment of this specification, the bidirectional long short-term memory network (Bi-directional Long Short-Term Memory, BILSTM) model is composed of a forward LSTM and a backward LSTM. Wherein, LSTM (Long Short-Term Memory) is a long short-term memory network, which is a time recursive neural network that can capture the long-distance dependencies between the words in a sentence, but LSTM is only unidirectional and can only encode semantic information from front to back, and cannot encode semantic information from back to front. Since the bidirectional long short-term memory network model is composed of a forward LSTM and a backward LSTM, the bidirectional long short-term memory network model can better capture bidirectional semantic features and extract contextual semantic features from text data.

[0061] In an embodiment of the present specification, the BERT model can output first feature vector data after processing the text data to be classified at the target business, and the first feature vector data output by the BERT model serves as input data of the bidirectional long short-term memory network model. After the bidirectional long short-term memory network model processes the first feature vector data, it can obtain second feature vector data used to reflect the contextual semantic features of the text data to be classified.

[0062] Step 106: Using the capsule network model, perform cluster analysis on the second feature vector data to obtain third feature vector data.

[0063] In the embodiments of this specification, the capsule network model may include: aspect capsules, bottom-level capsules, and high-level capsules. Aspect capsules are obtained by processing aspect words in the categorized text data, and bottom-level capsules are obtained by processing the target sentence in the categorized text data, containing the semantic features of each word in the target sentence. The capsule network model can measure the importance of the semantic features represented by the bottom-level capsules to the emotional tendency of the aspect words based on the aspect capsules. For example, for the target sentence "This book is wonderful, but the logistics is too bad", for the aspect word "book", the feature "wonderful" will be given a greater weight, causing it to deactivate the high-level capsule representing "positive", while features such as "too bad" will receive a lower weight, preventing it from deactivating the high-level capsule representing "negative". However, if the aspect word is "logistics", the feature "too bad" will be given a greater weight, causing it to deactivate the high-level capsule representing "negative", while features such as "wonderful" will receive a lower weight, preventing it from deactivating the high-level capsule representing "positive". Therefore, the capsule network model can distinguish overlapping features by clustering the data, give greater weight to features related to aspect words, and then extract features related to aspect words in the text data to be classified.

[0064] In the embodiments of this specification, the aspect capsules, bottom-level capsules, and high-level capsules in the capsule network model all exist in the form of capsule vectors. A capsule vector can be a group of neurons that express a feature. The length of the vector can represent the probability of the feature's existence, and the direction can contain specific attributes of the feature. A large amount of underlying semantic information is embedded in the underlying capsule. Therefore, the capsule network model does not require a large number of training samples for training. This advantage makes the capsule network model suitable for aspect-level sentiment analysis tasks with fewer training samples.

[0065] In an embodiment of the present specification, the bidirectional long short-term memory network model can output second feature vector data after processing the first feature vector data, and the second feature vector data output by the bidirectional long short-term memory network model serves as input data of the capsule network model. After the capsule network model performs cluster analysis on the second feature vector data, third feature vector data can be obtained. The third feature vector data contains semantic feature information related to aspect words.

[0066] Step 108: Using the output layer, perform classification processing based on the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0067] In the embodiment of this specification, the capsule network model can output third feature vector data after processing the second feature vector data, and the third feature vector data output by the capsule network model serves as input data of the output layer. After the output layer classifies the third feature vector data, the sentiment classification result corresponding to the aspect word can be obtained.

[0068] In the embodiments of this specification, the sentiment classification results can be two-sided or three-sided, and there is no specific limitation on this. Specifically, if the sentiment classification results are two-sided, they can be divided into "negative" and "positive"; if the sentiment classification results are three-sided, they can be divided into "negative," "neutral," and "positive." There is no specific limitation on the number of categories and the naming of the sentiment classification results, and they can be set according to needs.

[0069] In the embodiments of this specification, the output layer can use a softmax function to classify the received third eigenvector data, obtain the probabilities of various sentiment classification results, and then use the sentiment classification result with the highest probability as the final output sentiment classification result corresponding to the aspect word. The softmax function, also known as the normalized exponential function, is a generalization of the binary classification function to multi-classification, with the purpose of presenting the multi-classification results in the form of probabilities.

[0070] based on Figure 1 The method in this specification also provides some specific implementation plans of the method, which are described below.

[0071] In the embodiments of this specification, the data input to the aspect-level sentiment classification model is different from the data input to the BERT model. The data input to the aspect-level sentiment classification model must be processed before the text data to be classified at the target business of the BERT model can be obtained.

[0072] Based on this, Figure 1 In the method, in step 102, before receiving the text data to be classified at the target business using the BERT model and outputting the first feature vector data, the method may further include:

[0073] The target sentence and the aspect words at the target business are obtained.

[0074] According to the aspect words, a corresponding constructed sentence is matched for the target sentence.

[0075] Data processing is performed on the constructed sentence, the target sentence and the aspect words to obtain text data to be classified at the target business location.

[0076] In the embodiment of this specification, the text data to be classified at the target business can be the user comment text (target sentence) data related to the target business, which can be input into the BERT model after preliminary data processing. Specifically, the data input into the aspect-level sentiment classification model include target sentences and aspect words, wherein the target sentence can be the user comment sentence to be classified, and the aspect words can be pre-specified feature words corresponding to the aspects that you want to perform sentiment classification on in the target sentence. The aspect-level sentiment classification model can match the corresponding constructed sentences for the target sentence based on the input aspect words. For example: input the target sentence "The food in this restaurant tastes delicious, but the price is a bit expensive" and the aspect word "taste", the aspect-level sentiment classification model can match the constructed sentence "What do you think of the taste?" for the target sentence based on the input aspect word "taste". The aspect-level sentiment classification model performs data processing on the constructed sentences, target sentences and aspect words before it can obtain the text data to be classified at the target business input into the BERT model.

[0077] Correspondingly, matching a corresponding constructed sentence for the target sentence based on the aspect words may specifically include:

[0078] According to the aspect words, the aspect word category to which the aspect words belong is determined.

[0079] According to the aspect word category, a constructed sentence corresponding to the aspect word category is determined from a preset constructed sentence set.

[0080] The determined constructed sentence corresponding to the aspect word category is matched to the target sentence.

[0081] In the embodiments of this specification, various aspect words can be classified in advance, and then different constructed sentences can be set corresponding to different aspect word categories, and these constructed sentences can constitute a constructed sentence set. For example: the aspect words "price", "price" and "price" are classified into the category of "price", and the constructed sentence "What do you think of the price?" is set. When the target sentence "The food in this restaurant tastes delicious, but the price is a bit expensive" and the aspect word "price" are input, the aspect-level sentiment classification model can determine that the aspect word category to which the aspect word belongs is "price" based on the input aspect word "price", and then the aspect-level sentiment classification model can select the constructed sentence "What do you think of the price?" from the pre-set constructed sentence set to match it to the target sentence.

[0082] In the embodiments of this specification, by matching the target sentence with a constructed sentence corresponding to the aspect word category, the feature information of the aspect word can be integrated into the sentence expression, thereby increasing the degree of attention paid by the aspect-level sentiment classification model to content related to the aspect word, and thus helping to improve the classification accuracy of the aspect-level sentiment classification model.

[0083] Correspondingly, the data processing of the constructed sentence, the target sentence, and the aspect words to obtain the text data to be classified at the target business may specifically include:

[0084] Data splicing is performed on the constructed sentence, the target sentence, and the aspect words to obtain spliced data.

[0085] Data compensation is performed on the spliced data until the data length of the spliced data reaches a preset data length, thereby obtaining the text data to be classified at the target business.

[0086] In the embodiments of this specification, since the data input into the BERT model needs to ensure the consistency of data length, the text data to be classified input into the BERT model must ensure that it meets the preset data length. The preset data length can be set according to actual needs to ensure that the preset data length can meet the data length requirements of most text data to be classified. For example, the preset data length can be set to 512 characters. If the spliced data is less than 512 characters, the spliced data can be compensated until the data length of the spliced data reaches 512 characters; if the spliced data exceeds 512 characters, an error message about the data exceeding the limit can be returned, prompting the user to re-enter the target sentence.

[0087] In the embodiments of this specification, the data compensation method for the spliced data may be a method of adding "0" to the end of the sequence of the spliced data, or other data compensation methods may be used, which are not specifically limited.

[0088] Figure 3 A flowchart of a method for training an aspect-level sentiment classification model provided in an embodiment of this specification; Figure 1 The aspect-level sentiment classification model used in the method can be Figure 3 The model training method in is trained; Figure 3 As shown, the process may include the following steps:

[0089] Step 302: Obtain a training sample set; a training sample in the training sample set includes a first target sentence sample and a first aspect word sample of a target business; the label data of the training sample is used to reflect the sentiment classification result of the first target sentence sample corresponding to the first aspect word sample.

[0090] In an embodiment of the present specification, the training samples in the training sample set include not only target sentence samples and aspect word samples, but also label data. The label data of the training samples is used to reflect the sentiment classification results of the target sentence samples contained in the training samples corresponding to the aspect word samples contained in the training samples.

[0091] In the embodiments of this specification, numbers can be used to represent different sentiment classification results, thereby using numbers as label data for training samples. For example, for the sentiment classification results of three faces, the number 0 can represent "negative", the number 1 can represent "neutral", and the number 2 can represent "positive".

[0092] Step 304: using the training samples in the training sample set to train the initial aspect-level sentiment classification model to obtain the trained aspect-level sentiment classification model.

[0093] In the embodiments of this specification, an initial aspect-level sentiment classification model is trained using training samples from a training sample set to obtain a trained aspect-level sentiment classification model, which is a form of supervised machine learning. Supervised machine learning involves training a model using existing training samples. This model is then used to map all inputs to corresponding outputs, and a simple judgment is made on the outputs to achieve prediction and classification, enabling the model to predict and classify unknown data.

[0094] In the embodiments of this specification, after the aspect-level sentiment classification model is trained using training samples, the performance of the trained aspect-level sentiment classification model may be tested using validation samples.

[0095] Based on this, Figure 3 In the method, in step 304, after the initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model, the method may further include:

[0096] A verification sample set is obtained; a verification sample in the verification sample set includes a second target sentence sample and a second aspect word sample of the target business.

[0097] For the verification samples in the verification sample set, the verification samples are input into the trained aspect-level sentiment classification model to obtain a sentiment classification result output by the trained aspect-level sentiment classification model.

[0098] Obtain the sentiment classification label corresponding to the verification sample.

[0099] A performance test result of the trained aspect-level sentiment classification model is generated according to the sentiment classification label and the sentiment classification result.

[0100] In the embodiment of this specification, the verification samples in the verification sample set may include target sentence samples and aspect word samples. The verification samples also have corresponding sentiment classification labels, but the sentiment classification labels corresponding to the verification samples are not used as input to the aspect-level sentiment classification model.

[0101] In the embodiments of this specification, a model performance testing system or a corresponding model testing program can be used to test the performance of a trained aspect-level sentiment classification model. Taking the use of a model performance testing system to test the performance of a trained aspect-level sentiment classification model as an example, the model performance testing system can input a verification sample into the trained aspect-level sentiment classification model to obtain the sentiment classification result output by the model. The sentiment classification label corresponding to the obtained verification sample is then compared with the sentiment classification result output by the model to obtain the performance test result of the aspect-level sentiment classification model.

[0102] In practical applications, the performance test results of a model can be reflected through the model's performance evaluation indicators. Model performance evaluation indicators may include: model accuracy (the percentage of the number of targets or events correctly identified by the model to the total number of targets or events effectively identified), model recall (the percentage of the number of targets or events correctly identified by the model to the number of targets or events that should have been identified), and model F1 score.

[0103] Figure 1 The method and Figure 3 In the method presented in [1], the aspect-level sentiment classification model is a multi-layer neural network model composed of multiple single neural network models, such as the BERT model, the bidirectional long short-term memory network model, and the capsule network model. When performing aspect-level sentiment classification tasks, the multi-layer neural network model captures richer semantic features than single neural network models, achieving higher sentiment classification accuracy. Furthermore, the capsule network model is suitable for aspect-level sentiment classification tasks with fewer training samples. By introducing the capsule network model, the classification accuracy of the aspect-level sentiment classification model can be improved even with fewer training samples.

[0104] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 4 The embodiments of this specification provide corresponding Figure 1 A structural diagram of an aspect-level sentiment classification device. The device uses an aspect-level sentiment classification model, which may include: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the device may include:

[0105] The first feature vector generation module 402 is used to use the BERT model to receive the text data to be classified at the target business and output first feature vector data; the text data to be classified is generated based on the target sentences and aspect words of the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified.

[0106] The second feature vector generating module 404 is used to output second feature vector data after receiving the first feature vector data using the bidirectional long short-term memory network model; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified.

[0107] The third feature vector generating module 406 is configured to perform cluster analysis on the second feature vector data using the capsule network model to obtain third feature vector data.

[0108] The output module 408 is configured to utilize the output layer to perform classification processing based on the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0109] based on Figure 4 The present specification also provides some specific implementation plans of the device, which are described below.

[0110] Optionally, the device may further include:

[0111] The target sentence and aspect word acquisition module is used to acquire the target sentence and aspect word of the target business.

[0112] The constructed sentence matching module is used to match the corresponding constructed sentence for the target sentence according to the aspect words.

[0113] The module for generating text data to be classified is used to process the constructed sentence, the target sentence and the aspect words to obtain the text data to be classified at the target business.

[0114] Correspondingly, the constructed sentence matching module may specifically include:

[0115] The aspect word category determination unit is used to determine the aspect word category to which the aspect word belongs based on the aspect word.

[0116] The constructed sentence determining unit is configured to determine, based on the aspect word category, a constructed sentence corresponding to the aspect word category from a preset constructed sentence set.

[0117] The constructed sentence matching unit is used to match the determined constructed sentence corresponding to the aspect word category to the target sentence.

[0118] Correspondingly, the module for generating text data to be classified may specifically include:

[0119] The data splicing unit is used to perform data splicing on the constructed sentence, the target sentence and the aspect words to obtain spliced data.

[0120] The data compensation unit is used to perform data compensation on the spliced data until the data length of the spliced data reaches a preset data length, thereby obtaining the text data to be classified at the target business.

[0121] Figure 5 The embodiments of this specification provide corresponding Figure 3 A structural diagram of a training device for an aspect-level sentiment classification model. The aspect-level sentiment classification model may include: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the device may include:

[0122] The training sample acquisition module 502 is used to obtain a training sample set; a training sample in the training sample set includes a target sentence sample and an aspect word sample of the target business; the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample.

[0123] The model training module 504 is configured to train the initial aspect-level sentiment classification model using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

[0124] based on Figure 5 The present specification also provides some specific implementation plans of the device, which are described below.

[0125] Optionally, the device may further include:

[0126] The verification sample set acquisition module is used to acquire a verification sample set; a verification sample in the verification sample set includes a second target sentence sample and a second aspect word sample of the target business.

[0127] The sentiment classification result determination module is used to input the verification sample in the verification sample set into the trained aspect-level sentiment classification model to obtain the sentiment classification result output by the trained aspect-level sentiment classification model.

[0128] The sentiment classification label acquisition module is used to obtain the sentiment classification label corresponding to the verification sample.

[0129] The performance test result generating module is used to generate the performance test result of the trained aspect-level sentiment classification model according to the sentiment classification label and the sentiment classification result.

[0130] Based on the same idea, the embodiments of this specification also provide devices corresponding to the above methods.

[0131] Figure 6 The embodiments of this specification provide corresponding Figure 1 A structural diagram of an aspect-level sentiment classification device. Figure 6 As shown, the device 600 may include:

[0132] at least one processor 610; and,

[0133] A memory 630 in communication with the at least one processor; wherein,

[0134] The memory 630 stores an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model may include: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the memory 630 further stores instructions 620 executable by the at least one processor 610, wherein the instructions are executed by the at least one processor 610 to enable the at least one processor 610 to:

[0135] The BERT model is used to receive text data to be classified at the target business and output first feature vector data; the text data to be classified is generated based on the target sentences and aspect words of the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified.

[0136] After receiving the first feature vector data using the bidirectional long short-term memory network model, second feature vector data is output; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified.

[0137] The capsule network model is used to perform cluster analysis on the second feature vector data to obtain third feature vector data.

[0138] The output layer is used to perform classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word.

[0139] Figure 7 The embodiments of this specification provide corresponding Figure 3 A structural diagram of an aspect-level sentiment classification model training device. Figure 7 As shown, the device 700 may include:

[0140] at least one processor 710; and,

[0141] A memory 730 in communication with the at least one processor; wherein,

[0142] The memory 730 stores an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model may include: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the memory 730 also stores instructions 720 executable by the at least one processor 710, wherein the instructions are executed by the at least one processor 710 to enable the at least one processor 710 to:

[0143] A training sample set is obtained; a training sample in the training sample set includes a target sentence sample and an aspect word sample of a target business; and the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample.

[0144] The initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

[0145] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 6 and Figure 7 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0146] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0147] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

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

[0149] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0150] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0151] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0152] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0154] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0155] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

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

[0157] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0158] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.

[0159] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.

Claims

1. A method for aspect-level sentiment classification, characterized in that: The method uses an aspect-level sentiment classification model, which includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the method includes: Using the BERT model to receive text data to be classified at a target business, and outputting first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified; After receiving the first feature vector data using the bidirectional long short-term memory network model, outputting second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified; Using the capsule network model, performing cluster analysis on the second feature vector data to obtain third feature vector data; Using the output layer, performing classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word; Before receiving the text data to be classified at the target business by using the BERT model and outputting the first feature vector data, the method further includes: Acquire the target sentence and the aspect words at the target business; Matching corresponding constructed sentences for the target sentence according to the aspect words; Performing data processing on the constructed sentence, the target sentence, and the aspect words to obtain text data to be classified at the target business; Matching a corresponding constructed sentence for the target sentence based on the aspect words specifically includes: According to the aspect word, determining the aspect word category to which the aspect word belongs; According to the aspect word category, determining a constructed sentence corresponding to the aspect word category from a preset constructed sentence set; The determined constructed sentence corresponding to the aspect word category is matched to the target sentence.

2. The method according to claim 1, characterized in that The data processing of the constructed sentence, the target sentence and the aspect words to obtain the text data to be classified at the target business specifically includes: Performing data splicing on the constructed sentence, the target sentence, and the aspect words to obtain spliced data; Data compensation is performed on the spliced data until the data length of the spliced data reaches a preset data length, thereby obtaining the text data to be classified at the target business.

3. The method according to any one of claims 1 to 2, characterized in that The training method of the aspect-level sentiment classification model includes: Acquire a training sample set; wherein a training sample in the training sample set includes a first target sentence sample and a first aspect word sample of a target business; and the label data of the training sample is used to reflect the sentiment classification result of the first target sentence sample corresponding to the first aspect word sample; The initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

4. The method according to claim 3, characterized in that After the initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model, the method further includes: Acquire a verification sample set; wherein a verification sample in the verification sample set includes a second target sentence sample and a second aspect word sample of the target business; For the verification sample in the verification sample set, input the verification sample into the trained aspect-level sentiment classification model to obtain a sentiment classification result output by the trained aspect-level sentiment classification model; Obtain the sentiment classification label corresponding to the verification sample; A performance test result of the trained aspect-level sentiment classification model is generated according to the sentiment classification label and the sentiment classification result.

5. An aspect-level sentiment classification device, characterized in that: The device uses an aspect-level sentiment classification model, which includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the device includes: A first feature vector generation module is configured to receive text data to be classified at a target business using the BERT model and output first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is configured to reflect positional features and local semantic features of each word in the text data to be classified; A second feature vector generating module is configured to receive the first feature vector data using the bidirectional long short-term memory network model and output second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified; A third eigenvector generating module is configured to perform cluster analysis on the second eigenvector data using the capsule network model to obtain third eigenvector data; an output module, configured to utilize the output layer to perform classification processing based on the third eigenvector data to obtain a sentiment classification result corresponding to the aspect word; Before receiving the text data to be classified at the target business by using the BERT model and outputting the first feature vector data, the method further includes: Acquire the target sentence and the aspect words at the target business; Matching corresponding constructed sentences for the target sentence according to the aspect words; Performing data processing on the constructed sentence, the target sentence, and the aspect words to obtain text data to be classified at the target business; Matching a corresponding constructed sentence for the target sentence based on the aspect words specifically includes: According to the aspect word, determining the aspect word category to which the aspect word belongs; According to the aspect word category, determining a constructed sentence corresponding to the aspect word category from a preset constructed sentence set; The determined constructed sentence corresponding to the aspect word category is matched to the target sentence.

6. The device according to claim 5, characterized in that The training device of the aspect-level sentiment classification model includes: A training sample acquisition module is used to acquire a training sample set; one training sample in the training sample set includes a target sentence sample and an aspect word sample of a target business; the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample; The model training module is used to train the initial aspect-level sentiment classification model using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.

7. An aspect-level sentiment classification device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores an aspect-level sentiment classification model, wherein the aspect-level sentiment classification model includes: a BERT model, a bidirectional long short-term memory network model, a capsule network model, and an output layer; wherein the BERT model is connected to the bidirectional long short-term memory network model, the bidirectional long short-term memory network model is connected to the capsule network model, and the capsule network model is connected to the output layer; the memory further stores instructions executable by the at least one processor, wherein the instructions are executed by the at least one processor to enable the at least one processor to: Using the BERT model to receive text data to be classified at a target business, and outputting first feature vector data; the text data to be classified is generated based on a target sentence and aspect words at the target business; the first feature vector data is used to reflect the positional features and local semantic features of each word in the text data to be classified; After receiving the first feature vector data using the bidirectional long short-term memory network model, outputting second feature vector data; the second feature vector data is used to reflect the contextual semantic features of the text data to be classified; Using the capsule network model, performing cluster analysis on the second feature vector data to obtain third feature vector data; Using the output layer, performing classification processing according to the third feature vector data to obtain a sentiment classification result corresponding to the aspect word; Before receiving the text data to be classified at the target business by using the BERT model and outputting the first feature vector data, the method further includes: Acquire the target sentence and the aspect words at the target business; Matching corresponding constructed sentences for the target sentence according to the aspect words; Performing data processing on the constructed sentence, the target sentence, and the aspect words to obtain text data to be classified at the target business; Matching a corresponding constructed sentence for the target sentence based on the aspect words specifically includes: According to the aspect word, determining the aspect word category to which the aspect word belongs; According to the aspect word category, determining a constructed sentence corresponding to the aspect word category from a preset constructed sentence set; The determined constructed sentence corresponding to the aspect word category is matched to the target sentence.

8. The aspect-level sentiment classification device according to claim 7, characterized in that: The at least one processor is further capable of: Acquire a training sample set; wherein a training sample in the training sample set includes a target sentence sample and an aspect word sample of a target business; and the label data of the training sample is used to reflect the sentiment classification result of the target sentence sample corresponding to the aspect word sample; The initial aspect-level sentiment classification model is trained using the training samples in the training sample set to obtain the trained aspect-level sentiment classification model.