## 3 Methodology
### Sentiment Analysis Model Improvement
#### 3.3.2 Attention Layer  
The primary deficiencies of the present attention mechanism are as follows: (1) During the splicing process, the word vectors lose word positions with relative ease. (2) It results in the loss of information from intermediate vectors during the encoding process, which may influence the semantic richness. Therefore, in order to solve these problems, in this paper, the block attention mechanism is used in the third stage (left side of Figure 4), which enhances the contextual relationship between words and can filter the features of the deformed sentence matrix, resulting in enhanced attention to the features associated with the emotional polarity of the text. The original block attention mechanism only considers global information and does not consider the local relationship representation information between words. This scheme improves the original block attention mechanism strategy by adding the local association features of words, enhancing the importance of acquiring each channel of the feature map, and broadening the information captured by the network model. The exact calculation process is as follows:  
The weight values \(y_{1}\) and \(y_{2}\) of the word block matrix \(x_{i}\) are obtained by fusing the global and local information, respectively, and the Equations are shown in (4) and (5):  
\[y_{1}=\frac{1}{1+e^{(-(W_{1}*x_{i}+b_{1}))}} \tag{4}\]  
\[y_{2}=\frac{1}{1+e^{(-(W_{2}*x_{i}+b_{2}))}} \tag{5}\]  
In Equations (4) and (5), sigmoid denotes the activation function that can provide nonlinear modeling capability for the attention mechanism to map the output results to the range [0, 1]. \(W_{1}\) and \(W_{2}\) denote the weight matrix, and \(b_{1}\) and \(b_{2}\) denote the bias.  
\[h_{i}=[y_{1}*x_{i};\,y_{2}*x_{i}] \tag{6}\]  
Immediately afterwards, the weight matrices \(y_{1}\) and \(y_{2}\) calculated by Equations (4) and (5) continue to be multiplied with the word block matrix xi and then spliced to obtain the feature vector matrix \(h_{i}\) after information attention (Equation (6)), and the final output contains the vector matrix \(M^{FE}\) of hi after the block attention mechanism, where \(M\in R^{2d_{h}}\) and dh are the dimensions of the contextual embedding vectors. The improved block attention mechanism is shown in Figure 6.  
Figure 6 fuses the global and local feature information and finally splices the two feature information to broaden the model to capture the feature information of the context, thus improving the model's accuracy. Immediately following Equation (6), the output features \(M^{FE}\), obtained from the attention layer, are first input to a multilayer perceptron,  
and finally, the emotional polarity is predicted using the softmax layer, which is calculated as shown in Equations (7) and (8):  
\[L=MLP(M^{FE}) \tag{7}\]  
\[V=softmax(W_{p}L+b_{p}) \tag{8}\]  
The _MLP_ in Equation (7) represents the multilayer perceptron. \(P\) in Equation (8) has the same dimensions as the sentiment labels in the opinion dataset. \(W_{p}\in R^{d_{h}}\) denotes the learning weight matrix, and \(b_{p}\in R^{d_{h}}\) indicates the bias.