Judicial domain class case retrieval method and system based on large model
By applying a large model in the judicial field to identify and enhance the intention of judicial cases or problems, and combining vector model and Reranker model for similarity analysis, the problems of similar case search efficiency and accuracy in the existing technology are solved, and more efficient and Accurate search results.
Patent Information
- Application Number
- CN202411333023.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art has problems of efficiency and accuracy in the search for similar cases in the judicial field, and it is difficult to quickly and accurately screen similar cases from massive cases, and the complexity and diversity of case information lead to inaccuracy in the calculation of similarity.
Using a big model-based case search method, the user inputted judicial cases or judicial problem texts are identified and problem-enhanced through the big model, and the enhanced text is generated, and the similarity analysis is performed by combining the vector model and the Reranker model, and the output is performed with the user. The most relevant judicial instruments.
It improves the accuracy and efficiency of similar case searches, ensures the correct search direction, reduces interference from irrelevant information, quickly filters out highly relevant cases, and reduces search and screening time.
Smart Images

Figure CN119474409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to big models and judicial fields, and in particular to a method and system for retrieving similar cases in the judicial field based on big models. Background Art
[0002] In the judicial field, similar case retrieval is an important technology. It analyzes the key information and characteristics of the case and pushes similar cases to judges or legal practitioners for reference and reference. Traditional similar case retrieval methods are mostly based on keyword matching, which matches the text information of the case to find cases similar to the current case. Due to the particularity of case data in the judicial field, such as the complexity and diversity of the types of cases involved and different judgment standards, similar case retrieval methods based on keyword matching algorithms are difficult to accurately reflect the similarities between cases.
[0003] The core of similar case retrieval lies in the calculation of similarity between cases, which is usually based on natural language processing technology and machine learning algorithms. By extracting key information such as facts, evidence, and applicable law of the case, the system can automatically calculate the similarity between cases and push cases with high similarity to judges.
[0004] However, in the existing similar case retrieval process, there are still certain problems in terms of efficiency and accuracy. First, the efficiency problem is mainly reflected in the amount of data and processing speed. With the continuous increase in the number of cases, how to quickly and accurately screen out similar cases from massive cases has become a major challenge. Secondly, the accuracy problem mainly stems from the complexity and diversity of case information. Cases in the legal field often involve complex facts and legal application issues. The similarity calculation between cases is easily affected by many factors, such as the accuracy of the description of case facts and the applicability of legal provisions. How to accurately represent case information and calculate the similarity between cases is a key problem that needs to be solved in similar case retrieval technology. Therefore, how to improve the accuracy and efficiency of similar case retrieval is a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the technical problem to be solved by the present invention is: how to provide a method for similar case retrieval in the judicial field based on a big model, by which the intention of the judicial case or judicial question text input by the user is recognized and the question is enhanced through the big model to ensure the correctness of the similar case retrieval direction, and at the same time, the enhanced judicial case or judicial question text and the retrieved judicial documents are input into the big model for correlation analysis to accurately identify the judicial documents that are most relevant to the input judicial case or judicial question text (i.e., the user's question), thereby improving the accuracy and efficiency of similar case retrieval.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] A method for retrieving similar cases in the judicial field based on a large model, comprising:
[0008] S1: Construct a judicial document vector database by combining the vector model with the acquired judicial documents;
[0009] S2: Obtain input judicial case or judicial question text;
[0010] S3: Use a large model to identify the intent and enhance the question of the judicial case or judicial question text to generate an enhanced judicial case or judicial question text;
[0011] S4: Generate vectors for the enhanced judicial case or judicial question texts through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set;
[0012] S5: Input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
[0013] Preferably, the vector model is fine-tuned by a low-rank adaptive algorithm, and the specific steps are as follows:
[0014] S101: Create two low-rank matrices A and B with a rank of r for each original weight matrix of the vector model;
[0015] S102: original weight matrix of frozen vector model;
[0016] S103: Obtaining annotated judicial document data as fine-tuning data;
[0017] S104: Input the fine-tuning data into the vector model and output the corresponding predicted document vector;
[0018] S105: Calculate the loss based on the predicted document vector and the corresponding real document vector in combination with the loss function, and reversely optimize the low-rank matrices A and B in the vector model;
[0019] S106: Repeat steps S104 to S106 until the vector model converges or reaches a preset number of iteration rounds;
[0020] S107: Add the update amount of each original weight matrix of the vector model and its corresponding low-rank matrices A and B to obtain the final weight matrix, thereby achieving fine-tuning of the vector model.
[0021] Preferably, in step S3, the large model performs the following processing steps for intention recognition and question enhancement on the judicial case or judicial question text:
[0022] S301: parse and identify the intent of the judicial case or judicial question text through a large model to generate user intent;
[0023] S302: Decomposing the judicial case or judicial question text according to the user's intention to generate several question parts;
[0024] S303: combining the user intention with the question part, analyzing the relationship between the user intention and the question part, and determining the question part to be enhanced;
[0025] S304: Generate or rewrite the text of the question part that needs to be enhanced by using the language generation capability of the large model, so as to enhance the question part;
[0026] S305: Combine the enhanced question part with other question parts of the judicial case or judicial question text to form an enhanced judicial case or judicial question text.
[0027] Preferably, in step S4, a collection of neatly arranged judicial documents is generated through the following steps:
[0028] S401: vectorizing the enhanced judicial case or judicial question text through a vector model to obtain a judicial case or judicial question text vector;
[0029] S402: Calculate the inner product similarity between the judicial case or judicial question text vector and all judicial document vectors in the judicial document vector database; add the judicial documents corresponding to the judicial document vectors whose inner product similarity is greater than the similarity threshold to the preliminary screening judicial document set;
[0030] S403: Sort the judicial documents in the initial screening judicial document set by using the maximum marginal correlation model and the Reranker model to generate a refined judicial document set.
[0031] Preferably, in step S403, the processing steps of the maximum marginal correlation model and the Reranker model are as follows:
[0032] S4031: Selecting from the pre-screened judicial document set the judicial document corresponding to the document vector having the largest inner product similarity with the judicial case or judicial question text vector as the first document and adding it to the re-ranking set;
[0033] S4032: For the remaining judicial documents in the initial screening judicial document set, calculate the MMR value of each judicial document and the judicial case or judicial question text;
[0034] S4033: Select the judicial document with the largest MMR value and add it to the re-ranking set, and delete the judicial document from the initial screening judicial document set;
[0035] S4034: repeat steps S4032 to S4033 until the initial screening judicial document set is empty;
[0036] S4035: Take the judicial case or judicial question text and each document in the re-ranking set as the input of the Reranker model, and output the corresponding similarity score; sort each document in the re-ranking set according to the similarity score to form a refined judicial document set.
[0037] Preferably, in step S5, the processing steps of large model correlation analysis are as follows:
[0038] S501: inputting the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis;
[0039] S502: Encode the judicial case or judicial question text and the judicial document through an encoder to obtain an embedded representation of the judicial case or judicial question text and the judicial document;
[0040] S503: extracting global text features from the embedded representation of the judicial document through the temporal Transformer;
[0041] S504: Extract local text features from the embedded representation of judicial documents through a multi-scale Transformer;
[0042] S505: Fusing the global text features and the local text features of the judicial document to generate a fused text feature;
[0043] S506: Calculate the similarity score between the fused text features of each judicial document and the embedded representation of the judicial case or judicial question text;
[0044] S507: taking one or more judicial documents with the highest similarity scores as the most relevant judicial documents;
[0045] S508: Decode the embedded representation of the most relevant judicial document through a decoder to obtain the judicial document most relevant to the judicial case or judicial question text, and sort them by similarity to form a data set as a retrieval result.
[0046] Preferably, in step S503, the temporal Transformer includes an LN layer, an attention network layer, an LN layer and an MLP layer connected end to end in sequence; the input of the first LN layer is the input of the temporal Transformer; the input of the first LN layer and the output of the attention network layer are residually connected and serve as the input of the second LN layer; the input of the second LN layer and the output of the MLP layer are residually connected and serve as the output of the temporal Transformer.
[0047] Preferably, the attention network layer uses a multi-head self-attention mechanism;
[0048] The calculation formula of the multi-head self-attention mechanism is as follows:
[0049] MSA=Concat(head 1 ,...,head n )W O ;
[0050] head i =Attention(Q i ,K i ,V i );
[0051] Where: Concat represents the serial operation; head i represents the i-th attention head; Attention(Q i ,K i ,V i ) represents the attention of each attention head.
[0052] Preferably, in step S504, the multi-scale Transformer includes a deconvolution layer, an LN layer, an attention network layer, an LN layer, an MLP layer and a pooling layer connected end to end in sequence; the input of the deconvolution layer is the input of the multi-scale Transformer; the input of the first LN layer is residually connected to the output of the attention network layer as the input of the second LN layer; the input of the second LN layer and the output of the MLP layer are residually connected as the input of the pooling layer; the output of the pooling layer is the output of the multi-scale Transformer.
[0053] The present invention also discloses a judicial field similar case retrieval system based on a large model, and the judicial field similar case retrieval method of the present invention is implemented, including:
[0054] Judicial document vector database, constructed by combining vector models with acquired judicial documents;
[0055] A text input module is used to obtain the input text of judicial cases or judicial issues;
[0056] A text enhancement module is used to perform intent recognition and question enhancement on the text of judicial cases or judicial questions through a large model to generate enhanced text of judicial cases or judicial questions;
[0057] The document retrieval and sorting module is used to generate vectors for the enhanced judicial case or judicial question text through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set;
[0058] The result output module is used to input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
[0059] Compared with the prior art, the judicial case retrieval method based on the big model in the present invention has the following beneficial effects:
[0060] The present invention uses a large model to perform intent recognition and question enhancement on the input judicial case or judicial question text to generate an enhanced judicial case or judicial question text. First, the large model can accurately identify the core intention of the user's question, ensure that the subsequent similar case retrieval is in the correct direction, and avoid interference from irrelevant information. Secondly, through question enhancement technology, the large model can expand and refine the user's question, so that the question text is closer to the professional expression in the judicial field, thereby improving the accuracy and relevance of similar case retrieval. Finally, the enhanced user question becomes clearer and more specific, making it possible to locate relevant judicial documents more quickly, reducing unnecessary search and screening time, and thus improving the efficiency of similar case retrieval.
[0061] On the basis of enhancing the text of judicial cases or judicial issues, the present invention generates corresponding vectors for the enhanced judicial cases or judicial issues through a vector model (such as an M3-Embedding model), performs similarity retrieval in a judicial document vector database, and then uses a Reranker model to reorder the preliminary screening results to generate a refined judicial document set. First, the vector model can convert complex judicial document content into vectors in a high-dimensional space. This representation method makes the similarity calculation between texts direct and efficient, greatly improving the retrieval speed. Secondly, by calculating the similarity between the input text vector and the existing judicial document vector in the database, a preliminary screening judicial document set that is highly relevant to the current judicial case or issue can be quickly screened out, ensuring the accuracy of the retrieval. Finally, the Reranker model can further analyze and compare the judicial documents in the preliminary screening set, considering more dimensional correlation factors (such as the applicability of legal provisions, the similarity of case facts, the relevance of judgment results, etc.), thereby generating a more accurate and orderly refined judicial document set.
[0062] On the basis of enhancing the text of judicial cases or judicial issues and retrieving judicial documents, the present invention further inputs the enhanced text of judicial cases or judicial issues and the collection of finely sorted judicial documents into a large model for correlation analysis. First, through the correlation analysis of the large model, the judicial documents most relevant to the user's question can be quickly screened out from the collection of finely sorted judicial documents, avoiding the inefficiency caused by traditional manual retrieval or simple keyword matching, and greatly improving the retrieval speed. Secondly, the large model is used to perform intent recognition and question enhancement on the text of judicial cases or judicial issues, generating a more accurate and specific query text, and then combining the correlation analysis with the in-depth analysis of the judicial documents, which can accurately match user needs and the content of the judicial documents and improve the accuracy of the retrieval results. Finally, the correlation analysis of the large model not only considers the global characteristics of the text, but also combines the local characteristics for comprehensive evaluation, which can more comprehensively capture the potential relationship between the text of judicial cases or judicial issues and judicial documents, thereby providing more comprehensive and richer retrieval results. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to make the purpose, technical solution and advantages of the invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0064] Figure 1 It is a logical block diagram of the judicial field similar case retrieval method based on the big model;
[0065] Figure 2 It is a flowchart of the method for retrieving similar cases in the judicial field based on the big model;
[0066] Figure 3 , Figure 4 and Figure 5 This is a schematic diagram of the operation of the judicial case retrieval system after visualization. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but only represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0068] It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. In the description of the present invention, it should be noted that the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, or the orientation or position relationship in which the invention product is usually placed when used, which is 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 of the present invention. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance. In addition, the terms "horizontal", "vertical", etc. do not mean that the components are required to be absolutely horizontal or suspended, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", and does not mean that the structure must be completely horizontal, but can be slightly tilted. In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0069] The following is a further detailed description through specific implementation methods:
[0070] Embodiment 1:
[0071] This embodiment discloses a method for retrieving similar cases in the judicial field based on a large model.
[0072] like Figure 1 and Figure 2 As shown in the figure, the judicial case retrieval method based on the big model includes:
[0073] S1: Construct a judicial document vector database by combining the vector model with the acquired judicial documents;
[0074] S2: Obtain input judicial case or judicial question text;
[0075] S3: Use a large model to identify the intent and enhance the question of the judicial case or judicial question text to generate an enhanced judicial case or judicial question text;
[0076] S4: Generate vectors for the enhanced judicial case or judicial question texts through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set;
[0077] In this embodiment, the vector model uses the M3-Embedding model.
[0078] S5: Input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
[0079] The Qwen2-7b-instruck large model is used in this embodiment. The Qwen2-7b-instruck large model can be widely used in various scenarios that require natural language processing and generation capabilities.
[0080] The present invention uses a large model to perform intent recognition and question enhancement on the input judicial case or judicial question text to generate an enhanced judicial case or judicial question text. First, the large model can accurately identify the core intention of the user's question, ensure that the subsequent similar case retrieval is in the correct direction, and avoid interference from irrelevant information. Secondly, through question enhancement technology, the large model can expand and refine the user's question, so that the question text is closer to the professional expression in the judicial field, thereby improving the accuracy and relevance of similar case retrieval. Finally, the enhanced user question becomes clearer and more specific, making it possible to locate relevant judicial documents more quickly, reducing unnecessary search and screening time, and thus improving the efficiency of similar case retrieval.
[0081] On the basis of enhancing the text of judicial cases or judicial issues, the present invention generates corresponding vectors for the enhanced judicial cases or judicial issues through a vector model (such as an M3-Embedding model), performs similarity retrieval in a judicial document vector database, and then uses a Reranker model to reorder the preliminary screening results to generate a refined judicial document set. First, the vector model can convert complex judicial document content into vectors in a high-dimensional space. This representation method makes the similarity calculation between texts direct and efficient, greatly improving the retrieval speed. Secondly, by calculating the similarity between the input text vector and the existing judicial document vector in the database, a preliminary screening judicial document set that is highly relevant to the current judicial case or issue can be quickly screened out, ensuring the accuracy of the retrieval. Finally, the Reranker model can further analyze and compare the judicial documents in the preliminary screening set, considering more dimensional correlation factors (such as the applicability of legal provisions, the similarity of case facts, the relevance of judgment results, etc.), thereby generating a more accurate and orderly refined judicial document set.
[0082] On the basis of enhancing the text of judicial cases or judicial issues and retrieving judicial documents, the present invention further inputs the enhanced text of judicial cases or judicial issues and the collection of finely sorted judicial documents into a large model for correlation analysis. First, through the correlation analysis of the large model, the judicial documents most relevant to the user's question can be quickly screened out from the collection of finely sorted judicial documents, avoiding the inefficiency caused by traditional manual retrieval or simple keyword matching, and greatly improving the retrieval speed. Secondly, the large model is used to perform intent recognition and question enhancement on the text of judicial cases or judicial issues, generating a more accurate and specific query text, and then combining the correlation analysis with the in-depth analysis of the judicial documents, which can accurately match user needs and the content of the judicial documents and improve the accuracy of the retrieval results. Finally, the correlation analysis of the large model not only considers the global characteristics of the text, but also combines the local characteristics for comprehensive evaluation, which can more comprehensively capture the potential relationship between the text of judicial cases or judicial issues and judicial documents, thereby providing more comprehensive and richer retrieval results.
[0083] In the specific implementation process, in step S1, the specific steps are as follows:
[0084] 1) Perform text annotation processing on the obtained judicial documents;
[0085] 2) Calling the fine-tuned vector model to vectorize the annotated judicial documents to obtain the judicial document vector;
[0086] 3) The judicial document vectors of all judicial documents are stored in the constructed judicial document vector database.
[0087] In this embodiment, the training data composition of the vector model (M3-Embedding model) is as follows:
[0088] 1: Unsupervised Data:
[0089] Unlabeled text data is extracted from a large number of multilingual corpora, including Wikipedia, S2ORC, xP3, mC4, and CC-News. These data enrich the semantic understanding ability of the model by extracting rich semantic structures (such as title-text, title-abstract, instruction-output, etc.). The scale of unsupervised data reaches 120 million text pairs, covering 194 languages and 2,655 cross-language correspondences.
[0090] 2: Fine-tuning Data:
[0091] High-quality data from labeled corpora, including English, Chinese, and judicial document-specific datasets. For example, English datasets include HotpotQA, TriviaQA, NQ, MS MARCO, etc., while Chinese datasets include DuReader, T2-Ranking, NLI-zh, etc. Judicial document-specific datasets include judicial precedents, guiding cases, national laws, local regulations, judicial interpretations, etc. These datasets are used to further fine-tune the model to improve its performance on specific tasks and languages.
[0092] 3: Synthetic Data:
[0093] In order to solve the problem of insufficient data in the long document retrieval task, additional multilingual fine-tuning data (MultiLongDoc) was generated. By randomly selecting long articles from the Wikipedia and MC4 datasets, and randomly selecting paragraphs from them, and then using GPT-3.5 to generate questions based on these paragraphs, the generated questions and the selected articles constitute new text pairs, which increases the diversity and coverage of the training data.
[0094] Among them, the vector model is fine-tuned by the low-rank adaptive algorithm (LoRA algorithm), and the specific steps are as follows:
[0095] S101: Create two low-rank matrices A and B with a rank of r for each original weight matrix of the vector model;
[0096] S102: original weight matrix of frozen vector model;
[0097] S103: Obtaining annotated judicial document data as fine-tuning data;
[0098] S104: Input the fine-tuning data into the vector model and output the corresponding predicted document vector;
[0099] S105: Calculate the loss based on the predicted document vector and the corresponding real document vector in combination with the loss function, and reversely optimize the low-rank matrices A and B in the vector model;
[0100] S106: Repeat steps S104 to S106 until the vector model converges or reaches a preset number of iteration rounds;
[0101] S107: Add the update amount of each original weight matrix of the vector model and its corresponding low-rank matrices A and B to obtain the final weight matrix, thereby achieving fine-tuning of the vector model.
[0102] In the specific implementation process, the steps for the big model to identify the intent and enhance the question of the judicial case or judicial question text are as follows:
[0103] S301: parse and identify the intent of the judicial case or judicial question text through a large model to generate user intent;
[0104] In this embodiment, the big model can be used to implement parsing and intent recognition. The big model has learned a large amount of text data through pre-training, which contains various user queries and corresponding responses, so it can understand complex natural language and infer the user's intention. When a judicial case or judicial question text is input, the big model will analyze the language structure, keywords, context and other information of the question, and generate an output related to the question intent.
[0105] S302: Decomposing the judicial case or judicial question text according to the user's intention to generate several question parts (or sub-questions); decomposing the judicial case or judicial question text may include splitting a complex question into smaller sub-questions, or decomposing the question into different components (such as keywords, topics, context, etc.).
[0106] In this embodiment, the natural language processing capability of the big model is used to deeply understand and analyze the problem, ensuring that the decomposed part of the problem can accurately reflect the core meaning of the original problem. First, the big model sets a strategy for decomposing the problem according to the user's intention. Then the problem is decomposed by keyword extraction, context understanding or generative reasoning. Keyword extraction means that the big model can identify keywords related to the core intent by inputting judicial cases or judicial problem texts, such as "labor arbitration", "signing contracts", "wage arrears", etc. Context understanding means that the big model has an in-depth understanding of the context. It can further infer the type of case that the user may be concerned about based on the context information of the problem; generative reasoning means that the big model has the ability of generative reasoning, which can combine the case type understood in the context with the keyword extraction content and finally infer the case applicable to the problem. The case type, case cause and question content generated by the big model are integrated to ensure consistency with the core intent of the user's question.
[0107] S303: combining the user intention with the question part, analyzing the relationship between the user intention and the question part, and determining the question part to be enhanced;
[0108] In this embodiment, firstly, the large model can select the corresponding case element table by analyzing the case type and case element. Secondly, the large model can also determine the element satisfaction degree of the user input information according to the corresponding case element table.
[0109] S304: Generate or rewrite the text of the question part that needs to be enhanced by using the language generation capability of the large model, so as to enhance the question part;
[0110] In this embodiment, the big model can generate new text related to the original question and in line with the user's intention based on the judicial case or judicial question text input by the user, thereby enhancing the accuracy and completeness of the question. For example, the big model supplements or explains the judicial case or judicial question text based on the user's intention and in combination with the case element table (such as case type: criminal case, civil and commercial case, administrative case, etc.; case nature: whether it involves public interests, social impact, etc., whether it involves major legal principles or legal interpretations) to provide a more detailed or specific description.
[0111] S305: Combine the enhanced question part with other question parts of the judicial case or judicial question text to form an enhanced judicial case or judicial question text.
[0112] During the specific implementation process, the following steps are used to generate a collection of carefully sorted judicial documents:
[0113] S401: vectorizing the enhanced judicial case or judicial question text through a vector model to obtain a judicial case or judicial question text vector;
[0114] S402: Calculate the inner product similarity between the judicial case or judicial question text vector and all judicial document vectors in the judicial document vector database; add the judicial documents corresponding to the judicial document vectors whose inner product similarity is greater than the similarity threshold to the preliminary screening judicial document set;
[0115] In this embodiment, the calculation formula of the inner product similarity is expressed as:
[0116] a → b → = |a|·|b|·cosθ;
[0117] Where: θ represents a → and b → The angle between.
[0118] S403: Sort the judicial documents in the initial screening judicial document set by using the maximum marginal correlation model and the Reranker model to generate a refined judicial document set.
[0119] Specifically, the Maximum Marginal Relevance (MMR) model is an algorithm commonly used in data mining, machine learning, information retrieval, and recommendation systems. It aims to select a set of elements that are most relevant to a given query and have large differences from each other from a set of candidates. In document retrieval, the MMR model is used to improve the diversity and relevance of retrieval results. The Reranker model is a model used to rerank preliminary retrieval results. It improves the accuracy and relevance of search results by making a more refined assessment of the relevance between documents and queries.
[0120] The processing steps of the maximum marginal correlation model and the Reranker model are as follows:
[0121] S4031: Selecting from the pre-screened judicial document set the judicial document corresponding to the document vector having the largest inner product similarity with the judicial case or judicial question text vector as the first document and adding it to the re-ranking set;
[0122] S4032: For the remaining judicial documents in the initial screening judicial document set, calculate the MMR value of each judicial document and the judicial case or judicial question text. The MMR value comprehensively considers the similarity with the judicial case or judicial question text and the difference with other selected documents);
[0123] The calculation of MMR value is as follows:
[0124]
[0125] Where: Q represents the enhanced judicial case or judicial issue text; C represents the initial screening document set, R represents the re-ranking set, and λ is a parameter between 0 and 1, which is used to balance the importance of relevance and diversity. represents the index of the K sentences that obtain the maximum value, sim(Q,di) represents the similarity between the query Q and the document di, and sim(di,dj) represents the similarity between the documents di and dj.
[0126] S4033: Select the judicial document with the largest MMR value and add it to the re-ranking set, and delete the judicial document from the initial screening judicial document set;
[0127] S4034: repeat steps S4032 to S4033 until the initial screening judicial document set is empty;
[0128] S4035: Take the judicial case or judicial question text and each document in the re-ranking set as the input of the Reranker model, and output the corresponding similarity score; sort each document in the re-ranking set according to the similarity score to form a refined judicial document set.
[0129] In this embodiment, the similarity score refers to the similarity score between the document and the judicial case or judicial question text (query), rather than the embeddings. The re-ranking model is optimized using cross-entropy loss, so the similarity score is not limited to a specific range and can even be negative.
[0130] During the specific implementation process, the correlation analysis of the large model extracts the global text features and local text features of the judicial documents through the temporal Transformer and the multi-scale Transformer respectively, and then fuses the global text features and local text features of the judicial documents into fused text features. Finally, based on the fused text features, the similarity between the judicial document and the judicial case or judicial issue text is calculated and the most relevant judicial document is selected.
[0131] Specifically, the processing steps of large model correlation analysis are as follows:
[0132] S501: inputting the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis;
[0133] In this embodiment, the judicial case or judicial question text and judicial documents need to be converted into digital vectors that can be understood by the large model, which usually involves tokenization and word embedding, for example, using pre-trained word vectors or embedding layers within the model. The judicial case or judicial question text may be specially marked or encoded so that the model can distinguish it from other judicial document information.
[0134] S502: Encode the judicial case or judicial question text and the judicial document through an encoder to obtain an embedded representation of the judicial case or judicial question text and the judicial document;
[0135] S503: extracting global text features from the embedded representation of the judicial document through the temporal Transformer;
[0136] S504: Extract local text features from the embedded representation of judicial documents through a multi-scale Transformer;
[0137] S505: Fusing the global text features and the local text features of the judicial document to generate a fused text feature;
[0138] In this embodiment, the fusion of global text features and local text features can be achieved through weighted calculation.
[0139] S506: Calculate the similarity score between the fused text features of each judicial document and the embedded representation of the judicial case or judicial question text;
[0140] In this embodiment, the similarity score between the fused text features of the judicial document and the embedded representation of the judicial case or judicial issue text can be calculated by calculating the inner product similarity, Euclidean distance, Manhattan distance, etc.
[0141] S507: taking one or more judicial documents with the highest similarity scores as the most relevant judicial documents;
[0142] In this embodiment, the judicial documents with similarity scores exceeding a threshold are regarded as the most relevant judicial documents.
[0143] S508: Decode the embedded representation of the most relevant judicial document through a decoder to obtain the judicial document most relevant to the judicial case or judicial question text, and sort them by similarity to form a data set as a retrieval result.
[0144] Specific:
[0145] 1) The Temporal Transformer includes an LN (Layer Normalization) layer, an attention network layer, an LN layer, and an MLP (Multi-Layer Perceptron) layer connected end to end in sequence; the input of the first LN layer is the input of the Temporal Transformer; the input of the first LN layer and the output of the attention network layer are residually connected as the input of the second LN layer; the input of the second LN layer and the output of the MLP layer are residually connected as the output of the Temporal Transformer.
[0146] 2) The attention network layer uses a multi-head self-attention mechanism;
[0147] The calculation formula of the multi-head self-attention mechanism is as follows:
[0148] MSA=Concat(head 1 ,...,head n )W O ;
[0149] head i =Attention(Q i ,K i ,V i );
[0150] Where: Concat represents the serial operation; head i represents the i-th attention head; Attention(Q i ,K i ,V i ) represents the attention of each attention head;
[0151] Each attention head uses the scaled dot product attention mechanism to calculate attention, and the calculation formula is as follows:
[0152]
[0153] Where: W O Indicates d m dimensional linear projection layer; n represents the number of time frames; d m Represents the number of feature channels, that is, dimension.
[0154] The calculation formula of the multi-layer perceptron is as follows:
[0155] MLP(x)=σ(xW 1 +b 1 )W 2 +b 2 ;
[0156] Where: σ(·) represents the activation function GeLU; and They represent the fully connected layers of the multi-layer perceptron respectively; and Represents the fully connected layer and The bias of ; MLP(x) represents multi-layer perceptron.
[0157] In the Multi-Head Self-Attention Layer of the Transformer model, the outputs of multiple attention heads are usually concatenated together. This concatenation operation is to maintain and combine the information of different attention representations between multiple attention heads, thereby enriching the model's ability to represent the input sequence. In the multi-head self-attention mechanism, the model usually uses multiple attention heads to learn multiple different attention representations. head i The "i" in " represents the i-th attention head, which usually indicates a specific attention pattern or representation learned by this head. Multi-head self-attention allows the model to learn multiple different attention representations in parallel, and each head may focus on different features or relationships in the sequence.
[0158] 3) The multi-scale Transformer includes a deconvolution layer, an LN layer, an attention network layer, an LN layer, an MLP layer, and a pooling layer connected end to end in sequence; the input of the deconvolution layer is the input of the multi-scale Transformer; the input of the first LN layer is residually connected to the output of the attention network layer and serves as the input of the second LN layer; the input of the second LN layer and the output of the MLP layer are residually connected and serve as the input of the pooling layer; the output of the pooling layer serves as the output of the multi-scale Transformer.
[0159] The correlation analysis of the large model in the present invention can extract global and local features respectively through the time transformer and the multi-scale transformer, and then calculate the similarity between the judicial document and the judicial case or judicial problem text by fusing the text features. First, the time transformer can capture the global features of the judicial document that change over time, while the multi-scale transformer can focus on the local details and specific patterns in the text. By combining the two features, the text content can be understood more accurately, and the judicial document that best matches the judicial case or judicial problem text can be found. Secondly, due to the diversity and complexity of the legal provisions, cases, and terms involved in the judicial field, the model needs to have a certain adaptability to cope with various situations. By combining global and local features, the model can better adapt to judicial documents of different types and fields, and improve the versatility and flexibility of retrieval. Finally, the fusion of global and local text features can provide a richer and more comprehensive text representation, which helps the model to more accurately calculate the similarity between the judicial document and the judicial case or judicial problem text. This fusion method can make full use of the information in the text and improve the accuracy and reliability of the retrieval results.
[0160] Embodiment 2:
[0161] This embodiment discloses a judicial field similar case retrieval system based on a large model, which is implemented based on the judicial field similar case retrieval method of the first embodiment.
[0162] Figure 3 , Figure 4 and Figure 5 It is a visual interface for similar case retrieval systems in the judicial field.
[0163] Specifically, the judicial case retrieval system based on the big model includes:
[0164] Judicial document vector database, constructed by combining vector models with acquired judicial documents;
[0165] A text input module is used to obtain the input text of judicial cases or judicial issues;
[0166] A text enhancement module is used to perform intent recognition and question enhancement on the text of judicial cases or judicial questions through a large model to generate enhanced text of judicial cases or judicial questions;
[0167] The document retrieval and sorting module is used to generate vectors for the enhanced judicial case or judicial question text through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set;
[0168] The result output module is used to input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
[0169] The present invention uses a large model to perform intent recognition and question enhancement on the input judicial case or judicial question text to generate an enhanced judicial case or judicial question text. First, the large model can accurately identify the core intention of the user's question, ensure that the subsequent similar case retrieval direction is correct, and avoid interference from irrelevant information. Secondly, through question enhancement technology, the large model can expand and refine the user's question, so that the question text is closer to the professional expression in the judicial field, thereby improving the accuracy and relevance of similar case retrieval. Finally, the enhanced judicial case or judicial question text becomes clearer and more specific, making it possible to locate relevant judicial documents more quickly, reducing unnecessary search and screening time, and thus improving the efficiency of similar case retrieval.
[0170] On the basis of enhancing the text of judicial cases or judicial issues, the present invention generates corresponding vectors for the enhanced judicial cases or judicial issues through a vector model (such as an M3-Embedding model), performs similarity retrieval in a judicial document vector database, and then uses a Reranker model to reorder the preliminary screening results to generate a refined judicial document set. First, the vector model can convert complex judicial document content into vectors in a high-dimensional space. This representation method makes the similarity calculation between texts direct and efficient, greatly improving the retrieval speed. Secondly, by calculating the similarity between the input text vector and the existing judicial document vector in the database, a preliminary screening judicial document set that is highly relevant to the current judicial case or issue can be quickly screened out, ensuring the accuracy of the retrieval. Finally, the Reranker model can further analyze and compare the judicial documents in the preliminary screening set, considering more dimensional correlation factors (such as the applicability of legal provisions, the similarity of case facts, the relevance of judgment results, etc.), thereby generating a more accurate and orderly refined judicial document set.
[0171] On the basis of enhancing the text of judicial cases or judicial issues and retrieving judicial documents, the present invention further inputs the enhanced text of judicial cases or judicial issues and the collection of finely sorted judicial documents into a large model for correlation analysis. First, through the correlation analysis of the large model, the judicial documents most relevant to the user's question can be quickly screened out from the collection of finely sorted judicial documents, avoiding the inefficiency caused by traditional manual retrieval or simple keyword matching, and greatly improving the retrieval speed. Secondly, the large model is used to perform intent recognition and question enhancement on the text of judicial cases or judicial issues, generating a more accurate and specific query text, and then combining the correlation analysis with the in-depth analysis of the judicial documents, which can accurately match user needs and the content of the judicial documents and improve the accuracy of the retrieval results. Finally, the correlation analysis of the large model not only considers the global characteristics of the text, but also combines the local characteristics for comprehensive evaluation, which can more comprehensively capture the potential relationship between the text of judicial cases or judicial issues and judicial documents, thereby providing more comprehensive and richer retrieval results.
[0172] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit the technical solution. Those skilled in the art should understand that those modifications or equivalent substitutions of the technical solution of the present invention that do not depart from the purpose and scope of the technical solution should be included in the scope of the claims of the present invention.
Claims
1. A method for retrieving similar cases in the judicial field based on a large model, characterized in that: include: S1: Construct a judicial document vector database by combining the vector model with the acquired judicial documents; S2: Obtain input judicial case or judicial question text; S3: Use a large model to identify the intent and enhance the question of the judicial case or judicial question text to generate an enhanced judicial case or judicial question text; S4: Generate vectors for the enhanced judicial case or judicial question texts through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set; S5: Input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
2. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 1, characterized in that: Fine-tune the vector model through a low-rank adaptive algorithm. The specific steps are as follows: S101: Create two low-rank matrices A and B with a rank of r for each original weight matrix of the vector model; S102: original weight matrix of frozen vector model; S103: Obtaining annotated judicial document data as fine-tuning data; S104: Input the fine-tuning data into the vector model and output the corresponding predicted document vector; S105: Calculate the loss based on the predicted document vector and the corresponding real document vector in combination with the loss function, and reversely optimize the low-rank matrices A and B in the vector model; S106: Repeat steps S104 to S106 until the vector model converges or reaches a preset number of iteration rounds; S107: Add the update amount of each original weight matrix of the vector model and its corresponding low-rank matrices A and B to obtain the final weight matrix, thereby achieving fine-tuning of the vector model.
3. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 1, characterized in that: In step S3, the large model performs the following steps to identify the intent and enhance the question text of the judicial case or judicial question: S301: parse and identify the intent of the judicial case or judicial question text through a large model to generate user intent; S302: Decomposing the judicial case or judicial question text according to the user's intention to generate several question parts; S303: combining the user intention with the question part, analyzing the relationship between the user intention and the question part, and determining the question part to be enhanced; S304: Generate or rewrite the text of the question part that needs to be enhanced by using the language generation capability of the large model, so as to enhance the question part; S305: Combine the enhanced question part with other question parts of the judicial case or judicial question text to form an enhanced judicial case or judicial question text.
4. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 1, characterized in that: In step S4, a collection of neatly arranged judicial documents is generated through the following steps: S401: vectorizing the enhanced judicial case or judicial question text through a vector model to obtain a judicial case or judicial question text vector; S402: Calculate the inner product similarity between the judicial case or judicial question text vector and all judicial document vectors in the judicial document vector database; add the judicial documents corresponding to the judicial document vectors whose inner product similarity is greater than the similarity threshold to the preliminary screening judicial document set; S403: Sort the judicial documents in the initial screening judicial document set by using the maximum marginal correlation model and the Reranker model to generate a refined judicial document set.
5. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 4, characterized in that: In step S403, the processing steps of the maximum marginal correlation model and the Reranker model are as follows: S4031: Selecting from the pre-screened judicial document set the judicial document corresponding to the document vector having the largest inner product similarity with the judicial case or judicial question text vector as the first document and adding it to the re-ranking set; S4032: For the remaining judicial documents in the initial screening judicial document set, calculate the MMR value of each judicial document and the judicial case or judicial question text; S4033: Select the judicial document with the largest MMR value and add it to the re-ranking set, and delete the judicial document from the initial screening judicial document set; S4034: repeat steps S4032 to S4033 until the initial screening judicial document set is empty; S4035: Take the judicial case or judicial question text and each document in the re-ranking set as the input of the Reranker model, and output the corresponding similarity score; sort each document in the re-ranking set according to the similarity score to form a refined judicial document set.
6. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 1, characterized in that: In step S5, the processing steps of large model correlation analysis are as follows: S501: inputting the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis; S502: Encode the judicial case or judicial question text and the judicial document through an encoder to obtain an embedded representation of the judicial case or judicial question text and the judicial document; S503: extracting global text features from the embedded representation of the judicial document through the temporal Transformer; S504: Extract local text features from the embedded representation of judicial documents through a multi-scale Transformer; S505: Fusing the global text features and the local text features of the judicial document to generate a fused text feature; S506: Calculate the similarity score between the fused text features of each judicial document and the embedded representation of the judicial case or judicial question text; S507: taking one or more judicial documents with the highest similarity scores as the most relevant judicial documents; S508: Decode the embedded representation of the most relevant judicial document through a decoder to obtain the judicial document most relevant to the judicial case or judicial question text, and sort them by similarity to form a data set as a retrieval result.
7. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 6, characterized in that: In step S503, the temporal transformer includes an LN layer, an attention network layer, an LN layer, and an MLP layer connected end to end in sequence; the input of the first LN layer is the input of the temporal transformer; the input of the first LN layer and the output of the attention network layer are residually connected as the input of the second LN layer; the input of the second LN layer and the output of the MLP layer are residually connected as the output of the temporal transformer.
8. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 7, characterized in that: The attention network layer uses a multi-head self-attention mechanism; The calculation formula of the multi-head self-attention mechanism is as follows: MSA=Concat(head1,...,head n )W O ; head i =Attention(Q i ,K i ,V i ); Where: Concat represents the serial operation; head i represents the i-th attention head; Attention(Q i ,K i ,V i ) represents the attention of each attention head.
9. The method for retrieving similar cases in the judicial field based on a large model as claimed in claim 6, characterized in that: In step S504, the multi-scale Transformer includes a deconvolution layer, an LN layer, an attention network layer, an LN layer, an MLP layer and a pooling layer which are connected end to end in sequence; the input of the deconvolution layer is the input of the multi-scale Transformer; the input of the first LN layer is residually connected with the output of the attention network layer as the input of the second LN layer; the input of the second LN layer is residually connected with the output of the MLP layer as the input of the pooling layer; the output of the pooling layer is the output of the multi-scale Transformer.
10. A judicial case retrieval system based on a large model, characterized by: The implementation of the judicial field similar case retrieval method according to claim 1 includes: Judicial document vector database, constructed by combining vector models with acquired judicial documents; A text input module is used to obtain the input text of judicial cases or judicial issues; A text enhancement module is used to perform intent recognition and question enhancement on the text of judicial cases or judicial questions through a large model to generate enhanced text of judicial cases or judicial questions; The document retrieval and sorting module is used to generate vectors for the enhanced judicial case or judicial question text through the vector model, and perform similarity search in the judicial document vector database to obtain a preliminary screening judicial document set; rerank the preliminary screening judicial document set through the Reranker model to generate a refined judicial document set; The result output module is used to input the enhanced judicial case or judicial issue text and all judicial documents in the refined judicial document collection into the large model for correlation analysis, output the judicial documents most relevant to the judicial case or judicial issue text and sort them by similarity to form a data set as the retrieval result.
Citation Information
Cited By
Diversified judicial instruction data selection method and system based on large model perception
CN119886229A
Diversified Judicial Instruction Data Selection Method and System Based on Large Model Perception
CN119886229B
Water conservancy inspection retrieval execution method and system based on LoRA fine tuning
CN121350230A
Illegal capital risk mining and grading research and judgment method and system based on bidirectional semantic fusion
CN121683790A