Aspect-level sentiment analysis method based on multiple grammar and multiple frequencies
By combining the full-chain graph convolutional neural network and the semantic graph multi-frequency propagation network with the multi-head attention mechanism and the dynamic fusion mechanism, the problem of the existing methods failing to fully integrate multi-grammatical information and vocabulary frequency is solved, and the accuracy and performance of aspect-level sentiment analysis are improved.
Patent Information
- Application Number
- CN202510960156.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-07-11
AI Technical Summary
Existing aspect-level sentiment analysis methods fail to fully integrate multi-grammatical information and lexical frequency information, resulting in inaccurate sentiment judgment and failing to effectively utilize the dominance of different grammatical structures or feature paths, affecting model performance.
A full-chain graph convolutional neural network and a semantic graph multi-frequency propagation network are combined with a multi-head attention mechanism and a dynamic fusion mechanism to construct a multi-grammar and multi-frequency aspect-level sentiment analysis method. Through semantic role labeling and abstract semantic representation, low-pass filters and high-pass filters are designed to adaptively aggregate messages of different frequencies, dynamically fuse grammatical feature representations, and improve sentiment analysis performance.
It achieves more stable extraction of key semantic features, enhances the ability to capture complex emotional expressions, and improves the accuracy and generalization ability of aspect-level sentiment analysis.
Smart Images

