Aspect sentiment analysis method and system based on multiple tasks
Through a multi-task interactive network, combining the shared coding layer and the task-specific coding layer, the relationship between aspects of complex sentence structures and opinions in sentiment analysis is handled, which improves the accuracy of judgment of emotional polarity and solves the difficulty of correspondence between aspects and opinions and opinions. A sure question.
Patent Information
- Application Number
- CN202411301841.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-10
AI Technical Summary
In the emotional analysis task of complex sentence structure, the correspondence between aspects and perspective words is difficult to determine, resulting in a low accuracy rate of judging emotional polarity.
Using a multi-task-based aspect sentiment analysis method, the relationship between the context information and words of the text is captured by sharing coding layer, bidirectional LSTM, graph convolutional network, self-attention mechanism and multi-task interaction layer, and realizing aspect words and perspectives Word extraction, relationship recognition and emotional polarity judgment.
Improve the accuracy of the judgment of emotional polarity in aspects, especially in complex sentences and long texts, solves the emotional capture problem that is difficult to deal with by traditional methods, and reduces single-task bias.
Smart Images

Figure CN119293205A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical fields of artificial intelligence, deep learning and sentiment analysis, and in particular to a multi-task based aspect sentiment analysis method and system. Background Art
[0002] Technical solutions related to sentiment analysis (SA) include aspect sentiment analysis (ABSA), aspect category sentiment analysis (ACSA), aspect extraction (AE), aspect sentiment classification (ASC), sequence labeling, text classification, etc. Traditional ABSA models usually rely on manually designed features or single-task models, ignoring the inherent connection between tasks and making it difficult to fully utilize contextual information, especially when faced with complex sentence structures.
[0003] Through the above analysis, the problems and defects of the existing technology are: in the current complex sentence aspect sentiment analysis tasks, it is difficult to determine the correspondence between aspects and opinion words, resulting in a low accuracy rate in the final aspect sentiment polarity judgment. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the disclosed embodiment of the present invention provides a multi-task-based aspect sentiment analysis method and system, and the technical solution is as follows:
[0005] The present invention is implemented in this way, based on a multi-task aspect sentiment analysis method, comprising:
[0006] S1, input sentence after noise cleaning;
[0007] S2, processed by the shared encoding layer, generates the contextual embedding of the sentence;
[0008] S3, uses bidirectional LSTM and conditional random fields to capture the sequential dependency information of text and perform sequence labeling;
[0009] S4, uses graph convolutional networks to process the relationship between aspect words and evaluation words, and models the graph structure dependency between words;
[0010] S5, adopts the self-attention mechanism to capture the contextual information related to aspect words from the shared features for sentiment polarity judgment;
[0011] S6, through the multi-task interaction layer, realizes the information flow and feature sharing between different tasks;
[0012] S7 realizes aspect and opinion word extraction, aspect and opinion word relationship output, and sentiment polarity output.
[0013] In step S1, noise cleaning includes special character data and URL data.
[0014] In step S2, the context embedding of the sentence is generated after being processed by the shared encoding layer, including: using a pre-trained BERT model as a shared encoder to convert the input text into a high-dimensional context representation, and the shared encoder extracts common semantic features to provide a basic representation for subsequent tasks.
[0015] Furthermore, a task encoder layer is built on top of the shared encoder, and three task-specific encoders are designed to handle the specific needs of three major tasks: extraction of aspect words and evaluation words, classification of the correspondence between aspect words and evaluation words, and judgment of the sentiment polarity of aspect words.
[0016] In step S3, a bidirectional LSTM and CRF structure is used to capture the sequential dependency information of the text and implement sequence labeling of aspect words and evaluation words;
[0017] Bidirectional LSTM is suitable for sequence labeling tasks and captures global context information. Given an input sequence x = {x1, x2…x T}, where T is the sequence length; the hidden state generated by the forward LSTM is The hidden state generated by the backward LSTM is The output of the bidirectional LSTM is At each time step t, the forward and backward hidden states are concatenated, and the CRF layer learns a transfer matrix that represents the scores of transitions from one label to the next; these scores reflect the likelihood of different label combinations, and the output h of the LSTM t After being converted into a label score for each time step by the fully connected layer, these scores are used together with the transfer score to calculate the score of the entire sequence; after being decoded by the CRF layer, the model outputs the optimal label sequence. For the aspect word and evaluation word extraction tasks, these labels usually include: start B, internal I and external O annotations.
[0018] In step S4, the graph convolutional network (GCN) is used to process the relationship between aspect words and evaluation words, and the graph structure dependency relationship between words is modeled;
[0019] The graph convolutional network (GCN) is used to process the relationship between aspect words and evaluation words, model the graph structure dependency between words, regard the words in the input sequence as nodes of the graph, and the relationship between words as edges of the graph. This graph structure directly captures the dependency and contextual information between words. The structure of the graph is represented by an adjacency matrix, and each element of the matrix represents the connection relationship or weight between two nodes. GCN propagates and updates the representation of nodes through these connections.
[0020] GCN aggregates the representations of adjacent nodes with the representation of the central node through graph convolution operations to generate new node representations. This convolution operation is usually repeated in multiple graph convolution layers to gradually expand the receptive field of each node and capture richer relational information. Given an input embedding H (0) =X and the adjacency matrix A, the graph convolution operation of the lth layer is expressed as:
[0021] H (l+1) =σ(AH (l) W (l) )
[0022] Among them, W l is the weight matrix of the lth layer, σ is the nonlinear activation function ReLU, H (l) is the node representation of the lth layer.
[0023] In step S5, the self-attention mechanism is used to capture the contextual information related to the aspect words from the shared features for sentiment polarity judgment. The input of the sentiment polarity task encoder is the context embedding vectors generated from the shared encoder layer. These vectors represent the contextual information of each word in the input sentence. In order to focus on the sentiment polarity classification of a specific aspect word, it is necessary to determine which word or phrase in the sentence is the target aspect word. The position information of the aspect word will be used as a reference in subsequent processing. In order to accurately predict the sentiment polarity, the model focuses on the context part related to the aspect word. Through the attention mechanism, the model can dynamically weight the influence of different words in the sentence and highlight those words that have an important influence on the sentiment polarity. Given the context embedding h of an aspect word, a and the overall embedding vector H = {h1,h2,…,h T}, attention weight a i Obtained by calculating the correlation between the aspect word and each word:
[0024]
[0025] Among them, W a is a learnable weight matrix;
[0026] Use the attention weight to perform weighted summation on the representation of each word in the sentence to obtain the context representation h related to the aspect word c :
[0027]
[0028] This weighted representation can better capture the sentiment information associated with aspect words.
[0029] In step S6, the information flow and feature sharing between different tasks are realized through the multi-task interaction layer, including:
[0030] Inter-task attention interaction module: The output of each task-specific encoder passes through an attention module to selectively absorb key information from other tasks, thereby improving the feature expression capability of each task.
[0031] Information gating mechanism: A gating unit is introduced to control the amount of information received from other tasks to prevent interference from irrelevant information.
[0032] Bidirectional feature flow: A bidirectional feature flow mechanism is designed between the sequence labeling task and the relationship classification task to ensure the close connection between the extraction of aspect words and evaluation words and their corresponding relationship classification.
[0033] Furthermore, a dynamic task weight adjustment module is used to automatically adjust the weight λ of each task loss function according to the task performance during training to optimize the model training effect.
[0034] In step S7, aspect and opinion word extraction, aspect and opinion word relationship output, and sentiment polarity output are implemented, including: through joint training of multi-task encoders, the loss function combines the losses of all tasks and simultaneously updates the model parameters through back propagation; for these three task encoders, the following loss function is defined:
[0035] Sequence labeling loss L for aspect word and evaluation word extraction sequence
[0036]
[0037] in, Given an input x i After that, the model generates the real annotation sequence The probability of
[0038] The classification loss L of the correspondence between aspect words and evaluation words relation ;
[0039] For the relation classification task, the standard cross entropy loss is used; let the actual relation label for sample i be The relationship predicted by the model is y i , the loss function is expressed as:
[0040]
[0041] Where C is the number of relationship categories, is the true label of sample i in category j, P(y i,j ) is the probability of category j predicted by the model;
[0042] The loss of sentiment polarity judgment of aspect words L polarity ;
[0043] The sentiment polarity judgment task is a multi-classification task, which is measured by cross entropy loss. There are K types of sentiment polarity: positive, negative, and neutral. The actual polarity label is The model predicts a polarity of y i , the loss function is:
[0044]
[0045] in, is the true label of sample i in polarity category k, P(y i,k ) is the probability of category k predicted by the model;
[0046] The final total loss function is the weighted sum of the losses of each task:
[0047] L total =λ1L sequence +λ2L relation +λ3L polarity
[0048] Where λ1λ2λ3 is the weight of the corresponding task loss, which is adjusted according to the importance of the task or the performance of the model.
[0049] Another object of the present invention is to provide a multi-task-based aspect sentiment analysis system, which is used to regulate the multi-task-based aspect sentiment analysis method, and the system includes:
[0050] Aspect and opinion word extraction module, used to extract aspect and evaluation words from noise-cleaned sentences;
[0051] Aspect and opinion word combination module, used to combine all aspects extracted from the sentence with the evaluation words to obtain a tuple;
[0052] A module for identifying the correspondence between aspects and opinion words, which is used to input tuples into the relational classifier, determine whether the aspects and the evaluation words belong to a corresponding relationship, and finally find out the paired aspects and evaluation words;
[0053] The aspect sentiment classification module is used to input the sentence and aspect-evaluation words into the aspect sentiment classifier at the same time, and finally predict the sentiment polarity of the aspect in the sentence.
[0054] In combination with all the above-mentioned technical solutions, the advantages and positive effects of the present invention are as follows: the multi-task-based aspect sentiment analysis method provided by the present invention introduces a multi-task hierarchical interaction network. This method can dynamically adjust the weights of each task according to the performance in the training process through a task-specific coding layer and a multi-task interaction layer, as well as a dynamic task weight adjustment mechanism on the basis of a shared coding layer, so as to better balance the difficulty and contribution between tasks, and realize deep information sharing and collaborative optimization between different tasks. This structure can improve the performance of each task, especially in the case of data scarcity or strong task correlation, and improve the accuracy of sentence sentiment polarity recognition.
[0055] The multi-task aspect sentiment analysis method of the present invention includes three subtasks: aspect and opinion word extraction, aspect and opinion word correspondence recognition, and aspect sentiment classification. The method focuses on adding aspect and opinion word correspondence recognition on the basis of aspect and opinion word extraction, and adopts a combined training method to train the model to improve the accuracy of aspect and opinion word correspondence recognition. Therefore, the present invention solves the problem that the correspondence between aspect and opinion word is difficult to determine in complex sentence aspect sentiment analysis tasks, thereby improving the accuracy of aspect sentiment polarity judgment.
[0056] The advantages of the present invention are also reflected in the following important aspects:
[0057] First, the accuracy is improved. By sharing encoders and joint training, the model can share knowledge between multiple tasks, thereby improving the accuracy of each task. Especially in tasks such as aspect word and evaluation word extraction, relationship classification, and sentiment polarity determination, since the model can utilize feedback information from multiple tasks, the expected model accuracy will be significantly higher than that of a single-task model. Secondly, it has scene applicability. The model can adapt to a variety of scenarios, including but not limited to product review analysis, social media management, customer feedback management, etc. Regardless of the source, content, or language structure of the text data, the model can optimize its performance by training different data sets, making it suitable for different industries and application scenarios.
[0058] Secondly, the innovative application of multi-task joint learning. Currently, most sentiment analysis algorithms are designed for a single task. For example, tasks such as aspect extraction and sentiment polarity classification are usually performed separately. This model integrates the three tasks of aspect word and evaluation word extraction, relationship classification, and sentiment polarity determination into one framework. By sharing encoders and joint training, the model can effectively utilize the correlation between different tasks, thereby improving overall performance. This multi-task joint learning strategy is still a relatively new application direction in the field of sentiment analysis at home and abroad, filling the technical gap in multi-task integration.
[0059] Again, aspect sentiment analysis (ABSA) requires the model to accurately identify aspect words and corresponding sentiment expressions in complex sentences. This is especially difficult for long texts, implicit relationships, and complex sentences. Traditional methods usually perform poorly in complex situations and cannot accurately capture subtle sentiment information. The present invention utilizes a combination of attention mechanism and LSTM to better focus on sentiment expressions related to aspect words, thereby maintaining high accuracy in complex sentences and long texts. This method significantly improves the accuracy of aspect sentiment analysis and solves the problem of sentiment capture that is difficult to handle in traditional methods.
[0060] Finally, single-task bias is reduced. Through multi-task joint learning, the model can handle multiple related tasks simultaneously during training, including the extraction of aspect words and evaluation words, relationship classification, and sentiment polarity determination. This joint learning method helps the model share information between tasks, avoiding overfitting of the model on a single task, thereby reducing the generation of bias. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure;
[0062] Figure 1 is a flow chart of a multi-task-based aspect sentiment analysis method provided by an embodiment of the present invention;
[0063] Figure 2 This is a multi-task hierarchical interactive network architecture diagram of the multi-task-based aspect sentiment analysis method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific implementation disclosed below.
[0065] The present invention introduces a multi-task hierarchical interactive network. Based on the shared coding layer, the method can dynamically adjust the weight of each task according to the performance in the training process through the task-specific coding layer and the multi-task interactive layer, as well as the dynamic task weight adjustment mechanism, so as to better balance the difficulty and contribution between tasks and realize deep information sharing and collaborative optimization between different tasks. This structure can improve the performance of each task, especially when data is scarce or the task correlation is strong. The method includes the following steps:
[0066] S1, input sentence after noise cleaning;
[0067] S2, processed by the shared encoding layer, generates the contextual embedding of the sentence;
[0068] S3, uses bidirectional LSTM and conditional random fields to capture the sequential dependency information of text and perform sequence labeling;
[0069] S4, uses graph convolutional networks to process the relationship between aspect words and evaluation words, and models the graph structure dependency between words;
[0070] S5, adopts the self-attention mechanism to capture the contextual information related to aspect words from the shared features for sentiment polarity judgment;
[0071] S6, through the multi-task interaction layer, realizes the information flow and feature sharing between different tasks;
[0072] S7 realizes aspect and opinion word extraction, aspect and opinion word relationship output, and sentiment polarity output.
[0073] The multi-task aspect sentiment analysis method of the present invention includes three subtasks: aspect and opinion word extraction, aspect and opinion word correspondence recognition, and aspect sentiment classification. The method focuses on adding aspect and opinion word correspondence recognition on the basis of aspect and opinion word extraction, and adopts a combined training method to train the model to improve the accuracy of aspect and opinion word correspondence recognition. Therefore, the present invention solves the problem that the correspondence between aspect and opinion word is difficult to determine in complex sentence aspect sentiment analysis tasks, thereby improving the accuracy of aspect sentiment polarity judgment.
[0074] As a preference, Figure 2 As shown, the multi-task-based aspect sentiment analysis method provided by an embodiment of the present invention specifically includes the following steps:
[0075] 1. Clean noise data including special characters and URLs.
[0076] 2. Use the pre-trained BERT model as a shared encoder to convert the input text into a high-dimensional contextual representation. The shared encoder is responsible for extracting common semantic features and providing basic representations for subsequent tasks.
[0077] 3. Use bidirectional LSTM and CRF structures to capture the sequential dependency information of text and implement sequence labeling of aspect words and evaluation words;
[0078] Bidirectional LSTM is suitable for sequence labeling tasks and captures global context information. Given an input sequence x = {x1, x2…x T}, where T is the sequence length; the hidden state generated by the forward LSTM is The hidden state generated by the backward LSTM is The output of the bidirectional LSTM is At each time step t, the forward and backward hidden states are concatenated, and the CRF layer learns a transfer matrix that represents the scores of transitions from one label to the next; these scores reflect the likelihood of different label combinations, and the output h of the LSTM t After being converted into a label score for each time step by the fully connected layer, these scores are used together with the transfer score to calculate the score of the entire sequence; after being decoded by the CRF layer, the model outputs the optimal label sequence. For the aspect word and evaluation word extraction tasks, these labels usually include: start B, internal I and external O annotations.
[0079] 4. Use graph convolutional networks (GCN) to process the relationship between aspect words and evaluation words, and model the graph structure dependency between words. The words in the input sequence are regarded as nodes of the graph, and the relationship between words is regarded as the edges of the graph. This graph structure can directly capture the dependency and contextual information between words. The structure of the graph is usually represented by an adjacency matrix. Each element of the matrix represents the connection relationship or weight between two nodes (words). GCN propagates and updates the representation of the nodes through these connections. GCN aggregates the representation of adjacent nodes with the representation of the central node through graph convolution operations to generate new node representations. This convolution operation is usually repeated in multiple graph convolution layers to gradually expand the receptive field of each node and capture richer relationship information. Given the input embedding H (0) =X and the adjacency matrix A, the graph convolution operation of the lth layer can be expressed as:
[0080] H (l+1) =σ(AH (l) W (l) )
[0081] Among them, W l is the weight matrix of the lth layer, σ is the nonlinear activation function ReLU, H (l) is the node representation of the lth layer.
[0082] 5. Use the self-attention mechanism to capture contextual information related to aspect words from shared features for sentiment polarity judgment. The input of the sentiment polarity task encoder is the context embedding vectors generated from the shared encoder layer. These vectors represent the contextual information of each word in the input sentence. In order to focus on the sentiment polarity classification of a specific aspect word, it is necessary to determine which word or phrase in the sentence is the target aspect word. The position information of the aspect word will be used as a reference in subsequent processing. In order to accurately predict sentiment polarity, the model needs to focus on the contextual part related to the aspect word. Through the attention mechanism, the model can dynamically weight the influence of different words in the sentence and highlight those words that have an important impact on sentiment polarity. Given the context embedding h of an aspect worda and the overall embedding vector H = {h1,h2,…,h T}, attention weight a i It can be obtained by calculating the correlation between the aspect word and each word:
[0083]
[0084] Among them, W a is a learnable weight matrix.
[0085] Use the attention weight to perform weighted summation on the representation of each word in the sentence to obtain the context representation h related to the aspect word c :
[0086]
[0087] This weighted representation can better capture the sentiment information associated with aspect words.
[0088] 6. Through innovative multi-task interaction mechanisms, information flow and feature sharing between different tasks are realized, including:
[0089] Inter-task attention interaction module: The output of each task-specific encoder passes through an attention module to selectively absorb key information from other tasks, thereby improving the feature expression capability of each task.
[0090] Information gating mechanism: A gating unit is introduced to control the amount of information received from other tasks to prevent interference from irrelevant information.
[0091] Bidirectional feature flow: A bidirectional feature flow mechanism is designed between the sequence labeling task and the relationship classification task to ensure the close connection between the extraction of aspect words and evaluation words and their corresponding relationship classification.
[0092] 7. Through joint training of multi-task encoders, the loss function combines the losses of all tasks and updates the model parameters simultaneously through back propagation. For these three task encoders, the following loss function can be defined:
[0093] Sequence labeling loss L for aspect word and evaluation word extraction sequence
[0094]
[0095] in, Given an input x i After that, the model generates the real annotation sequence probability.
[0096] The classification loss L of the correspondence between aspect words and evaluation words relation;
[0097] For the relation classification task, the standard cross entropy loss is used. Assume that for sample i, the actual relation label is The relationship predicted by the model is y i , the loss function can be expressed as:
[0098]
[0099] Where C is the number of possible relationship categories, is the true label of sample i in category j, P(y i,j ) is the probability of class j predicted by the model.
[0100] The loss of sentiment polarity judgment of aspect words L polarity
[0101] The sentiment polarity judgment task is a multi-classification task, which is measured by cross entropy loss. There are K possible categories of sentiment polarity (positive, negative, neutral), and the actual polarity label is The model predicts a polarity of y i , the loss function is:
[0102]
[0103] in, is the true label of sample i in polarity category k, P(y i,k ) is the probability of class k predicted by the model.
[0104] The final total loss function is the weighted sum of the losses of each task:
[0105] L total =λ1L sequence +λ2L relation +λ3L polarity
[0106] Among them, λ1λ2λ3 are the weights corresponding to the task loss, which can be adjusted according to the importance of the task or the performance of the model.
[0107] The multi-task aspect sentiment analysis method of the present invention includes three subtasks: aspect and opinion word extraction, aspect and opinion word correspondence recognition, and aspect sentiment classification. The method focuses on adding aspect and opinion word correspondence recognition on the basis of aspect and opinion word extraction, and adopts a combined training method to train the model to improve the accuracy of aspect and opinion word correspondence recognition. Therefore, the present invention solves the problem that the correspondence between aspect and opinion word is difficult to determine in complex sentence aspect sentiment analysis tasks, thereby improving the accuracy of aspect sentiment polarity judgment.
[0108] The multi-task aspect sentiment analysis system provided by the embodiment of the present invention includes:
[0109] Aspect and opinion word extraction module, used to extract aspect and evaluation words from noise-cleaned sentences;
[0110] Aspect and opinion word combination module, used to combine all aspects extracted from the sentence with the evaluation words to obtain a tuple;
[0111] A module for identifying the correspondence between aspects and opinion words, which is used to input tuples into the relational classifier, determine whether the aspects and the evaluation words belong to a corresponding relationship, and finally find out the paired aspects and evaluation words;
[0112] The aspect sentiment classification module is used to input the sentence and aspect-evaluation words into the aspect sentiment classifier at the same time, and finally predict the sentiment polarity of the aspect in the sentence.
[0113] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0114] Since the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present invention, their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0115] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment.
[0116] According to an embodiment of the present application, the present invention also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0117] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0118] An embodiment of the present invention further provides an information data processing terminal, which, when executed on an electronic device, provides a user input interface to implement the steps in the above method embodiments. The information data processing terminal is not limited to mobile phones, computers, and switches.
[0119] An embodiment of the present invention further provides a server, which is used to provide a user input interface to implement the steps in the above method embodiments when executed on an electronic device.
[0120] An embodiment of the present invention further provides a computer program product. When the computer program product is run on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0122] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0123] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered within the protection scope of the present invention.
Claims
1. A multi-task based aspect sentiment analysis method, characterized in that: The method includes: S1, input sentence after noise cleaning; S2, processed by the shared encoding layer, generates the contextual embedding of the sentence; S3, uses bidirectional LSTM and conditional random fields to capture the sequential dependency information of text and perform sequence labeling; S4, uses graph convolutional networks to process the relationship between aspect words and evaluation words, and models the graph structure dependency between words; S5, adopts the self-attention mechanism to capture the contextual information related to aspect words from the shared features for sentiment polarity judgment; S6, through the multi-task interaction layer, realizes the information flow and feature sharing between different tasks; S7 realizes aspect and opinion word extraction, aspect and opinion word relationship output, and sentiment polarity output.
2. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S1, noise cleaning includes special character data and URL data.
3. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S2, the context embedding of the sentence is generated after being processed by the shared encoding layer, including: using a pre-trained BERT model as a shared encoder to convert the input text into a high-dimensional context representation, and the shared encoder extracts common semantic features to provide a basic representation for subsequent tasks.
4. The multi-task based aspect sentiment analysis method according to claim 3, characterized in that: A task encoder layer is built on top of the shared encoder, and three task-specific encoders are designed to handle the specific needs of three major tasks: extraction of aspect words and evaluation words, classification of the correspondence between aspect words and evaluation words, and judgment of the sentiment polarity of aspect words.
5. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S3, a bidirectional LSTM and CRF structure is used to capture the sequential dependency information of the text and implement sequence labeling of aspect words and evaluation words; Bidirectional LSTM is suitable for sequence labeling tasks and captures global context information. Given an input sequence x = {x1, x2…x T }, where T is the sequence length; the hidden state generated by the forward LSTM is The hidden state generated by the backward LSTM is The output of the bidirectional LSTM is At each time step t, the forward and backward hidden states are concatenated, and the CRF layer learns a transfer matrix that represents the scores of transitions from one label to the next; these scores reflect the likelihood of different label combinations, and the output h of the LSTM t After being converted into label scores for each time step by the fully connected layer, these scores are used together with the transfer scores to calculate the score of the entire sequence; after being decoded by the CRF layer, the model outputs the optimal label sequence; for aspect word and evaluation word extraction tasks, these labels usually include: start B, internal I and external O annotations.
6. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S4, the graph convolutional network (GCN) is used to process the relationship between aspect words and evaluation words, and the graph structure dependency relationship between words is modeled; The words in the input sequence are regarded as nodes of the graph, and the relationship between words is regarded as the edge of the graph. This graph structure directly captures the dependency and contextual information between words. The structure of the graph is represented by an adjacency matrix. Each element of the matrix represents the connection relationship or weight between two nodes. GCN propagates and updates the representation of nodes through these connections. GCN aggregates the representations of adjacent nodes with the representation of the central node through graph convolution operations to generate new node representations. This convolution operation is usually repeated in multiple graph convolution layers to gradually expand the receptive field of each node and capture richer relational information. Given an input embedding H (0) =X and the adjacency matrix A, the graph convolution operation of the lth layer is expressed as: l (l+1) =σ(AH (l) W (l) ) Among them, W l is the weight matrix of the lth layer, σ is the nonlinear activation function ReLU, H (l) is the node representation of the lth layer.
7. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S5, the self-attention mechanism is used to capture the contextual information related to the aspect words from the shared features for sentiment polarity judgment. The input of the sentiment polarity task encoder is the context embedding vectors generated from the shared encoder layer. These vectors represent the contextual information of each word in the input sentence. In order to focus on the sentiment polarity classification of a specific aspect word, it is necessary to determine which word or phrase in the sentence is the target aspect word. The position information of the aspect word will be used as a reference in subsequent processing. In order to accurately predict the sentiment polarity, the model focuses on the context part related to the aspect word. Through the attention mechanism, the model can dynamically weight the influence of different words in the sentence and highlight those words that have an important influence on the sentiment polarity. Given the context embedding h of an aspect word, a and the overall embedding vector H = {h1,h2,…,h T }, attention weight a i Obtained by calculating the correlation between the aspect word and each word: Among them, W a is a learnable weight matrix; Use the attention weight to perform weighted summation on the representation of each word in the sentence to obtain the context representation h related to the aspect word c : This weighted representation can better capture the sentiment information associated with aspect words.
8. The multi-task based aspect sentiment analysis method according to claim 1, characterized in that: In step S6, the information flow and feature sharing between different tasks are realized through the multi-task interaction layer, including: Inter-task attention interaction module: The output of each task-specific encoder passes through an attention module to selectively absorb key information from other tasks, thereby improving the feature expression ability of each task; Information gating mechanism: A gating unit is introduced to control the amount of information received from other tasks to prevent interference from irrelevant information; Bidirectional feature flow: A bidirectional feature flow mechanism is designed between the sequence labeling task and the relationship classification task to ensure the close connection between the extraction of aspect words and evaluation words and their corresponding relationship classification; A dynamic task weight adjustment module is used to automatically adjust the weight λ of each task loss function according to the task performance during training to optimize the model training effect.
9. The multi-task based aspect sentiment analysis method according to claim 8, characterized in that: In step S7, aspect and opinion word extraction, aspect and opinion word relationship output, and sentiment polarity output are implemented, including: through joint training of multi-task encoders, the loss function combines the losses of all tasks and simultaneously updates the model parameters through back propagation; for these three task encoders, the following loss function is defined: Sequence labeling loss L for aspect word and evaluation word extraction sequence in, Given an input x i After that, the model generates the real annotation sequence probability; The classification loss L of the correspondence between aspect words and evaluation words relation ; For the relation classification task, the standard cross entropy loss is used; let the actual relation label for sample i be The relationship predicted by the model is y i , the loss function is expressed as: Where C is the number of relationship categories, is the true label of sample i in category j, P(y i,j ) is the probability of category j predicted by the model; The loss of sentiment polarity judgment of aspect words L polarity ; The sentiment polarity judgment task is a multi-classification task, which is measured by cross entropy loss. There are K types of sentiment polarity: positive, negative, and neutral. The actual polarity label is The model predicts a polarity of y i , the loss function is: in, is the true label of sample i in polarity category k, P(y i,k ) is the probability of category k predicted by the model; The final total loss function is the weighted sum of the losses of each task: L total =λ1L sequence +λ2L relation +λ3L polarity Where λ1λ2λ3 are the weights of the corresponding task loss, which are adjusted according to the importance of the task or the performance of the model.
10. A multi-task based aspect sentiment analysis system, characterized in that: The system is used to regulate the multi-task-based aspect sentiment analysis method according to any one of claims 1 to 9, and the system comprises: Aspect and opinion word extraction module, used to extract aspect and evaluation words from noise-cleaned sentences; Aspect and opinion word combination module, used to combine all aspects extracted from the sentence with the evaluation words to obtain a tuple; A module for identifying the correspondence between aspects and opinion words, which is used to input tuples into the relational classifier, determine whether the aspects and the evaluation words belong to a corresponding relationship, and finally find out the paired aspects and evaluation words; The aspect sentiment classification module is used to input the sentence and aspect-evaluation words into the aspect sentiment classifier at the same time, and finally predict the sentiment polarity of the aspect in the sentence.
Citation Information
Cited By
Multi-task language processing model training method and device and related equipment
CN120598061A