Intelligent judicial multi-task prediction method based on dynamic difficult case perception
By constructing a multi-task prediction model, difficult case samples in judicial data are dynamically identified and adjusted, which solves the limitations of static thresholds and single evaluation indicators in the judicial field, and improves the prediction accuracy and robustness of the model, especially its performance under extreme class imbalance conditions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SOUTH CHINA UNIV OF TECH
- Filing Date
- 2025-11-10
- Publication Date
- 2026-04-21
AI Technical Summary
Existing difficult case detection technologies suffer from several drawbacks in judicial applications. Static thresholds cannot match the dynamic learning state of the model, single evaluation indicators are insufficient to capture multi-dimensional complexity, and extreme class imbalances lead to insufficient model prediction accuracy and robustness.
A multi-task prediction model based on deep neural networks is constructed. Through a shared encoder, a crime prediction layer, a legal provision recommendation layer, a difficult case identification module, and an adaptive threshold dynamic adjustment mechanism, difficult case samples are dynamically identified and adjusted. The learning effect is optimized by combining prediction entropy, normalized prediction dispersion, and cross-task consistency score.
It significantly improves the model's prediction accuracy and robustness, alleviates the problem of extreme class imbalance, enhances the legal rationality and interpretability of legal provision recommendations, and achieves the synchronous evolution of multi-dimensional difficult case identification and model learning state.
Smart Images

