# Accusations and Law Articles Prediction in the Field of Environmental Protection
## 4 Methodology
### Cross-Attention Infusion Mechanism  
At the core of our model is the CROSSATT module, which employs a cross-attention mechanism to dynamically focus on different parts of the text embeddings [39]. This mechanism enables the model to weigh the importance of various words within the context of the legal scenario being analyzed. By comparing and contrasting different segments of the embedded text, the model can identify patterns and relationships that are crucial for understanding the case. In this way, the encoder facilitates a deeper semantic understanding of each word, allowing subsequent layers of the model to effectively process and analyze the structured data for accurate legal outcome predictions [26]. \[ \begin{split}\text{h}^{\text{fc}}&=Att(\text{h}^{\text{f}}, \text{h}^{\text{c}})\\ \text{h}^{\text{fc}}&=Att(\text{h}^{\text{f}},\text{h}^{ \text{k}})\\ \text{h}^{\text{ck}}&=Att(\text{h}^{\text{c}},\text{h}^{ \text{k}})\end{split}  \tag{3}\]  
The attention between fact description and charge description, represented as \(\text{h}^{\text{fc}}=Att(\text{h}^{\text{f}},\text{h}^{\text{c}})\), utilizes embeddings from both the fact and charge descriptions to dynamically focus on the interaction between the factual narrative and specific legal accusations. The attention calculation is as follows:  
\[e^{\text{fc}}=(\text{W}_{\text{Q}}^{\text{f}}\text{h}^{\text{f}})(\text{W}_{ \text{K}}^{\text{c}}\text{h}^{\text{c}})^{\text{T}} \tag{4}\]  
\[\text{fc}^{\prime}=v_{\text{fc}}^{\text{T}}\tanh(e^{\text{fc}}+\text{b}^{ \text{fc}}) \tag{5}\]  
\[\text{h}^{\text{fc}}=softmax\left(\frac{e^{\text{fc}^{\prime}}}{\sqrt{d_{k}}} \right)(\text{W}_{\text{V}}^{\text{c}}\text{h}^{\text{c}}) \tag{6}\]  
where \(\text{h}^{\text{fc}}\) is the attention output that combines fact and charge descriptions; \(\text{W}_{\text{Q}^{\prime}}^{\text{f}}\), \(\text{W}_{\text{K}^{c}}^{\text{c}}\), and \(\text{W}_{\text{V}}^{\text{c}}\) are trainable weight matrices for fact descriptions and charge descriptions; \(\text{h}^{\text{f}}\) and \(\text{h}^{\text{c}}\) are the embeddings for fact and charge descriptions, respectively; and \(d_{k}\) is the dimensionality scaling factor for the softmax normalization. Similarly, the attention between charge description and external knowledge, denoted by \(\text{h}^{\text{ck}}=Att(\text{h}^{\text{c}},\text{h}^{\text{k}})\), leverages the embeddings from the charge descriptions and integrates them with external legal knowledge, enhancing the model's understanding of the legal context. This is computed by the following:  
\[e^{\text{ck}}=(\text{W}_{\text{Q}}^{\text{c}}\text{h}^{\text{c}})(\text{W}_{ \text{K}}^{\text{k}}\text{h}^{\text{k}})^{\text{T}} \tag{7}\]  
\[e^{\text{ck}^{\prime}}=v_{\text{ck}}^{\text{T}}\tanh(e^{\text{ck}}+\text{b}^{ \text{ck}}) \tag{8}\]  
\[\text{h}^{\text{ck}}=softmax\left(\frac{e^{\text{ck}^{\prime}}}{\sqrt{d_{k}} }\right)\left(\text{W}_{\text{V}}^{\text{k}}\text{h}^{\text{k}}\right) \tag{9}\]  
where \(\text{h}^{\text{ck}}\) is the attention output that combines charge descriptions and external knowledge; \(\text{W}_{\text{Q}}^{\text{c}}\), \(\text{W}_{\text{K}}^{\text{k}}\), and \(\text{W}_{\text{V}}^{\text{k}}\) are trainable weight matrices for charge descriptions and external knowledge; and \(\text{h}^{\text{c}}\) and \(\text{h}^{\text{k}}\) are the embeddings for charge descriptions and external knowledge, respectively. Lastly, the attention mechanism between fact description and external knowledge, expressed as \(\text{h}^{\text{fc}}=Att(\text{h}^{\text{f}},\text{h}^{\text{k}})\), allows the model to align factual details with broader legal principles and statutes, facilitating a comprehensive analysis that supports robust legal judgment prediction.