A slow-thinking legal question-answering method and device based on the judge's perspective
By combining a multi-dimensional legal vector knowledge base with a lightweight large model, the legal question-and-answer system achieves multi-angle knowledge retrieval and reflection, improving the accuracy and comprehensiveness of legal questions and answers and solving the problem of incomplete retrieval in existing technologies.
Patent Information
- Application Number
- CN202411799924.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-09
AI Technical Summary
Existing legal question-and-answer systems based on RAG technology suffer from incomplete search results and internal contradictions in the searched knowledge, leading to a significant decrease in the accuracy of answers.
It adopts a slow thinking model based on the judge's perspective, builds a multi-dimensional legal vector knowledge base, generates easy-to-match search queries, and uses a lightweight large model for knowledge screening and reflection, so as to achieve multi-angle retrieval, screening and reflection and generate accurate legal answers.
It significantly improves the accuracy, reliability, and comprehensiveness of the legal Q&A system, and solves the problem of incomplete search results caused by a single search.
Smart Images

Figure CN119719296B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, and in particular to a legal question-and-answer method and apparatus based on a judge's perspective and a slow-thinking mode. Background Technology
[0002] With advancements in model algorithms, the development of scalable basic model architectures, and the abundance of high-quality datasets, large language model technology has achieved remarkable success. However, large language model systems still face challenges such as lagging knowledge updates, insufficient coverage of long-tail knowledge, data leakage risks, and high training and inference costs. Especially in specific domains, due to a lack of representative knowledge, they still suffer from problems like "illusions." To address these issues, retrieval-enhanced generative techniques have emerged. By introducing information retrieval mechanisms, relevant objects are retrieved from existing data warehouses to enhance the results generated by large language models, thereby improving accuracy and robustness.
[0003] However, current legal question-answering systems based on RAG technology are mostly limited to single searches. The retrieved knowledge often fails to fully or partially cover all knowledge points, and internal contradictions may exist between the knowledge points, leading to a significant decrease in the accuracy of the answers. To address this issue, this invention proposes a legal question-answering method based on a judge's perspective and a slow-thinking mode. This method first understands the user's input question from a judge's perspective, generating a search query statement that is easy to match with the current knowledge base. Then, relying on a lightweight large model, it uses a constructed multi-dimensional knowledge filter and reflector in the legal domain to accurately filter highly relevant legal knowledge. The reflector then evaluates whether this knowledge is sufficient to answer the user's question. If the evaluation result is sufficient, the large model answers the user's question based on the retrieved knowledge; if the evaluation result is insufficient, a new search statement is automatically generated for a second search, and so on, until the retrieved knowledge can answer the user's question or the set number of reflections is reached. Using this judge-perspective slow-thinking mode, the accuracy of legal question answering can be significantly improved. Summary of the Invention
[0004] To address the issues of incomplete content retrieval and internal contradictions and inadequacies in the retrieved knowledge in existing RAG technology for legal Q&A, this invention aims to provide a legal Q&A method and apparatus based on a judge's perspective and a slow-thinking mode, in order to improve the accuracy, reliability, robustness, and comprehensiveness of the legal Q&A system.
[0005] To achieve the above objectives, the technical solution of the present invention includes the following:
[0006] A legal question-and-answer method based on a judge's perspective and a slow-thinking approach, the method comprising:
[0007] Construct a multi-dimensional legal vector knowledge base;
[0008] The system understands the user's question and generates several search queries.
[0009] The search query is performed in the multi-dimensional legal vector knowledge base to obtain relevant legal knowledge about the user's question.
[0010] The relevant legal knowledge is screened to construct a candidate knowledge base, and the legal knowledge in the candidate knowledge base is evaluated to determine whether it is sufficient to answer the user's question.
[0011] If the legal knowledge in the candidate knowledge base is sufficient to fully answer the user's question, then an answer to the user's question is generated based on the legal knowledge in the candidate knowledge base.
[0012] Furthermore, the construction of the multi-dimensional legal vector knowledge base includes:
[0013] Collect raw data and clean it according to timeliness, accuracy, consistency and validity; wherein, the raw data includes: legal Q&A pairs, laws and regulations and case data;
[0014] The cleaned raw data is then deeply analyzed and refined to form a legal Q&A dataset A = {(t i a i g i s i | i = 1, ..., n A}、 Set of laws and regulations B={(l i d i c i e i , k i | i = 1, ..., n B} and case dataset C = {(y i f i b i p i , z i | i = 1, ..., n C}; where t i Let a represent the question content corresponding to the i-th legal question and answer data. i Let g represent the answer corresponding to the i-th legal question and answer data. i s represents the summary of questions corresponding to the i-th legal Q&A data. i Indicates the data source corresponding to the i-th legal question and answer data, n A Let l represent the data size of the legal question and answer dataset A. i d represents the name of the law or regulation corresponding to the i-th legal provision. i c represents the directory corresponding to the i-th legal provision. ie represents the content of the legal provision corresponding to the i-th legal provision. i This represents the interpretation of the i-th legal provision, k. i This represents the key element corresponding to the i-th legal provision, n. B y represents the data size of the legal and regulatory set B. i f represents the cause of action for the i-th case. i b represents the findings of the trial of the i-th case data. i This court believes that p represents the data of the i-th case. i The judgment for the i-th case data is as follows, z i This represents the case summary of the i-th case data, n C Indicate the data size of the case dataset C;
[0015] Generate question content t i Key element k i Case summary i The sparse and dense vectors are generated and stored in the legal question-and-answer data set A, the legal regulations set B, and the case data set C, respectively. Then, they are imported into the corresponding legal question-and-answer vector knowledge base, legal regulations vector knowledge base, and case data vector knowledge base.
[0016] Furthermore, the process of understanding the user's question and generating several search query statements includes:
[0017] When searching the legal question-and-answer vector knowledge base, if it is a single-turn dialogue, the user's question is used as the search query for the legal question-and-answer vector knowledge base; if it is a multi-turn dialogue, the user's question is rewritten based on the historical dialogue and a referential resolution strategy is used, and the rewritten question is used as the search query for the legal question-and-answer vector knowledge base.
[0018] When searching the legal and regulatory vector knowledge base, a question-based legal key element prompt instruction is adopted. Using a large language model, the legal field to which the question belongs is clarified, and the core legal facts, legal scenarios, legal subjects and other key legal elements in the user's question are extracted. These key legal elements are then concatenated as the search statement for the legal and regulatory knowledge base.
[0019] When searching the case data vector knowledge base, based on the prompt corpus of user questions and case summaries, a case summary prompt instruction is generated. After generating the case summary corresponding to the user question using a large language model, the case summary corresponding to the user question is used as the search query statement for the case data vector knowledge base.
[0020] Further, the relevant legal knowledge is screened, including:
[0021] Based on the legal analysis of similar cases, the detailed explanation of laws and regulations, and the determination of the same purpose of the issues, a relevance assessment standard is defined.
[0022] Based on relevance assessment criteria, a relevance assessment prompt instruction is constructed; wherein, the relevance assessment prompt instruction requires the output of a highly relevant knowledge list, and the information in the relevance assessment prompt instruction includes: similar case knowledge, legal and regulatory knowledge, legal Q&A knowledge, user questions, and relevance assessment prompt corpus;
[0023] For user question samples and knowledge blocks recalled based on those user question samples, a highly relevant knowledge list is output using a large language model and relevance assessment prompts.
[0024] A knowledge filtering model is trained based on the highly relevant knowledge list;
[0025] The trained knowledge screening model is used to screen the relevant legal knowledge.
[0026] Furthermore, assess whether the legal knowledge in the candidate knowledge base is sufficient to adequately answer the user's question, including:
[0027] Based on the legal analysis of similar cases, the detailed explanation of laws and regulations, and the determination of the same purpose of the issues, a knowledge reflection assessment standard is defined.
[0028] Based on the knowledge reflection and evaluation criteria, legal knowledge from the candidate knowledge base is embedded into reflection and evaluation prompts, and a large model is used to evaluate whether the legal knowledge in the candidate knowledge base is sufficient to answer the user's question. The information in the reflection and evaluation prompts includes: similar case knowledge, legal knowledge, legal Q&A knowledge, user questions, and reflection and evaluation prompt corpus.
[0029] Furthermore, generating the answer to the user's question based on legal knowledge in the candidate knowledge base includes:
[0030] Based on the inverse fusion sorting algorithm, the legal knowledge in the candidate knowledge base is deduplicated and reordered to generate the final knowledge list;
[0031] The user's question and the final knowledge list are embedded into the instructions to generate an answer, and a large model is used to generate a natural language answer to the user's question.
[0032] Furthermore, based on the inverse fusion sorting algorithm, the legal knowledge in the candidate knowledge base is deduplicated and reordered to generate a final knowledge list, including:
[0033] Deduplication of legal knowledge in the candidate knowledge base;
[0034] Select the knowledge content to be input into the large model based on different types of knowledge;
[0035] Using the inverse fusion sorting method, the similarity between the selected knowledge content to be input into the large model and the user's question is calculated, and the deduplicated legal knowledge is sorted based on the similarity to obtain the final knowledge list; wherein, the legal knowledge in the final knowledge list is integrated according to type.
[0036] Furthermore, the method also includes:
[0037] If the legal knowledge in the candidate knowledge base is insufficient to fully answer the user's question, a new search query will be generated based on the user's question and the deficiencies in the legal knowledge in the candidate knowledge base.
[0038] Based on the new search query, the search for the query in the multi-dimensional legal vector knowledge base is re-executed to obtain the relevant legal knowledge for the user's question.
[0039] A legal question-and-answer device based on a judge's perspective and a slow-thinking mode, the device comprising:
[0040] The knowledge base construction module is used to build a multi-dimensional legal vector knowledge base.
[0041] The statement generation module is used to understand user questions and generate several search query statements;
[0042] A knowledge retrieval model is used to retrieve the search query statement in the multi-dimensional legal vector knowledge base to obtain relevant legal knowledge about the user's question.
[0043] The knowledge assessment module is used to filter the relevant legal knowledge to build a candidate knowledge base and assess whether the legal knowledge in the candidate knowledge base is sufficient to answer the user's question.
[0044] The answer generation module is used to generate an answer to the user's question based on the legal knowledge in the candidate knowledge base, provided that the legal knowledge in the candidate knowledge base is sufficient to fully answer the user's question.
[0045] An electronic device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the legal question-and-answer method based on the judge's perspective and slow thinking mode as described above.
[0046] Compared with the prior art, the present invention has at least the following beneficial effects.
[0047] In the problem understanding phase, this invention, from a judge's perspective, generates easily searchable query statements for different knowledge bases based on the user's input question, improving recall accuracy. The method also relies on multiple dimensions, including legal analysis of similar cases, detailed explanations of laws and regulations, and determination of the same purpose of the question, to construct a multi-dimensional knowledge filter and reflector in the legal field. The knowledge filter filters the recalled knowledge, resolving issues such as internal contradictions and irrelevance among knowledge. Based on the reflector, it determines whether the knowledge fully answers the user's question and generates iterative queries adapted to different dimensions, addressing the problem of incomplete search content in current RAG-based legal question-answering systems due to single searches. This constructs a slow-thinking mode for legal question answering. Therefore, introducing a judge-perspective-based slow-thinking mode into a RAG-based legal question-answering system enables multi-angle knowledge retrieval, filtering, and reflection, achieving efficient and sufficient extraction of legal knowledge content and significantly improving the accuracy of legal question answering. Attached Figure Description
[0048] Figure 1 This is a flowchart of a legal question-and-answer method based on a judge's perspective and a slow-thinking approach.
[0049] Figure 2 Flowchart for building a legal knowledge vector library module. Detailed Implementation
[0050] To further illustrate the technical solutions of the present invention, the present invention will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0051] The present invention provides a legal question-and-answer method based on a judge's perspective and a slow-thinking model, such as... Figure 1 As shown, the process includes steps S1 to S8.
[0052] Step S1: Construct a multi-dimensional legal vector knowledge base.
[0053] This invention constructs a multi-dimensional legal vector knowledge base through steps such as collection, cleaning, organization, knowledge processing, vectorization, and updating. In this embodiment, the legal vector knowledge base includes three vector knowledge bases: legal Q&A, laws and regulations, and case data. Figure 2 Specifically, it includes the following key steps:
[0054] Step S11: Knowledge collection and cleaning.
[0055] First, we extensively collected original materials such as legal Q&A pairs, laws and regulations, and case data from various authoritative legal databases and official websites (e.g., the Supreme People's Court, China Legal Service Network, etc.). Case data included practical cases and judgments. Then, we rigorously screened and cleaned these materials from the perspectives of timeliness, accuracy, consistency, and effectiveness, removing duplicates, errors, and outdated information to ensure the accuracy and timeliness of the knowledge base.
[0056] Step S12: Knowledge processing.
[0057] This invention performs in-depth analysis and refinement of the cleaned knowledge to form knowledge units with legal expertise.
[0058] In terms of legal question-and-answer data processing, for a legal question-and-answer dataset A = {(t} with millions of questions... i a i s i | i = 1, ..., n A}, where t i 、a i and s i Let n represent the question content, answer, and data source corresponding to the i-th data point, respectively. A The size of the legal question and answer dataset A is represented by the following two legal information processing strategies: (1) Extraction of legal key points and conclusions: Using large language model technology, based on the preset answer summary prompts (see Table 1), the answers in the legal question and answer pairs are analyzed in depth to accurately extract the legal key points and conclusive statements. This process aims to eliminate knowledge redundancy and ensure that the extracted information is direct, accurate and focused on the core legal points. (2) Precise extraction and matching of laws and regulations: Using efficient pattern matching technology, such as the extraction rules in Table 2 and the fuzzy query statements in Table 3, the names, specific items and content summaries of laws and regulations mentioned in the answer text are identified. Subsequently, using the fuzzy matching algorithm, the complete legal and regulatory content that matches the identification results is retrieved from the authoritative legal and regulatory database. This step ensures the accuracy and completeness of the extracted legal and regulatory names, items and content information. The content processed by the above two strategies is integrated into a new field called answer summary g, thereby improving the practical value and accuracy of the legal question and answer pairs. The final legal question and answer dataset is represented as: A={(t i a i g i s i | i = 1, ..., n A The information contained in the answer summary prompts includes: the answer content of the legal questions and answers, and the prompt corpus for the answer summary.
[0059] Table 1: Answer Summary Hints
[0060]
[0061] Table 2 Rules for Extracting Legal Provisions
[0062]
[0063] Table 3 Fuzzy Query Statements
[0064]
[0065] Regarding the handling of laws and regulations, the following process is mainly adopted for the textual content of laws and regulations: First, according to established rules, the legal provisions are broken down one by one to construct a set of laws and regulations B = {(l i d i c i | i = 1, ..., n B}, where l i d i and c i Let n represent the name of the law or regulation corresponding to the i-th legal provision, its directory, and the content of the legal provision, respectively. B This represents the total size of the set, containing over one million currently valid laws and regulations. Then, based on the collected interpretations of the regulations, relational matching techniques are used to match the interpretations with the legal provisions. A new variable `e` is added to the set of laws and regulations to represent the interpretation of a legal provision: B = {(l...} i d i c i ,e i | i = 1, ..., n B Finally, using large language model technology, by setting key element prompts for laws and regulations (see Table 4), key elements such as legal scenarios and core constituent elements involved in the interpretation of regulations and the content of legal provisions are accurately extracted and denoted as k. The final set of laws and regulations is B = {(l i ,d i ,c i ,e i ,k i |i = 1, ..., n B}
[0066] Table 4: Key Element Hints
[0067]
[0068] Regarding case data processing, for the collected documents of over 2 million civil, criminal, and administrative cases, the following processing methods were mainly adopted: First, using existing document segmentation technology, the main components of the case were accurately extracted, including but not limited to the case name, the section on investigation, the section on the court's opinion, and the section on the judgment; next, using a large language model, and employing the case summary prompts as shown in Table 5, the factual details in the investigation section were summarized to extract the core plot of the case; finally, based on the extracted and summarized information, a structured case dataset was constructed, C={(y i f i , b i p i , z i | i = 1, ..., n C}, where y i f i , b i p i , z i These represent the cause of action, findings of investigation, the court's opinion, the judgment, and a summary of the case in the i-th case, respectively. C This indicates the total size of the set.
[0069] Table 5: Case Summary and Instructions
[0070]
[0071] Step S13: Knowledge vectorization.
[0072] To efficiently retrieve knowledge information matching specific user needs from the knowledge base, for the multiple knowledge sets constructed in step S12, the question content contained in set A, the key elements generated in set B, and the case summary in set C are converted into two forms of vector representation—sparse vectors and dense vectors—using a vector embedding model, and stored in sets A, B, and C respectively. These vectors can capture the semantic features and contextual relationships of legal knowledge, providing a foundation for subsequent information retrieval and self-reflection. Optionally, industry-leading embedding models such as bge-m3 and bce are used as the core algorithms for vectorization processing.
[0073] Step S14: Import the vector library.
[0074] By storing the text content and vectors from legal question-and-answer sets, legal regulations sets, and case data sets into a vector library, an external legal vector knowledge base can be constructed. Optionally, the vector library can be Milvus, Elasticsearch, etc.
[0075] Step S2: Based on a lightweight large model, construct a multi-dimensional knowledge screening and reflection tool in the legal field to achieve accurate screening of highly relevant legal knowledge and effective iterative generation of new search query statements.
[0076] (1) Training data is synthesized based on large language models.
[0077] 1. The relevance assessment criteria are defined based on three dimensions: legal analysis of similar cases, detailed explanation of laws and regulations, and determination of the similarity of the issue's purpose. In the dimension of legal analysis of similar cases, the focus is on whether the facts of the case, the points of contention, and the legal subjects are consistent, and whether the reasoning and legal basis of the case are useful. In the dimension of detailed explanation of laws and regulations, the validity of the provisions is analyzed based on the interpretation and content of the legal provisions. In the dimension of determining the similarity of the issue's purpose, the focus is on whether the legal relationships, legal subjects, legal acts, legal consequences, and the purpose of the issue are consistent in the statement of the issue.
[0078] 2. Based on the relevance assessment criteria, construct relevance assessment prompts, as shown in Table 6:
[0079] Table 6: Correlation Assessment Hints
[0080]
[0081]
[0082] 3. Assign numbers to user questions and retrieved cases, laws and regulations, and Q&A-type knowledge, and substitute them into the relevance assessment prompts. Using a large language model, output a list of highly relevant knowledge. Highly relevant knowledge is labeled "relevant"; otherwise, it is labeled "irrelevant," thus generating training data.
[0083] (2) Knowledge Filtering Model Training. For the dataset generated in the above steps, add the knowledge category to the beginning of each knowledge item. Use the bge-m3 embedding model to encode the user's question and knowledge separately, and then concatenate them as input. Input this into an LSTM model, and add a fully connected layer on top of the LSTM model to map the hidden states to two categories (i.e., relevant and irrelevant). Then, use the Sigmoid function to map the output to a range of 0-1, and set a threshold of 0.5 to determine which category the output belongs to.
[0084] (3) Construct a multidimensional knowledge reflector based on a lightweight large language model.
[0085] 1. The knowledge reflection and evaluation standard is defined based on three dimensions: legal analysis of similar cases, detailed explanation of laws and regulations, and determination of the same purpose of the question. In the dimension of legal analysis of similar cases, the focus is on whether the reasoning and legal basis in all provided cases are sufficient to resolve the user's question; in the dimension of detailed explanation of laws and regulations, the analysis is based on all legal interpretations and clause content to determine whether the clause is sufficient to support the answer to the user's question; in the dimension of determining the same purpose of the question, the focus is on whether the content of the answer summary is sufficient to answer the user's question.
[0086] 2. Based on the knowledge reflection and evaluation criteria, construct reflection and evaluation prompt instructions, as shown in Table 7. The output requirements are clearly defined in the reflection and evaluation prompt instructions: if the knowledge is sufficient, return "Terminate search"; otherwise, based on the reflection results, generate a search query statement for the corresponding dimension.
[0087] Table 7: Reflection and Evaluation Instructions
[0088]
[0089] 3. Based on a lightweight large language model, a multi-dimensional knowledge reflector is constructed using reflection and evaluation prompts.
[0090] Step S3: From a legal perspective, analyze the user's input question from multiple dimensions and granularities, and generate search queries that are easy to match with legal Q&A, laws and regulations, and case knowledge bases.
[0091] The generation of retrieval query statements includes the following three aspects:
[0092] (1) Matching the direction of the legal question and answer knowledge base. For single-turn dialogues, the user's original question q is directly used as the search query statement; for multi-turn dialogues, based on historical dialogues, a referential resolution strategy is adopted to rewrite the user's question q with pronouns to generate the rewritten question q′, which is used as the search query statement for legal questions.
[0093] (2) Matching legal and regulatory directions. Using the question-based legal key element prompts shown, and utilizing a large language model, the legal domain to which the question belongs is identified. The core legal facts, legal scenarios, legal subjects, and other key legal elements in the user's question are extracted and combined to form the search statement for the legal and regulatory knowledge base.
[0094] (3) Matching the case knowledge base direction. Using case summary prompts and leveraging a large language model, a case description consistent with the case summary template is generated as the retrieval query statement for the case knowledge base.
[0095] Finally, based on the knowledge characteristics of different knowledge bases, unique search query statements are generated for each, and a comprehensive query statement is constructed: Q = {q1, ..., q3}.
[0096] Step S4: Based on the retrieval query, retrieve the Top K knowledge items from each vector knowledge base to construct a candidate knowledge base.
[0097] (1) Input the retrieval query Q into the vector representation model to generate sparse and dense vectors, respectively, as follows: in Let represent the sparse vector and dense vector corresponding to the i-th query statement, respectively.
[0098] (2) Information retrieval system based on V Q A hybrid retrieval strategy is adopted to retrieve the Topk corresponding similar question-and-answer pairs, similar cases, relevant legal provisions, and relevant legal points from each legal knowledge base, denoted as Z = {Z1, ..., Z3}, where Z... i ={z i,1 ,…,z i,k}, Z i This represents the list of knowledge retrieved from the i-th knowledge base.
[0099] Step S5: Evaluate the candidate knowledge base.
[0100] Based on a multi-dimensional knowledge filter, highly relevant legal knowledge is selected and stored in a candidate knowledge base P (the knowledge in P will serve as the basis for generating the final legal opinion or answer). Subsequently, a reflector uses a reflective mechanism to evaluate whether the selected knowledge is sufficient to adequately answer the user's question, based on the selected knowledge and the user's specific question. If the evaluation result is insufficient, a new search query, Q, is automatically generated. new ={q 1,new ,…,q 3,new If the evaluation result is sufficient, the retrieval process terminates and proceeds to the next step S7.
[0101] Step S6: Search iteration and termination.
[0102] Based on the search statement generated in step S5, Q new ={q 1,new , ..., q 3,new Repeat steps S4 and S5 until the preset maximum number of reflections is reached (3).
[0103] S7: Candidate knowledge verification.
[0104] Based on the Reverse Fission Ranking (RRF) technique, the knowledge contained in the candidate knowledge base P is deduplicated and reordered. The specific steps are as follows:
[0105] (1) Deduplication is performed on the knowledge contained in the candidate knowledge base P to avoid duplicate knowledge being input into the large model;
[0106] (2) Select the knowledge content to be input into the large model for different types of knowledge. For example, for a list of legal question-and-answer knowledge, select the question description and answer summary as knowledge: "Question: t i Key Legal Points: g i "; For the list of legal provisions, select the content of the legal provisions as knowledge: "c i ".
[0107] (3) Using the Reverse Fission Ranking (RRF) method, calculate the similarity between each piece of knowledge selected in step S72 and the user's question, sort the selected knowledge, and finally generate an optimized knowledge list: Z′={z′1,…,z′ n}
[0108] (4) The optimized knowledge list Z′ is integrated according to categories to form structured knowledge content, which facilitates the generation of subsequent answers.
[0109] Step S8: Generate an answer.
[0110] Based on the finalized knowledge list K′, and using the prompts and heavyweight models shown in Table 8, answers to user questions are generated.
[0111] Table 8: Prompt Instructions for Generating Answers
[0112]
[0113]
[0114] It should be noted that the above descriptions are merely embodiments and accompanying drawings of the present invention, intended to provide a better understanding of the invention, and are not intended to limit the invention. Those skilled in the art will recognize that the present invention can be implemented in various ways. Various substitutions, variations, and modifications are possible without departing from the spirit and scope of the invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the preferred embodiments, and the scope of protection claimed by the present invention is determined by the scope defined in the claims.
Claims
1. A legal question-and-answer method based on a judge's perspective and a slow-thinking model, characterized in that... The method includes: Construct a multi-dimensional legal vector knowledge base; The system understands the user's question and generates several search queries. The search query is performed in the multi-dimensional legal vector knowledge base to obtain relevant legal knowledge about the user's question. The relevant legal knowledge is screened to construct a candidate knowledge base, and the legal knowledge in the candidate knowledge base is evaluated to determine whether it is sufficient to answer the user's question. If the legal knowledge in the candidate knowledge base is insufficient to fully answer the user's question, a new search query is generated based on the user's question and the deficiencies in the legal knowledge in the candidate knowledge base. Based on the new search query, the search for the search query in the multi-dimensional legal vector knowledge base is re-executed to obtain the relevant legal knowledge for the user's question. If the legal knowledge in the candidate knowledge base is sufficient to fully answer the user's question, then generate an answer to the user's question based on the legal knowledge in the candidate knowledge base; The construction of the multi-dimensional legal vector knowledge base includes: Collect raw data and clean it according to timeliness, accuracy, consistency and validity; The original materials include: legal Q&A pairs, laws and regulations, and case data; The cleaned raw data is then deeply analyzed and refined to form a legal Q&A dataset A = {(t i , a i g i s i | i = 1, ..., n A }、 Set of laws and regulations B={(l i d i c i e i k i | i = 1, ..., n B } and case dataset C = {(y i f i b i , p i , z i | i = 1, ..., n C }; where t i Let a represent the question content corresponding to the i-th legal question and answer data. i Let g represent the answer corresponding to the i-th legal question and answer data. i s represents the summary of answers corresponding to the i-th legal question and answer data. i Indicates the data source corresponding to the i-th legal question and answer data, n A Let l represent the data size of the legal question and answer dataset A. i d represents the name of the law or regulation corresponding to the i-th legal provision. i c represents the directory corresponding to the i-th legal provision. i e represents the content of the legal provision corresponding to the i-th legal provision. i This represents the interpretation of the i-th legal provision, k. i This represents the key element corresponding to the i-th legal provision, n. B y represents the data size of the legal and regulatory set B. i f represents the cause of action for the i-th case. i b represents the findings of the trial of the i-th case data. i This court believes that p represents the data of the i-th case. i The judgment for the i-th case data is as follows, z i This represents the case summary of the i-th case data, n C Indicates the data size of the case dataset C, and the answer summary g i The generation is based on a large language model for answer a i Analysis and answer a i Extraction of the names, entries, and content summaries of Chinese laws and regulations, including the key element k. i The generation is based on a large language model of the legal provisions. i With legal interpretation e i The legal context and core elements involved, and the case summary. i The generation is based on a large language model to investigate and determine f. i The summarization and conclusion of the facts in China; Generate question content t i Key element k i Case summary i The sparse and dense vectors are generated and stored in the legal question and answer data set A, the legal regulations set B, and the case data set C, respectively. Then, they are imported into the corresponding legal question and answer vector knowledge base, legal regulations vector knowledge base, and case data vector knowledge base. The assessment of whether the legal knowledge in the candidate knowledge base is sufficient to adequately answer the user's question includes: Based on the legal analysis of similar cases, the detailed explanation of laws and regulations, and the determination of the same purpose of the issues, a knowledge reflection assessment standard is defined. Based on the knowledge reflection and evaluation criteria, legal knowledge from the candidate knowledge base is embedded into reflection and evaluation prompts, and a large model is used to evaluate whether the legal knowledge in the candidate knowledge base is sufficient to answer the user's question. The information in the reflection and evaluation prompts includes: similar case knowledge, legal knowledge, legal Q&A knowledge, user questions, and reflection and evaluation prompt corpus.
2. The method according to claim 1, characterized in that, The process of understanding user questions and generating several search query statements includes: When searching the legal question-and-answer vector knowledge base, if it is a single-turn dialogue, the user's question is used as the search query for the legal question-and-answer vector knowledge base; if it is a multi-turn dialogue, the user's question is rewritten based on the historical dialogue and a referential resolution strategy is used, and the rewritten question is used as the search query for the legal question-and-answer vector knowledge base. When searching the legal and regulatory vector knowledge base, a question-based legal key element prompt instruction is adopted. Using a large language model, the legal field to which the question belongs is clarified, and the core legal facts, legal scenarios, legal subjects and other key legal elements in the user's question are extracted. These key legal elements are then concatenated as the search statement for the legal and regulatory knowledge base. When searching the case data vector knowledge base, based on the prompt corpus of user questions and case summaries, a case summary prompt instruction is generated. After generating the case summary corresponding to the user question using a large language model, the case summary corresponding to the user question is used as the search query statement for the case data vector knowledge base.
3. The method according to claim 1, characterized in that, The relevant legal knowledge was filtered, including: Based on the legal analysis of similar cases, the detailed explanation of laws and regulations, and the determination of the same purpose of the issues, a relevance assessment standard is defined. Based on relevance assessment criteria, a relevance assessment prompt instruction is constructed; wherein, the relevance assessment prompt instruction requires the output of a highly relevant knowledge list, and the information in the relevance assessment prompt instruction includes: similar case knowledge, legal and regulatory knowledge, legal Q&A knowledge, user questions, and relevance assessment prompt corpus; For user question samples and knowledge blocks recalled based on those user question samples, a highly relevant knowledge list is output using a large language model and relevance assessment prompts. A knowledge filtering model is trained based on the highly relevant knowledge list; The trained knowledge screening model is used to screen the relevant legal knowledge.
4. The method according to claim 1, characterized in that, The process of generating an answer to the user's question based on legal knowledge from the candidate knowledge base includes: Based on the inverse fusion sorting algorithm, the legal knowledge in the candidate knowledge base is deduplicated and reordered to generate the final knowledge list; The user's question and the final knowledge list are embedded into the instructions to generate an answer, and a large model is used to generate a natural language answer to the user's question.
5. The method according to claim 4, characterized in that, The method, based on the inverse fusion sorting algorithm, deduplicates and reorders the legal knowledge in the candidate knowledge base to generate a final knowledge list, including: Deduplication of legal knowledge in the candidate knowledge base; Select the knowledge content to be input into the large model based on different types of knowledge; Using the inverse fusion sorting method, the similarity between the selected knowledge content to be input into the large model and the user's question is calculated, and the deduplicated legal knowledge is sorted based on the similarity to obtain the final knowledge list; wherein, the legal knowledge in the final knowledge list is integrated according to type.
6. A legal question-and-answer device based on a judge's perspective and a slow-thinking mode, characterized in that, The device includes: The knowledge base construction module is used to build a multi-dimensional legal vector knowledge base. The statement generation module is used to understand user questions and generate several search query statements; A knowledge retrieval model is used to retrieve the search query statement in the multi-dimensional legal vector knowledge base to obtain relevant legal knowledge about the user's question. The knowledge assessment module is used to filter the relevant legal knowledge to build a candidate knowledge base and assess whether the legal knowledge in the candidate knowledge base is sufficient to answer the user's question. The answer generation module is used to generate a new search query statement based on the deficiencies in the legal knowledge in the candidate knowledge base when the legal knowledge in the candidate knowledge base is insufficient to fully answer the user's question. Based on the new search query statement, the module re-executes the search of the query statement in the multi-dimensional legal vector knowledge base to obtain relevant legal knowledge about the user's question. When the legal knowledge in the candidate knowledge base is sufficient to fully answer the user's question, the module generates an answer to the user's question based on the legal knowledge in the candidate knowledge base. The construction of the multi-dimensional legal vector knowledge base includes: Collect raw data and clean it according to timeliness, accuracy, consistency and validity; The original materials include: legal Q&A pairs, laws and regulations, and case data; The cleaned raw data is then deeply analyzed and refined to form a legal Q&A dataset A = {(t i , a i g i s i | i = 1, ..., n A }、 Set of laws and regulations B={(l i d i c i e i k i | i = 1, ..., n B } and case dataset C = {(y i f i b i , p i , z i | i = 1, ..., n C }; where t i Let a represent the question content corresponding to the i-th legal question and answer data. i Let g represent the answer corresponding to the i-th legal question and answer data. i s represents the summary of answers corresponding to the i-th legal question and answer data. i Indicates the data source corresponding to the i-th legal question and answer data, n A Let l represent the data size of the legal question and answer dataset A. i d represents the name of the law or regulation corresponding to the i-th legal provision. i c represents the directory corresponding to the i-th legal provision. i e represents the content of the legal provision corresponding to the i-th legal provision. i This represents the interpretation of the i-th legal provision, k. i This represents the key element corresponding to the i-th legal provision, n. B y represents the data size of the legal and regulatory set B. i f represents the cause of action for the i-th case. i b represents the findings of the trial of the i-th case data. i This court believes that p represents the data of the i-th case. i The judgment for the i-th case data is as follows, z i This represents the case summary of the i-th case data, n C Indicates the data size of the case dataset C, and the answer summary g i The generation is based on a large language model for answer a i Analysis and answer a i Extraction of the names, entries, and content summaries of Chinese laws and regulations, including the key element k. i The generation is based on a large language model of the legal provisions. i With legal interpretation e i The legal context and core elements involved, and the case summary. i The generation is based on a large language model to investigate and determine f. i The summarization and conclusion of the facts in China; Generate question content t i Key element k i Case summary i The sparse and dense vectors are generated and stored in the legal question and answer data set A, the legal regulations set B, and the case data set C, respectively. Then, they are imported into the corresponding legal question and answer vector knowledge base, legal regulations vector knowledge base, and case data vector knowledge base. The assessment of whether the legal knowledge in the candidate knowledge base is sufficient to adequately answer the user's question includes: Based on the legal analysis of similar cases, the detailed explanation of laws and regulations, and the determination of the same purpose of the issues, a knowledge reflection assessment standard is defined. Based on the knowledge reflection and evaluation criteria, legal knowledge from the candidate knowledge base is embedded into reflection and evaluation prompts, and a large model is used to evaluate whether the legal knowledge in the candidate knowledge base is sufficient to answer the user's question. The information in the reflection and evaluation prompts includes: similar case knowledge, legal knowledge, legal Q&A knowledge, user questions, and reflection and evaluation prompt corpus.
7. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the legal question-and-answer method based on the judge's perspective and slow thinking mode as described in any one of claims 1-5.
Citation Information
Patent Citations
Intelligent legal question and answer method based on retrieval enhanced language model
CN118277538A