Figure CN121327144B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, and in particular to an intelligent judicial multi-task prediction method based on dynamic difficult case perception. Background Technology
[0002] In deep learning model training, hard example mining techniques are crucial for improving model robustness and generalization ability. The core idea is to identify and reinforce learning those hard examples that are most valuable for improving model performance, such as samples located at the decision boundary, with high uncertainty, or high loss. In general domains, methods such as online hard example mining (which selects the sample with the highest loss for gradient updates) and Focal Loss (which automatically adjusts sample weights through modulation factors) have proven effective.
[0003] However, existing difficult case detection technologies exhibit significant limitations when dealing with complex textual data in professional fields such as the judiciary. First, mainstream methods generally rely on static, pre-set judgment thresholds. This static nature fails to match the dynamic evolution of the model throughout the training cycle: in the early stages of training, the model's predictions are generally unconfident, and an excessively high fixed threshold will cause the vast majority of samples to be labeled as difficult cases, rendering the focusing strategy meaningless; while in the later stages of training, the model's overall confidence improves, and an excessively low fixed threshold cannot filter out truly stubborn boundary cases, leading to insufficient motivation for optimization in the later stages of training. Second, judicial texts are semantically complex, and the difficulty of cases often manifests in multiple dimensions, making it difficult for a single evaluation metric to comprehensively and accurately capture their essence. For example, a sample may perform reasonably well on a single task, but its prediction results across tasks may show logical inconsistencies; this implicit "difficulty" cannot be measured by a single task evaluation metric.
[0004] More importantly, in judicial data with extreme class imbalances, traditional fixed-weight strategies may backfire. They may cause the model to overemphasize noisy boundary regions, thereby impairing the fit to the overall data distribution and failing to fundamentally improve the ability to identify classes with fewer samples. Therefore, there is an urgent need in this field for a dynamic hard-case detection method that can be implemented throughout the entire training process, possess multi-dimensional evaluation capabilities, and adaptively adjust recognition criteria and processing strategies to overcome the bottlenecks of existing technologies in professional applications. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings and deficiencies of the prior art and provide an intelligent judicial multi-task prediction method based on dynamic difficult case perception. It is mainly applied to the intelligent analysis of criminal cases. It improves the prediction accuracy and robustness of the model by collaboratively learning two tasks: crime prediction and legal provision recommendation, and by using dynamic difficult case mining to solve the problem of extreme class imbalance in judicial data.
[0006] To achieve the above objectives, the technical solution provided by this invention is as follows: an intelligent judicial multi-task prediction method based on dynamic difficult case perception. This method constructs a multi-task prediction model based on a deep neural network. During the training phase, this multi-task prediction model optimizes the learning effect through difficult case identification and dynamic threshold adjustment. During the inference phase, it outputs the crime prediction result and the legal provision recommendation result. The multi-task prediction model consists of a shared encoder, a crime prediction layer, a legal provision recommendation layer, a difficult case identification module, and an adaptive threshold dynamic adjustment mechanism. The shared encoder uses a pre-trained language model to perform deep semantic encoding on the case fact description text, extracting a unified semantic representation vector. The crime prediction layer and the legal provision recommendation layer respectively receive the semantic representation vector and output the crime prediction probability distribution and the legal provision recommendation probability distribution through their respective neural network layers. The difficult case identification module comprehensively evaluates the sample difficulty by calculating the prediction entropy value, normalized prediction dispersion, and cross-task consistency score. The adaptive threshold dynamic adjustment mechanism dynamically updates the difficult case judgment threshold according to the training process.
[0007] The specific implementation of this intelligent judicial multi-task prediction method includes the following steps:
[0008] S1. Training Phase: Real judicial case data is acquired as training samples. Each training sample contains a case fact description text, a set of crime labels, and a set of legal provision labels. The training samples are input into the multi-task prediction model for training. First, a shared encoder encodes the case fact description text to obtain a semantic representation vector. Then, the crime prediction layer and the legal provision recommendation layer output the crime prediction probability distribution and the legal provision recommendation probability distribution, respectively, based on the semantic representation vector. The crime prediction result is determined based on the crime prediction probability distribution, and the legal provision recommendation result is determined based on the legal provision recommendation probability distribution. The difficult case identification module calculates the prediction entropy, normalized prediction dispersion, and cross-task consistency score based on the crime prediction result and legal provision recommendation result output by the model and the crime label set and legal provision label set in the training samples to comprehensively evaluate the sample difficulty, thereby identifying difficult case samples. At the same time, an adaptive threshold dynamic adjustment mechanism dynamically updates the difficult case judgment threshold, that is, assigns higher weights to difficult case samples to optimize model training. After multiple rounds of training iterations, the multi-task prediction model with optimal performance is obtained.
[0009] S2, Reasoning Stage: Obtain the factual description text of the case to be predicted, input the factual description text of the case to be predicted into the multi-task prediction model with the best performance, and output the crime prediction result and the legal provision recommendation result.
[0010] Furthermore, during the training phase, the input case fact description text is represented as... ,in Indicates length is The text sequence, Indicates the first in the text sequence Each character, subscript The range of values is The case fact description text undergoes the following preprocessing operations before input: text cleaning, format mark removal, and special character filtering to ensure the standardization and consistency of the input text.
[0011] The pre-trained language model BERT was used as a shared encoder to perform deep semantic encoding on the case fact description text. The specific encoding process was as follows: First, a special marker [CLS] was added to the beginning of the text sequence, and a special marker [SEP] was added to the end of the text sequence to form a marker sequence that conformed to the BERT input format. Then, the marker sequence was input into BERT, which contains a 12-layer Transformer encoder. Through layer-by-layer feature extraction and self-attention mechanism, the hidden layer representation matrix was calculated and output. ,in Represents the set of real numbers. This represents the hidden layer dimension of BERT, where the hidden layer represents a matrix. Each line corresponds to the context-related semantic representation of a word in the input sequence. This context-related semantic representation integrates the semantic information of the word in the entire case fact description text.
[0012] The hidden layer representation matrix Extract the hidden state vector corresponding to the [CLS] marked position. The hidden state vector is used as the global semantic representation vector of the entire case fact description text. The global semantic representation vector aggregates the semantic information of the entire case fact description text through BERT's self-attention mechanism, which can capture the key legal elements and factual features of the case and provide a unified semantic basis for subsequent multi-task prediction.
[0013] Furthermore, the global semantic representation vector is input into the crime prediction layer for crime prediction. The specific processing flow is as follows: First, a Dropout regularization operation is applied to the input vector to predict the crime based on probability. The Dropout regularization operation randomly sets some neuron outputs to zero to prevent overfitting. Then, a linear transformation layer is used to perform dimension mapping on the regularized vector. The parameters of this linear transformation layer include a weight matrix. and bias vector ,in This represents the total number of crime categories; the linear transformation layer will... 3D semantic representation vector mapping to By defining the crime category space, we obtain the original output vector. The calculation formula is:
[0014] ;
[0015] Finally, the original output vector is transformed into a probability distribution using the softmax activation function, outputting the crime prediction probability distribution. ,in The variable represents the crime label; the first element of the crime prediction probability distribution. element Text describing the facts of the case Predicted as a crime The probability, subscript The range of values is , Indicates the first For each crime category, the probability is calculated using the following formula:
[0016] ;
[0017] In the formula, Represents the original output vector The One element, Represents the original output vector The 1 element, index in the summation symbol The range of values is .
[0018] Furthermore, the global semantic representation vector is input into the legal provision recommendation layer for legal provision recommendation. The processing flow of the legal provision recommendation layer is similar to that of the crime prediction layer, but the activation function is different. The specific processing flow is as follows: first, the same Dropout regularization operation is applied to the input vector, and then the regularized vector is dimension-mapped through a linear transformation layer. The parameters of the linear transformation layer include a weight matrix. and bias vector ,in The linear transformation layer maps the semantic representation vector to the total number of legal provisions. The original output vector is obtained by using the label space of the law elements. The calculation formula is:
[0019] ;
[0020] Finally, the applicability probability of each legal provision is calculated independently using the sigmoid activation function, and the recommended probability distribution of legal provisions is output. ,in Represents the legal provision label vector; the first of the legal provision recommendation probability distributions element Indicates the first individual legal provisions Applicable to case fact description text The probability, subscript The range of values is , Indicates the first individual legal provisions Whether it applies, when =0 indicates that it is not applicable. =1 indicates applicability, and the formula for calculating the probability is:
[0021] ;
[0022] In the formula, Represents the original output vector The One element, This represents the sigmoid activation function. Since a case may be subject to multiple legal provisions, the sigmoid activation function is used to make the prediction of each legal provision independent, thereby achieving multi-label classification.
[0023] The final output of the legal provision recommendation layer is the legal provision recommendation result. By setting a judgment threshold The probability distribution is obtained by filtering, and its mathematical expression is:
[0024] ;
[0025] In the formula, Recommended threshold values for legal provisions.
[0026] Furthermore, the difficult case identification module performs the following operations:
[0027] Calculate the prediction entropy value for the crime prediction task. This is used to quantify the uncertainty of the model's crime prediction; the prediction entropy value is based on the Shannon entropy definition in information theory, and is calculated by weighted summation of the prediction probabilities of all crime categories, as shown in the formula:
[0028] ;
[0029] When considering a specific sample, i.e., a factual description text of a specific case... When a model has high confidence in predicting a certain crime category, while the probabilities of other categories are close to 0, the prediction entropy is low, indicating high prediction certainty. Conversely, when the model predicts probabilities evenly across multiple crime categories, the prediction entropy is high, indicating uncertainty in the model's judgment of the crime for that sample; this sample is a hard example. In actual calculations, to avoid... The numerical problem, when At that time, it was agreed Its contribution to the predicted entropy value is 0;
[0030] Constructing a crime-legal provision association matrix As prior legal knowledge, the method for constructing the crime-legal provision association matrix is as follows: traverse the training dataset. For each training sample in the dataset, the index is... The range of values is , This represents the total number of training samples. Indicates the first Case text, Indicates the first The true charge label for each case Indicates the first A set of real legal provisions labels for each case; statistically analyze the frequency of simultaneous occurrence of each crime and each legal provision in the training dataset, and calculate the elements of the correlation matrix. This element represents the crime. With legal provisions The formula for calculating the strength of relevance in judicial practice is as follows:
[0031] ;
[0032] In the formula, Represents the crimes in the training dataset With legal provisions The number of cases occurring simultaneously This indicates that the training dataset contains crimes. The total number of cases, and the range of the correlation strength is: ;
[0033] For each training sample, the normalized prediction dispersion is calculated based on the probability distribution of the legal provisions. This is used to measure the uncertainty of the model in legal provision recommendation. Since legal provision recommendation is a multi-label classification task, directly using Shannon entropy is not applicable. Therefore, a normalized prediction dispersion is designed. The specific calculation process of the normalized prediction dispersion is as follows: First, screen for prediction probabilities exceeding a preliminary threshold. The legal provisions constitute the candidate legal provisions set. The initial threshold is used to filter out irrelevant legal provisions, focusing the calculation on the legal provisions that the model deems applicable; then, the normalized prediction dispersion is calculated for the legal provisions in the candidate legal provision set, using the following formula:
[0034] ;
[0035] In the formula, The cardinality of the candidate legal provisions set, i.e., the number of elements, is represented by the summation symbol. The summation rate of all legal provisions is calculated. The normalized prediction dispersion is obtained by averaging the log probabilities of candidate legal provisions, reflecting the average certainty of the model's predictions of these legal provisions. When the model's prediction probabilities for all candidate legal provisions are higher than the preset value, the normalized prediction dispersion is low. When there are many candidate legal provisions but the prediction probabilities are lower than the preset value, the normalized prediction dispersion is high, indicating that the model has difficulty in selecting legal provisions. This sample is a difficult example sample.
[0036] Calculate cross-task consistency score This is used to evaluate the consistency of the prediction results of the two tasks, crime prediction and legal provision recommendation, in terms of legal logic; the cross-task consistency score is based on a pre-constructed crime-legal provision association matrix. , of which elements Indicates the crime With legal provisions The strength of association in judicial practice is calculated by statistically analyzing the frequency of simultaneous occurrence of crimes and legal provisions in the training dataset; the formula for calculating the cross-task consistency score is:
[0037] ;
[0038] In the formula, The category of crime with the highest predicted probability. Indicates the prediction of the crime and the first individual legal provisions The strength of the association, For the legal provisions, the recommendation layer is the first The original output value of each law, and the law after sigmoid activation. Predicted probability The calculation formula is:
[0039] ;
[0040] For each training sample, the cross-task consistency score quantifies the degree of coordination between the prediction results of the two tasks by weighting and summing the correlation strength between the predicted crime and all legal provisions with the prediction probability of the corresponding legal provisions. A high consistency score indicates that the predicted crime and the recommended legal provisions match well in legal logic and conform to the rules of judicial practice. A low consistency score indicates that the predictions of the two tasks may be contradictory, and the sample may be near the decision boundary and belong to the difficult case.
[0041] Based on the above predicted entropy value Normalized prediction dispersion Cross-task consistency score Comprehensive judgment of difficult case samples; for case fact description text If any of the following conditions are met, it is marked as a hard example:
[0042] Predicting entropy Exceeding the entropy threshold ,Right now This indicates a high degree of uncertainty in predicting the charges;
[0043] Normalized prediction dispersion Exceeding the dispersion threshold ,Right now This indicates a high degree of uncertainty regarding the recommended legal provisions;
[0044] Cross-task consistency score Below the consistency threshold ,Right now This indicates that the charge is inconsistent with the legal provisions predicted.
[0045] Crime Predicted Losses Exceeding the loss threshold ,Right now This indicates that the model is in the factual description text of the case. Fitting on the surface is difficult; among them , , To increase the number of training steps Dynamically adjusted threshold A fixed consistency threshold; The cross-entropy loss for crime prediction, where Text describing the facts of the case The true charge label;
[0046] By combining the above four conditions using logical OR operations, difficult samples in the training process can be identified from multiple dimensions, including ambiguous samples located at the category boundary, inconsistent samples where the crime and the legal provision prediction contradict each other, and high-loss samples where the model is difficult to fit.
[0047] Furthermore, the adaptive threshold dynamic adjustment mechanism performs the following operations:
[0048] Set an initial entropy threshold before training begins. and initial loss threshold Simultaneously set the threshold update interval. and time window size Used for collecting statistical samples;
[0049] During the training process, every The threshold update is triggered once per training batch, for the ... Sample Its predicted entropy value The crime prediction loss is defined as the Shannon entropy of the probability distribution of the crime prediction for that sample by the model. Defined as model on samples Cross-entropy loss for crime prediction;
[0050] Multi-task prediction model collection time window The set of predicted entropy values for all training samples. and the set of crime prediction loss values for:
[0051] ;
[0052] ;
[0053] in, This indicates the current training step count; the time window design ensures that threshold updates are based on the model's recent performance and can reflect the learning status of the current training phase.
[0054] Dynamically updating thresholds based on percentile statistics, i.e., calculating the set of predicted entropy values. The 75th percentile as the new entropy threshold Calculate the set of crime prediction loss values The 75th percentile was used as the new loss threshold. Using the 75th percentile means marking the worst 25% of samples as difficult examples. This proportion can balance the focus on difficult examples with training stability. The advantage of the percentile statistical method over the fixed threshold is its adaptability: when the overall uncertainty of the model is high in the early stage of training, the threshold calculated by the percentile is also relatively high. As training progresses and the model performance improves, the percentile threshold automatically decreases, always maintaining the standard of relatively difficult sample identification.
[0055] By dynamically updating the threshold using the percentile-based statistical method, the entropy threshold changes from its initial value. Dynamically decreasing to the final value The loss threshold is from the initial loss threshold. Dynamically decreasing to the final value .
[0056] Furthermore, the specific details of the loss function and hard example weighting during model training are as follows:
[0057] The weights of the difficult examples are set as follows: The weights of the non-difficult sample are ,in The sample weights will affect the gradient update in subsequent loss calculations; the higher the sample weight, the greater its contribution to the model parameter update.
[0058] Construct a joint loss function for multiple tasks as the total loss function. The overall optimization objective of the model is to minimize the weighted combination of the crime prediction loss and the legal provision recommendation loss for the case fact description text. Total loss function Defined as:
[0059] ;
[0060] Crime Predicted Losses Using weighted cross-entropy:
[0061] ;
[0062] In the formula, Text describing the facts of the case The weights;
[0063] Legal recommendations for loss Using the binary cross-entropy form:
[0064] ;
[0065] In the formula, The dynamic weighting coefficients for the legal provision recommendation task are used to balance the learning progress of the two tasks; in batch training, the total loss of each batch is the average of the losses of all samples within the batch. :
[0066] ;
[0067] In the formula, This represents the set of samples in the current training batch. Batch size;
[0068] Dynamic task weights The system adaptively adjusts based on the learning progress of the crime prediction and legal provision recommendation tasks, with adjustment factors... Changes in losses between the two tasks , The differences are negatively correlated, and the formula is:
[0069] ;
[0070] In the formula, , and They represent the first The change in predicted loss based on crime and the change in loss recommended by legal provisions over a time interval. Indicates the first The decrease in predicted loss due to crime over a given time interval. This indicates the amount of loss recommended by the law. and They represent the first The average loss of the two tasks over a time interval. and They represent the first The average loss of the two tasks over a time interval. As the benchmark weighting coefficient, The adaptive threshold dynamic adjustment mechanism ensures that the two tasks maintain a relatively balanced learning progress during training, preventing one task from converging too early or stagnating, thereby improving the stability and overall performance of multi-task joint learning.
[0071] Furthermore, knowledge transfer is achieved during model training through a shared encoding layer and a crime-legal provision association matrix, and the specific details of the model output are as follows:
[0072] Based on the crime-legal provision association matrix, the semantic representation vector is shared through a shared encoder. During training, gradient signals from crime prediction loss and legal provision recommendation loss are received simultaneously. The parameters are updated through the backpropagation algorithm, enabling the crime prediction and legal provision recommendation tasks to learn from each other's training signals and achieve knowledge transfer.
[0073] During the training process, the correlation matrix is used. As prior knowledge, the cross-task consistency score is used to apply soft constraints to the model predictions in order to enhance the legal and logical rationality of the model output.
[0074] Output the final crime prediction result Legal recommendations .
[0075] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0076] 1. By constructing a crime-legal provision association matrix to explicitly encode prior legal knowledge, the legal logic in judicial practice is integrated into the model training, which significantly improves the legal rationality and interpretability of the prediction results.
[0077] 2. A difficult case identification mechanism was designed that integrates prediction entropy, normalized prediction dispersion, cross-task consistency score and task loss value. Compared with the existing technology that only relies on a single dimension of evaluation, it can identify difficult case samples more comprehensively and accurately.
[0078] 3. By adopting a dynamic threshold update method based on percentile statistics, the criteria for judging difficult cases are adaptively evolved with the training process, overcoming the limitations of the traditional fixed threshold method and realizing the synchronous evolution of difficult case identification and model learning state.
[0079] 4. By using a dual knowledge transfer path of shared encoder parameters and soft constraints of the association matrix, a small number of crimes can obtain additional training signals through high-frequency legal provisions, which effectively alleviates the problem of extreme class imbalance in judicial data.
[0080] 5. Experimental results show that the method of the present invention has achieved a significant improvement in the F1 score of the tail category, while maintaining the high performance of the head category, and has achieved a balance in the recognition performance of all categories, with a significant reduction in the overall variance, proving the effectiveness and practicality of the method of the present invention. Attached Figure Description
[0081] Figure 1 This is a flowchart for training and optimizing a multi-task prediction model.
[0082] Figure 2 A flowchart for perceiving dynamic difficult examples.
[0083] Figure 3 A comparison chart showing the improvement effect of class imbalance. Detailed Implementation
[0084] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.
[0085] This embodiment discloses an intelligent judicial multi-task prediction method based on dynamic difficult case perception. The method constructs a multi-task prediction model based on a deep neural network. During the training phase, this model optimizes the learning effect through difficult case identification and dynamic threshold adjustment. During the inference phase, it outputs crime prediction results and legal provision recommendation results. The multi-task prediction model consists of a shared encoder, a crime prediction layer, a legal provision recommendation layer, a difficult case identification module, and an adaptive threshold dynamic adjustment mechanism. The shared encoder uses a pre-trained language model to perform deep semantic encoding on the case fact description text, extracting a unified semantic representation vector. The crime prediction layer and the legal provision recommendation layer respectively receive the semantic representation vector and output the crime prediction probability distribution and the legal provision recommendation probability distribution through their respective neural network layers. The difficult case identification module comprehensively evaluates the sample difficulty by calculating the prediction entropy value, normalized prediction dispersion, and cross-task consistency score. The adaptive threshold dynamic adjustment mechanism dynamically updates the difficult case judgment threshold according to the training process.
[0086] The specific implementation of this intelligent judicial multi-task prediction method includes the following steps:
[0087] S1, Training Phase: (e.g., ...) Figure 1As shown, real judicial case data is obtained as training samples. Each training sample contains a case fact description text, a set of crime labels, and a set of legal provision labels. The training samples are input into the multi-task prediction model for training. First, the shared encoder encodes the case fact description text to obtain a semantic representation vector. Then, the crime prediction layer and the legal provision recommendation layer output the crime prediction probability distribution and the legal provision recommendation probability distribution, respectively, based on the semantic representation vector. The crime prediction result is determined according to the crime prediction probability distribution, and the legal provision recommendation result is determined according to the legal provision recommendation probability distribution. The difficult case identification module calculates the prediction entropy, normalized prediction dispersion, and cross-task consistency score based on the crime prediction result and legal provision recommendation result output by the model and the crime label set and legal provision label set in the training samples to comprehensively evaluate the sample difficulty, thereby identifying difficult case samples. At the same time, the adaptive threshold dynamic adjustment mechanism dynamically updates the difficult case judgment threshold, that is, assigns higher weights to difficult case samples to optimize model training. After multiple rounds of training iterations, the multi-task prediction model with the best performance is obtained.
[0088] S2, Reasoning Stage: Obtain the factual description text of the case to be predicted, input the factual description text of the case to be predicted into the multi-task prediction model with the best performance, and output the crime prediction result and the legal provision recommendation result.
[0089] Specifically, during the training phase, the input case fact description text is represented as follows: ,in Indicates length is The text sequence, Indicates the first in the text sequence Each character, subscript The range of values is The case fact description text undergoes the following preprocessing operations before input: text cleaning, format mark removal, and special character filtering to ensure the standardization and consistency of the input text.
[0090] The pre-trained language model BERT was used as a shared encoder to perform deep semantic encoding on the case fact description text. The specific encoding process was as follows: First, a special marker [CLS] was added to the beginning of the text sequence, and a special marker [SEP] was added to the end of the text sequence to form a marker sequence that conformed to the BERT input format. Then, the marker sequence was input into BERT, which contains a 12-layer Transformer encoder. Through layer-by-layer feature extraction and self-attention mechanism, the hidden layer representation matrix was calculated and output. ,in Represents the set of real numbers. This represents the hidden layer dimension of BERT, where the hidden layer represents a matrix. Each line corresponds to the context-related semantic representation of a word in the input sequence. This context-related semantic representation integrates the semantic information of the word in the entire case fact description text.
[0091] The hidden layer representation matrix Extract the hidden state vector corresponding to the [CLS] marked position. The hidden state vector is used as the global semantic representation vector of the entire case fact description text. The global semantic representation vector aggregates the semantic information of the entire case fact description text through BERT's self-attention mechanism, which can capture the key legal elements and factual features of the case and provide a unified semantic basis for subsequent multi-task prediction.
[0092] Specifically, the global semantic representation vector is input into the crime prediction layer for crime prediction. The specific processing flow is as follows: First, a Dropout regularization operation is applied to the input vector to predict the crime based on probability. The Dropout regularization operation randomly sets some neuron outputs to zero to prevent overfitting. Then, a linear transformation layer is used to perform dimension mapping on the regularized vector. The parameters of this linear transformation layer include a weight matrix. and bias vector ,in This represents the total number of crime categories; the linear transformation layer will... 3D semantic representation vector mapping to By defining the crime category space, we obtain the original output vector. The calculation formula is:
[0093] ;
[0094] Finally, the original output vector is transformed into a probability distribution using the softmax activation function, outputting the crime prediction probability distribution. ,in The variable represents the crime label; the first element of the crime prediction probability distribution. element Text describing the facts of the case Predicted as a crime The probability, subscript The range of values is , Indicates the first For each crime category, the probability is calculated using the following formula:
[0095] ;
[0096] In the formula, Represents the original output vector The One element, Represents the original output vector The 1 element, index in the summation symbol The range of values is .
[0097] Specifically, the global semantic representation vector is input into the legal provision recommendation layer for legal provision recommendation. The processing flow of the legal provision recommendation layer is similar to that of the crime prediction layer, but the activation function is different. The specific processing flow is as follows: first, the same Dropout regularization operation is applied to the input vector, and then the regularized vector is dimension-mapped through a linear transformation layer. The parameters of the linear transformation layer include a weight matrix. and bias vector ,in The linear transformation layer maps the semantic representation vector to the total number of legal provisions. The original output vector is obtained by using the label space of the law elements. The calculation formula is:
[0098] ;
[0099] Finally, the applicability probability of each legal provision is calculated independently using the sigmoid activation function, and the recommended probability distribution of legal provisions is output. ,in Represents the legal provision label vector; the first of the legal provision recommendation probability distributions element Indicates the first individual legal provisions Applicable to case fact description text The probability, subscript The range of values is , Indicates the first individual legal provisions Whether it applies, when =0 indicates that it is not applicable. =1 indicates applicability, and the formula for calculating the probability is:
[0100] ;
[0101] In the formula, Represents the original output vector The One element, This represents the sigmoid activation function. Since a case may be subject to multiple legal provisions, the sigmoid activation function is used to make the prediction of each legal provision independent, thereby achieving multi-label classification.
[0102] The final output of the legal provision recommendation layer is the legal provision recommendation result. By setting a judgment threshold The probability distribution is obtained by filtering, and its mathematical expression is:
[0103] ;
[0104] In the formula, Recommended threshold values for legal provisions.
[0105] Specifically, the difficult example identification module performs the following operations:
[0106] Calculate the prediction entropy value for the crime prediction task. This is used to quantify the uncertainty of the model's crime prediction; the prediction entropy value is based on the Shannon entropy definition in information theory, and is calculated by weighted summation of the prediction probabilities of all crime categories, as shown in the formula:
[0107] ;
[0108] When considering a specific sample, i.e., a factual description text of a specific case... When a model has high confidence in predicting a certain crime category, while the probabilities of other categories are close to 0, the prediction entropy is low, indicating high prediction certainty. Conversely, when the model predicts probabilities evenly across multiple crime categories, the prediction entropy is high, indicating uncertainty in the model's judgment of the crime for that sample; this sample is a hard example. In actual calculations, to avoid... The numerical problem, when At that time, it was agreed Its contribution to the predicted entropy value is 0;
[0109] Constructing a crime-legal provision association matrix As prior legal knowledge, the method for constructing the crime-legal provision association matrix is as follows: traverse the training dataset. For each training sample in the dataset, the index is... The range of values is , This represents the total number of training samples. Indicates the first Case text, Indicates the first The true charge label for each case Indicates the first A set of real legal provisions labels for each case; statistically analyze the frequency of simultaneous occurrence of each crime and each legal provision in the training dataset, and calculate the elements of the correlation matrix. This element represents the crime. With legal provisions The formula for calculating the strength of relevance in judicial practice is as follows:
[0110] ;
[0111] In the formula, Represents the crimes in the training dataset With legal provisions The number of cases occurring simultaneously This indicates that the training dataset contains crimes. The total number of cases, and the range of the correlation strength is: ;
[0112] For each training sample, the normalized prediction dispersion is calculated based on the probability distribution of the legal provisions. This is used to measure the uncertainty of the model in legal provision recommendation. Since legal provision recommendation is a multi-label classification task, directly using Shannon entropy is not applicable. Therefore, a normalized prediction dispersion is designed. The specific calculation process of the normalized prediction dispersion is as follows: First, screen for prediction probabilities exceeding a preliminary threshold. The legal provisions constitute the candidate legal provisions set. The initial threshold is used to filter out irrelevant legal provisions, focusing the calculation on the legal provisions that the model deems applicable; then, the normalized prediction dispersion is calculated for the legal provisions in the candidate legal provision set, using the following formula:
[0113] ;
[0114] In the formula, The cardinality of the candidate legal provisions set, i.e., the number of elements, is represented by the summation symbol. The summation rate of all legal provisions is calculated. The normalized prediction dispersion is obtained by averaging the log probabilities of candidate legal provisions, reflecting the average certainty of the model's predictions of these legal provisions. When the model's prediction probabilities for all candidate legal provisions are higher than the preset value, the normalized prediction dispersion is low. When there are many candidate legal provisions but the prediction probabilities are lower than the preset value, the normalized prediction dispersion is high, indicating that the model has difficulty in selecting legal provisions. This sample is a difficult example sample.
[0115] Calculate cross-task consistency score This is used to evaluate the consistency of the prediction results of the two tasks, crime prediction and legal provision recommendation, in terms of legal logic; the cross-task consistency score is based on a pre-constructed crime-legal provision association matrix. , of which elements Indicates the crime With legal provisions The strength of association in judicial practice is calculated by statistically analyzing the frequency of simultaneous occurrence of crimes and legal provisions in the training dataset; the formula for calculating the cross-task consistency score is:
[0116] ;
[0117] In the formula, The category of crime with the highest predicted probability. Indicates the prediction of the crime and the first individual legal provisions The strength of the association, For the legal provisions, the recommendation layer is the first The original output value of each law, and the law after sigmoid activation. Predicted probability The calculation formula is:
[0118] ;
[0119] For each training sample, the cross-task consistency score quantifies the degree of coordination between the prediction results of the two tasks by weighting and summing the correlation strength between the predicted crime and all legal provisions with the prediction probability of the corresponding legal provisions. A high consistency score indicates that the predicted crime and the recommended legal provisions match well in legal logic and conform to the rules of judicial practice. A low consistency score indicates that the predictions of the two tasks may be contradictory, and the sample may be near the decision boundary and belong to the difficult case.
[0120] Based on the above predicted entropy value Normalized prediction dispersion Cross-task consistency score Comprehensive judgment of difficult case samples; for case fact description text If any of the following conditions are met, it is marked as a hard example:
[0121] Predicting entropy Exceeding the entropy threshold ,Right now This indicates a high degree of uncertainty in predicting the charges;
[0122] Normalized prediction dispersion Exceeding the dispersion threshold ,Right now This indicates a high degree of uncertainty regarding the recommended legal provisions;
[0123] Cross-task consistency score Below the consistency threshold ,Right now This indicates that the charge is inconsistent with the legal provisions predicted.
[0124] Crime Predicted Losses Exceeding the loss threshold ,Right now This indicates that the model is in the factual description text of the case. Fitting on the surface is difficult; among them , , To increase the number of training steps Dynamically adjusted threshold A fixed consistency threshold; The cross-entropy loss for crime prediction, where Text describing the facts of the case The true charge label;
[0125] By combining the above four conditions using logical OR operations, difficult samples in the training process can be identified from multiple dimensions, including ambiguous samples located at the category boundary, inconsistent samples where the crime and the legal provision prediction contradict each other, and high-loss samples where the model is difficult to fit.
[0126] Specifically, the adaptive threshold dynamic adjustment mechanism performs the following operations:
[0127] Set an initial entropy threshold before training begins. and initial loss threshold Simultaneously set the threshold update interval. and time window size Used for collecting statistical samples;
[0128] During the training process, every The threshold update is triggered once per training batch, for the ... Sample Its predicted entropy value The crime prediction loss is defined as the Shannon entropy of the probability distribution of the crime prediction for that sample by the model. Defined as model on samples Cross-entropy loss for crime prediction;
[0129] Multi-task prediction model collection time window The set of predicted entropy values for all training samples. and the set of crime prediction loss values for:
[0130] ;
[0131] ;
[0132] in, This indicates the current training step count; the time window design ensures that threshold updates are based on the model's recent performance and can reflect the learning status of the current training phase.
[0133] Dynamically updating thresholds based on percentile statistics, i.e., calculating the set of predicted entropy values. The 75th percentile as the new entropy threshold Calculate the set of crime prediction loss values The 75th percentile was used as the new loss threshold. Using the 75th percentile means marking the worst 25% of samples as difficult examples. This proportion can balance the focus on difficult examples with training stability. The advantage of the percentile statistical method over the fixed threshold is its adaptability: when the overall uncertainty of the model is high in the early stage of training, the threshold calculated by the percentile is also relatively high. As training progresses and the model performance improves, the percentile threshold automatically decreases, always maintaining the standard of relatively difficult sample identification.
[0134] By dynamically updating the threshold using the percentile-based statistical method, the entropy threshold changes from its initial value. Dynamically decreasing to the final value The loss threshold is from the initial loss threshold. Dynamically decreasing to the final value .
[0135] Specifically, the loss function and the weighting of hard examples in model training are as follows:
[0136] The weights of the difficult examples are set as follows: The weights of the non-difficult sample are ,in The sample weights will affect the gradient update in subsequent loss calculations; the higher the sample weight, the greater its contribution to the model parameter update.
[0137] Construct a joint loss function for multiple tasks as the total loss function. The overall optimization objective of the model is to minimize the weighted combination of the crime prediction loss and the legal provision recommendation loss for the case fact description text. Total loss function Defined as:
[0138] ;
[0139] Crime Predicted Losses Using weighted cross-entropy:
[0140] ;
[0141] In the formula, Text describing the facts of the case The weights;
[0142] Legal recommendations for loss Using the binary cross-entropy form:
[0143] ;
[0144] In the formula, The dynamic weighting coefficients for the legal provision recommendation task are used to balance the learning progress of the two tasks; in batch training, the total loss of each batch is the average of the losses of all samples within the batch. :
[0145] ;
[0146] In the formula, This represents the set of samples in the current training batch. Batch size;
[0147] Dynamic task weights The system adaptively adjusts based on the learning progress of the crime prediction and legal provision recommendation tasks, with adjustment factors... Changes in losses between the two tasks , The differences are negatively correlated, and the formula is:
[0148] ;
[0149] In the formula, , and They represent the first The change in predicted loss based on crime and the change in loss recommended by legal provisions over a time interval. Indicates the first The decrease in predicted loss due to crime over a given time interval. This indicates the amount of loss recommended by the law. and They represent the first The average loss of the two tasks over a time interval. and They represent the first The average loss of the two tasks over a time interval. As the benchmark weighting coefficient, The adaptive threshold dynamic adjustment mechanism ensures that the two tasks maintain a relatively balanced learning progress during training, preventing one task from converging too early or stagnating, thereby improving the stability and overall performance of multi-task joint learning.
[0150] Specifically, knowledge transfer is achieved during model training through a shared encoding layer and a crime-legal provision association matrix, and the specific details of the model output are as follows:
[0151] Based on the crime-legal provision association matrix, the semantic representation vector is shared through a shared encoder. During training, gradient signals from crime prediction loss and legal provision recommendation loss are received simultaneously. The parameters are updated through the backpropagation algorithm, enabling the crime prediction and legal provision recommendation tasks to learn from each other's training signals and achieve knowledge transfer.
[0152] During the training process, the correlation matrix is used. As prior knowledge, the cross-task consistency score is used to apply soft constraints to the model predictions in order to enhance the legal and logical rationality of the model output.
[0153] Output the final crime prediction result Legal recommendations .
[0154] Figure 2 illustrates the core workflow of the model training phase. The process begins with "Start Training" and "Initialize Thresholds," then enters a "Batch Training" loop. In each batch, the model first performs "Forward Propagation to Calculate Output," obtaining predictions of crimes and legal provisions; subsequently, it "Calculates Sample Entropy and Loss" to assess the learning difficulty of each sample. Based on Macro-F1, Weighted-F1, accuracy, and Top-K accuracy, the process enters a crucial decision-making stage—"Determining Negative Samples," which identifies difficult samples in the current training based on dynamic thresholds. For samples determined to be difficult, a "High Weight 2.0" is set to give them greater attention in loss calculation; while non-difficult samples are "Set to Normal Weight 1.0." Afterward, the model "Calculates Weighted Loss" and performs "Backpropagation Update" to optimize parameters. A dynamic feedback loop is embedded in the process: it checks if the "Update Interval" has been reached. If the condition is met, it triggers the steps of "Collecting Statistical Information" and "Updated Dynamic Thresholds," ensuring that the criteria for determining difficult samples can adaptively evolve with the training process. The updated threshold will be used for training in subsequent batches until the "training complete?" condition is met, at which point training will finally "end".
[0155] Figure 2 This invention clearly demonstrates how it achieves continuous focus and efficient utilization of difficult sample data through a closed loop of perception, weighting, and adaptive adjustment.
[0156] To verify the effectiveness of the method of this invention, Macro-F1, Weighted-F1, accuracy and Top-K accuracy were used as evaluation criteria. The method was compared with the baseline method on the authoritative judicial dataset CAIL2018. The experimental results are shown in Table 1.
[0157] Table 1. Analysis of Experimental Results
[0158]
[0159] Experimental results show that the method of this invention significantly outperforms the baseline in all evaluation metrics. Specifically, the Macro-F1 score for crime prediction reaches 59.87%, an improvement of 24.7% compared to the baseline; the Weighted-F1 score and accuracy improve to 90.17% and 90.70%, respectively. In the legal provision recommendation task, the Top-5 and Top-10 accuracies reach 91.46% and 93.56%, respectively, both exceeding 16 percentage points compared to the baseline. These results fully demonstrate the effectiveness of the method of this invention.
[0160] Figure 3 This demonstrates the significant effectiveness of the method of the present invention in handling the class imbalance problem. For example... Figure 3 As shown in (a), we categorize crimes into head categories based on the number of samples (sample size). ), Central Category ( ) and tail category ( The comparison results show that the method of the present invention provides the most significant improvement in the tail category. For example... Figure 3 As shown in (b), the method of this invention achieves significantly higher recognition accuracy than the baseline method for tail-related offenses where samples are scarce. Figure 3 As shown in the violin plot in (c), the F1 score distribution of the method of the present invention is more concentrated, the median is significantly improved, and the overall variance is lower. Smaller size results in more balanced overall performance. For example... Figure 3 As shown in (d), the method of the present invention outperforms the baseline method on almost all tail categories, especially for the extreme tail categories with the fewest samples, where the performance improvement is the greatest, fully verifying the effectiveness of the present invention in solving the problem of extreme class imbalance.
[0161] Experimental Conclusions: Addressing the issues of rigid hard case identification standards and insufficient multi-task collaboration in existing judicial intelligence models when handling extreme class imbalanced data, this invention proposes an intelligent judicial multi-task prediction method based on dynamic hard case perception. Experimental evaluation on the authoritative judicial dataset CAIL2018 shows that the proposed method significantly improves model performance. Specifically, the Macro-F1 score for crime prediction reaches 60.19% (an improvement of over 25 percentage points), and the Top-5 and Top-10 accuracy for legal provision recommendations both exceed 94%, comprehensively outperforming existing baseline methods. Future research will explore the generalization ability of this method on broader judicial tasks (such as sentence prediction) and how to combine it with large-scale language models to enhance model interpretability. It has broad application prospects in the construction of smart courts and the development of judicial auxiliary intelligent systems and deserves widespread promotion.
[0162] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A multi-task prediction method for intelligent judicial practice based on dynamic difficult case perception, characterized in that: This method constructs a multi-task prediction model based on a deep neural network. During the training phase, this model optimizes learning through difficult example identification and dynamic threshold adjustment. During the inference phase, it outputs crime prediction results and legal provision recommendation results. The multi-task prediction model consists of a shared encoder, a crime prediction layer, a legal provision recommendation layer, a difficult example identification module, and an adaptive threshold dynamic adjustment mechanism. The shared encoder uses a pre-trained language model to perform deep semantic encoding on the case fact description text, extracting a unified semantic representation vector. The crime prediction layer and the legal provision recommendation layer respectively receive the semantic representation vector and output the crime prediction probability distribution and the legal provision recommendation probability distribution through their respective neural network layers. The difficult example identification module comprehensively evaluates sample difficulty by calculating prediction entropy, normalized prediction dispersion, and cross-task consistency score. The adaptive threshold dynamic adjustment mechanism dynamically updates the difficult example judgment threshold according to the training process. The specific implementation of this intelligent judicial multi-task prediction method includes the following steps: S1. Training Phase: Real judicial case data is acquired as training samples. Each training sample contains a case fact description text, a set of crime labels, and a set of legal provision labels. The training samples are input into the multi-task prediction model for training. First, a shared encoder encodes the case fact description text to obtain a semantic representation vector. Then, the crime prediction layer and the legal provision recommendation layer output the crime prediction probability distribution and the legal provision recommendation probability distribution, respectively, based on the semantic representation vector. The crime prediction result is determined based on the crime prediction probability distribution, and the legal provision recommendation result is determined based on the legal provision recommendation probability distribution. The difficult case identification module calculates the prediction entropy, normalized prediction dispersion, and cross-task consistency score based on the crime prediction result and legal provision recommendation result output by the model and the crime label set and legal provision label set in the training samples to comprehensively evaluate the sample difficulty, thereby identifying difficult case samples. At the same time, an adaptive threshold dynamic adjustment mechanism dynamically updates the difficult case judgment threshold, that is, assigns higher weights to difficult case samples to optimize model training. After multiple rounds of training iterations, the multi-task prediction model with optimal performance is obtained. S2, Reasoning Stage: Obtain the factual description text of the case to be predicted, input the factual description text of the case to be predicted into the multi-task prediction model with the best performance, and output the crime prediction result and the legal provision recommendation result.
2. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 1, characterized in that, During the training phase, the input case fact description text is represented as follows: ,in Indicates length is The text sequence, Indicates the first in the text sequence Each character, subscript The range of values is The case fact description text undergoes the following preprocessing operations before input: text cleaning, format mark removal, and special character filtering to ensure the standardization and consistency of the input text. The pre-trained language model BERT was used as a shared encoder to perform deep semantic encoding on the case fact description text. The specific encoding process was as follows: First, a special marker [CLS] was added to the beginning of the text sequence, and a special marker [SEP] was added to the end of the text sequence to form a marker sequence that conformed to the BERT input format. Then, the marker sequence was input into BERT, which contains a 12-layer Transformer encoder. Through layer-by-layer feature extraction and self-attention mechanism, the hidden layer representation matrix was calculated and output. ,in Represents the set of real numbers. This represents the hidden layer dimension of BERT, where the hidden layer represents a matrix. Each line corresponds to the context-related semantic representation of a word in the input sequence. This context-related semantic representation integrates the semantic information of the word in the entire case fact description text. The hidden layer representation matrix Extract the hidden state vector corresponding to the [CLS] marked position. The hidden state vector is used as the global semantic representation vector of the entire case fact description text. The global semantic representation vector aggregates the semantic information of the entire case fact description text through BERT's self-attention mechanism, which can capture the key legal elements and factual features of the case and provide a unified semantic basis for subsequent multi-task prediction.
3. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 2, characterized in that, The global semantic representation vector is input into the crime prediction layer for crime prediction. The specific processing flow is as follows: First, a Dropout regularization operation is applied to the input vector to predict the crime based on probability. The Dropout regularization operation randomly sets some neuron outputs to zero to prevent overfitting. Then, a linear transformation layer is used to perform dimension mapping on the regularized vector. The parameters of this linear transformation layer include a weight matrix. and bias vector ,in This represents the total number of crime categories; the linear transformation layer will... 3D semantic representation vector mapping to By defining the crime category space, we obtain the original output vector. The calculation formula is: ; Finally, the original output vector is transformed into a probability distribution using the softmax activation function, outputting the crime prediction probability distribution. ,in The variable represents the crime label; the first element of the crime prediction probability distribution. element Text describing the facts of the case Predicted as a crime The probability, subscript The range of values is , Indicates the first For each crime category, the probability is calculated using the following formula: ; In the formula, Represents the original output vector The One element, Represents the original output vector The 1 element, index in the summation symbol The range of values is .
4. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 3, characterized in that, The global semantic representation vector is input into the legal provision recommendation layer for legal provision recommendation. The processing flow of the legal provision recommendation layer is similar to that of the crime prediction layer, but the activation function is different. The specific processing flow is as follows: First, the same Dropout regularization operation is applied to the input vector. Then, the regularized vector is dimension-mapped through a linear transformation layer. The parameters of the linear transformation layer include a weight matrix. and bias vector ,in The linear transformation layer maps the semantic representation vector to the total number of legal provisions. The original output vector is obtained by using the label space of the law elements. The calculation formula is: ; Finally, the applicability probability of each legal provision is calculated independently using the sigmoid activation function, and the recommended probability distribution of legal provisions is output. ,in Represents the legal provision label vector; the first of the legal provision recommendation probability distributions element Indicates the first individual legal provisions Applicable to case fact description text The probability, subscript The range of values is , Indicates the first individual legal provisions Whether it applies, when =0 indicates that it is not applicable. =1 indicates applicability, and the formula for calculating the probability is: ; In the formula, Represents the original output vector The One element, This represents the sigmoid activation function. Since a case may be subject to multiple legal provisions, the sigmoid activation function is used to make the prediction of each legal provision independent, thereby achieving multi-label classification. The final output of the legal provision recommendation layer is the legal provision recommendation result. By setting a judgment threshold The probability distribution is obtained by filtering, and its mathematical expression is: ; In the formula, Recommended threshold values for legal provisions.
5. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 4, characterized in that, The difficult case identification module performs the following operations: Calculate the prediction entropy value for the crime prediction task. This is used to quantify the uncertainty of the model's crime prediction; the prediction entropy value is based on the Shannon entropy definition in information theory, and is calculated by weighted summation of the prediction probabilities of all crime categories, as shown in the formula: ; When considering a specific sample, i.e., a factual description text of a specific case... When a model has high confidence in predicting a certain crime category, while the probabilities of other categories are close to 0, the prediction entropy is low, indicating high prediction certainty. Conversely, when the model predicts probabilities evenly across multiple crime categories, the prediction entropy is high, indicating uncertainty in the model's judgment of the crime for that sample; this sample is a hard example. In actual calculations, to avoid... The numerical problem, when At that time, it was agreed Its contribution to the predicted entropy value is 0; Constructing a crime-legal provision association matrix As prior knowledge of law; The method for constructing the crime-legal provision association matrix is as follows: traverse the training dataset. For each training sample in the dataset, the index is... The range of values is , This represents the total number of training samples. Indicates the first Case text, Indicates the first The true charge label for each case Indicates the first A set of real legal provisions labels for each case; statistically analyze the frequency of simultaneous occurrence of each crime and each legal provision in the training dataset, and calculate the elements of the correlation matrix. This element represents the crime. With legal provisions The formula for calculating the strength of relevance in judicial practice is as follows: ; In the formula, Represents the crimes in the training dataset With legal provisions The number of cases occurring simultaneously This indicates that the training dataset contains crimes. The total number of cases, and the range of the correlation strength is: ; For each training sample, the normalized prediction dispersion is calculated based on the probability distribution of the legal provisions. This is used to measure the uncertainty of the model in legal provision recommendation. Since legal provision recommendation is a multi-label classification task, directly using Shannon entropy is not applicable. Therefore, normalized prediction dispersion is designed. The specific calculation process of the normalized prediction dispersion is as follows: First, screen for prediction probabilities exceeding a preliminary threshold. The legal provisions constitute the candidate legal provisions set. The initial threshold is used to filter out irrelevant legal provisions, focusing the calculation on the legal provisions that the model deems applicable; then, the normalized prediction dispersion is calculated for the legal provisions in the candidate legal provision set, using the following formula: ; In the formula, The cardinality of the candidate legal provisions set, i.e., the number of elements, is represented by the summation symbol. The summation rate of all legal provisions is calculated. The normalized prediction dispersion is obtained by averaging the log probabilities of candidate legal provisions, reflecting the average certainty of the model's predictions of these legal provisions. When the model's prediction probabilities for all candidate legal provisions are higher than the preset value, the normalized prediction dispersion is low. When there are many candidate legal provisions but the prediction probabilities are lower than the preset value, the normalized prediction dispersion is high, indicating that the model has difficulty in selecting legal provisions. This sample is a difficult example sample. Calculate cross-task consistency score This is used to evaluate the consistency of the prediction results between the two tasks of crime prediction and legal provision recommendation in terms of legal logic; the cross-task consistency score is based on a pre-constructed crime-legal provision association matrix. , of which elements Indicates the crime With legal provisions The strength of association in judicial practice is calculated by statistically analyzing the frequency of simultaneous occurrence of crimes and legal provisions in the training dataset; the formula for calculating the cross-task consistency score is: ; In the formula, The category of crime with the highest predicted probability. Indicates the prediction of the crime and the first individual legal provisions The strength of the association, For the legal provisions, the recommendation layer is the first The original output value of each law, and the law after sigmoid activation. Predicted probability The calculation formula is: ; For each training sample, the cross-task consistency score quantifies the degree of coordination between the prediction results of the two tasks by weighting and summing the correlation strength between the predicted crime and all legal provisions with the prediction probability of the corresponding legal provisions. A high consistency score indicates that the predicted crime and the recommended legal provisions match well in legal logic and conform to the rules of judicial practice. A low consistency score indicates that the predictions of the two tasks may be contradictory, and the sample may be near the decision boundary and belong to the difficult case. Based on the above predicted entropy value Normalized prediction dispersion Cross-task consistency score Comprehensive judgment of difficult case samples; for case fact description text If any of the following conditions are met, it is marked as a hard example: Predicting entropy Exceeding the entropy threshold ,Right now This indicates a high degree of uncertainty in predicting the charges. Normalized prediction dispersion Exceeding the dispersion threshold ,Right now This indicates a high degree of uncertainty regarding the recommended legal provisions; Cross-task consistency score Below the consistency threshold ,Right now This indicates that the charge is inconsistent with the legal provisions predicted. Crime Predicted Losses Exceeding the loss threshold ,Right now This indicates that the model is in the factual description text of the case. Fitting on the surface is difficult; among them , , To increase the number of training steps Dynamically adjusted threshold A fixed consistency threshold; The cross-entropy loss for crime prediction, where Text describing the facts of the case The true charge label; By combining the above four conditions using logical OR operations, difficult samples in the training process can be identified from multiple dimensions, including ambiguous samples located at the category boundary, inconsistent samples where the crime and the legal provision prediction contradict each other, and high-loss samples where the model is difficult to fit.
6. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 5, characterized in that, The adaptive threshold dynamic adjustment mechanism performs the following operations: Set an initial entropy threshold before training begins. and initial loss threshold ; Simultaneously set the threshold update interval and time window size Used for collecting statistical samples; During the training process, every The threshold update is triggered once per training batch, for the ... Sample Its predicted entropy value The crime prediction loss is defined as the Shannon entropy of the probability distribution of the crime prediction for that sample by the model. Defined as model on samples Cross-entropy loss for crime prediction; Multi-task prediction model collection time window The set of predicted entropy values for all training samples. and the set of crime prediction loss values for: ; ; in, This indicates the current training step count; the time window design ensures that threshold updates are based on the model's recent performance and can reflect the learning status of the current training phase. Dynamically updating thresholds based on percentile statistics, i.e., calculating the set of predicted entropy values. The 75th percentile as the new entropy threshold Calculate the set of predicted loss values for the crime. The 75th percentile was used as the new loss threshold. Using the 75th percentile means marking the worst 25% of samples as hard examples. This proportion can balance hard example focus with training stability. The advantage of the percentile statistical method over the fixed threshold is its adaptability: when the overall uncertainty of the model is high in the early stage of training, the threshold calculated by the percentile is also relatively high. As training progresses and model performance improves, the percentile threshold automatically decreases, maintaining a standard for identifying relatively difficult samples. By dynamically updating the threshold using the percentile-based statistical method, the entropy threshold changes from its initial value. Dynamically decreasing to the final value The loss threshold is from the initial loss threshold. Dynamically decreasing to the final value .
7. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 6, characterized in that, The specifics of the loss function and hard example weighting in model training are as follows: The weights of the difficult examples are set as follows: The weights of the non-difficult sample are ,in ; The sample weights will affect the gradient update in the subsequent loss calculation; the higher the weight of the sample, the greater its contribution to the model parameter update. Construct a joint loss function for multiple tasks as the total loss function. The overall optimization objective of the model is to minimize the weighted combination of the crime prediction loss and the legal provision recommendation loss for the case fact description text. Total loss function Defined as: ; Crime Predicted Losses Using weighted cross-entropy: ; In the formula, Text describing the facts of the case The weights; Legal recommendations for loss Using the binary cross-entropy form: ; In the formula, The dynamic weighting coefficients for the legal provision recommendation task are used to balance the learning progress of the two tasks; in batch training, the total loss of each batch is the average of the losses of all samples within the batch. : ; In the formula, This represents the set of samples in the current training batch. Batch size; Dynamic task weights The system adaptively adjusts based on the learning progress of the crime prediction and legal provision recommendation tasks, with adjustment factors... Changes in losses between the two tasks , The differences are negatively correlated, and the formula is: ; In the formula, , and They represent the first The change in predicted loss based on crime and the change in loss based on legal provisions over a time interval. Indicates the first The decrease in predicted loss due to crime over a given time interval. This indicates the amount of loss recommended by the law. and They represent the first The average loss of the two tasks over a time interval. and They represent the first The average loss of the two tasks over a time interval. As the benchmark weighting coefficient, The adaptive threshold dynamic adjustment mechanism ensures that the two tasks maintain a relatively balanced learning progress during training, preventing one task from converging too early or stagnating, thereby improving the stability and overall performance of multi-task joint learning.
8. The intelligent judicial multi-task prediction method based on dynamic difficult case perception according to claim 7, characterized in that, Knowledge transfer is achieved during model training through a shared encoding layer and a crime-legal provision association matrix. The specific details of the model output are as follows: Based on the crime-legal provision association matrix, the semantic representation vector is shared through a shared encoder. During training, gradient signals from crime prediction loss and legal provision recommendation loss are received simultaneously. The parameters are updated through the backpropagation algorithm, enabling the crime prediction and legal provision recommendation tasks to learn from each other's training signals and achieve knowledge transfer. During the training process, the correlation matrix is used. As prior knowledge, the cross-task consistency score is used to apply soft constraints to the model predictions in order to enhance the legal and logical rationality of the model output. Output the final crime prediction result Legal recommendations .
Citation Information
Patent Citations
Intelligent auxiliary handling method for legal affairs and multi-agent system
CN120256605A
Method for training deep neural network and apparatus
US20210012198A1