Social relationship guided multi-level feature interaction fusion microblog sentiment analysis method
By constructing a multi-level feature interaction fusion method guided by social relationships, and using BERT and LINE models to extract Weibo text and user features, and combining CNN and self-attention mechanism for feature fusion, the problem of insufficient utilization of social relationships and data noise in Weibo sentiment analysis is solved, thus improving the accuracy of sentiment analysis.
Patent Information
- Application Number
- CN202211602922.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-12-13
AI Technical Summary
Existing Weibo sentiment analysis methods fail to fully utilize social relationship networks to improve sentiment consistency, and there are data noise and lexical sparsity issues when introducing social relationships.
We extract Weibo text and user interaction features using BERT and LINE models, construct a Weibo relationship weight network, use CNN and self-attention mechanism for feature fusion, and combine a Softmax classifier for sentiment classification.
It improves the sentiment consistency of Weibo relationship networks, reduces data noise, enriches text features, avoids single-channel misjudgment, and enhances the accuracy of sentiment analysis.
Smart Images

Figure CN116244429B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of natural language processing, and relates to a microblog sentiment analysis method based on multi-level feature interaction fusion guided by social relationship. BACKGROUND
[0002] In recent years, Twitter and Sina Weibo have become popular platforms for users to publish and spread microblog information. Analyzing the sentiment of microblogs on large social platforms can help governments or e-commerce companies perceive the public's views on various topics (such as political events, celebrities, daily life, etc.), and it has a wide range of applications in both academic and industrial fields. Microblog sentiment analysis aims to quickly determine the sentiment of a large amount of data, reducing human input while providing timely feedback information to decision-makers for quick decision-making.
[0003] The basic idea of the microblog sentiment analysis method is to train a sentiment classifier on a dataset that has been manually labeled with sentiment, and then use the classifier as a sentiment analysis model to identify the sentiment of unlabeled microblogs. Specifically, it involves two steps: preprocessing of microblog text data and establishment of a sentiment analysis model. In the preprocessing aspect, after removing special symbols and stop words, the sentences of the microblog text are converted into corresponding word formats by using a word segmentation tool. In the aspect of establishing a sentiment analysis model, a neural network model is constructed to solve the mapping function from the word format of the microblog text to the sentiment feature. However, due to the use of network neologisms and special symbols in microblogs, the vocabulary in microblogs is sparse, leading to the problem of vocabulary sparsity. To solve this problem, researchers have shifted their attention to the interactive activities between microblogs (i.e., interactive behaviors such as following, liking, and retweeting on social platforms). By identifying relationship microblogs through interactive behaviors, the target microblog is expanded to solve the problem of vocabulary sparsity.
[0004] Undoubtedly, the introduction of interactive activity information can to some extent solve the problem of low sentiment recognition rate caused by data noise in microblogs. Early methods of introducing interactive activities into microblog sentiment analysis use user following relationships to construct a relationship network between microblogs, thereby expanding the target microblog with relationship microblogs. However, as the number of user-published microblogs increases, it brings too much data noise to the target microblog. To address this problem, current research methods consider single factors such as topic features, user similarity, and microblog similarity in the construction of microblog relationship networks to filter data noise. However, the existing research methods have the following defects: (1) multiple factors are not considered to filter the microblog relationship network to improve the probability of sentiment consistency of the relationship network; (2) only the target microblog is used as an expansion feature to solve the data sparsity problem, and the microblog relationship network is not involved in guiding the interaction between microblogs. Therefore, the existing technology is not sufficient for the research of microblog sentiment analysis combined with social relationships. SUMMARY
[0005] Therefore, the present application aims to provide a social relationship guided multi-level feature interaction fusion microblog sentiment analysis method.
[0006] To achieve the above-mentioned purpose, the present application provides the following technical solutions:
[0007] The social relationship guided multi-level feature interaction fusion microblog sentiment analysis method comprises the following steps:
[0008] Step 1, extraction of microblog text and user interaction features. The microblog text and user social behavior data are preprocessed, different dimension BERT pre-training models are used to extract the word-level and sentence-level features of the microblog text, and LINE is used to extract the relationship features of the social information, so as to represent them in a tensor format that can be recognized by a computer.
[0009] Further, the specific process of step 1 comprises:
[0010] First, for the microblog text s i , the features of the state of the last hidden layer in the BERT model (l is the length of the sentence) are used as the word-level representation features. The [CLS] feature of the last hidden layer output by the BERT model is used as the sentence-level representation feature. Then, after the BERT encoder, the output text features can be represented as:
[0011]
[0012]
[0013] wherein d0, d1 are the dimensions of the two BERT pre-training models, represents the word-level feature output by the first dimension BERT model, represents the sentence-level feature output by the first dimension BERT model, and Linear(X, y) means multiplying the feature X by an over-trained matrix to map the output feature dimension to y dimensions. Finally, the feature representation of all microblog texts can be obtained:
[0014]
[0015] Then, the user interaction feature extraction. The user interaction feature extraction is divided into two steps: construction of a microblog relationship weight network and embedding of the microblog relationship weight network. Construction of a microblog relationship weight network. The attention relationship between users the mentioned label of the microblog published by the user the theme label of the microblog published by the user Three aspects to build the relationship weight network between microblogs. The rules for the microblog relationship established by the topic label (#) are as follows: two microblogs are under the same topic, and the relationship weight is represented as the number of shared topics of the two microblogs. The rules for the micro-microblog relationship established by the mention label (@) are as follows: (1) microblog A mentions user B, and user B publishes microblog B, then microblog A and microblog B have an edge with a weight of 1; (2) two microblogs have the same mentioned user, and the weight is the number of mentioned users. The rules for the microblog relationship established by the user follow are as follows: (1) there is a follow relationship between users, and the user publishes a microblog, then there is an edge with a weight of 1 between these microblogs; (2) the microblogs published by the same user have an edge with a weight of 1. Finally, a microblog relationship weight network E(i,j,w) can be built.
[0016] Finally, the embedding of the microblog relationship weight network. LINE is used to embed the nodes in a weight network into corresponding low-dimensional feature vectors. For the microblog relationship weight network E(i,j,w) established in the first step, the microblog nodes v i and v j can obtain the embedding representation of each microblog node in the weight network by minimizing the embedding loss function O.
[0017]
[0018] where (i,j,w i,j ) represents that there is an edge between microblog i and microblog j with a weight of w i,j , represents the low-dimensional embedding vector of microblog i, represents the vector when is regarded as the context. The microblog relationship embedding representation is generated as The number of microblogs is m, and the dimension of the microblog node embedding is d r . Among them, the microblog nodes that do not participate in social interaction are filled with noise vectors of the same dimension The embedding matrix representation of m microblog nodes is
[0019] Step 2, fusion of word-level features. A double-channel CNN with multiple different size convolution kernels is used to fuse word-level features.
[0020] Further, the specific process of step 2 includes:
[0021] First, for the word-level feature vector i extracted from the microblog text s , the word-level feature output extracted by CNN is represented as:
[0022] y={y1 y 2 ,...,y L}
[0023]
[0024] where y i represents the output of the i-th convolution kernel, is the stack of two BERT outputs to convolutional dual channels, W l and b l represent the weight matrix and bias of the l-th convolution kernel, respectively, represents the convolution operation; represents the output of the l-th convolution kernel in a window containing h words. Then, the important part p in the text is found by the max-pooling layer and all features are connected in the last dimension. The final word-level feature is represented as:
[0025] p = cat([maxpool(y 1 ), maxpool(y 2 ),..., maxpool(y L )])
[0026] Then, in order to unify the dimensions, the word-level feature p is mapped to d r dimension, i.e. is represented as
[0027] p s = Linear(p, d r )
[0028] Finally, the extraction of sentence-level features. The sentence-level feature of the first BERT is used as the overall sentence feature. That is, the sentence feature is also mapped to d r dimension, i.e. is represented as:
[0029]
[0030] Step 3, interaction of word-level, sentence-level and relationship features. The relationship features in step 1 are used to guide the interaction of the word-level features in step 2 and the sentence-level features in step 1, and the interactive word-level features and the interactive sentence-level features are obtained.
[0031] Further, the specific process of the step 3 comprises:
[0032] Firstly, the guided interaction of relationship features. The construction of the microblog similarity matrix, the guided interaction of word-level and sentence-level.
[0033] Then, the construction of the micro-blog similarity matrix. The micro-blog similarity matrix is constructed using the relationship feature, which is defined as the normalized value of the similarity of two node vectors. The embedding matrix of m micro-blog nodes is represented as For the i-th micro-blog node embedding The micro-blog similarity matrix M is obtained as:
[0034]
[0035]
[0036] h = Tanh(sum r (M r -I (1) *v noise )*sum r (M r -I*v noise ))
[0037] M corr = ReLU(Tanh((h·h T -I)*10))
[0038] Where ||v i || F is the Frobenius norm of vector v i ,·is matrix multiplication, * is element multiplication, sum r () represents summing the matrix by row. I (1) is the all-1 matrix, I is the identity matrix. M corr is the correction matrix, mainly to correct the micro-blog text similarity noise caused by the randomly filled micro-blog node filling vector v noise . Tanh and ReLU are activation functions, as follows:
[0039] ReLU(x) = max(0, x)
[0040]
[0041] Finally, the guided interaction at the word and sentence levels. For m micro-blog, the word-level feature after interaction The sentence-level feature after interaction The output is respectively:
[0042]
[0043]
[0044]
[0045] Step 4, the first fusion of features. Take the relationship feature of step 1 as Q (query vector), the sentence-level feature of step 3 as K (key vector), and the word-level feature of step 3 as V (value vector) as features, build an attention fusion network to fuse the three features for the first time, and obtain the first fusion feature. Specifically, take the micro-blog relationship feature M r as the guide query (Q), the sentence-level feature h cls after interaction as the key (K), and the word-level feature h s as the value (V), input into the self-attention mechanism to obtain the first fusion feature of the guided micro-blog text:
[0046] h att =SelfAtt(Q=M r ,K=h s ,V=h cls )
[0047]
[0048] where d k is the dimension of the key vector K. Q, K, and V are the corresponding query, key, and value vectors.
[0049] Step 5, the second fusion of features. The dynamic weighting coefficients are used to complete the weight distribution of the first fusion feature of step 4, the word-level feature after interaction of step 3, and the sentence-level feature after interaction. Build an interactive fusion network to fuse the weighted features for the second time.
[0050] Further, the specific process of step 5 includes:
[0051] First, dynamic weighting. Stack the first fusion feature h att , the word-level feature after interaction h cls , and the sentence-level feature after interaction h s to obtain the weighted feature:
[0052] h stack =Stack([h s ,h att ,h cls ])
[0053] h c =(h stack ) T *[a1,a2,a3]
[0054] where is the stacked feature, and [a1, a2, a3] is the dynamic weighting coefficient of the three features.
[0055] Then, the interaction fusion network. Similar to the word-level feature fusion network, the weighted features are fused for the second time using CNN to obtain the fused features h as:
[0056]
[0057] h={h 1 ,h 2 ,...,h L}
[0058] Finally, the features after interaction are obtained by average pooling and spliced in the last dimension. The fused features are obtained as
[0059] h f =cat([avgpool(h 1 ),avgpool(h 2 ),...,avgpool(h L )])
[0060] Step 6, microblog sentiment classification. A Softmax sentiment classifier is constructed to classify the sentiment of the microblog. The cross-entropy loss function is used as the training loss function, and the back propagation algorithm is used to train the model to obtain the microblog sentiment analysis model.
[0061] Further, the specific process of step 6 includes:
[0062] First, a Softmax classifier is constructed to complete the classification of the text sentiment:
[0063]
[0064] Wherein, num_class is the sentiment category corresponding to the microblog text.
[0065] Finally, the back propagation algorithm is used to train the model, and the cross-entropy loss function is used as the loss function in the training process. The model is optimized by optimizing the loss function, and the expression is:
[0066]
[0067]
[0068] Wherein, J(w,b) is the loss of the whole sample, m is the sample quantity, y (i) 、 are the real sample probability distribution and the predicted sample probability distribution of the sample respectively. Lambda is the coefficient of L2 regularization.
[0069] The beneficial effects of the present application are:
[0070] 1) For the existing microblog sentiment analysis method combined with social relationship, the problem of low probability of microblog relationship network sentiment consistency is constructed, multiple factors are considered to filter the microblog relationship network, and the probability of relationship network sentiment consistency is improved.
[0071] 2) For the existing method, only the target microblog is used as an expansion feature to solve the data sparsity problem, and the microblog relationship network is not involved in guiding the interaction between microblogs, so a kind of sentiment analysis network using social relationship to guide microblog text interaction is extracted.
[0072] 3) For the user who does not participate in social activities on the social platform, noise is eliminated when introducing social relationship.
[0073] 4) The BERT pre-training model of the double channel is used to extract the word level and sentence level features of the microblog text together, which enriches the text features. At the same time, the weighted fusion network is designed to fuse the text features, avoiding the misjudgment of the single channel.
[0074] Other advantages, objects and features of the present application will be set forth in part in the following specification, and in part will be apparent from the study thereof, or can be learned from practice of the present application. The objects and other advantages of the present application can be realized and obtained by the following description. BRIEF DESCRIPTION OF DRAWINGS
[0075] In order to make the purpose, technical scheme and advantages of the present application clearer, the preferred detailed description of the present application will be combined with the drawings as follows, wherein:
[0076] Figure 1 The flow chart of the microblog sentiment analysis network method based on BERT under the guidance of social relationship of the present application;
[0077] Figure 2 The system model diagram of the microblog sentiment analysis network method based on BERT under the guidance of social relationship of the present application. DETAILED DESCRIPTION
[0078] The embodiments of the present application will be described below through specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in the specification. The present application can also be implemented or applied by different specific embodiments, and the details in the specification can be modified or changed based on different views and applications without departing from the spirit of the present application. It should be noted that the diagrams provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and the following examples and features in the examples can be combined with each other without conflict.
[0079] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0080] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0081] like Figure 1 As shown, this invention provides a microblog sentiment analysis method based on multi-level feature interaction fusion guided by social relationships. The implementation scenario involves training a network model for sentiment analysis using the mentioned method on a dataset containing microblog text and corresponding sentiment and social information, enabling the model to classify the sentiment of the microblog text. The specific implementation steps are as follows:
[0082] Step 1: Use the BERT pre-trained model and LINE to preprocess the Weibo text and social information respectively, that is, use vectors to represent the Weibo text and social information.
[0083] First, the BERT pre-trained model is a deep model trained by Google on a large amount of unlabeled datasets. It can represent the input Weibo text as a corresponding vector format, that is, the word-level and sentence-level features of the Weibo text. Specifically, for Weibo text s i After passing through BERT, s can be obtained. i Word-level features (l is the length of the sentence) and sentence-level features This paper uses BERT with two different dimensions, d0 and d1, to extract features together, as follows:
[0084]
[0085]
[0086] Next, through the follow relationships between users References in the text Thematic relationships in the text To construct the micro-blog relationship network. Specifically, for the follow relationship between users If there is a follow relationship between users and the users post micro-blog, there is an edge between these micro-blog with weight 1; There is an edge between micro-blog posted by the same user with weight 1. For the mention relationship in the text After micro-blog A mentions user B, user B posts micro-blog B, there is an edge between micro-blog A and micro-blog B with weight 1; Two micro-blog have the same mentioned user, the weight is the number of mentioned same user. For the theme relationship in the text Two micro-blog are under the same theme, then there is an edge between two micro-blog with the number of same theme weight. Finally, a micro-blog relationship weight network E(i,j,w) is obtained.
[0087] Finally, by inputting the micro-blog relationship weight network E(i,j,w) into the LINE network, the vector representation of each micro-blog is obtained. Specifically, the vector representation of each micro-blog node is obtained by optimizing the following function, that is, the relationship feature:
[0088]
[0089] Step 2, fuse word-level features by CNN, use relationship features to guide word-level and sentence-level features and perform the first fusion.
[0090] First, fuse the word-level features by CNN. For micro-blog text s i The extracted word-level feature vector The word-level feature output extracted by CNN Then find the important part p of the text through the max-pooling layer and connect all the features in the last dimension. Get the final word-level feature is expressed as:
[0091] y={y 1 ,y 2 ,...,y L}
[0092]
[0093] p=cat([maxpool(y 1 ),maxpool(y 2 ),...,maxpool(y L )])
[0094] Map the word-level feature p to d r dimension, that is is expressed as:
[0095] p s =Linear(p,dr )
[0096] Sentence features Also mapped as d r dimension, i.e. denoted as:
[0097]
[0098] Then use the relationship features to guide the word-level and sentence-level features. For the i-th micro-blog node embedding Get the micro-blog similarity matrix M as:
[0099]
[0100]
[0101] h = Tanh(sum r (M r -I (1) *v noise )*sum r (M r -I*v noise ))
[0102] M corr = ReLU(Tanh((h·h T -I)*10))
[0103] For m micro-blog, the word-level features after interaction Sentence-level features after interaction The outputs are respectively:
[0104]
[0105]
[0106]
[0107] Finally, the first fusion. With the micro-blog relationship features M r as the query (Q), with the sentence-level features h cls after interaction as the key value (K), and with the word-level features h s as the value (V), input into the self-attention mechanism to obtain the guided micro-blog text once-fused features:
[0108] h att = SelfAtt(Q = M r , K = h s , V = h cls )
[0109]
[0110] Step 3, build a feature fusion network to fuse features twice and classify microblog sentiment.
[0111] First, the first fused feature h att , the interactive word-level feature h cls , and the interactive sentence-level feature h s are stacked and dynamically weighted. The weighted feature is:
[0112] h stack = Stack([h s , h att , h cls ])
[0113] h c = (h stack ) T *[a1, a2, a3]
[0114] Next, similar to the word-level feature fusion network, the weighted feature is fused for the second time using CNN, and the fused feature h is obtained as:
[0115]
[0116] h = {h 1 , h 2 ,..., h L}
[0117] The interactive feature is obtained by average pooling and concatenated in the last dimension. The fused feature is:
[0118] h f = cat([avgpool(h 1 ), avgpool(h 2 ),..., avgpool(h L )])
[0119] Then, a Softmax classifier is built to complete the text sentiment classification:
[0120]
[0121] Finally, the back propagation algorithm is used to train the model, and the cross-entropy loss function is used as the loss function in the training process. The model is optimized by optimizing the loss function, and the expression is:
[0122]
[0123]
[0124] After the above steps are completed, a model for microblog sentiment classification is finally obtained, and the model can be used after being saved. Given a microblog text, the model can be used to obtain the sentiment tendency of the model after inputting the microblog text into the model.
[0125] Figure 2 The system model diagram of the application is described below in conjunction with the drawings, including the following modules:
[0126] Module one: microblog feature extraction module. Two different dimension pre-training BERT encoders are used to convert microblog texts into tensor format word-level and sentence-level features; social information is used to construct a microblog relationship network, and LINE is used to embed microblog nodes in the microblog relationship network into relationship features.
[0127] Module two: microblog feature interaction module. A double-channel, multi-convolution kernel CNN word-level feature fusion network is constructed to interact and fuse word-level features; a microblog similarity matrix is constructed using relationship features, and the microblog similarity matrix is used to guide the interaction of microblog text word-level and sentence-level features; an Attention network is constructed to fuse the word-level features after interaction, the sentence-level features after interaction, and the relationship features for the first time, obtaining once fused features.
[0128] Module three: microblog feature fusion and sentiment classification module. The once fused features, the word-level features after interaction, and the sentence-level features after interaction are stacked and then weighted; an interactive fusion network is constructed to fuse the features after weight distribution for the second time; a cross-entropy loss function is used as a training loss function, and a back propagation algorithm is used to train the model, obtaining a microblog sentiment analysis model for sentiment classification of microblog texts.
[0129] Optionally, module one specifically includes:
[0130] (1) Extraction of microblog text and relationship features. Including extraction of microblog text features and extraction of microblog relationship features.
[0131] Let all microblogs be represented as C={c1,c2,c3,...,c m}(m is the number of microblogs in the data set). For any microblog c i , it contains microblog text s i and microblog interaction features x i (including user follow relationship user mention topic label ).
[0132] (1.1) Extraction of micro-blog text features. Extraction of word-level and sentence-level features. In order to obtain the local semantic features and global sentence context features in the text, word-level features and sentence-level features are extracted from the text to obtain lexical and contextual sentiment features. Two different dimension pre-trained BERT models are used to complete this work. Specifically, for the micro-blog text s i The features of the state of the last hidden layer in the BERT model (l is the length of the sentence) are used as word-level representation features. The [CLS] feature of the last hidden layer output by the BERT model is used as the sentence-level representation feature. Then, the output text features after the BERT encoder can be represented as:
[0133]
[0134]
[0135] where d0, d1 are the dimensions of the two BERT pre-training models, represents the word-level features output by the first dimension BERT model, represents the sentence-level features output by the first dimension BERT model, Linear(X, y) means multiplying the feature X by an over-trained matrix, so that the output feature dimension is mapped to y. Finally, the feature representation of all micro-blog texts can be obtained:
[0136]
[0137] (1.2) Extraction of user interaction features. The extraction of user interaction features is divided into two steps: construction of a micro-blog relationship weight network and embedding of the micro-blog relationship weight network.
[0138] Construction of the micro-blog relationship weight network. The attention relationship between users the mention label of the micro-blog published by the user the theme label of the micro-blog published by the user Three aspects are used to construct the relationship weight network between microblogs. The rules for the microblog relationship established by the topic label (#) are as follows: two microblogs are under the same topic, and the relationship weight is represented as the number of the same topics shared by the two microblogs. The rules for the micro-microblog relationship established by the mention label (@) are as follows: (1) after microblog A mentions user B, user B publishes microblog B, then microblog A and microblog B have an edge with a weight of 1; (2) two microblogs have the same mentioned user, and the weight is the number of the mentioned same user. The rules for the microblog relationship established by the user follow are as follows: (1) there is a follow relationship between users, and the user publishes a microblog, then these microblogs have an edge with a weight of 1; (2) the microblogs published by the same user have an edge with a weight of 1. Finally, a microblog relationship weight network E(i,j,w) can be constructed.
[0139] Embedding of the microblog relationship weight network. LINE is used to embed the nodes in a weight network into corresponding low-dimensional feature vectors. For the microblog relationship weight network E(i,j,w) established in the first step, the microblog node v i and v j can obtain the embedding representation of each microblog node in the weight network by minimizing the embedding loss function O.
[0140]
[0141] where (i,j,w i,j ) represents that there is an edge between microblog i and microblog j with a weight of w i,j , represents the low-dimensional embedding vector of microblog i, represents the vector when is regarded as the context. The microblog relationship embedding representation is generated as The number of microblogs is m, and the dimension of the microblog node embedding is d r . Among them, the microblog nodes not participating in social interaction are filled with noise vectors of the same dimension The embedding matrix representation of m microblog nodes is
[0142] Optionally, the second module specifically comprises:
[0143] (1) word-level feature fusion network. A double-channel CNN with multiple different size convolution kernels is used to extract word-level high-order features. Specifically, for the word-level feature vector i extracted from the microblog text s The output of the word-level feature extracted by the CNN is represented as:
[0144] y={y 1 ,y 2 ,...,yL}
[0145]
[0146] where y i represents the output of the i-th convolution kernel, is the stack of two BERT outputs to convolutional dual channels, W l and b l represent the weight matrix and bias of the l-th convolution kernel, respectively, represents the convolution operation; represents the output of the l-th convolution kernel in a window containing h words. Then, the important part p in the text is found by the max-pooling layer and all features are connected in the last dimension. The final word-level feature is represented as:
[0147] p = cat([maxpool(y 1 ), maxpool(y 2 ),..., maxpool(y L )])
[0148] In order to unify the dimensions, the word-level feature p is mapped to d r dimension, i.e. is represented as
[0149] p s = Linear(p, d r )
[0150] Extraction of sentence-level features. The sentence-level features of the first BERT are used as the overall sentence features. That is, the sentence feature is also mapped to d r dimension, i.e. is represented as:
[0151]
[0152] (2) Guided interaction of relationship features. Construction of microblog similarity matrix, guided interaction of word-level and sentence-level.
[0153] (2.1) Construction of microblog similarity matrix. The relationship features are used to construct the microblog similarity matrix, which is defined as the normalized value of the similarity of two node vectors. The embedding matrix of m microblog nodes is represented as For the i-th microblog node embedding The microblog similarity matrix M is obtained as:
[0154]
[0155]
[0156] h = Tanh(sum r (M r -I (1) *v noise )*sum r (M r -I*v noise ))
[0157] M corr = ReLU(Tanh((h·h T -I)*10))
[0158] where ||v i || F is the Frobenius norm of vector v i ,·is matrix multiplication, * is element multiplication, sum r () represents summing a matrix by row. I (1) is the all-one matrix, I is the identity matrix. M corr is the correction matrix, mainly to correct the microblog text similarity noise brought by the randomly filled filling vector v noise of the microblog node. Tanh and ReLU are activation functions as follows:
[0159] ReLU(x) = max(0, x)
[0160]
[0161] (2.2) Guided interaction at word and sentence level. For m microblogs, the post-interaction word-level feature post-interaction sentence-level feature is output as follows:
[0162]
[0163]
[0164]
[0165] (3) First fusion of features. The Attention network is constructed to extract the first fusion of the interaction features, post-interaction word-level features, and post-interaction sentence-level features. Specifically, taking the microblog relationship feature M r as the guide query (Q), taking the post-interaction sentence-level feature h cls as the key value (K), and taking the word-level feature h s as the value (V), input into the self-attention mechanism to obtain the first fusion feature of the guided microblog text:
[0166] h attSelfAtt(Q=M r ,K=h s ,V=h cls )
[0167]
[0168] where d k is the dimension of the key-value vector K. Q, K, V are the corresponding query, key-value, value vectors.
[0169] Optionally, the third module specifically comprises:
[0170] (1) Dynamic weighting. The first fused feature h att , the post-interaction word-level feature h cls , and the post-interaction sentence-level feature h s are stacked and dynamically weighted. The weighted feature is:
[0171] h stack =Stack([h s ,h att ,h cls ])
[0172] h c =(h stack ) T *[a1,a2,a3]
[0173] wherein, is the stacked feature, and [a1, a2, a3] is the dynamic weighting coefficient of the three features.
[0174] (2) Interaction fusion network. Similar to the word-level feature fusion network, CNN is used to fuse the weighted feature for the second time, and the fused feature h is obtained as:
[0175]
[0176] h={h 1 ,h 2 ,...,h L}
[0177] Then, the post-interaction feature is obtained by average pooling and spliced in the last dimension. The fused feature is
[0178] h f =cat([avgpool(h 1 ),avgpool(h 2 ),...,avgpool(h L )])
[0179] (3) Microblog sentiment classification. A Softmax classifier is constructed to complete the classification of text sentiment:
[0180]
[0181] where num_class is the sentiment category corresponding to the microblog text.
[0182] The model is trained using the back propagation algorithm, and the cross-entropy loss function is used as the loss function in the training process. The model is optimized by optimizing the loss function, and the expression is:
[0183]
[0184]
[0185] where J(w,b) is the loss of the whole sample, m is the sample number, y (i) , is the real sample probability distribution and the predicted sample probability distribution of the sample, respectively. λ is the coefficient of L2 regularization.
[0186] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit it. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced equivalently without departing from the purpose and scope of the technical solutions, which should be covered in the scope of the claims of the present application.
Claims
1. A social relationship guided multi-level feature interaction fusion microblog sentiment analysis method, characterized in that: The method comprises the following steps: Step 1, extraction of micro-blog text and user interaction features; the micro-blog text and the social behavior data of the user are preprocessed, the word-level and sentence-level features of the micro-blog text are extracted using different dimension BERT pre-training models, and the relationship features of the social information are extracted using LINE, and are represented in a tensor format that can be recognized by a computer; Step 2, fusion of word-level features; a CNN with a double channel and multiple different size convolution kernels is used to fuse the word-level features; Step 3, interaction of word-level, sentence-level and relationship features; the word-level features in step 2 and the sentence-level features in step 1 are guided to interact by using the relationship features in step 1, to obtain the word-level features after interaction and the sentence-level features after interaction; Step 4, first fusion of features; the relationship features in step 1 are used as a query vector Q, the sentence-level features in step 3 are used as a key value vector K, and the word-level features in step 3 are used as a value vector V as features, an attention fusion network is constructed to perform first fusion on the three features, and a first fusion feature is obtained; Step 5, second fusion of features; a dynamic weighting coefficient is used to complete weight distribution of the first fusion feature in step 4, the word-level features after interaction in step 3 and the sentence-level features after interaction; an interactive fusion network is constructed to perform second fusion on the weighted features; Step 6, micro-blog sentiment classification; a Softmax sentiment classifier is constructed to classify the sentiment of the micro-blog; a cross-entropy loss function is used as a training loss function, and a back propagation algorithm is used to train the model, to obtain a micro-blog sentiment analysis model; The specific process of step 1 comprises: First, for the micro-blog text , the features of the state of the last hidden layer in the BERT model , is the length of the sentence, as a word-level representation feature; the [CLS] feature of the last hidden layer output by the BERT model is the sentence-level representation feature; then the text feature output by the BERT encoder is represented as: in, , For the dimensions of the two BERT pre-trained models, This represents the word-level features output by the BERT model in the first dimension. This represents the sentence-level features output by the BERT model in the first dimension. The significance lies in giving features Multiplying by an excessively trainable matrix maps the output feature dimensions to... Dimension; ultimately, the feature representations of all Weibo texts are obtained: ; Then, the extraction of user interaction features; the extraction of user interaction features is divided into two steps: the construction of microblog relationship weight network and the embedding of microblog relationship weight network; the construction of microblog relationship weight network; the relationship between users is constructed from the following three aspects , the mention tag of the microblog published by the user , the theme tag of the microblog published by the user The relationship weight network between microblogs is constructed; the rule for the microblog relationship established by the theme tag # is that two microblogs are under the same theme, and the relationship weight is represented as the number of shared theme of the two microblogs; the rule for the micro-microblog relationship established by the mention tag @ is that (1) After micro-blog A mentions user B, user B publishes micro-blog B, then there is an edge between micro-blog A and micro-blog B with a weight of 1; (2) Two micro-blogs have the same mentioned user, and the weight is the number of mentioned users; The rule for the micro-blog relationship established by relying on user attention is: (1) There is an attention relationship between users, and the user publishes a micro-blog, then there is an edge between these micro-blogs with a weight of 1; (2) There is an edge between microblogs published by the same user with weight 1; finally, a microblog relationship weight network is constructed ; Finally, the embedding of the microblog relationship weight network; LINE is used to embed the nodes in a weight network into corresponding low-dimensional feature vectors; for the microblog relationship weight network established in the first step , the microblog nodes and , the embedding representation of each microblog node in the weight network is obtained by minimizing the embedding loss function ; wherein, represents a micro-blog and a micro-blog has an edge with weight between them, represents a low-dimensional embedding vector of a micro-blog , wherein represents a vector when is regarded as a context; the generated micro-blog relationship embedding is represented as , the number of micro-blogs is , and the dimension of the micro-blog node embedding is ; wherein the micro-blog nodes not participating in social interaction are filled with noise vectors of the same dimension ; the embedding matrix of micro-blog nodes is represented as .
2. The social relationship guided multi-level feature interaction fusion microblog sentiment analysis method of claim 1, wherein: The specific process of step 2 comprises: First, for the micro-blog text extracted word-level feature vector , , the word-level feature output extracted by CNN is represented as: wherein represents the output of the th convolution kernel, is the stack of two BERT outputs to convolutional dual channels, and represent the weight matrix and bias of the th convolution kernel, respectively, denotes the convolution operation; represents the output of the th convolution kernel in a window of words; then, the important parts of the text are found by a max-pooling layer and all features are concatenated in the last dimension; resulting in the final word-level features is represented as: Then, for the unity of the dimension, the word-level features are mapped to dimension, i.e. , represented as: Finally, the extraction of the sentence-level features; the sentence-level features of the first BERT are used as the overall sentence features; that is, the sentence features are also mapped as dimension, that is , is expressed as: 。 3.The social relationship guided multi-level feature interaction fusion micro-blog sentiment analysis method of claim 2, characterized in that: The specific process of step 3 comprises: Firstly, the guided interaction of relationship features; the construction of a micro-blog similarity matrix, the guided interaction of word-level and sentence-level features; Then, the micro-blog similarity matrix is constructed; the micro-blog similarity matrix is constructed using the relationship feature, and is defined as the normalized value of the similarity of two node vectors; The embedding matrix of the i-th micro-blog node is represented as ; for the i-th micro-blog node embedding , the micro-blog similarity matrix is obtained as follows: where is the Frobenius norm of vector , is the matrix multiplication, is the element multiplication, denotes the sum of a matrix by row; is the all-one matrix, is the identity matrix; is the correction matrix, which is used to correct the micro-blog text similarity noise caused by the filling vector of the randomly filled micro-blog node and , is the activation function, as follows: Finally, the guided interaction at word level and sentence level; for the micro-blog, the word-level feature after interaction , the sentence-level feature after interaction The outputs are respectively: 。 4. The social relationship guided multi-level feature interaction fusion microblog sentiment analysis method of claim 3, characterized in that: The specific process of step 4 comprises: with micro-blog relationship features as the guided query Q, with the interactive sentence-level features as the key value K, with the word-level features as the value V, input into the self-attention mechanism to obtain the guided micro-blog text one-time fusion features: wherein, is a key-value vector of dimensionality , , are corresponding query, key, value vector.
5. The social relationship guided multi-level feature interaction fusion microblog sentiment analysis method of claim 4, wherein: The specific process of step 5 comprises: First, dynamic weighting; the first fusion feature , the interaction after the word-level feature , the interaction after the sentence-level feature stacking dynamic weighting; the weighted feature is: wherein, is the feature after stacking, is the dynamic weighting coefficient for 3 features; Then, the interactive fusion network; using CNN to the weighted features for the second fusion, get the fused features To: Finally, the features after interaction are obtained through average pooling and spliced in the last dimension; the fusion features are 。 6. The social relationship guided multi-level feature interaction fusion microblog sentiment analysis method of claim 5, wherein: The specific process of step 6 comprises: Firstly, a Softmax classifier is constructed to complete the classification of the text sentiment: wherein, is a sentiment category corresponding to the micro-blog text; Finally, the model is trained by using a back propagation algorithm, a cross-entropy loss function is used as a loss function in the training process, the model is optimized by optimizing the loss function, and the expression is: wherein, is the loss for the whole of the sample, is the number of samples, , are the true sample probability distribution and the predicted sample probability distribution of the sample, respectively; is the coefficient of L2 regularization.