Encoder training method, judgment prediction method and device for legal judgment
By constructing sample case triplets and training the encoder, the problem of insufficient accuracy of existing encoders in legal judgments is solved, and high-accuracy prediction of case judgment results is achieved.
Patent Information
- Application Number
- CN202111482210.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2041-12-06
AI Technical Summary
During the training process of existing encoders, high-frequency cases dominate, resulting in low accuracy of legal judgment results based on existing encoders.
Construct a sample case triplet, including the sample original case, the sample similar case and the sample dissimilar case. By training the encoder, the distance between the sample original case and the sample similar case is made smaller than the distance between the sample original case and the sample dissimilar case. The accuracy of the encoder is improved through the category decoder and the decision prediction model.
The accuracy of the encoder in coding cases is improved, thereby improving the prediction accuracy of legal decision outcomes, especially the ability to distinguish between high-frequency and low-frequency cases.
Smart Images

Figure CN114138937B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of legal judgment, and in particular to an encoder training method, a judgment prediction method and a device for legal judgment. Background Art
[0002] Case-based legal judgment prediction (LJR) is a key task in legal intelligence, typically consisting of three subtasks: crime prediction, legal provision prediction, and sentence prediction. Existing research efforts fall into two main categories: single-task modeling and multi-task modeling. The former aims to improve the performance of algorithms on a specific subtask by leveraging more information sources and more advanced network architectures, while the latter aims to improve the performance of algorithms on the entire legal judgment prediction task by modeling the different topological structures between subtasks. Both single-task and multi-task modeling predict judgment outcomes based on the encoder's encoding of the case. However, because they only encode the original sample cases, high-frequency cases dominate the encoder training process, ultimately resulting in poorly accurate predictions based on the output of the trained encoder.
[0003] In summary, the judgment results obtained by the existing encoder in the prior art have low accuracy.
[0004] Therefore, the existing technology still needs to be improved and enhanced. Summary of the Invention
[0005] To solve the above technical problems, the present invention provides an encoder training method, a judgment prediction method and a device for legal judgment, which solves the problem of low accuracy of judgment results obtained by existing encoders in the prior art.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a method for training an encoder for legal judgment, comprising:
[0008] Constructing a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal article and / or the same crime, and the sample dissimilar case and the sample original case are subject to different legal articles and / or different crimes, and the sample dissimilar case is a high-frequency case;
[0009] An encoder is trained based on the sample case triples to obtain a trained encoder, which is used to encode the content of the case.
[0010] In one implementation, the step of training an encoder based on the sample case triples to obtain a trained encoder includes:
[0011] The encoder is trained until the distance between the sample original case and the sample similar case in the sample case triplet is less than the distance between the sample original case and the sample dissimilar case, the distance between the sample original case and the sample similar case is obtained by the original case encoding result of the sample original case by the encoder and the similar case encoding result of the sample similar case by the encoder, the distance between the sample original case and the sample similar case is used to reflect the similarity between the original case encoding result and the similar case encoding result, the distance between the sample original case and the sample dissimilar case is obtained by the original case encoding result and the dissimilar case encoding result of the sample dissimilar case by the encoder, the distance between the sample original case and the sample dissimilar case is used to reflect the similarity between the original case encoding result and the dissimilar case encoding result of the sample dissimilar case.
[0012] In one implementation, the step of training an encoder based on the sample case triples to obtain a trained encoder includes:
[0013] According to the sample original case in the sample case triple, obtaining the sample original case category corresponding to the sample original case;
[0014] Encoding the sample original case according to the encoder to obtain an original case encoding result corresponding to the sample original case;
[0015] Get the category decoder corresponding to the original case of the sample;
[0016] The encoder is trained until the decoding category obtained by the category decoder performing category decoding on the original case encoding result output by the encoder matches the decoding category, thereby obtaining a trained encoder, wherein the setting condition is obtained by a prediction loss function value composed of the original case category of the sample and the decoding category.
[0017] In one implementation, the step of training an encoder based on the sample case triples to obtain a trained encoder includes:
[0018] According to the sample original case in the sample case triple, obtaining the sample original case crime and the sample original case law clause corresponding to the sample original case;
[0019] Encoding the sample original case according to the encoder to obtain an original case encoding result corresponding to the sample original case;
[0020] Obtaining a category decoder corresponding to the original case of the sample;
[0021] Decoding the original case encoding result by the category decoder to obtain a decoded original case category;
[0022] Obtaining a decision prediction model corresponding to the sample original case according to the decoded original case category;
[0023] Obtaining the predicted original case crime and the predicted original case law corresponding to the sample original case based on the judgment prediction model;
[0024] The encoder is trained until the predicted original case charge matches the sample original case charge and / or the predicted original case law section matches the sample original case law section, thereby obtaining a trained encoder.
[0025] In one implementation, the step of training an encoder based on the sample case triples to obtain a trained encoder includes:
[0026] The encoder is trained according to the sample case triples until a function value corresponding to a result output by the encoder converges, thereby obtaining a trained encoder.
[0027] In one implementation, the function value corresponding to the result output by the encoder is equal to the distance plus the prediction loss function value plus the prediction result value, wherein the distance is obtained by the encoder encoding the original case corresponding to the sample original case, the similar case encoding result corresponding to the sample similar case encoding, and the dissimilar case encoding result corresponding to the sample dissimilar case encoding. The distance is used to reflect the similarity of the original case encoding result, the similar case encoding result, and the dissimilar case encoding result. The prediction loss function value is composed of the sample original case category corresponding to the sample original case and the decoding category. The prediction result value is obtained by predicting the sample original case through a decision prediction model.
[0028] In a second aspect, an embodiment of the present invention further provides a method for predicting a legal decision result based on an encoder, comprising:
[0029] Input the case to be predicted into the trained encoder to obtain the trained encoder
[0030] The encoder treats the encoding result of the prediction case, and the encoder after training is the encoder obtained by training the encoder with the sample case triples;
[0031] Performing category decoding on the encoding result to obtain the category corresponding to the case to be predicted;
[0032] When the category corresponding to the case to be predicted is a high-frequency category case, the legal article and / or the crime in the judgment result corresponding to the case to be predicted is obtained by using a high-frequency judgment prediction model;
[0033] When the category corresponding to the case to be predicted is a low-frequency category case, the legal provision and / or the crime in the judgment result corresponding to the case to be predicted is obtained through a low-frequency judgment prediction model.
[0034] In a third aspect, an embodiment of the present invention further provides an apparatus for predicting a legal judgment result, wherein the apparatus includes the following components:
[0035] A triplet construction module is used to construct a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal provisions and / or the same charges, and the sample dissimilar case and the sample original case are subject to different legal provisions and / or different charges, and the sample dissimilar case is a high-frequency case;
[0036] The encoder training module is used to train an encoder based on the sample case triples to obtain a trained encoder, and the encoder is used to encode the content of the case.
[0037] In a fourth aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and an encoder training program for legal judgment results or a prediction program for legal judgment results based on an encoder, which is stored in the memory and can be run on the processor. When the processor executes the encoder training program for legal judgment results or the prediction program for legal judgment results based on an encoder, the steps of the encoder training method for legal judgment or the prediction method for legal judgment results based on an encoder are implemented as described above.
[0038] In a fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which is stored an encoder training program for legal judgment results or a prediction program for legal judgment results based on an encoder. When the encoder training program for legal judgment results is executed by a processor or the prediction program for legal judgment results based on an encoder is executed by a processor, the steps of the above-mentioned encoder training method for legal judgment or the above-mentioned prediction method for legal judgment results based on an encoder are implemented.
[0039] Beneficial effect: The present invention first constructs a sample case triple, and the sample case triple includes a sample original case, a sample similar case, and a sample dissimilar case. Among them, the sample dissimilar case is a case that is dissimilar to the sample original case, and the sample dissimilar case is a high-frequency case (a case that occurs frequently). The encoder is trained by the sample case triple. Since the sample dissimilar case is a high-frequency case, in the process of training the encoder, the intra-class distinction of high-frequency cases and the inter-class distinction of low-frequency cases can be constrained, thereby weakening the influence of high-frequency cases on the encoder, thereby improving the accuracy of the encoder in encoding the case, and on the basis of accurate encoding, further improving the accuracy of the prediction of the case judgment result.
[0040] In addition, since the present invention constructs case triples based on legal provisions and charges, legal provisions and charges are introduced into the case triples, which realizes the refinement of the encoder and improves the accuracy of the prediction of the case judgment results. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is the overall flow chart of the present invention;
[0042] Figure 2 is a flowchart of the case triple-based legal decision prediction algorithm of the present invention;
[0043] Figure 3 This is a block diagram of the internal structure of a terminal device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following is a clear and complete description of the technical solutions of the present invention in conjunction with the embodiments and the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0045] Research has found that case-based legal judgment prediction (LJR) is a key task in legal intelligence, typically consisting of three subtasks: crime prediction, legal provision prediction, and sentence prediction. Existing research efforts fall into two main categories: single-task modeling and multi-task modeling. The former aims to improve algorithm performance on a specific subtask by leveraging more information sources and more advanced network architectures, while the latter aims to improve algorithm performance on the entire LJR task by modeling the different topological structures between subtasks. Both single-task and multi-task modeling methods predict judgment outcomes based on the encoder's encoding of the case. However, because they only encode the original case, high-frequency cases dominate the encoder's training process, ultimately resulting in poorly accurate predictions based on the output of the trained encoder.
[0046] To address the above-mentioned technical problems, the present invention provides an encoder training method, a judgment prediction method, and an apparatus for legal judgments, which address the low accuracy of judgments predicted by existing prediction methods. In specific implementations, a sample case triple is constructed using the original sample case, a sample similar case, and a sample dissimilar case. An encoder is trained based on this case triple to obtain a trained encoder. The trained encoder is used to input the case to be predicted to obtain an encoding result for the case to be predicted, and the encoding result is used to predict the judgment result corresponding to the case to be predicted. This embodiment utilizes case triples to improve the accuracy of case judgment prediction.
[0047] For example, the original case is burglary, with the corresponding crime being theft and the violation being Article A of the Criminal Code. A similar case is theft in a public place, with the corresponding crime being theft and the violation being Article A. A dissimilar case is financial fraud, with the corresponding crime being fraud and the violation being Article B of the Criminal Code. Financial fraud occurs most frequently in all cases, making it a high-frequency case. Theft in a public place and burglary share the same crime and article, making them similar cases. However, financial fraud and burglary share different crime and article, making them dissimilar cases. Therefore, a case triple can be constructed using burglary, theft in a public place, and financial fraud.
[0048] Exemplary Methods
[0049] The method for predicting the legal judgment result of this embodiment can be applied to a terminal device, which can be a terminal product with computing functions, such as a computer. This embodiment includes two parts: one is to train the encoder, and the other is to predict based on the trained encoder, such as Figure 1As shown in , the method for predicting the legal judgment result specifically includes the following steps:
[0050] S100, constructing a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal provision and / or the same crime, and the sample dissimilar case and the sample original case are subject to different legal provisions and / or different crimes, and the sample dissimilar case is classified as a high-frequency case.
[0051] This embodiment obtains sample original cases, sample similar cases, and sample dissimilar cases by sampling the case library. Moreover, regardless of whether the sample original case is a high-frequency case (a case that occurs frequently) or a low-frequency case (a case that occurs occasionally and occurs less frequently), the case characteristics of high and low frequencies are not considered when selecting sample similar cases. Instead, sample similar cases with the same legal provisions and / or the same charges as the sample original cases are randomly selected. In selecting sample dissimilar cases, the case library is first divided into high and low frequencies, and then sample dissimilar cases with different legal provisions and / or different charges as the sample original cases are randomly selected from the high-frequency case library. After selecting the sample original case, sample similar case, and sample dissimilar case, these three are used to construct a sample case triple.
[0052] Let f represent the original sample case: f = [S; y1, y2, y att ], where S={S1,S2,…,S n}, indicating that the sentence S i The fact description consists of y1, which is the legal label, and y2, which is the crime label. att is a class label, when f is a high frequency case y att =1, otherwise y att = 0. For the original case f, randomly sample similar cases from the candidate case set with the same legal article label or crime label and Regardless of the category label of the original case f, it is derived from samples with different legal labels or different crime labels and high frequency (y att =1) randomly sample the candidate case set to obtain the sample dissimilar case f dis Finally, we can get the case triples when considering the law and case triples when considering charges
[0053] S200 , training an encoder based on the sample case triples to obtain a trained encoder, wherein the encoder is used to encode the content of the case.
[0054] This embodiment includes four methods for training the encoder, which are described below:
[0055] The first method includes: training the encoder until the distance between the sample original case and the sample similar case in the sample case triplet is less than the distance between the sample original case and the sample dissimilar case, the distance between the sample original case and the sample similar case is obtained by the original case encoding result of the sample original case by the encoder and the similar case encoding result of the sample similar case by the encoder, and the distance between the sample original case and the sample dissimilar case is obtained by the original case encoding result and the dissimilar case encoding result of the sample dissimilar case by the encoder.
[0056] The specific process of the first method is as follows:
[0057] (1) Use the encoder to be trained to encode the original sample case, the sample similar case, and the sample dissimilar case respectively:
[0058] Taking the original sample case as an example, each sentence of the original sample case is recorded as S i : where w i,j Represents the jth word in the i-th sentence. When a word-level encoding v is performed on each sentence Si Operation, the process can be expressed as:
[0059]
[0060]
[0061]
[0062] Among them, W w is a weight matrix, b w is a bias vector, u w is a trainable context vector, GRU represents the Bi-directional Geted Recurrent Units (Bi-GRUs) encoder, GRU The arrows above indicate the order of encoding, i.e. forward encoding and reverse encoding.
[0063] Through the above formula, the encoder's encoding of each word is obtained, and then the encoder encodes the sentence containing the encoded word to obtain the sentence encoding h i (representation vector of each sentence):
[0064]
[0065] In each sentence encoding h i Based on this, the original case of the sample is encoded to obtain the original case encoding result v f :
[0066]
[0067]
[0068] Among them, W S is the weight sentence, b S is the bias vector, u S is a trainable context vector.
[0069] The same operation is performed for sample-similar cases and sample-dissimilar cases to obtain the similar case encoding results of the encoder for sample-similar cases. The encoder's encoding results for dissimilar cases of sample dissimilar cases Depend on The representation vector that constitutes the sample case triple
[0070] (2) In order to extract effective information about case relationships from sample case triples to further refine the encoding layer, relational attention modeling aims to constrain the encoded dialectical vector to retain the similar structure in the original sample case triples, that is, the distance between the original sample case and the similar sample case ||rr sim || is smaller than the distance between the original sample case and the sample dissimilar case||rr dis ||, where r, r sim 、r dis The calculation formula is as follows:
[0071]
[0072]
[0073] r=W r,3 (σ(W r,1 v f +(W r,2 v f +b r,2 )))
[0074] Use L triplet Represents the distance between the original case of the sample and the similar case of the sample ||rr sim || is smaller than the distance between the original sample case and the sample dissimilar case||rr dis ||:
[0075] L triplet =max(0,β+||rr sim ||-||rr dis ||)
[0076] Among them, W r,1 、W r,2 、W r,3 are three weight matrices, b r,2 is a bias vector, σ(·) is a sigmoid activation function, and β is a weight parameter.
[0077] In the process of training the encoder, the parameters involved in the encoder are continuously adjusted until the encoder output Calculated ||rr sim || and ||rr dis || If the following relationship is satisfied, the encoder training is completed:
[0078] ||rr sim ||-||rr dis ||<beta
[0079] Where beta is a set constant.
[0080] The second method includes: obtaining the sample original case category corresponding to the sample original case based on the sample original case in the sample case triplet; training the encoder until the decoding category obtained by the category decoder performing category decoding on the original case encoding result output by the encoder meets the set conditions, and obtaining the trained encoder, and the set conditions are obtained through the prediction loss function value composed of the sample original case category and the decoding category.
[0081] The specific process of the second method is as follows:
[0082] The original case encoding result v obtained by the first method is decoded by the category decoder f Perform category decoding to obtain the decoding category
[0083]
[0084] Use L category express The sample original case category y corresponding to the sample original case att The gap between:
[0085]
[0086] Where W c,1 and W c,2are two weight matrices, b c,2 is a bias vector, relu(·) and softmax(·) are two activation functions, and L(a,b) is a prediction loss function.
[0087] During the encoder training process, v f will continue to change, and It will also continue to change, and finally be reflected in L category Continues to change until L category Satisfy the setting conditions (the setting conditions in this embodiment are L category is close enough to 0), the encoder training is completed.
[0088] In this embodiment, L category The purpose of terminating the encoder training is to further learn the high-frequency and low-frequency cases discriminatively.
[0089] The third method includes the following steps S201, S202, S203, S204, and S205:
[0090] S201, according to the sample original case in the sample case triple, obtain the sample original case crime and the sample original case law clause corresponding to the sample original case.
[0091] S202 , decoding the original case encoding result obtained by encoding the sample original case by the encoder through a category decoder to obtain a decoded original case category.
[0092] The case categories in this embodiment include high-frequency cases and low-frequency cases.
[0093] S203: Obtain a decision prediction model corresponding to the sample original case according to the decoded original case category.
[0094] The decision prediction model in this embodiment includes a high-frequency case decision prediction model and a low-frequency case decision prediction model.
[0095] S204: Obtain the predicted original case crime and the predicted original case law corresponding to the sample original case based on the judgment prediction model.
[0096] S205 , training the encoder until the predicted original case charge matches the sample original case charge and / or the predicted original case law section matches the sample original case law section, to obtain a trained encoder.
[0097] The specific process of the third method is as follows:
[0098]
[0099] The meaning of the above formula is: when the original case of the sample is the low-frequency case 0, the low-frequency decoder is used to encode the original case v f Decode and get the result of the crime verdict Legal judgment results Recalculate The loss function value between the original case crime y1 and the sample is calculated. The loss function value between the original case law of the sample y2 is added to obtain L MTL When the original case of the sample is high-frequency case 1, the high-frequency decoder is used to encode the original case result v f Decode and perform the above operation to get L MTL .
[0100] During the encoder training process, v f Constantly changing, the corresponding L MTL Constantly changing, when L MTL When it is close enough to 0, the encoder training is completed.
[0101] The fourth method includes: training an encoder based on the sample case triples until a function value corresponding to a result output by the encoder converges, thereby obtaining a trained encoder, wherein the function value is equal to the distance plus the prediction loss function value plus the prediction result value.
[0102] The fourth method is expressed as follows:
[0103] L=L triplet +L category +L MTL
[0104] L triplet 、L category 、L MTL The original case encoding result v of the encoder for the original case of the sample is involved f , when L converges, the training of the encoder is completed.
[0105] Only one of the first, second, third and fourth methods can be used as the termination condition to train the encoder. This embodiment preferably uses the fourth method as the termination condition to train the encoder. The fourth method can improve the accuracy of encoder training.
[0106] S300 , inputting the case to be predicted into the trained encoder to obtain an encoding result of the case to be predicted by the trained encoder.
[0107] The case to be predicted is a case for which no verdict is known. A case verdict prediction model is required to predict the verdict for the case to be predicted. Before using the case verdict prediction model, the case to be predicted must be encoded. Therefore, this embodiment uses a trained encoder to encode the case to be predicted, facilitating the case verdict prediction model's prediction of the verdict for the case to be predicted.
[0108] S400: Obtaining a judgment result corresponding to the case to be predicted based on the encoding result.
[0109] The encoding result corresponding to the case to be predicted is decoded by a category decoder to obtain the category corresponding to the case to be predicted. The category in this embodiment includes high-frequency cases and low-frequency cases.
[0110] This embodiment performs the following predictions for two categories of cases to be predicted:
[0111] When the category corresponding to the case to be predicted is a high-frequency category case, the legal provision and / or the crime in the judgment result corresponding to the case to be predicted is obtained through a high-frequency judgment prediction model.
[0112] When the category corresponding to the case to be predicted is a low-frequency category case, the legal provision and / or the crime in the judgment result corresponding to the case to be predicted is obtained through a low-frequency judgment prediction model.
[0113] Below is Figure 2 Take the following as an example to illustrate the overall process of case prediction in the present invention:
[0114] First, a similar case, an original case, and a dissimilar case are sampled. These three form a case triplet, which is used as a sample to train the encoder. During the training process, if the original case is a high-frequency case, the high-frequency decoder is used to decode the encoder's encoding results to obtain the corresponding crime and legal section predictions. If the original case is a low-frequency case, the low-frequency decoder is used to decode the encoder's encoding results to obtain the corresponding crime and legal section predictions. The crime and legal section predictions are compared with the crime and legal section in the sample corresponding to the original case, and the encoder is trained based on the comparison results until the encoder training is complete.
[0115] In summary, the present invention first constructs a sample case triple, wherein the sample dissimilar cases in the sample case triple that are dissimilar to the sample original case are high-frequency cases. The encoder is trained by the sample case triple. Since the sample dissimilar cases are high-frequency cases, in the process of training the encoder, the intra-class distinction of high-frequency cases and the inter-class distinction of low-frequency cases can be constrained, thereby weakening the influence of high-frequency cases on the encoder, thereby improving the accuracy of the encoder in encoding the case, and on the basis of accurate encoding, further improving the accuracy of the prediction of the case judgment result. In addition, since the present invention constructs case triples based on legal provisions and charges, legal provisions and charges are introduced into the case triple, which realizes the refinement of the encoder, thereby improving the accuracy of the prediction of the case judgment result.
[0116] Exemplary devices
[0117] This embodiment also provides a device for predicting a legal judgment result, the device comprising the following components:
[0118] A triplet construction module is used to construct a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal provisions and / or the same charges, and the sample dissimilar case and the sample original case are subject to different legal provisions and / or different charges, and the sample dissimilar case is a high-frequency case;
[0119] An encoder training module, configured to train an encoder based on the sample case triples to obtain a trained encoder, wherein the encoder is used to encode the content of the case;
[0120] An encoding module, configured to input the case to be predicted into the trained encoder to obtain an encoding result of the case to be predicted by the trained encoder;
[0121] The prediction module is used to obtain the judgment result corresponding to the case to be predicted based on the encoding result.
[0122] Based on the above embodiment, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 3As shown. The terminal device includes a processor, memory, network interface, display screen, and temperature sensor connected via a system bus. The processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for predicting the result of a legal judgment is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen. The temperature sensor of the terminal device is pre-set inside the terminal device to detect the operating temperature of the internal device.
[0123] Those skilled in the art will understand that Figure 3 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the solution of the present invention, and does not constitute a limitation on the terminal device to which the solution of the present invention is applied. The specific terminal device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0124] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a legal judgment result prediction program stored in the memory and executable on the processor. When the processor executes the legal judgment result prediction program, the following operating instructions are implemented:
[0125] Constructing a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal article and / or the same crime, and the sample dissimilar case and the sample original case are subject to different legal articles and / or different crimes, and the sample dissimilar case is a high-frequency case;
[0126] Training an encoder based on the sample case triples to obtain a trained encoder, wherein the encoder is used to encode the content of the case;
[0127] Inputting the case to be predicted into the trained encoder to obtain an encoding result of the case to be predicted by the trained encoder;
[0128] According to the coding result, a judgment result corresponding to the case to be predicted is obtained.
[0129] Those skilled in the art will appreciate that all or part of the processes in the above-described embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described embodiments. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAM bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).
[0130] In summary, the present invention discloses an encoder training method, decision prediction method, and device for legal judgments. The method comprises: first, constructing a sample case triple, wherein a sample dissimilar case is a case that is dissimilar to the original sample case, and the sample dissimilar case is a high-frequency case. The encoder is trained using the sample case triple. Since the sample dissimilar cases are high-frequency cases, the influence of high-frequency cases on the encoder can be weakened during the encoder training process, thereby improving the encoder's case encoding accuracy. Furthermore, based on accurate encoding, the accuracy of case judgment prediction is further improved.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for training an encoder for legal judgment, characterized in that: include: Constructing a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal article and / or the same crime, and the sample dissimilar case and the sample original case are subject to different legal articles and / or different crimes, and the sample dissimilar case is a high-frequency case; Training an encoder based on the sample case triples to obtain a trained encoder, wherein the encoder is used to encode the content of the case; The step of training an encoder based on the sample case triples to obtain a trained encoder includes: An encoder is trained according to the sample case triples until the function value corresponding to the result output by the encoder converges, thereby obtaining a trained encoder; the function value corresponding to the result output by the encoder is equal to the distance plus the prediction loss function value plus the prediction result value, wherein the distance is obtained by the encoder encoding the original case corresponding to the sample original case encoding, the similar case encoding result corresponding to the sample similar case encoding, and the dissimilar case encoding result corresponding to the sample dissimilar case encoding; the distance is used to reflect the similarity of the original case encoding result, the similar case encoding result, and the dissimilar case encoding result; the prediction loss function value is composed of the sample original case category and the decoding category corresponding to the sample original case; and the prediction result value is obtained by predicting the sample original case through a decision prediction model; L=L triplet +L category +L MTL L is the function value corresponding to the result output by the encoder; L triplet =max(0,β+||rr sim ||-||rr dis ||) r=W r,3 (σ(W r,1 v f +(W r,2 v f +b r,2 ))) Among them, L triplet is the distance, W r,1 、W r,2 、W r,3 are three weight matrices, b r,2 is a bias vector, σ(·) is a sigmoid activation function, and β is a weight parameter; In each sentence encoding h i Based on this, the original case of the sample is encoded to obtain the original case encoding result v f , Coding results for similar cases, The results of the dissimilar case coding for the coder for the sample dissimilar cases; L category is the predicted loss function value, y att is the sample original case category corresponding to the sample original case, The original case encoding result v is encoded by the category decoder f Perform the decoding to obtain the category decoding; L MTL To predict the result value, a low-frequency decoder is used to encode the original case result v f Decode and get the result of the crime verdict Legal judgment results y1 is the crime in the original sample case, and y2 is the legal provision in the original sample case.
2. The encoder training method for legal judgment according to claim 1, characterized in that The step of training an encoder based on the sample case triples to obtain a trained encoder includes: The encoder is trained until the distance between the sample original case and the sample similar case in the sample case triplet is less than the distance between the sample original case and the sample dissimilar case, the distance between the sample original case and the sample similar case is obtained by the original case encoding result of the sample original case by the encoder and the similar case encoding result of the sample similar case by the encoder, the distance between the sample original case and the sample similar case is used to reflect the similarity between the original case encoding result and the similar case encoding result, the distance between the sample original case and the sample dissimilar case is obtained by the original case encoding result and the dissimilar case encoding result of the sample dissimilar case by the encoder, the distance between the sample original case and the sample dissimilar case is used to reflect the similarity between the original case encoding result and the dissimilar case encoding result of the sample dissimilar case.
3. The encoder training method for legal judgment according to claim 1, characterized in that The step of training an encoder based on the sample case triples to obtain a trained encoder includes: According to the sample original case in the sample case triple, obtaining the sample original case category corresponding to the sample original case; Encoding the sample original case according to the encoder to obtain an original case encoding result corresponding to the sample original case; Get the category decoder corresponding to the original case of the sample; The encoder is trained until the decoding category obtained by the category decoder performing category decoding on the original case encoding result matches the category of the original case of the sample, thereby obtaining a trained encoder.
4. The encoder training method for legal judgment according to claim 1, characterized in that The step of training an encoder based on the sample case triples to obtain a trained encoder includes: According to the sample original case in the sample case triple, obtaining the sample original case crime and the sample original case law clause corresponding to the sample original case; Encoding the sample original case according to the encoder to obtain an original case encoding result corresponding to the sample original case; Obtaining a category decoder corresponding to the original case of the sample; Decoding the original case encoding result by the category decoder to obtain the decoded original case category; Obtaining a decision prediction model corresponding to the sample original case according to the decoded original case category; Obtaining the predicted original case crime and the predicted original case law corresponding to the sample original case based on the judgment prediction model; The encoder is trained until the predicted original case charge matches the sample original case charge and / or the predicted original case law section matches the sample original case law section, thereby obtaining a trained encoder.
5. A method for predicting legal judgment results based on an encoder, characterized in that: include: Inputting the case to be predicted into a trained encoder to obtain an encoding result of the trained encoder on the case to be predicted, wherein the trained encoder is an encoder obtained by training the encoder using the sample case triples, and the trained encoder is an encoder trained based on the encoder training method for legal judgment according to any one of claims 1 to 4; Performing category decoding on the encoding result to obtain the category corresponding to the case to be predicted; When the category corresponding to the case to be predicted is a high-frequency category case, the legal article and / or the crime in the judgment result corresponding to the case to be predicted is obtained by using a high-frequency judgment prediction model; When the category corresponding to the case to be predicted is a low-frequency category case, the legal provision and / or the crime in the judgment result corresponding to the case to be predicted is obtained through a low-frequency judgment prediction model.
6. A device for a method of training an encoder for legal judgment, characterized in that: The device comprises the following components: A triplet construction module is used to construct a sample case triplet, wherein the sample case triplet consists of a sample original case, a sample similar case, and a sample dissimilar case, wherein the sample similar case and the sample original case are subject to the same legal provisions and / or the same charges, and the sample dissimilar case and the sample original case are subject to different legal provisions and / or different charges, and the sample dissimilar case is a high-frequency case; An encoder training module, configured to train an encoder based on the sample case triples to obtain a trained encoder, wherein the encoder is used to encode the content of the case; The step of training an encoder based on the sample case triples to obtain a trained encoder includes: An encoder is trained according to the sample case triples until the function value corresponding to the result output by the encoder converges, thereby obtaining a trained encoder; the function value corresponding to the result output by the encoder is equal to the distance plus the prediction loss function value plus the prediction result value, wherein the distance is obtained by the encoder encoding the original case corresponding to the sample original case encoding, the similar case encoding result corresponding to the sample similar case encoding, and the dissimilar case encoding result corresponding to the sample dissimilar case encoding; the distance is used to reflect the similarity of the original case encoding result, the similar case encoding result, and the dissimilar case encoding result; the prediction loss function value is composed of the sample original case category and the decoding category corresponding to the sample original case; and the prediction result value is obtained by predicting the sample original case through a decision prediction model; L=L triplet +L category +L MTL L is the function value corresponding to the result output by the encoder; L triplet =max(0,β+||rr sim ||-||rr dis ||) r=W r,3 (σ(W r,1 v f +(W r,2 v f +b r,2 ))) Among them, L triplet is the distance, W r,1 、W r,2 、W r,3 are three weight matrices, b r,2 is a bias vector, σ(·) is a sigmoid activation function, and β is a weight parameter; In each sentence encoding h i Based on this, the original case of the sample is encoded to obtain the original case encoding result v f , Coding results for similar cases, The results of the dissimilar case coding for the coder for the sample dissimilar cases; L category is the predicted loss function value, y att is the sample original case category corresponding to the sample original case, The original case encoding result v is encoded by the category decoder f Perform the decoding to obtain the category decoding; L MTL To predict the result value, a low-frequency decoder is used to encode the original case result v f Decode and get the result of the crime verdict Legal judgment results y1 is the crime in the original sample case, and y2 is the legal provision in the original sample case.
7. A terminal device, characterized in that: The terminal device includes a memory, a processor, and an encoder training program for legal judgment results or a prediction program for legal judgment results based on an encoder, which is stored in the memory and can be run on the processor. When the processor executes the encoder training program for legal judgment results or the prediction program for legal judgment results based on an encoder, it implements the steps of the encoder training method for legal judgment according to any one of claims 1 to 4 or the prediction method for legal judgment results based on an encoder according to claim 5.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores an encoder training program for legal judgment results or a prediction program for legal judgment results based on the encoder. When the encoder training program for legal judgment results is executed by the processor or the prediction program for legal judgment results based on the encoder is executed by the processor, the steps of the encoder training method for legal judgment according to any one of claims 1 to 4 or the prediction method for legal judgment results based on the encoder according to claim 7 are implemented.
Citation Information
Patent Citations
Hyperspherical collaborative metric recommendation device and method based on pre-trained semantic model
CN111651558A
Legal provision recommendation method based on legal provision relationship
CN112148867A