Class case matching method and system based on behavior pattern divide-and-conquer prompt
By decomposing the judicial case matching task into subtasks and using the thinking chain prompt technology, the problem of insufficient accuracy and interpretability in the similar case matching task is solved, and the matching ability and transparency of the large language model are improved.
Patent Information
- Application Number
- CN202410431845.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-11
- Publication Date
- 2024-09-10
AI Technical Summary
In the judicial field, in the similar case matching task, due to the inconsistent interpretations of various judicial personnel, it leads to the problem of different judgments of similar cases. It is difficult to achieve high accuracy and interpretability with existing technology, especially in zero-sample and few-sample scenarios. Deep learning models and large language models have limited performance on such tasks.
The judicial case matching task is decomposed into multiple subtasks by manually defining behavioral patterns, and the thinking chain prompt technology is used to guide the large language model to match each subtask, and the final matching result is obtained by aggregating the subtask results, which improves the efficiency of similar case matching. Accuracy and interpretability.
It improves the accuracy and interpretability of large language models in similar case matching tasks, alleviates the problem of insufficient planning, decomposition and reasoning capabilities for complex problems, and achieves more accurate and transparent judicial similar case matching results.
Smart Images

Figure CN118626871A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of similar case matching, and relates to a similar case matching method and system based on behavior pattern divide-and-conquer prompts. Background Art
[0002] At present, the number of cases that the courts need to handle is increasing year by year. In recent years, with the continuous breakthroughs in big data applications represented by judicial documents and natural language processing technology, how to apply artificial intelligence technology in the judicial field and improve the efficiency of judicial personnel in case handling has gradually become a hot topic in legal technology research. On the issue of similar case judgments, due to the inconsistent interpretation of cases by various judicial personnel and the different grasp of the legal judgment standards, the problem of "different judgments for similar cases" cannot be well solved. Driven by these related applications, how to better extract the semantic features of legal documents to more accurately match similar cases has very important research significance in the legal field.
[0003] Similar case matching (SCM) is a key topic in the field of legal intelligence, which aims to support judicial decision-making by identifying similar cases in past legal documents. High-quality annotated data is very scarce in the judicial field. In such zero-shot and few-shot scenarios, deep learning models that mainly use fully supervised learning often fail to achieve the expected results and lack interpretability. In recent years, large language models (LLMs) combined with prompt learning have performed well in zero-shot learning tasks, but they still have limitations for highly professional specific field tasks such as similar case matching. Summary of the invention
[0004] The purpose of the present invention is to provide a similar case matching method and system based on behavioral pattern divide-and-conquer prompts to improve the accuracy and explainability of similar case matching.
[0005] In order to achieve the above object, the basic scheme of the present invention is: a similar case matching method based on behavioral pattern divide-and-conquer prompts, comprising the following steps:
[0006] For different types of judicial case matching tasks, legal experts manually predefine behavior patterns and decompose the judicial case matching tasks into multiple subtasks according to different behavior patterns;
[0007] Using thought chain prompts, the large language model matches similar cases for each subtask based on behavioral patterns;
[0008] Obtain similar case matching results of all subtasks and aggregate them to obtain the final judicial similar case matching prediction results.
[0009] The working principle and beneficial effects of this basic solution are as follows: This technical solution is based on the behavioral pattern divide-and-conquer prompt engineering method to improve the performance of LLM in similar case matching tasks. The behavioral pattern represents the relevant specific behaviors and their properties involved in the case fact description, and is an important judicial element. Therefore, the behavioral pattern is integrated into the prompt engineering to guide LLM to reason based on domain knowledge, thereby improving the accuracy of similar case matching.
[0010] This method decomposes the complex similar case matching task into multiple subtasks according to the behavior pattern, and then uses the thinking chain prompt technology to let LLM perform SCM on the subtasks of different behavior patterns, and obtains the final result of similar case matching by aggregating the results of each subtask, thereby improving the accuracy and explainability of similar case matching.
[0011] Furthermore, based on the behavior pattern, the judicial case matching task is divided into multiple subtasks partition(x), specifically:
[0012]
[0013] Among them, x is the task input, k is the total number of subtasks, Prompt template generated for the i-th subtask.
[0014] Decomposing a complex judicial case matching task into multiple simple subtasks alleviates the defect that large language models are unable to plan, decompose and reason about complex problems, thereby improving the reasoning ability of large language models in complex judicial case matching tasks.
[0015] Furthermore, using the thought chain prompts, the large language model matches similar cases for each subtask based on the behavior pattern. The specific steps are as follows:
[0016] according to Follow the thought chain prompts to form the final template:
[0017]
[0018] in, The final prompt constructed for the ith subtask in the current behavior mode; The prompt template generated for the i-th subtask; cot prompt Represents the process of generating thought chains, based on manually defined prompt templates Generate the final prompt template for the current behavior pattern
[0019] Will As the final input of the large language model, the large language model completes the prediction:
[0020]
[0021] Among them, result i Represents the prediction result of the current subtask.
[0022] The thought chain prompt technology guides the model to decompose multi-step complex problems into intermediate steps and explicitly displays the reasoning process of the large language model, avoiding traditional end-to-end black box reasoning and improving the interpretability of the model. At the same time, the thought chain prompt template also guides the model to solve the task in the correct way, thereby obtaining more accurate task results.
[0023] Furthermore, the similar case matching results of all subtasks are obtained and aggregated to obtain the final judicial similar case matching prediction results. The specific method is as follows:
[0024] For each subtask, the case matching result i , analyze the rules and obtain the judicial case matching results under the current subtask:
[0025] prediction i =regular(result i )
[0026] Among them, prediction i Represents the voting selection of the behavior mode corresponding to the current subtask; regular(·) is an extractor;
[0027] Summarize the voting results of all subtasks:
[0028]
[0029]
[0030] Among them, k is the total number of subtasks, option j Represents the number of votes obtained by candidate case j; weight represents the voting weight of the current subtask; for the number of votes for each candidate case, the highest number of votes is taken as the aggregation result finalOptions:
[0031] finalOptions=max(option1,…,option N )
[0032] Where N is the total number of candidate cases;
[0033] If multiple candidate cases have the same number of votes, finalOptions may contain multiple candidate cases, that is, finalOptions = [finalOptions1,…,finalOptionsK ], finalOptions j The original option corresponding to the candidate case i ; Where 1≤j≤K, 1≤i≤N; K is the total number of candidate cases with the highest number of votes.
[0034] The analysis of cases by subtasks under a single behavior mode is often one-sided and incomplete, so it is necessary to integrate the results of each subtask to obtain a more accurate answer.
[0035] Furthermore, for any input sequence finalOptions θ , and get the final answer by minimizing its perplexity:
[0036]
[0037]
[0038] in, is the option with the lowest current perplexity, θ represents the input parameter of the large language model, and PPL is the perplexity of the large language model; w j Represents the input sequence finalOptions θ Each word in w j ∈finalOptions θ , l θ finalOptions θ The length of the sequence;
[0039] Finalization The corresponding option is the final option currently input, that is, the final result of judicial case matching.
[0040] The perplexity (PPL) of the large language model is used to complete the final comparison and obtain more accurate judicial case matching results.
[0041] The present invention also provides a similar case matching system based on behavioral pattern divide-and-conquer prompts, comprising a divide-and-conquer module, a solution module and an aggregation module connected in sequence;
[0042] The divide-and-conquer module is used to divide the judicial case-matching task into multiple subtasks, the solution module is used to perform case-matching on each subtask, and the aggregation module is used to aggregate the case-matching results to obtain the final judicial case-matching prediction result.
[0043] By utilizing the divide-and-conquer module, solution module, and aggregation module of the system, the large language model is guided to parse cases based on the divide-and-conquer prompts based on behavioral patterns, so that the large language model can plan and decompose complex similar case matching problems, thereby obtaining more accurate similar case matching results. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a flow chart of a similar case matching method based on behavioral pattern divide-and-conquer prompts of the present invention;
[0045] Figure 2 It is a schematic diagram of the result of constructing a prompt template for an example of a behavior pattern of a loan contract based on a similar case matching method of the present invention based on behavioral pattern divide-and-conquer prompts. DETAILED DESCRIPTION
[0046] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0047] In the description of the present invention, it is necessary to understand that the terms "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0048] In the description of the present invention, unless otherwise specified and limited, it should be noted that the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the internal connection between two components. It can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to the specific circumstances.
[0049] The present invention discloses a similar case matching method based on behavioral pattern divide-and-conquer prompts, and improves the performance of LLM in similar case matching tasks based on the behavioral pattern divide-and-conquer prompt engineering method. Based on the behavioral pattern divide-and-conquer prompts, the large language model is guided to parse the case, and the basic reasoning guidance is realized through the defined behavioral pattern, so that the large language model can plan and decompose complex similar case matching problems, thereby obtaining more accurate similar case matching results. Figure 1 As shown in the figure, similar case matching includes the following steps:
[0050] For a given judicial case matching task, the task is divided into multiple subtasks based on behavioral patterns. For judicial case matching tasks of different types (such as civil cases, criminal cases, etc.), legal experts manually predefine behavioral patterns, and the task is decomposed into multiple subtasks according to different behavioral patterns. The behavioral pattern represents the relevant specific behaviors and their properties involved in the description of case facts, and is an important judicial element. Therefore, the behavioral pattern is integrated into the prompt engineering to guide LLM to reason based on domain knowledge, thereby improving the accuracy of case matching.
[0051] Using thought chain prompts, the large language model matches similar cases for each subtask based on behavioral patterns;
[0052] Obtain similar case matching results of all subtasks and aggregate them to obtain the final judicial similar case matching prediction results, thereby improving the accuracy and explainability of similar case matching.
[0053] In a preferred solution of the present invention, based on the behavior pattern, the judicial case matching task is divided into multiple subtasks partition(x), specifically:
[0054]
[0055] Among them, x is the task input, k is the total number of subtasks, Prompt template generated for the i-th subtask.
[0056] For example, for civil loan cases, the following five groups of behavior patterns can be defined based on existing knowledge: 1. Loan contract; 2. Payment method; 3. Loan contract; 4. Repayment behavior; 5. Guarantee behavior. The prompt template will guide the large language model to match similar cases for the above five behavior patterns, such as Figure 2 shown.
[0057] In a preferred embodiment of the present invention, the thinking chain prompt is used to perform similar case matching on each subtask based on the behavior pattern. The specific steps are as follows:
[0058] according to According to the thought chain (which can be manually defined in advance, different case types and behavior patterns will have different thought chains), the final template is formed:
[0059]
[0060] in, The final prompt constructed for the ith subtask in the current behavior mode; The prompt template generated for the i-th subtask; cot prompt Represents the process of generating thought chains, based on manually defined prompt templates Generate the final prompt template for the current behavior pattern By cot prompt Generate,cot prompt It is a specific step to generate the final template based on the manually defined examples
[0061] The prompt template mainly includes two parts: examples and questions. The example part is divided into example cases, behavior patterns, behavior pattern thinking chains, and example results. The behavior patterns and behavior pattern thinking chains are the core components that guide the subsequent large language model reasoning and need to be manually written based on the selected example cases. The question part includes target cases and target questions, which are the real problems that the large language model needs to solve.
[0062] Will As the final input of the large language model, the large language model completes the prediction:
[0063]
[0064] Among them, result i Represents the prediction result of the current subtask.
[0065] In a preferred embodiment of the present invention, the similar case matching results of all subtasks are obtained and aggregated to obtain the final judicial similar case matching prediction result. The specific method is as follows:
[0066] For each subtask, the case matching result i , analyze the rules and obtain the judicial case matching results under the current subtask:
[0067] prediction i =regular(result i )
[0068] Among them, prediction i Represents the voting choice of the behavior mode corresponding to the current subtask; regular(·) is an extractor. In the generation result of the large language model, in addition to the result judgment of similar case matching, a series of intermediate processes are also output. The extractor is responsible for extracting the result judgment from it to obtain the voting result of the current subtask.
[0069] Summarize the voting results of all subtasks:
[0070]
[0071]
[0072] Among them, k is the total number of subtasks, option j Represents the number of votes obtained by candidate case j; weight represents the voting weight of the current subtask; for the number of votes for each candidate case, the highest number of votes is taken as the aggregation result finalOptions:
[0073] finalOptions=max(option1,…,option N )
[0074] Where N is the total number of candidate cases;
[0075] If multiple candidate cases have the same number of votes, finalOptions may contain multiple candidate cases, that is, finalOptions = [finalOptions1,…,finalOptions K ], finalOptions j The original option corresponding to the candidate case i ; Where 1≤j≤K, 1≤i≤N; K is the total number of candidate cases with the highest number of votes.
[0076] More preferably, the perplexity (PPL) of the large language model is used to complete the final comparison. For any input sequence finalOptions θ , and get the final answer by minimizing its perplexity:
[0077]
[0078]
[0079] in, is the option with the lowest current perplexity, θ represents the input parameter of the large language model, and PPL is the perplexity of the large language model; w j Represents the input sequence finalOptions θ Each word in w j ∈finalOptions θ , l θ finalOptions θ The length of the sequence;
[0080] Finalization The corresponding option is the final option currently input, that is, the final result of judicial case matching.
[0081] The present invention uses the CAIL2019 dataset to test the performance of the model of the method of the present invention. The CAIL-2019 dataset is a dataset that focuses on similar case matching tasks. The input of the dataset is a triple (A, B, C), where A, B, and C are all factual description texts of judicial cases. The goal of this dataset is to determine whether case A is more similar to case B or case C, that is, this task simplifies similar case matching into a classification problem. The model needs to predict the label corresponding to the triple based on the similarity between case A and case B and the similarity between case A and case C. If case A is more similar to case B, it is recorded as a positive example, otherwise it is recorded as a negative example. All judicial case texts in CAI L-2019 are from the China Judgment Documents Network. The dataset contains 8,138 triples, of which 5,102 triples are divided into training sets, 1,536 triples are divided into test sets, and 1,500 triples are divided into verification sets. All cases are related to civil lending, and their labels are manually annotated by judicial professionals.
[0082] The CAIL-2019 dataset is mainly composed of civil loan cases. By using legal expertise to analyze such cases, the total number of partition k is set to 5. Specifically, there are the following five groups of partition prompts and their corresponding thinking chains:
[0083] Payment behavior: Analyze the payment behavior in the case, such as payment method, actual payment amount, payment voucher, etc.
[0084] Purpose of loan: The specific purpose of the loan for the borrower in the case, such as for business capital turnover, for daily expenses, etc.
[0085] Repayment behavior: Analyze the repayment behavior of the borrower in the case, such as whether repayments are made on time, actual repayment amount, etc.
[0086] Guarantee behavior: Analyze the guarantee behavior in the case, such as whether there is a guarantor, the relationship between the guarantor and the borrower, etc.
[0087] Loan contract: Analyze the specific terms of the loan contract included in the case, such as the loan amount, interest rate, agreed term, etc.
[0088] The following large language models were selected for experiments:
[0089] ChatGLM-3: ChatGLM-3 is a large language model based on the GLM architecture and optimized for Chinese question-answering and conversation.
[0090] Baichuan-2: Baichuan-2 is mainly built based on the vanilla Transformer, which optimizes the feedforward layer of the traditional Transformer and performs well in vertical fields such as medical care and justice.
[0091] Wisdom-Interrogatory: This model uses Baichuan2 as the base model and completes incremental pre-training on legal documents, judicial cases, judicial question-and-answer data and other corpora. Compared with the base model, it has more professional and rich judicial knowledge.
[0092] Chinese-Llama-alpaca-2: This model uses Llama-2 as the base model, expands and optimizes the Chinese vocabulary, and uses large-scale Chinese data for incremental pre-training. Compared with Llama-2, it has stronger Chinese understanding capabilities.
[0093] LawGPT: Based on Chinese-Llama-alpaca-2, LawGPT expands the judicial-specific vocabulary and conducts large-scale incremental pre-training of Chinese judicial corpus, enhancing the basic semantic understanding ability of the large language model in the judicial field.
[0094] Accuracy (Acc) is selected as the main test indicator. In large language models, there is a certain probability that the answer will be abandoned. Such predictions are counted separately in the abstention rate (Abs), and this part of the data is removed from the accuracy statistics. Therefore, the traditional accuracy calculation formula is adjusted:
[0095]
[0096] Among them, TP represents the number of true positives, TN represents the number of true negatives, FP represents the number of false positives, FN represents the number of false negatives, and ABS represents the total number of abstentions. The calculation method of abstention rate is:
[0097]
[0098] In particular, since the PPL-type template does not require the model to generate answers, it only needs to calculate the perplexity corresponding to the options, and there is no abstention situation, the abstention rate is not counted during the experiment.
[0099] The experimental results (as shown in Table 1) prove that for the current large language model, the similar case matching task is still very difficult. In the absence of prompt template guidance, it is difficult to make correct similar case matching capabilities, which is specifically manifested in low accuracy and high abandonment rate. In the method of the present invention, the accuracy rate is improved by an average of 4.3%, and the abandonment rate of the model has dropped significantly, and the abandonment rate of most large language models has dropped to 0.0. This shows that the method can effectively decompose complex similar case matching problems and help large language models better understand problems and make judgments.
[0100] Table 1. Similar case matching results of CAI L-2019
[0101]
[0102]
[0103] The present invention also provides a similar case matching system based on behavioral pattern divide-and-conquer prompts, including a divide-and-conquer module, a solution module and an aggregation module that are electrically connected in sequence.
[0104] The divide-and-conquer module is used to divide the judicial case matching task into multiple subtasks, that is, a complex judicial case matching task is decomposed into multiple simple subtasks, alleviating the defect that the large language model cannot plan, decompose and reason about complex problems, thereby improving the reasoning ability of the large language model in complex judicial case matching tasks.
[0105] The solution module is used to match similar cases for each subtask. Specifically, based on the thought chain prompt, the large language model is used to analyze the various behavioral patterns of the case to generate answers to each subtask. The thought chain prompt technology guides the model to decompose complex multi-step problems into intermediate steps and explicitly displays the reasoning process of the large language model, avoiding traditional end-to-end black box reasoning and improving the interpretability of the model. At the same time, the thought chain prompt template also guides the model to solve the task in the correct way, thereby obtaining more accurate task results.
[0106] The aggregation module is used to aggregate similar case matching results to obtain the final judicial similar case matching prediction results. The analysis of cases by subtasks under a single behavior mode is often one-sided and incomplete, so the results of each subtask need to be integrated through the aggregation module to obtain a more accurate answer.
[0107] The case-like matching task of the present invention is divided into multiple parallel subtasks based on behavioral patterns for solution and aggregation into the final answer, which realizes the divide-and-conquer solution of complex problems by a large language model in a zero-sample scenario and improves the model's judicial case-like matching capability in a zero-sample scenario.
[0108] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0109] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A similar case matching method based on behavioral pattern divide-and-conquer prompts, characterized in that: The steps include: For different types of judicial case matching tasks, by pre-defining behavioral patterns, the judicial case matching tasks are decomposed into multiple subtasks according to different behavioral patterns; Using thought chain prompts, the large language model matches similar cases for each subtask based on behavioral patterns; Obtain similar case matching results of all subtasks and aggregate them to obtain the final judicial similar case matching prediction results.
2. The similar case matching method based on behavioral pattern divide-and-conquer prompts as claimed in claim 1 is characterized in that: Based on the behavior pattern, the judicial case matching task is divided into multiple subtasks partition(x), specifically: Among them, x is the task input, k is the total number of subtasks, Prompt template generated for the i-th subtask.
3. The similar case matching method based on behavioral pattern divide-and-conquer prompts as claimed in claim 1, characterized in that: Using thought chain prompts, the large language model matches similar cases for each subtask based on behavioral patterns. The specific steps are as follows: according to Follow the thought chain prompts to form the final template: in, The final prompt constructed for the ith subtask in the current behavior mode; The prompt template generated for the i-th subtask; cot prompt Represents the process of generating thought chains, based on manually defined prompt templates Generate the final prompt template for the current behavior pattern Will As the final input of the large language model, the large language model completes the prediction: Among them, result i Represents the prediction result of the current subtask.
4. The similar case matching method based on behavioral pattern divide-and-conquer prompts as claimed in claim 1, characterized in that: Obtain the similar case matching results of all subtasks and aggregate them to obtain the final judicial similar case matching prediction results. The specific method is as follows: For each subtask, the case matching result i , analyze the rules and obtain the judicial case matching results under the current subtask: prediction i =regular(result i ) Among them, prediction i Represents the voting selection of the behavior mode corresponding to the current subtask; regular(·) is an extractor; Summarize the voting results of all subtasks: Among them, k is the total number of subtasks, option j Represents the number of votes obtained by candidate case j; weight represents the voting weight of the current subtask; for the number of votes for each candidate case, the highest number of votes is taken as the aggregation result finalOptions: finalOptions=max(option1,…,option N ) Where N is the total number of candidate cases; If multiple candidate cases have the same number of votes, finalOptions may contain multiple candidate cases, that is, finalOptions = [finalOptions1,…,finalOptions K ], finalOptions j The original option corresponding to the candidate case i ; Where 1≤j≤K, 1≤i≤N; K is the total number of candidate cases with the highest number of votes.
5. The similar case matching method based on behavioral pattern divide-and-conquer prompts as claimed in claim 4 is characterized in that: For any input sequence finalOptions θ , and get the final answer by minimizing its perplexity: in, is the option with the lowest current perplexity, θ represents the input parameter of the large language model, and PPL is the perplexity of the large language model; w j Represents the input sequence finalOptions θ Each word in w j ∈finalOptions θ , l θ finalOptions θ The length of the sequence; Finalization The corresponding option is the final option currently input, that is, the final result of judicial case matching.
6. A similar case matching system based on behavioral pattern divide-and-conquer prompts, characterized in that: It includes a divide-and-conquer module, a solution module and an aggregation module connected in sequence; The divide-and-conquer module is used to divide the judicial case-matching task into multiple subtasks, the solution module is used to perform case-matching on each subtask, and the aggregation module is used to aggregate the case-matching results to obtain the final judicial case-matching prediction result.
Citation Information
Patent Citations
Dialog-type radiotherapy planning system based on voice recognition and dialog-type radiotherapy making method based on voice recognition
CN107978315A
Causal representation learning framework for judicial case matching
CN116561252A
Big data-based judicial field case pushing method
CN116610770A
Multi-task case feature extraction method based on consistent thinking chain reasoning
CN117609758A
Cited By
Task matching method and system
CN119272070A
Fault diagnosis method, device, equipment, medium and product
CN121166768A