Figure CN120805937A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application provides an aspect-level sentiment analysis method based on multi-grammar and multi-frequency, and belongs to the technical field of aspect-level sentiment analysis. BACKGROUND
[0002] Internet has become a component of various fields of society, and a large amount of data with emotional color is generated on social network media and online portals every day, which covers books, characters, hotels, restaurants and other fields, and contains huge commercial and social value. Research shows that consumers are more inclined to trust comments and ratings from strangers before purchasing products or services, and in their subconscious, they are more willing to purchase goods or services with a large number of positive evaluations. Therefore, it is particularly important to use sentiment analysis technology to mine aspect words and emotional polarity from a large amount of comment data.
[0003] Aspect-level sentiment analysis (also known as fine-grained sentiment analysis) is a deep and detailed sentiment analysis task, and its core goal is to accurately identify aspect words in comment text and classify their emotional tendencies. Traditional aspect-level sentiment analysis methods mainly rely on feature engineering to train traditional machine learning classifiers, and the performance of such methods is heavily dependent on handcrafted features, which consumes a large amount of human and material resources. In recent years, with the rapid development of neural network technology, deep neural networks have achieved remarkable results in many application fields. In this context, the research of aspect-level sentiment analysis has also experienced a transition from traditional methods relying on feature engineering to deep learning methods. At present, deep learning-based models can be mainly summarized as follows: methods based on recurrent neural networks (RNN), methods based on convolutional neural networks (CNN), methods introducing attention mechanisms, methods using pre-trained models, and methods based on graph neural networks. These methods each have unique advantages and have shown great potential in the field of aspect-level sentiment analysis.
[0004] The above methods have been widely applied in aspect-level sentiment analysis, but most of the work has not considered incorporating multi-grammar information such as dependency structure, semantic role labeling, abstract semantic representation, etc. into the aspect-level sentiment analysis task. Only a few works have considered dependency tree and constituent tree structure information, and these works have the following shortcomings:
[0005] (1) Only pay attention to single syntax structure information, without considering the fusion effect of multiple syntax representations. The influence of different label information in semantic role labeling and abstract semantic representation on aspect-level sentiment analysis performance is different. Semantic role labeling identifies the semantic role of each component in the sentence (such as agent, patient, time, etc.), helps the model to accurately locate the dependency relationship between aspect words and sentiment words, and reduces the misjudgment caused by syntactic ambiguity; Abstract semantic representation integrates the core semantic relationship of the sentence (such as action, state, cause and effect) in the form of a graph structure, and captures the deep semantics beyond the syntax structure. This global semantic perspective enhances the context relevance, especially in dealing with implicit sentiment or complex sentence, which can more stably extract key semantic features.
[0006] (2) The guiding role of word frequency information is ignored, resulting in inaccurate sentiment judgment. Different frequency words can form unique semantic patterns, providing important basis for sentiment polarity judgment. If this dimension is ignored, the model may misjudge when dealing with complex emotional expressions or ambiguous words, weaken the ability to capture context sensitivity, and ultimately affect the accuracy of the analysis results.
[0007] (3) The dominant position of different syntax structures or feature paths is not fully utilized, and the representations obtained by different paths are not dynamically fused, resulting in a decline in model performance. Different syntax structures or feature paths have significant differences in their contribution to sentiment judgment in different scenarios, but existing methods usually assume that the contribution of all paths is equal, or statically select a fixed path as the dominant one, which limits the model's ability to capture complex emotional expressions. SUMMARY
[0008] To solve the technical problems in the background art, the technical solution adopted by the present application is to provide an aspect-level sentiment analysis method based on multiple syntax and multiple frequency, which includes the following analysis steps:
[0009] Step 1: Use a pre-trained general domain embedding method to obtain a general embedding representation of a single word as the final embedding representation of a sentence;
[0010] Step 2: Use the Mamba model to obtain the long-distance dependency relationship between each word as further representation of the sentence;
[0011] Step 3: Use a fully connected graph convolutional neural network to capture semantic information and dependency relationships in the text, including:
[0012] Step 3.1: Construct a fully connected semantic graph and perform random edge pruning;
[0013] Step 3.2: Further extract semantic information and dependency relationships using a graph convolutional neural network;
[0014] Step 4: Constructing a semantic graph multi-frequency propagation network to realize semantic role and abstract semantic coding, including:
[0015] Step 4.1: Combining semantic role labeling with abstract semantic representation and multi-frequency propagation to construct semantic role graph coding;
[0016] Step 4.2: Designing low-pass and high-pass filters to filter signals from node features;
[0017] Step 4.3: Using filters to adaptively aggregate messages with different frequencies, and then gradually distribute multi-frequency information on the graph, with each node receiving multi-frequency signals from K-hop neighbors, ultimately obtaining multi-frequency representation, realizing semantic graph coding of sentences;
[0018] Step 5: Using alignment operations to convert full-chain graph coding and semantic coding to a unified feature space, including:
[0019] Step 5.1: Using a multi-head attention mechanism to enhance the feature representation of full-chain graph coding and semantic graph coding, and then converting them to a unified feature space;
[0020] Step 5.2: Using a mean square error loss function to measure the alignment of the two in the unified feature space;
[0021] Step 6: Using a dynamic fusion mechanism to construct the final sentence representation, including:
[0022] Step 6.1: Using full-chain graph coding and semantic graph coding to construct dynamic fusion weights;
[0023] Step 6.2: Using dynamic fusion weights to realize the fusion of full-chain graph coding and semantic graph coding, and constructing the final sentence representation;
[0024] Step 7: Generating a sentiment probability distribution through a softmax function;
[0025] Step 8: Constructing a corresponding loss function to realize model training.
[0026] The specific method of step 1 is:
[0027] Using BERT embedding method to realize word embedding representation , where the general domain vector representation of the word is , and is taken as the word vector representation , then the sentence comment representation is .
[0028] The specific method of step 2 is:
[0029] First, the sentence is commented Projection and separation are performed, and then one-dimensional convolution processing is performed, and the calculation formula of the processing is:
[0030] ;
[0031] ;
[0032] wherein, represents a gating signal, represents an input projection matrix, represents a SiLU activation function;
[0033] Subsequently, is input into the SSM module for processing, and the calculation formula adopted for processing is:
[0034] ;
[0035] ;
[0036] ;
[0037] ;
[0038] ;
[0039] ;
[0040] ;
[0041] ;
[0042] ;
[0043] ;
[0044] wherein, is a time step parameter, represents an input projection matrix, represents an element-level multiplication, represents an output projection matrix, , , , is a parameter matrix of each layer, represents a sequence length, is a learnable residual connection coefficient;
[0045] The result obtained by processing the SSM module is input into the gating mechanism:
[0046] ;
[0047] Finally, the output result is obtained:
[0048] ;
[0049] wherein, is an output projection matrix;
[0050] The output sentence representation is defined as .
[0051] The specific method of step 3.1 is:
[0052] Based on the sentence representation output by step 2, an adjacency matrix of a fully connected graph is constructed , wherein represents the edge weight between node i and node j, and the edge weight is determined by calculating the similarity between word vectors, and the calculation formula is:
[0053] ;
[0054] Random edge pruning is performed on the fully connected graph, and a mask matrix M with the same dimension as the adjacency matrix A is randomly generated, wherein each element is set to 0 with a probability of p, and otherwise 1, and the pruned adjacency matrix is:
[0055] ;
[0056] wherein, represents element-wise multiplication;
[0057] Using a normalized weighted sum method based on the adjacency matrix, the pruned adjacency matrix is converted into node representation , and for each node i, its new element representation is:
[0058] ;
[0059] wherein, is the element in the i-th row and j-th column of the pruned adjacency matrix , representing the edge weight between node i and node j, and the representation of all nodes is composed into a matrix , and the expression is:
[0060] .
[0061] The specific method of step 3.2 is:
[0062] The node representation is obtained by using a graph convolutional neural network , the expression is:
[0063] ;
[0064] wherein, are the weights and bias of learning, respectively;
[0065] The expression of the sentence is obtained as:
[0066] .
[0067] The specific method of step 4 is:
[0068] Step 4.1: Combine semantic role labeling and abstract semantic representation to build semantic graph, including:
[0069] The sentence comment is analyzed by semantic role labeling and abstract semantic representation, and then the semantic graph is constructed ;
[0070] wherein, is a set of words, represented as {f i}, including entity nodes and abstract semantic nodes, all of which are words;
[0071] is a set of edges, which is a SRL relationship edge and an AMR logical edge, representing the relationship between predicates and entities and the abstract semantic relationship between words;
[0072] The normalized graph Laplacian matrix can be expressed as ;
[0073] wherein, the adjacency matrix , is a diagonal matrix, and I is a unit matrix;
[0074] Step 4.2: Use multi-frequency filter to realize abstract semantic representation coding, including:
[0075] Design a low-pass filter and a high-pass filter , wherein the high-pass filter is equivalent to the normalized graph Laplacian matrix, and the expression is:
[0076] ;
[0077] ;
[0078] Step 4.3: Construct graph learning method to obtain sentence representation, including:
[0079] Use weighted sum to combine low-frequency and high-frequency messages, and the expression is:
[0080] ;
[0081] wherein, is the input of the k-th layer, is the weight matrix of low and high frequency information;
[0082] ;
[0083] wherein, is the neighboring node of node i, and are the weight contributions of the low and high frequency signals of node j to node i, which satisfy the constraint condition ;
[0084] ;
[0085] wherein, is the concatenation operation, is a trainable weight matrix, is the hyperbolic tangent function, which is used to scale the values in [-1, 1];
[0086] Based on the calculation of , the importance of the change of different frequency components is modeled. If , the high frequency message dominates, and node i receives the difference between node i and neighbor j;
[0087] Finally, the multi-frequency information is gradually distributed on the graph by stacking K layers, each node receives multi-frequency signals from K-hop neighbors, and the output of the last layer is used as the multi-frequency representation , and the abstract semantic graph encoding of the sentence is represented as:
[0088] .
[0089] The specific method of step 5 is:
[0090] The full-chain graph encoding representation and the semantic graph encoding representation are converted into a unified feature space by using the alignment operation, obtaining the new full-chain graph encoding representation and the semantic graph encoding representation , including:
[0091] Step 5.1: Use the multi-head attention mechanism to enhance the feature expression of the full-chain graph encoding representation and the semantic graph encoding representation , and then convert them into a unified feature space, the expression is:
[0092] ;
[0093] ;
[0094] wherein, is a weight matrix for converting the output of multi-head attention to a unified feature space;
[0095] Step 5.2: In order to measure the alignment degree of the full-chain graph encoding representation and the semantic graph encoding representation in the unified feature space, the mean square error loss function is used for processing, and the expression is:
[0096] ;
[0097] wherein, represents the dimension of the feature representation.
[0098] The specific method of the step 6 is:
[0099] The dynamic fusion mechanism is adopted to construct the final sentence representation , including:
[0100] Step 6.1: The aligned full-chain graph encoding representation and the semantic graph encoding representation are used to predict the sentiment score of the decoder composed of MLP , , and the calculation formula is:
[0101] ;
[0102] The difference between the single-path feature and the fusion feature sentiment score is used to indicate the amount of effective information provided by the corresponding path, and the sentiment score is used to further guide the attention weight;
[0103] Step 6.2: For the weight of the single-path feature, the sentiment score of the single-path feature and y is inversely proportional, so the inverse proportional function exp(-kx) and the normalization operation are selected, and during the training, the basic true value of y is used to convert the single-path feature sentiment score to the sentiment ratio , , and the calculation formula is:
[0104] ;
[0105] ;
[0106] wherein, k represents the slope of the function, which can scale the sentiment ratio;
[0107] To unify the length and dimension axis for single-path feature knowledge enhanced representation where, is the sequence length, d m is the vector dimension, the obtained representation of each path feature is updated by a knowledge enhanced representation:
[0108] The obtained representation is first summed as the input of the first dynamic attention block , the expression is:
[0109] ;
[0110] ;
[0111] where, is composed of two linear layers, and represent the length and dimension of the fusion stage;
[0112] Then, the dynamic attention blocks are stacked to form a pipeline, while using the output of the previous block , the knowledge enhanced representation and the sentiment ratio , as the input of the next block, and obtaining its output , the expression is:
[0113] ;
[0114] where, DAM is the dynamic attention module;
[0115] In the dynamic attention module, the cross-modal attention module is adopted to capture the similar information amount between the single-path feature representation and the fusion feature representation , and gradually determine the dominant path;
[0116] The fusion feature is taken as Q, the single-path feature is taken as K and V, and the layer norm LN is performed, the expression is:
[0117] ;
[0118] The sentiment ratio is multiplied by the intermediate representation to further guide the dynamic fusion, and the obtained representation is added to the fusion feature representation of the input to fine-tune the contribution of different syntax, the expression is:
[0119] ;
[0120] ;
[0121] Finally, the output of the dynamic attention block is obtained by inputting the multi-head attention and the feed-forward neural network ;
[0122] The output of the last block is taken as the final fusion representation .
[0123] The specific method of the step 7 is as follows:
[0124] The obtained fusion representation is fed into a linear layer and then processed by a softmax function to generate an emotion probability distribution p, expressed as:
[0125] ;
[0126] wherein, W and b are weights and biases, respectively. The specific method of the step 8 is as follows:
[0127] Step 8.1: define the standard cross-entropy loss for calculation, expressed as:
[0128] ;
[0129] wherein, D is a set of all emotion-aspect pairs, C is a set of emotion polarities, and θ is a model trainable parameter.
[0130] Step 8.2: define the expression of the total loss, expressed as:
[0131] ;
[0132] wherein, and are used to balance the two loss functions
[0133] . The present application has the beneficial effects relative to the prior art: the aspect-level sentiment analysis method based on multi-grammar and multi-frequency proposed by the present application is based on social media comments, adopts a full-chain graph convolutional neural network and a semantic graph multi-frequency propagation network to obtain sentence representations from different angles, then adopts an alignment operation and a dynamic fusion mechanism to obtain a comprehensive sentence representation, and realizes aspect-level sentiment analysis, wherein:
[0134] The present application has the beneficial effects relative to the prior art: the aspect-level sentiment analysis method based on multi-grammar and multi-frequency proposed by the present application is based on social media comments, adopts a full-chain graph convolutional neural network and a semantic graph multi-frequency propagation network to obtain sentence representations from different angles, then adopts an alignment operation and a dynamic fusion mechanism to obtain a comprehensive sentence representation, and realizes aspect-level sentiment analysis, wherein:
[0135] The semantic graph multi-frequency propagation network designed by the application comprises entity nodes and abstract semantic nodes, all of which are words, and the edges are SRL relationship edges and AMR logical edges, representing the relationship between predicates and entities and abstract semantic relationships, then low-pass filters and high-pass filters are designed to filter signals from node features, and the filters are used to adaptively aggregate messages with different frequencies to obtain multi-frequency representation, and further obtain comprehensive semantic graph coding representation. The network can capture deep semantics beyond syntactic structure, and can more stably extract key semantic features.
[0136] The alignment operation designed by the application enhances the feature expression of each branch through an attention mechanism, and then converts both to a unified feature space, and then uses a mean square error loss function to measure the alignment degree of both in the unified feature space. The module can supplement and improve the feature representation learned by each branch, and further improve the classification performance.
[0137] The dynamic fusion mechanism designed by the application constructs dynamic fusion weights through the feature representation of the two paths, and then obtains fusion representation through dynamic cross fusion according to the fusion weights, obtains comprehensive feature expression, and improves the performance of aspect-level sentiment analysis. BRIEF DESCRIPTION OF DRAWINGS
[0138] The application will be further described below with reference to the drawings:
[0139] Figure 1 The framework flowchart of the aspect-level sentiment analysis method based on multi-grammar and multi-frequency of the application is shown.
[0140] Figure 2 The framework flowchart of the dynamic attention module in the embodiment of the application is shown. DETAILED DESCRIPTION
[0141] As shown in Figure 1 and Figure 2 To solve the problems existing in the current aspect-level sentiment analysis method, the application proposes a multi-grammar and multi-frequency based aspect-level sentiment analysis scheme. First, a full-chain graph convolutional neural network is used to capture the syntactic information and dependency relationship of the comment, then the comment is analyzed in combination with semantic role labeling and abstract semantic representation, and multi-frequency propagation is used to capture the semantic correlation of each word in the text, a double-channel graph neural network is constructed, then the full-chain graph coding and semantic graph coding are converted to a unified feature space through alignment operation, and finally a dynamic fusion mechanism is used to obtain comprehensive sentence expression, thereby improving the performance of aspect-level sentiment analysis.
[0142] The method of the application will be further described below with reference to the drawings.
[0143] As described previously, the current syntax-based aspect-level sentiment analysis method only focuses on single syntax structure information, ignores the deep potential semantic relationship between words, and ignores the guiding role of word frequency information; therefore, the aspect-level sentiment analysis method provided by the present application is as follows. Figure 1 As shown in FIG. 1, the aspect-level sentiment analysis method provided by the present application is an incremental framework, which comprises embedding representation, Mamba model, full-chain graph convolutional neural network, semantic graph multi-frequency propagation network, alignment module, dynamic fusion mechanism and softmax layer.
[0144] The aspect-level sentiment analysis method provided by the present application is based on a double-channel graph neural network, that is, a full-chain graph convolutional neural network and a semantic graph multi-frequency propagation network, and the specific operation process is as follows.
[0145] Step 1: embedding representation of word vectors in a comment sentence is realized by using an embedding representation method.
[0146] First, the word embedding representation is realized by using a BERT embedding method , so that different words usually have different meanings, wherein the universal domain vector representation of a word is , and is taken as the word vector representation , that is, the sentence comment representation .
[0147] Step 2: further word representation is obtained by using a Mamba model.
[0148] First, the sentence comment is projected and separated, and then one-dimensional convolution processing is performed, and the calculation formula of the processing is as follows.
[0149] ;
[0150] ;
[0151] Wherein, represents a gate signal, represents an input projection matrix, represents a SiLU activation function.
[0152] Subsequently, the result of the SSM module is input into the gating mechanism for processing, and the calculation formula used for processing is as follows:
[0153] ;
[0154] ;
[0155] ;
[0156] ;
[0157] ;
[0158] ;
[0159] ;
[0160] ;
[0161] ;
[0162] ;
[0163] wherein, is a time step parameter, represents an input projection matrix, represents an element-level multiplication, represents an output projection matrix, , , , is a parameter matrix of each layer, represents a sequence length, is a learnable residual connection coefficient.
[0164] The result of the SSM module processing is input into the gating mechanism:
[0165] ;
[0166] Finally, the output result is obtained:
[0167] ;
[0168] wherein, is an output projection matrix.
[0169] Therefore, the sentence representation is defined as .
[0170] Step 3: Capture semantic information and dependency relationships in the text using a fully connected graph convolutional neural network, which includes building a fully connected semantic graph and performing edge pruning, and a graph convolutional neural network:
[0171] Step 3.1: Build a fully connected semantic graph and perform random edge pruning:
[0172] Based on the output of the previous step, construct an adjacency matrix of a fully connected graph , where represents the edge weight between node i and node j, and the edge weight is determined by calculating the similarity between word vectors, with the formula:
[0173] .
[0174] To prevent overfitting and improve the generalization ability of the model, random edge pruning is needed for the fully connected graph, and a mask matrix M of the same dimension as the adjacency matrix A is randomly generated, where each element is set to 0 with probability p, and 1 otherwise. The pruned adjacency matrix is:
[0175] ;
[0176] where, represents element-wise multiplication.
[0177] Using the normalized weighted sum method based on the adjacency matrix, the pruned adjacency matrix is converted to node representation , and for each node i, its new element representation is:
[0178] ;
[0179] where, is the element in the i-th row and j-th column of the pruned adjacency matrix , and represents the edge weight between node i and node j. The representations of all nodes are combined to form a matrix , with the expression:
[0180] .
[0181] Step 3.2: Obtain node representation using a graph convolutional network, with the expression:
[0182] ;
[0183] where, are the learned weights and biases, respectively.
[0184] The expression of the sentence is obtained as follows:
[0185] .
[0186] Step 4: Combining semantic role labeling and abstract semantic representation, a semantic graph multi-frequency propagation network is used to construct a semantic role graph code, and then the semantic relationship of the concept words in the sentence is obtained. The semantic graph multi-frequency propagation network used includes semantic graph construction, multi-frequency filtering, and graph learning, wherein:
[0187] Step 4.1: Construct a semantic graph by combining semantic role labeling and abstract semantic representation:
[0188] Perform semantic role labeling and abstract semantic representation analysis on the sentence comment, and then construct a semantic graph , wherein is a node set (a word set), represented as {f i}, including entity nodes and abstract semantic nodes, all of which are words, is an edge set, which is an SRL relationship edge and an AMR logical edge, representing the relationship between predicates and entities and the abstract semantic relationship between words. Adjacency matrix .
[0189] The normalized graph Laplacian matrix can be represented as ;
[0190] wherein, is a diagonal matrix, and I is a unit matrix.
[0191] Step 4.2: Use a multi-frequency filter to realize abstract semantic representation coding:
[0192] Design a low-pass filter and a high-pass filter :
[0193] ;
[0194] .
[0195] Step 4.3: Construct a graph learning method to obtain sentence representation:
[0196] Use a weighted sum to combine low-frequency and high-frequency messages, and the expression is:
[0197] ;
[0198] wherein, is the input of the k layer, is the weight matrix of the low-frequency and high-frequency information;
[0199] ;
[0200] where, is the neighboring node of node i, and are the low and high frequency signal of node j’s weight contribution to node i, which satisfy the constraint condition ;
[0201] ;
[0202] where, is the concatenation operation, is a trainable weight matrix, is the hyperbolic tangent function to scale values in [-1, 1].
[0203] Based on the above calculation, the importance of the change of different frequency components can be easily modeled, if then the high frequency message dominates, and node i receives the difference between node i and neighbor j.
[0204] Finally, the multi-frequency information is gradually distributed on the graph; by stacking K layers, each node receives multi-frequency signals from K-hop neighbors, and uses the output of the last layer as the multi-frequency representation as , the abstract semantic graph encoding representation of the sentence is .
[0205] Step 5: Align the full-chain graph encoding representation and the semantic graph encoding representation into a unified feature space to obtain new full-chain graph encoding representation and semantic graph encoding representation , the specific method is:
[0206] Step 5.1: Use the multi-head attention mechanism to enhance the feature expression of the full-chain graph encoding representation and the semantic graph encoding representation , and then convert them into a unified feature space, the expression is:
[0207] ;
[0208] ;
[0209] where, is the weight matrix used to convert the output of multi-head attention to a unified feature space.
[0210] Step 5.2: In order to measure the full-chain graph encoding representation and the semantic graph encoding representation The alignment degree in the unified feature space is processed using the mean square error (MSE) loss function, and the expression is:
[0211] ;
[0212] wherein, represents the dimension of the feature representation.
[0213] Step 6: Adopting a dynamic fusion mechanism to construct the final sentence representation , the specific method is:
[0214] Step 6.1: Using the aligned full-chain graph encoding representation and the semantic graph encoding representation to predict the sentiment score of the decoder composed of MLP , , the calculation formula is:
[0215] ;
[0216] Since the difference between the single-path feature and the fusion feature sentiment score can indicate the amount of effective information provided by the corresponding path, the sentiment score is used to further guide the attention weight.
[0217] Step 6.2: For the weight of the single-path feature, the sentiment score of the single-path feature and y is inversely proportional, so the inverse function exp(-kx) and the normalization operation are selected, and during training, the single-path feature sentiment score is converted to the sentiment ratio , , the calculation formula is:
[0218] ;
[0219] ;
[0220] wherein, k represents the slope of the function, which can scale the sentiment ratio.
[0221] In addition, in order to unify the length and dimension axis for the single-path feature knowledge enhanced representation , wherein, is the sequence length, d m represents the vector dimension, and a projector is used to obtain the updated knowledge enhanced representation of each path feature . First, the obtained representation is summed as the input of the first dynamic attention block , and the expression is:
[0222] ;
[0223] ;
[0224] wherein, is composed of two linear layers, and denote the length and dimension of the fusion stage;
[0225] Then, stack the dynamic attention blocks to form a pipeline, while using the output of the previous block , the knowledge-enhanced representation and the sentiment ratio , as the input of the next block and obtain its output , the expression is:
[0226] ;
[0227] wherein, DAM is a dynamic attention module.
[0228] In the dynamic attention module, first introduce the cross-modal attention module (CAttn), which gradually determines the dominant path by capturing the amount of similar information between the single-path feature representation and the fusion feature representation . Since the Q of attention is used to specify the position of attention, the fusion feature is taken as Q, the single-path feature is taken as K and V, and the layer norm (LN) is performed, the expression is:
[0229] ;
[0230] Next, since the sentiment ratio can further guide the dynamic fusion, it is multiplied by the intermediate representation .
[0231] Then, add the obtained representation and the fusion feature representation of the input to fine-tune the contribution of different syntax, the expression is:
[0232] ;
[0233] ;
[0234] Finally, input to multi-head attention and feedforward neural network to obtain the output of the dynamic attention block.
[0235] Take the output of the last block as the final fusion representation .
[0236] Step 7: Produce sentiment probability distribution by softmax function: The obtained fused representation is fed into a linear layer, and then processed by a softmax function to produce sentiment probability distribution p, expressed as:
[0237] ;
[0238] wherein, W and b are weights and biases, respectively. and .
[0239] Step 8: Build the corresponding loss function to realize model training.
[0240] Step 8.1: Define the standard cross-entropy loss for computing, expressed as:
[0241] ;
[0242] wherein, D is the set of all sentiment-aspect pairs, C is the set of sentiment polarities, and θ is the model trainable parameters.
[0243] Step 8.2: Define the expression of the total loss, expressed as:
[0244] ;
[0245] wherein, and are used to balance the two loss functions and .
[0246] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A multi-grammar and multi-frequency aspect-level sentiment analysis method, characterized by: The analysis steps include the following: Step 1: Use the pre-trained general domain embedding method to obtain the general embedding representation of the word as the final embedding representation of the sentence; Step 2: Use the Mamba model to obtain the long-distance dependency between each word as a further representation of the sentence; Step 3: Use a full-chain graph convolutional neural network to capture the semantic information and dependencies in the text, including: Step 3.1: Build a fully connected semantic graph and perform random edge pruning; Step 3.2: Use graph convolutional neural network to further extract semantic information and dependency relationships; Step 4: Construct a semantic graph multi-frequency propagation network to implement semantic roles and abstract semantic encoding, including: Step 4.1: Combine semantic role labeling with abstract semantic representation and multi-frequency propagation to construct semantic role graph encoding; Step 4.2: Design low-pass filters and high-pass filters to filter the signals from the node features; Step 4.3: Use filters to adaptively aggregate messages with different frequencies, and then gradually distribute the multi-frequency information on the graph. Each node receives multi-frequency signals from its K-hop neighbors, and finally obtains a multi-frequency representation to achieve semantic graph encoding of the sentence. Step 5: Use alignment operations to convert the full chain graph encoding and semantic encoding into a unified feature space, including: Step 5.1: Use a multi-head attention mechanism to enhance the feature representation of the full-chain graph encoding representation and the semantic graph encoding representation, and then transform them into a unified feature space; Step 5.2: Use the mean squared error loss function to measure the degree of alignment between the two in the unified feature space; Step 6: Use a dynamic fusion mechanism to construct the final sentence representation, including: Step 6.1: Use the full-chain graph encoding representation and the semantic graph encoding representation to construct dynamic fusion weights; Step 6.2: Use dynamic fusion weights to fuse the full-chain graph encoding representation and the semantic graph encoding representation to construct the final sentence representation; Step 7: Use the softmax function to generate the sentiment probability distribution; Step 8: Construct the corresponding loss function to implement model training.
2. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 1 is: Using BERT embedding method to realize word embedding representation , where the word The general domain vector is represented as ,Will As word vector representation , then the sentence comment is represented as .
3. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 2 is: First, comment on the sentence Projection and separation are performed, and then one-dimensional convolution processing is performed. The calculation formula for the processing is: ; ; in, represents the gating signal, represents the input projection matrix, represents the SiLU activation function; Then it will The data is input into the SSM module for processing. The calculation formula used for processing is: ; ; ; ; ; ; ; ; ; ; in, is the time step parameter, represents the input projection matrix, represents element-wise multiplication, represents the output projection matrix, , , , is the parameter matrix of each layer, represents the sequence length, is the learnable residual connection coefficient; The results obtained by the SSM module are input into the gating mechanism: ; Finally, the output result is: ; in, is the output projection matrix; The output sentence representation is defined as .
4. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 3.1 is: Based on the sentence representation output in step 2, construct an adjacency matrix of a fully connected graph ,in Represents the edge weight between node i and node j, edge weight It is determined by calculating the similarity between word vectors. The calculation formula is: ; Randomly crop the edges of the fully connected graph and randomly generate a mask matrix M with the same dimensions as the adjacency matrix A, where each element With probability p set to 0, otherwise to 1, the pruned adjacency matrix for: ; in, represents element-wise multiplication; The clipped adjacency matrix is transformed into Convert to node representation , for each node i, its new element represents for: ; in, is the clipped adjacency matrix The element in the i-th row and j-th column represents the edge weight between node i and node j, and the representation of all nodes is composed of a matrix , the expression is: 。 5. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 3.2 is: Using graph convolutional neural networks to obtain node representation , the expression is: ; in, are the learned weights and biases respectively; The expression of the sentence obtained in this way is: 。 6. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 4 is: Step 4.1: Combine semantic role labeling and abstract semantics to construct a semantic graph, including: Perform semantic role labeling and abstract semantic representation analysis on sentence comments, and then construct a semantic graph ; in, is a word set, represented by {f i }, including entity nodes and abstract semantic nodes, both of which are words; It is a set of edges, which are SRL relation edges and AMR logic edges, representing the relationship between predicates and entities and the abstract semantic relationship between words; The normalized graph Laplacian matrix can be expressed as ; Among them, the adjacency matrix , is the diagonal matrix, I is the identity matrix; Step 4.2: Implement abstract semantic representation encoding using multi-frequency filters, including: Design a low-pass filter and a high-pass filter , where the high-pass filter is equivalent to the normalized graph Laplacian matrix, expressed as: ; ; Step 4.3: Construct a graph learning method to obtain sentence representation, including: Use weighted sum to combine low-frequency and high-frequency messages, expressed as: ; in, is the input of layer k, is the weight matrix of low-frequency and high-frequency information; ; in, are the adjacent nodes of node i, and is the weighted contribution of the low-frequency and high-frequency signals of node j to node i, which satisfy the constraints ; ; in, It is a cascade operation. is a trainable weight matrix, is the hyperbolic tangent function, which is used to scale values in [-1, 1]; Based on The calculation of , models the importance of the changes in different frequency components, if , then high-frequency messages dominate, and node i receives the difference between node i and neighbor j; Finally, the multi-frequency information is gradually distributed on the graph by stacking K layers. Each node receives multi-frequency signals from its K-hop neighbors and uses the output of the last layer as the multi-frequency representation: , the abstract semantic graph encoding of the sentence is represented as: 。 7. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 5 is: Use alignment operation to encode the full chain graph and semantic graph encoding representation Convert to a unified feature space to obtain a new full-chain graph encoding representation , and semantic graph encoding representation ,include: Step 5.1: Use multi-head attention mechanism to enhance the full chain graph encoding representation and semantic graph encoding representation The feature expression of , and then the two are converted into a unified feature space, the expression is: ; ; in, is the weight matrix used to convert the output of multi-head attention into a unified feature space; Step 5.2: To measure the full chain graph encoding representation and semantic graph encoding representation The degree of alignment in the unified feature space is processed using the mean square error loss function, which is expressed as: ; in, Indicates the dimension of feature representation.
8. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 6 is: Adopt dynamic fusion mechanism to construct final sentence representation ,include: Step 6.1: Encode the representation using the aligned full-chain graph and semantic graph encoding representation To predict the sentiment score of the decoder composed of MLP , , the calculation formula is: ; The difference between the single path feature and the fusion feature sentiment score is used to indicate the effective information provided by the corresponding path. To further guide the attention weights; Step 6.2: For the weight of the single path feature, the single path feature It is inversely proportional to the sentiment score of y, so the inverse proportional function exp(-kx) and normalization operation are selected. During training, the single path feature sentiment score is converted to Convert to sentiment ratio , , the calculation formula is: ; ; Where k represents the slope of the function, which can scale the sentiment ratio; To unify the single-path feature knowledge enhancement representation The length and dimension of the axis, where is the sequence length, d m Represents the vector dimension, using the projector to obtain each path feature Updated knowledge enhancement representation: First, the representation obtained Summation as the first dynamic attention block The input expression is: ; ; in, It consists of two linear layers, and represents the length and dimension of the fusion phase; Then, dynamic attention blocks are stacked to form a pipeline, and at the same time, the previous block is used Output, knowledge-enhanced representation and sentiment ratio , as input to the next block and obtain its output , the expression is: ; Among them, DAM is the dynamic attention module; In the dynamic attention module, a cross-modal attention module is used to capture single-path feature representation and fusion feature representation The amount of similar information between them gradually determines the dominant path; The fusion feature is used as Q, the single path features are used as K and V, and the layer norm LN is performed. The expression is: ; Emotion Ratio Multiply by the intermediate representation To further guide dynamic fusion, and combine the obtained representation and input The fusion feature representation of is added to fine-tune the contribution of different grammars. The expression is: ; ; Finally, Input multi-head attention and feedforward neural network to get the output of dynamic attention block ; The output of the last block is used as the final fusion representation .
9. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 7 is: The obtained fusion is represented as It is fed into the linear layer and then processed by the softmax function to produce the sentiment probability distribution p, which is expressed as: ; in, and are weights and biases respectively.
10. The multi-grammar and multi-frequency aspect-level sentiment analysis method according to claim 1, characterized in that: The specific method of step 8 is: Step 8.1: Define the standard cross entropy loss for calculation, which is expressed as: ; Where D is the set of all emotion-aspect pairs, C is the set of emotion polarities, and θ is the model trainable parameter; Step 8.2: Define the total loss expression as: ; in, and Used to balance the two loss functions and .
Citation Information
Patent Citations
Emotion analysis method and device, electronic equipment and storage medium
CN112966074A
Electroencephalogram depression diagnosis method based on multi-frequency domain decomposition
CN118490232A
Fine-grained sentiment analysis method based on double-branch graph convolutional network
CN118689958A
Aspect-level sentiment analysis method combining syntax tree and graph network
CN119149734A
Mobile terminal information extraction system and method based on OCR (Optical Character Recognition) and local large language model
CN120279557A