# A Sentence Prediction Approach Incorporating Trial Logic Based on Abductive Learning
## 3 Methods
### Sentencing Calculation  
To be more in line with the flow of the trial, the sentence calculation module was designed in accordance with the Sentencing Guidelines. As shown in Figure 4, we can see the process for obtaining a base sentence and a final sentence separately. We first combined the amount of money involved in the case obtained from the judgment documents with the sentence range obtained by logical reasoning based on the legal knowledge base to design a method to obtain the base sentence.  
\[\textit{BaseSentence}=\beta m+\gamma \tag{4}\]  
where \(\beta\) represents the adjustment of the amount of theft to the starting sentence, \(m\) represents the amount of theft in the case, and \(\gamma\) represents the starting sentence in the statute. Since the base sentence is not defined in detail in the Sentencing Guidelines, we can only calculate it based on one of the reference theft amounts, while the base sentence can only be within the range specified in the involved law. Therefore, we constructed a one-dimensional function of the amount to calculate the base sentence.  
To focus on the key plot elements and consider the global features of the case, we combined the key plot elements with the general features of the case by referring to the self-attention [24] approach. In this way, not only the global features, but also the key circumstances are considered. By combining the information of key plot elements and general features of the case, we generated an attention weight for each part of the text and weighted the text information, which can help us better capture the information related to the key plot in the text paragraph.  
We first performed feature extraction on the two texts by BERT as in Section 3.2 and obtained the vector \(D\) of common features of the case and the feature vector \(E\) of key elements of the case, where both \(D\) and \(E\) are global information about the respective text.  
Then, we put these two vectors through a control attention mechanism to obtain features about the plot descriptions that exacerbate the critical plot element parts.  
\[V=W^{V}D \tag{5}\]  
\[K=W^{K}D \tag{6}\]  
\[Q=W^{Q}E \tag{7}\]  
multiplying the two eigenvectors with the matrix \(W\) yields \(V\), \(K\), and \(Q\).  
\[Attention(Q,K,V)=softmax(\frac{QK^{T}}{\sqrt{d_{k}}})V \tag{8}\]  
We calculated the dot product between \(Q\) and \(K\). Next, for its result to be too large, a constraint operation was performed to divide the result by \(\sqrt{d_{k}}\), where \(d_{k}\) is the dimensionality of the vector \(K\). After that, a softmax layer was added to it to normalize the result  
Figure 4: A flow chart of the trial according to the relevant documents. (**a**) Base sentence; (**b**) final sentence.  
and then multiplied by the matrix \(V\) to obtain the final weight summation representation \(Attention\). Moreover, the obtained results were plugged into a layer of the neural network, while the base sentence was added for linear regression, and finally, the final sentence was obtained.  
The whole algorithmic process of sentencing calculation presented in this section is shown in Algorithm 2.  
```
0: Accident description data \(D_{i}\) of judgment document and amount of theft \(M_{i}\); key circumstance element \(Y_{i}\); real sentence \(S_{i}\); unlabeled data \(D_{j}\) with their related laws Laws, amount of theft \(M_{j}\) and key circumstance element \(Y_{j}\) obtained from a previous mission; legal knowledge base (KB)
0:\(D_{j}\) corresponding to sentence \(S_{j}\)
1:\(g\leftarrow\text{TrainModel}(D_{i},M_{i},Y_{i},S_{i})\)# Training neural network \(g\)
2:\(\gamma\leftarrow\text{Abduce}(M_{j},Laves,KB)\)
3:\(BaseSentence\leftarrow\beta\times M_{j}+\gamma\)
4:\(S_{j}\gets g(BaseSentence,D_{j},Y_{j})\)
5:return\(S_{j}\)
```  
**Algorithm 2** Sentencing calculation.