## 3 Methods
### Context Semantic Encoder  
In customer service conversation scenarios, the sentiment of each utterance relates to the contextual information because of the continuity of the dialogue. Therefore, encoding contextual semantic information is critical for conversational sentiment analysis.  
To obtain the contextual semantic information of the conversation, we use different BiGRU networks to extract different contextual semantic features and then use the attention mechanism to weigh contextual semantic features. Specifically, in the customer service conversation scenario, the conversation text is divided into two types according to different speaker identities, i.e., customer and agent conversation text. Then, we use different BiGRU networks to encode them. In addition, in order to model the contextual semantic association relationship between speakers, this paper inputs the contextual semantic features of the above two encodings into the new BiGRU network to obtain a global contextual semantic encoding representation. The calculation process is as follows:  
\[\overset{\rightarrow}{g_{t}}=\overset{\rightarrow}{GRU}\Big{(}\overset{ \rightarrow}{g_{t-1}},u_{t}\Big{)} \tag{2}\]  
\[\overset{\leftarrow}{g_{t}}=\overset{\leftarrow}{GRU}\Big{(}\overset{ \leftarrow}{g_{t-1}},u_{t}\Big{)} \tag{3}\]  
\[g_{t}=\Big{[}\overset{\rightarrow}{g_{t}},\overset{\leftarrow}{g_{t}}\Big{]},t=1,2,\dots,K \tag{4}\]  
where \(u_{t}\) is the utterance representation after the ERNIE pre-model coding; \(\overset{\rightarrow}{g_{t}}\) and \(\overset{\leftarrow}{g_{t}}\) are the output vector results of the forward and backward GRU networks, respectively; and \(g_{t}\) is the utterance representation that contains contextual semantic information.  
In addition, considering the long-distance dependence between the semantics of the conversation context in the customer service conversation, and the inconsistency of the semantic contribution weight of the context utterances at different distances to the current utterance, we use the attention mechanism to weigh the contextual semantic information of different utterances. The specific details are shown in Figure 3.  
Specifically, we use the BiGRU network to encode the utterance and obtain the vector representation, and then match it with the vector representation of other utterances to obtain the corresponding attention weights. The calculation process is as follows:  
\[\alpha_{t}=softmax(u_{t}w_{\alpha}\left[g_{1},g_{2},\dots,g_{t-1}\right]) \tag{5}\]  
Figure 3: Attention mechanism weighting contextual semantics.  
\[softmax(g)=\left[\frac{e^{g_{1}}}{\sum_{i}e^{g_{i}}},\frac{e^{g_{2}}}{\sum_{i}e^{g_ {i}}},\cdots\right] \tag{6}\]  
where \(g_{1},g_{2},\ldots,g_{t-1}\) are the vector representations of utterances encoded by the BiGRU network; \(\alpha_{t}\) is the attention weight matrix; and \(w_{a}\) is the parameter to be learned during training. The context vector representation \(c_{t}\) related to the utterance \(g_{t}\) is obtained by weighting the utterances to sum:  
\[c_{t}=\alpha_{t}\left[g_{1},g_{2},\ldots,g_{t-1}\right]^{T} \tag{7}\]  
Finally, the context vector representation related to the utterance \(g_{t}\) is input into the fully connected network to obtain a textual representation \(G_{t}\) of the fused conversation context semantic information:  
\[G_{t}=ReLU(W_{\text{C}}(g_{t}\oplus c_{t})+b_{c}) \tag{8}\]  
where ReLU is an activation function, \(\oplus\) represents the vector stitching operation, and \(W_{\text{C}}\) and \(b_{c}\) are the trainable model parameters.