Law intelligent question and answer method and system based on multi-agent dynamic role scheduling and hybrid retrieval, electronic device and storage medium

By employing a multi-agent dynamic role scheduling and hybrid retrieval method, this approach solves the problem of disjointed structured question decomposition and professional generation in complex legal intelligent question-answering systems, thereby achieving efficient and professional legal consultation responses.

CN121524312BActive Publication Date: 2026-04-17CENT SOUTH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CENT SOUTH UNIV
Filing Date
2026-01-14
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing legal intelligent question-answering systems suffer from problems such as incomplete structured question decomposition, insufficient in-depth factual evidence, and inconsistent professional generation when handling complex legal inquiries, making it difficult to meet high standards of logical rigor and factual accuracy.

Method used

A multi-agent dynamic role scheduling and hybrid retrieval method is adopted. The consultation request is decomposed into a structured task chain through a decomposition reasoning cognitive framework, and a hybrid retrieval is carried out using a dynamic weight allocation mechanism. Combined with a multi-agent collaborative generation architecture, the adapter is dynamically selected to generate a response.

Benefits of technology

It enables scenario-based adaptation of legal services, improves the professional relevance, lowers the deployment threshold of multi-agent systems, ensures efficient evidence acquisition and generation, and eliminates the problems of outdated knowledge and logical gaps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121524312B_ABST
    Figure CN121524312B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of artificial intelligence and law, and specifically provides a legal intelligent question and answer method and system based on multi-agent dynamic role scheduling and mixed retrieval, an electronic device and a storage medium, the method comprising: generating a structured task chain of a plurality of to-be-retrieved sub-tasks; generating a structured evidence set; constructing a multi-intelligent collaborative generation architecture; and generating a legal consultation reply based on the structured evidence set by using the multi-intelligent collaborative generation architecture. The application innovatively introduces role adapter scheduling logic, and the system can analyze whether the user request is "right protection operation", "judgment prediction" or "theoretical learning" like a "law firm partner", and then dynamically activate the corresponding target adapter. This dynamic scheduling mechanism gives the system the ability to adapt to different legal scenarios, ensuring that each answer is executed by the most suitable "expert role", significantly improving the professional degree of service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of interdisciplinary technology of artificial intelligence and law, and relates to a legal intelligent question answering method, system, electronic device and storage medium based on multi-agent dynamic role scheduling and hybrid retrieval. Background Technology

[0002] With the rapid development of large-scale language model technology, it has shown great potential in knowledge-intensive and logic-demanding professional fields such as law, and is regarded as a transformative tool for solving complex legal tasks (such as legal document drafting, case opinion generation, and judicial judgment prediction).

[0003] With the rapid modernization of the legal system and the increasing public demand for legal services, the development of scalable and reliable automated legal technologies has become an urgent need. However, when existing technologies are directly applied to complex Chinese legal consultation scenarios, their inherent technical shortcomings become apparent, including:

[0004] First, the lack of structured reasoning ability means that the model cannot reliably reproduce the multi-step logical analysis process required by legal experts (such as fact identification, rule application, and conclusion formation), and tends to give jumpy conclusions directly.

[0005] Second, there are knowledge limitations. On the one hand, the model suffers from the problem of internal "model illusion" due to the limitations of its parameterized memory, which may generate or cite completely fabricated or incorrect legal provisions. On the other hand, the model suffers from the problem of external "knowledge obsolescence" because its knowledge is solidified after pre-training, and it cannot keep up with newly promulgated laws or judicial interpretations.

[0006] Third, the model lacks domain expertise and fails to grasp the unique terminology, document paradigms, and argumentation structures within the Chinese legal discourse system. Consequently, the responses it generates often sound colloquial and may even provide incorrect legal advice.

[0007] To address these issues, various legal-specific models have emerged, such as LAWGPT, LawyerLLAMA, DISC-LawLLM, and ChatLaw. However, these generally offer fragmented solutions and fail to address the root causes systematically. Specifically, some models that focus on knowledge injection through supervised fine-tuning (SFT) (such as DISC-LawLLM), while possessing domain knowledge to some extent, may still produce logically inconsistent or contradictory outputs without a robust and controllable structured reasoning mechanism. Other models that explore complex workflows or embed legal argumentation paradigms (such as legal syllogisms), if their core remains reliant on general models, may lack deep and fine-grained domain knowledge, thus failing to arrive at truly reliable legal conclusions. Although almost all of these models integrate Retrieval Augmentation (RAG) to provide factual evidence, for legal issues requiring multi-step, complex logical reasoning, a single RAG process is often insufficient to support a complete chain of arguments.

[0008] In summary, the core technical problem in the current field lies in the fragmented nature of existing solutions. Specifically, when handling legal consultations, key aspects such as structured problem decomposition, in-depth fact-finding, and professional generation are often disconnected and optimized independently. This fails to form a complete and coherent processing flow, from receiving the user's initial consultation, to the logical reasoning and evidence retrieval in the intermediate stages, and finally to generating a professional-level response. This break in the process directly makes it difficult for existing solutions to systematically meet the multiple high standards of logical rigor, factual accuracy, and domain expertise required in legal consultation tasks. Summary of the Invention

[0009] To address the shortcomings of existing technologies, this invention aims to provide a legal intelligent question-answering method, system, electronic device, and storage medium based on multi-agent dynamic role scheduling and hybrid retrieval, so as to ensure a comprehensive and orderly analysis of the questions.

[0010] This invention provides a legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval, comprising the following steps:

[0011] Step S1: Input the user's original legal consultation request into the decomposition reasoning cognitive framework. The decomposition reasoning cognitive framework parses and maps the unstructured natural language text in the original legal consultation request into a structured task chain containing multiple sub-tasks to be retrieved.

[0012] Step S2: For the structured task chain, perform a search on each subtask to be searched, and generate search keywords and search vectors;

[0013] The query feature word weights for each subtask to be retrieved are calculated using a dynamic weight allocation mechanism based on query specificity quantification.

[0014] The ratio of lexical retrieval to semantic retrieval is dynamically adjusted according to weights, and evidence data is obtained in parallel from the legal knowledge base to generate a structured evidence set.

[0015] Step S3: Construct a multi-intelligent collaborative generation architecture;

[0016] A multi-intelligent collaborative generation architecture is adopted to perform in-depth feature analysis on the structured evidence set and the original legal consultation request, obtain the type features of the original legal consultation request, and dynamically select the target role adapter that matches the type features from multiple role model adapters of the multi-intelligent collaborative generation architecture.

[0017] The general parameters of the basic large language and large model are merged and loaded with the special parameters of the target role adapter, and legal consultation responses are generated based on the structured evidence set.

[0018] Furthermore, the specific process of obtaining the structured task chain of multiple subtasks to be retrieved in step S1 is as follows:

[0019] S1.1 Perform feature evaluation on the original legal consultation request to obtain the task type of the original legal consultation request; the task type includes direct retrieval tasks or composite analysis tasks; the direct retrieval tasks refer to single knowledge point queries with clear objectives and no need for multi-step reasoning; the composite analysis tasks refer to complex scenario descriptions involving multiple legal relationships, requiring long-chain causal deduction, or involving conflicts in the application of law.

[0020] S1.2 If it is marked as a direct retrieval task, it will be directly passed to step S2 for regular retrieval;

[0021] If a task is marked as a composite analysis task, it is input into the decomposition reasoning cognitive framework. The decomposition reasoning cognitive framework performs in-depth decomposition of the composite analysis task based on the structured task chain mapping logic, and obtains semantic category labels containing five consecutive analysis stages: definition, fact, law, reasoning and action, and generates corresponding sub-tasks to be retrieved.

[0022] Furthermore, the specific methods for characterizing the original legal consultation request are as follows:

[0023] By employing prompt word engineering techniques, a single large language model is configured as an evaluation and processing unit by loading a pre-set system instruction set;

[0024] The evaluation and processing unit uses preset logical judgment rules to perform feature matching on the unstructured natural language text in the original legal consultation request in order to determine the task type.

[0025] Furthermore, the logical decision-making rules include the following computer execution criteria:

[0026] ① Structured identifier detection;

[0027] The system checks whether the text contains standard legal and regulatory citation formats; if so, it tends to classify it as a direct search category.

[0028] ② Define query template detection;

[0029] The system detects whether the text contains explicit conceptual query sentences; if so, it tends to classify it as a direct retrieval type.

[0030] ③ Detection of decision-making intentions and narratives;

[0031] The text is examined to determine whether it contains decision-making words seeking strategic advice, words judging legality, or whether it is a narrative description containing specific case details; if so, it is likely to be classified as a composite analysis type.

[0032] Furthermore, the specific process of generating search keywords and search vectors in step S2 is as follows:

[0033] A single sub-problem to be retrieved As input, it is fed into the independent lexical and semantic search engines in the dynamically weighted hybrid search enhancement generation system;

[0034] The lexical search engine and the semantic search engine concurrently execute their respective search algorithms in the legal knowledge base for the received sub-questions to be searched, and obtain search keywords and search vectors.

[0035] Furthermore, the specific method for obtaining search keywords is as follows:

[0036] Using the Chinese word segmentation tool Jieba and loading a legal-specific dictionary, we performed precise word segmentation on the sub-questions to be retrieved and on every piece of text data in the knowledge base.

[0037] Calculate the subproblem to be retrieved With text data The relevance score, and based on the sub-question to be retrieved. With text data correlation score For text data The search keywords are then filtered to obtain the search terms.

[0038] Furthermore, the specific method for obtaining the retrieval vector is as follows:

[0039] Using a pre-trained language model as the embedding layer, the sub-question to be retrieved is... Transform into a vector of subproblems Text data Convert to text vector ;

[0040] Compute subproblem vectors and text vector cosine similarity ;

[0041] Based on cosine similarity To evaluate the subproblem vector and text vector The relevance is used to obtain the retrieval vector.

[0042] Furthermore, the specific process for calculating the query feature word weights for each subtask to be retrieved is as follows:

[0043] By utilizing the term frequency-inverse text data frequency idea in the dynamic weight allocation mechanism of query specificity quantification, the term frequency and inverse text data frequency of each term in the query feature words of each subtask to be retrieved are quantified;

[0044] Normalize the word frequencies to obtain the normalized word frequencies. ;

[0045] Normalization based on word frequency Calculate the sub-problem to be retrieved based on the frequency of inverse text data. Feature word weights .

[0046] Furthermore, the specific process of dynamically adjusting the ratio of lexical retrieval to semantic retrieval based on weights in step S2 is as follows:

[0047] A variant of the Sigmoid function is used as the weight mapping function to construct a continuous weight mapping function;

[0048] The feature word weights are mapped to values ​​within the interval [0,1], based on the feature word weights. The changes automatically adjust the weights assigned to the lexical search engine. and semantic search engine weight allocation .

[0049] Furthermore, the specific method for generating the structured evidence set in step S2 is as follows:

[0050] A weighted inverse sorting fusion algorithm is used to calculate any text data. Fusion score ;

[0051] Fusion score The expression is as follows:

[0052] ;

[0053] in, For any text data Rank in the lexical sorting list; For any text data Rank in the semantically ordered list; It is a smoothing constant, which reduces the excessive influence of highly ranked text data on the total score and enhances the robustness of the fusion result;

[0054] The hybrid retrieval-enhanced generation system processes all retrieved text data from the legal knowledge base. Calculate their fusion scores, sort them in descending order of scores, and finally output the top score. The most relevant text data are used as each sub-question to be retrieved. Evidence-based materials; among which, parameters The selection of values ​​follows the principle of evidence integrity, and the range of values ​​is set to... ;

[0055] The dynamically weighted hybrid retrieval enhancement generation system categorizes and stores the acquired evidence-based materials according to sub-task labels, and calls the underlying large language model to process each sub-question to be retrieved. Generate preliminary analytical responses;

[0056] All the analytical responses were integrated to form a complete set of structured evidence.

[0057] Furthermore, the multi-intelligent collaborative generation architecture includes a role adapter storage area and a scheduling unit;

[0058] The role adapter storage area is the foundation of the multi-intelligent collaborative generation architecture, and it stores a general intelligent agent adapter and multiple role intelligent agent adapters.

[0059] The scheduling unit is the control core of the multi-intelligent collaborative generation architecture. The structured evidence set and the user's original legal consultation request are input into the scheduling unit. The scheduling unit performs deep feature analysis and dynamically selects an optimal target adapter from the role adapter storage area to perform the final parameter merging reasoning task by comprehensively evaluating the type characteristics of the original legal consultation request.

[0060] Furthermore, the role adapter storage area includes multiple role adapters, and each role adapter includes multiple specialized role adapters. Each specialized role adapter acquires its unique capabilities through specialized fine-tuning on a specific, high-quality legal corpus.

[0061] Among them, several patented role adapters include:

[0062] General-purpose intelligent agent adapter: serving as the foundation of the system, used to handle broad legal knowledge questions and answers that do not require a specific professional perspective;

[0063] Lawyer Intelligent Agent Adapter: Fine-tuned on real-world legal consultation question-and-answer datasets to learn to provide client-centric, practical, and actionable strategy recommendations;

[0064] Judge Agent Adapter: Fine-tuned on a real judicial judgment document dataset to learn to perform rigorous and neutral logical analysis, with a language style close to that of court judgments;

[0065] Expert Agent Adapter: Fine-tuned on a dataset of authoritative legal journal articles to learn in-depth legal analysis and theoretical interpretation, with a more academic and objective perspective.

[0066] The present invention also provides an electronic device, including a memory and a processor;

[0067] The memory is used to store computer programs that can run on the processor;

[0068] When the processor executes the computer program, it implements the steps of the legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described above.

[0069] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the legal intelligent question-answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described above.

[0070] Compared with the prior art, the present invention has the following beneficial effects:

[0071] (1) A dynamic role scheduling mechanism based on intent recognition was constructed to realize the scenario-based adaptation of legal services;

[0072] Existing technologies typically use a single model to handle all inquiries, lacking flexibility. This invention innovatively introduces role adapter scheduling logic, allowing the system to act like a "law firm partner," first analyzing whether the user's request requires "practical rights protection," "judgment prediction," or "theoretical learning," and then dynamically activating the corresponding target adapter. This dynamic scheduling mechanism endows the system with adaptability to different legal scenarios, ensuring that each response is executed by the most suitable "expert role," significantly improving the professional relevance of the service.

[0073] (2) Low-cost, high-concurrency multi-agent system construction was achieved by utilizing parameter decoupling technology;

[0074] Building multi-agent systems typically faces significant challenges in terms of GPU memory and computing power. This invention employs QLoRA low-rank fine-tuning technology to encapsulate the professional capabilities of different roles, such as lawyers, judges, and experts, into independent lightweight adapter files. This parameter-level decoupling design eliminates the need for the system to load multiple full-scale models simultaneously; role switching can be achieved simply by dynamically merging a small number of parameters during inference. This not only significantly lowers the deployment threshold for multi-agent systems but also ensures high system efficiency in high-concurrency scenarios.

[0075] (3) Collaborative division of labor and logical control among intelligent agents are realized through structured task chains;

[0076] This invention analyzes complex legal issues into a structured task chain, essentially constructing an intelligent agent collaboration protocol. By breaking down tasks into standardized nodes such as "definition," "facts," and "reasoning," the system can guide different functional processing units (such as retrieval units and reasoning units) to collaborate sequentially. This design transforms abstract legal thinking into a workflow that can be strictly executed by a computer, effectively solving the common problems of task goal drift and logical discontinuity in multi-agent collaboration.

[0077] (4) It endows the agent with dual-channel hybrid retrieval capabilities, thereby improving the recall and precision of evidence acquisition;

[0078] To provide accurate basis for the agent's decision-making, this invention designs a dual-channel retrieval module with dynamic weights as the core tool of the agent. The system can automatically determine whether to call the "precise legal provision search" or "fuzzy case information search" capability based on the feature word weights of the subtask. This mechanism is equivalent to giving the agent the ability to adaptively adjust, ensuring that it can obtain high-quality structured evidence support when processing different types of legal information.

[0079] (5) A strong constraint generation mechanism based on evidence set was established, eliminating the risk of the agent "playing freely";

[0080] To address the common problem of large-scale intelligent agents being prone to "illusions," this invention introduces structured evidence set constraints during the generation phase. The system mandates that when generating responses, the agent's parameter reasoning process must be strictly anchored to the retrieved real-time evidence. This mechanism adds a "safety lock" to the multi-agent system, preserving the agent's reasoning ability while fundamentally eliminating the risk of fabricating legal provisions out of thin air, thus solving the problem of outdated knowledge.

[0081] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the figures. Attached Figure Description

[0082] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:

[0083] Figure 1 This is a flowchart illustrating a legal intelligent question-answering method based on multi-agent dynamic role scheduling and hybrid retrieval in an embodiment of the present invention;

[0084] Figure 2 This is a schematic diagram of the operation flow of a legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval in an embodiment of the present invention;

[0085] Figure 3 yes Figure 2 A flowchart illustrating the process of a dynamically weighted hybrid retrieval enhancement generation system. Detailed Implementation

[0086] To make the above-mentioned objectives, features, and advantages of the present invention clearer and easier to understand, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the accompanying drawings of the present invention are all in a simplified form and use non-precise proportions, and are only used to facilitate and clearly assist in illustrating the implementation of the present invention; the "several" mentioned in the present invention are not limited to the specific number shown in the examples in the accompanying drawings; the orientations or positional relationships indicated by terms such as "front," "middle," "rear," "left," "right," "up," "down," "top," "bottom," and "center" mentioned in the present invention are all based on the orientations or positional relationships shown in the accompanying drawings of the present invention, and do not indicate or imply that the device or component referred to must have a specific orientation, nor should they be construed as limitations on the present invention.

[0087] Example 1:

[0088] See Figures 1 to 3 As shown, the legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval provided by the present invention includes the following steps:

[0089] Step 1: Input the user's original legal consultation request into the Decomposition-Reasoning Cognitive Framework (DRCF). The DRCF parses and maps the unstructured natural language text in the original legal consultation request into a structured task chain containing multiple sub-tasks to be retrieved.

[0090] Preferably, the specific process for obtaining a structured task chain of multiple subtasks to be retrieved is as follows:

[0091] S1.1. Perform feature evaluation on the original legal consultation request to determine whether the original legal consultation request is a direct retrieval task or a complex analysis task; the direct retrieval task refers to a single knowledge point query with a clear objective and no need for multi-step reasoning; the complex analysis task refers to a complex scenario description involving multiple legal relationships, requiring long-chain causal deduction, or involving conflicts in the application of law.

[0092] S1.2 If it is marked as a direct retrieval task, it will be directly passed to step S2 for regular retrieval;

[0093] If a task is marked as a composite analysis task, it is input into the decomposition reasoning cognitive framework. The decomposition reasoning cognitive framework performs in-depth decomposition of the composite analysis task based on the structured task chain mapping logic, and obtains semantic category labels containing five consecutive analysis stages: definition, fact, law, reasoning and action, and generates corresponding sub-tasks to be retrieved.

[0094] The five consecutive analysis phases refer to:

[0095] ① Definition: Eliminate semantic ambiguity in queries and establish an unambiguous conceptual foundation for subsequent analysis;

[0096] ② Facts: Accurately extract and structure the core factual elements of the case from user narratives;

[0097] ③ Law: Accurately mapping the identified factual elements to specific legal norms;

[0098] ④ Reasoning: By raising core analytical questions, a logical bridge is built from facts to conclusions;

[0099] ⑤ Action: Transform abstract legal analysis into concrete, actionable strategy recommendations for users.

[0100] This invention ensures the structural integrity of the data and the automation and robustness of subsequent processes by strictly controlling the output of the decomposition processing unit to a standardized JSON object representation (JavaScriptObjectNotation, JavaScript object representation), which serves as the digital carrier of the structured task chain.

[0101] A further preferred method for characterizing the original legal consultation request is as follows:

[0102] Prompt engineering is employed to configure a single large language model as an evaluation processing unit by loading a pre-set system instruction set. The pre-set system instruction set rules include logical decision rule definitions, few-shot guidance, and output format constraints, wherein:

[0103] ① Definition of logical judgment rules;

[0104] A set of pre-defined logical judgment criteria is used to perform feature matching and initial type screening of the input text;

[0105] ② Small sample size guidance;

[0106] By providing several sets of pre-set "legal task consultation type" comparison examples, which include input-output pairs of "original consultation request" and "type determination result", the model is guided to identify by analogy whether the task belongs to the direct retrieval type or the composite analysis type, thereby achieving accurate classification of task type.

[0107] ③ Output format constraints;

[0108] The model is explicitly required to output the judgment results in a reconstructed data format (JSON) to ensure automated processing in subsequent steps.

[0109] This assessment and processing unit does not rely on subjective judgment, but rather performs feature matching on the unstructured natural language text in the original legal consultation request based on a pre-set system instruction set to determine the task type; specifically, the logical determination rules include the following computer execution standards:

[0110] ① Structured identifier detection;

[0111] The system checks whether the text contains standard legal and regulatory citation formats (such as "Article 1077 of the Civil Code"); if it does, it is likely to be classified as a direct search category.

[0112] ② Define query template detection;

[0113] The system checks whether the text contains explicit conceptual queries (such as "What is apparent proxy"); if it does, it tends to be classified as a direct retrieval type.

[0114] ③ Detection of decision-making intentions and narratives;

[0115] The text is examined to determine whether it contains decision-making words seeking strategic advice (such as "What should I do?"), legality judgment words (such as "Is this legal?"), or whether it is a narrative description containing specific case details (time, place, people); if so, it is likely to be classified as a composite analysis type.

[0116] Further preferred, see Table 1 for a decomposition example of the structured task chain mapping logic applied to the "labor contract dispute" scenario. The user's original legal question is, "The company said it's not doing well and fired me. Is this legal? What should I do?" Because this question matches the "decision intent and narrative detection" rule (containing "whether it's legal," "what to do," and the company's dismissal narrative), the system classifies it as a composite analysis task and decomposes it as follows:

[0117] Table 1: Detailed Examples of Application in the "Labor Contract Dispute" Scenario

[0118]

[0119] Step 2: For the structured task chain, perform a search on each subtask to be searched, and generate search keywords and search vectors;

[0120] Calculate the feature word weights for each subtask to be retrieved based on the search keywords and search vectors;

[0121] The ratio of lexical retrieval to semantic retrieval is dynamically adjusted based on weights, and evidence data is obtained in parallel from the legal knowledge base to generate a structured evidence set.

[0122] Preferably, in this embodiment, a dual-channel retrieval module is used to retrieve each subtask to be retrieved, generating retrieval keywords and retrieval vectors.

[0123] Preferably, before searching each subtask to be searched, to achieve complementary advantages, a dual-channel search strategy in the dynamically weighted hybrid search enhancement generation system is used for parallel execution to construct a comprehensive candidate set; the specific process is as follows:

[0124] The same sub-problem to be searched As input, it is simultaneously fed into the independent lexical and semantic search engines in the dynamically weighted hybrid search enhancement generation system;

[0125] The lexical search engine and the semantic search engine concurrently execute their respective search algorithms on the received sub-questions to be searched within the legal knowledge base. After the search is completed, search keywords and search vectors are obtained. Specifically, the lexical search engine obtains search keywords after the search, and the semantic search engine obtains search vectors after the search. The search keywords and search vectors together constitute a comprehensive candidate set for the next stage of fusion and ranking, ensuring that subsequent processing can utilize both precise keyword matching information and deep semantic association information.

[0126] The aforementioned legal knowledge base refers to a database composed of a series of authoritative legal texts (including currently effective laws, administrative regulations, and judicial interpretations obtained from official channels). More preferably, to facilitate subsequent accurate retrieval and processing, the legal texts are standardized preprocessed text data; specifically, the original legal texts are systematically segmented into independent text data units based on individual legal provisions. This knowledge base provides a unified and reliable data source for lexical and semantic retrieval.

[0127] The lexical retriever is responsible for precise retrieval based on keyword matching. Its core technology is the Okapi BM25 algorithm, a more advanced probabilistic ranking model than the traditional TF-IDF model. The superiority of BM25 lies in the introduction of two key concepts: Term Frequency Saturation and Document Length Normalization. The former addresses the score bias problem caused by linear growth in term frequency, while the latter provides a fairer comparison benchmark between text data of different lengths.

[0128] The semantic retrieval system aims to achieve recall based on deep semantic understanding. Its technical principle is the Vector Space Model, which maps unstructured text to a high-dimensional, continuous semantic vector space. In this space, semantic similarity is quantified as the spatial distance between vectors.

[0129] A further preferred method is to obtain the search keywords based on a lexical search engine as follows:

[0130] Before applying a lexical search engine, the Chinese word segmentation tool Jieba (a high-efficiency Chinese word segmentation library in Python) is used, along with a legal-specific dictionary, to accurately segment the sub-question to be searched and each piece of text data in the knowledge base. Then, the sub-question to be searched is calculated. With text data The relevance score, and based on the sub-question to be retrieved. With text data correlation score For text data The search keywords are then filtered to obtain the search terms.

[0131] Subproblem to be retrieved With text data correlation score The expression is as follows:

[0132] ;

[0133] ;

[0134] in, Sub-problem to be retrieved The total number of keywords contained therein; This is a traversal index for keywords, representing the formula's application to the first to the last keyword in the query. Sum the keywords; Used to measure query terms The importance of; For word frequency; These are parameters used to adjust word frequency saturation. The value is 0.75; For adjusting text data length Relative to the average text data length Normalization parameter, The value is 0.75.

[0135] This invention optimizes the lexical search engine to provide extremely high search accuracy for queries containing specific terms such as explicit legal entities and legal provision numbers.

[0136] A further preferred method is to obtain the retrieval vector based on the semantic retrieval tool as follows:

[0137] Using a pre-trained language model as the embedding layer, the sub-question to be retrieved is... Transform into a vector of subproblems Text data Convert to text vector ;

[0138] Compute subproblem vectors and text vector cosine similarity ;

[0139] Based on cosine similarity (CosineSimilarity) is used to evaluate the subproblem vector. and text vector The relevance is used to obtain the retrieval vector.

[0140] Cosine similarity The expression is as follows:

[0141] ;

[0142] in, Let be the dimension of the vector; when The closer the value is to 1, the more semantically relevant it is.

[0143] As a further embodiment of the present invention, to efficiently perform the aforementioned similarity search in a large-scale legal knowledge base, the semantic retrieval engine uses the FAISS (Facebook AI Similarity Search) vector retrieval engine to construct the index. This index structure supports Approximate Nearest Neighbor (ANN) search, which can reduce the search time from linear complexity to logarithmic level while sacrificing minimal precision, thereby meeting the needs of real-time retrieval. Furthermore, considering the characteristics of legal texts, the retrieval engine also employs a conditional chunking strategy to process long text data, ensuring text processability while preserving the semantic integrity of short texts such as individual legal provisions to the greatest extent possible.

[0144] As a further solution in this embodiment, in order to address the differences in retrieval strategy preferences among different types of queries, this invention also proposes a dynamic weight allocation mechanism based on query specificity quantification to calculate the feature word weights of each subtask to be retrieved.

[0145] Specifically, the core of the dynamic weight allocation mechanism based on query specificity quantification is to calculate a query specificity score. Its principle is to utilize the Term Frequency-Inverse Document Frequency (TF-IDF) concept to quantify the term frequency and inverse document frequency of each term in the query feature words of each subtask to be retrieved; then, the subtask to be retrieved is calculated. Feature word weights .

[0146] Term frequency (TF) represents the frequency of words. In text data The frequency of occurrence in the text; to avoid bias in long text data, word frequencies are usually normalized;

[0147] Normalization of word frequency The expression is as follows:

[0148] ;

[0149] in: Represented as a word In the query The number of times it appears in This represents the total number of occurrences of all words in the query.

[0150] Inverse Document Frequency (IDF) is used to measure the frequency of a word. The universal importance; a word In more text data If it appears in the text, it indicates that the frequency value of its inverse text data is lower;

[0151] Inverse text data frequency value The expression is as follows:

[0152] ;

[0153] in, This represents the total number of documents in the legal knowledge base. Indicated as a containing word The number of documents;

[0154] Based on the above two points, the system addresses the sub-problem of retrieval. Calculate its feature word weights That is, the average TF-IDF value of all terms in the query;

[0155] Feature word weights The expression is as follows:

[0156] ;

[0157] in, This represents the set of terms included in the query.

[0158] Preferably, the specific process for generating a structured evidence set is as follows:

[0159] A variant of the Sigmoid function is used as the weight mapping function to construct a continuous weight mapping function, thereby achieving a smooth transition and automatic adjustment of the retrieval strategy; feature word weights are mapped to values ​​in the interval [0,1], thus dynamically allocating weights to the lexical retrieval machine. And assigning weights to the semantic search engine ;

[0160] in:

[0161] Lexical search engine weight allocation Assign weights to semantic search engines The sum is:

[0162] ;

[0163] Lexical searcher weights The calculation formula is as follows:

[0164] ;

[0165] in, As a specific benchmark threshold, For adjustment coefficients, It is a natural constant.

[0166] Semantic retrieval system weight allocation The calculation formula is as follows:

[0167] .

[0168] This application, through the aforementioned continuous mapping mechanism, can determine the weight of feature words. Automatic weight adjustment based on feature word weight changes: Significantly higher than the specificity benchmark threshold Time (e.g., including specific legal provisions). The system automatically approaches 1, and then performs high-precision matching tasks; when the feature word weights... Significantly lower than Time (e.g., colloquial description). Automatically approaching 0, the system dominates the semantic understanding task; when the feature word weights near At this time, the system automatically allocates balanced weights (such as around 0.5) to achieve a mixed and complementary effect. For example, when querying "Article 41 of the Labor Contract Law", due to the presence of highly specific words, the calculated feature word weights are... The value is relatively high; after substituting it into the formula... The value will be automatically adjusted to a high value close to 1 (e.g., 0.9) to ensure an exact match; however, for queries like "Can employees be dismissed if the company is not doing well?", the wording is colloquial, and the feature word weights are adjusted accordingly. Lower, after substituting into the formula It will be automatically adjusted to a lower value (such as 0.2), thus giving the semantic retriever a higher weight to understand legal intent.

[0169] Preferred, specific threshold and adjustment coefficient The settings follow the principle of "balancing smooth transition and discriminative power," and are determined through empirical optimization. Specifically, on a representative validation set including legal provision retrieval, scenario consultation, and mixed queries, the results are evaluated... After qualitative evaluation of the candidate values, it was found that the threshold was too low. While a threshold of 0.01 can capture all terms, it can easily misjudge ordinary questions as specialized queries, leading to over-reliance on lexical retrieval; conversely, an excessively high threshold... A threshold of 0.1 or higher indicates insufficient sensitivity and risks overlooking key legal terms in factual statements. The final threshold will then be determined. The optimal value is 0.05, which ensures that the system is sensitive enough to queries containing legal terms while avoiding misclassification of ordinary, colloquial queries. It is a robust choice achieved under theoretical guidance and practical verification. The value of determines the "sensitivity" to weight changes; in this embodiment, the preferred value is... This value ensures that the weights have a moderate ability to distinguish between different values ​​near the threshold, avoiding the boundary mutation effect caused by traditional fixed thresholds. It is a robust choice achieved under theoretical guidance and practical verification.

[0170] Preferably, the specific method for generating a structured evidence set is as follows:

[0171] Weights are assigned based on search keywords, search vectors, and the lexical search engine. and semantic search engine weight allocation The hybrid retrieval enhancement generation system employs a weighted reciprocal ranking fusion (RRF) algorithm to generate a structured evidence set.

[0172] Among them, the core advantage of the inverse ranking fusion algorithm lies in its score independence. It does not rely on the original scores returned by different retrieval machines with different scales, but only uses the "ranking" information of the text data in their respective lists, making it particularly robust when fusing heterogeneous retrieval systems.

[0173] A further optimized process for generating a structured evidence set is as follows:

[0174] ① Using a weighted inverse sorting fusion algorithm, calculate the fusion of any text data. Fusion score ;

[0175] Fusion score The expression is as follows:

[0176] ;

[0177] in, For any text data Rank in the lexical sorting list; For any text data Rank in the semantically ordered list; It is a smoothing constant (in this embodiment, The optimal value is 60, which reduces the excessive influence of highly ranked text data on the total score and enhances the robustness of the fusion results.

[0178] ② The hybrid retrieval enhancement generation system processes all retrieved text data from the legal knowledge base. Calculate their fusion scores, sort them in descending order of scores, and finally output the top score. The top K most relevant text data are used as the sub-questions to be retrieved. Evidence-based materials;

[0179] Among them, parameters The selection of values ​​follows the principle of "evidence integrity," and the preferred range of values ​​is... In this embodiment, it is set This value is derived from empirical testing and aims to ensure that each sub-problem can obtain multi-dimensional evidence support (such as currently effective laws, administrative regulations, and judicial interpretations), while avoiding noise interference caused by introducing too many low-relevance tail documents and preventing exceeding the context window limit of the large language model.

[0180] ③ The dynamically weighted hybrid retrieval enhancement generation system categorizes and stores the acquired evidence-based materials according to sub-task tags (such as "definition", "fact", "law"), and calls the underlying large language model to process each sub-question to be retrieved. Generate preliminary analytical responses.

[0181] ④ Integrate all the analytical responses to form a complete set of structured evidence.

[0182] Step 3: Construct a multi-agent collaborative generation architecture; Based on the structured evidence set and the original legal consultation request, use the multi-agent collaborative generation architecture to generate the final legal consultation response.

[0183] The multi-intelligence collaborative generation architecture is responsible for using the structured evidence set generated in the preceding stages and the original legal consultation request as a complete context, and employing a multi-role generation module to perform the final reasoning generation. This module analyzes user intent, dynamically loads pre-built role model adapters, and merges the basic capabilities of the general model with the professional parameters of specific roles to generate a final legal response with a specific professional perspective and logical coherence. This generation architecture aims to solve the problem that a single language model cannot effectively support the diverse professional roles in the legal field. By decomposing the overall capabilities into multiple independent role adapters, it achieves deep encapsulation of specific professional "personalities" and a high degree of control over the output style.

[0184] Preferably, the fundamental reason for constructing a multi-intelligence collaborative generation architecture is that a single language model is difficult to effectively accommodate the diverse and even conflicting professional roles in the legal field within its parameter space. This invention solves this problem by decomposing the overall capability into multiple independent role model adapters. This design achieves deep encapsulation of professional knowledge, avoiding the knowledge "averaging" problem that may occur when a single model learns multiple conflict styles; at the same time, by deterministically selecting adapters, it ensures a high degree of control over the output style.

[0185] This multi-intelligent collaborative generation architecture consists of two core components: a role adapter storage area and a scheduling unit.

[0186] ① Character adapter storage area;

[0187] The role adapter storage area is the foundation of the multi-agent collaborative generation architecture, storing a general agent adapter and multiple role agent adapters. Each adapter file corresponds to a specific legal professional role. The professional capabilities of these adapters do not come from the general model, but are independent parameter files trained using the low-rank fine-tuning technique (QLoRA).

[0188] ② Scheduling unit;

[0189] The scheduling unit is the control core of the multi-intelligence collaborative generation architecture. Its input consists of a structured evidence set generated in the previous stage, containing all evidence-based materials, and the user's original legal consultation request. The core task of the scheduling unit is to perform deep feature analysis on the structured evidence set and the original legal consultation request. By comprehensively evaluating the type characteristics of the user's intent in the original legal consultation request (including practical rights protection actions and judgment prediction, etc.), it dynamically selects an optimal target adapter from the role adapter storage area to execute the final parameter merging inference task.

[0190] Preferably, the role adapter storage area includes multiple role adapters, and each role adapter includes multiple specialized role adapters. Each specialized role adapter acquires its unique capabilities through specialized fine-tuning on specific, high-quality legal corpora. Specifically, the multiple patented role adapters include:

[0191] General-purpose intelligent agent adapter: serving as the foundation of the system, used to handle broad legal knowledge questions and answers that do not require a specific professional perspective;

[0192] Lawyer Intelligent Agent Adapter: Fine-tuned on real-world legal consultation question-and-answer datasets to learn to provide client-centric, practical, and actionable strategy recommendations;

[0193] Judge Agent Adapter: Fine-tuned on a real judicial judgment document dataset to learn to perform rigorous and neutral logical analysis, with a language style close to that of court judgments;

[0194] Expert Agent Adapter: Fine-tuned on a dataset of authoritative legal journal articles to learn in-depth legal analysis and theoretical interpretation, with a more academic and objective perspective.

[0195] Furthermore, to efficiently train the aforementioned multiple specialized agents with limited computing resources, this application employs QLoRA (Quantized Low-Rank Adaptation), an efficient parameter fine-tuning technique. Compared to full-scale fine-tuning, which requires updating all parameters and consumes enormous computing resources, and standard LoRA, which, although reducing training parameters, still requires loading a full-precision (e.g., 16-bit) pedestal model, resulting in high memory usage, QLoRA reduces the memory usage of the pedestal model through quantization techniques. This makes it possible to train ultra-large-scale models on a single standard GPU without sacrificing fine-tuning performance.

[0196] In this embodiment, the pre-trained base model specifically uses the Qwen3-8B large language model. QLoRA makes it possible to train and deploy this ultra-large-scale model on a single standard GPU. Its implementation principle is as follows: First, the main weights of the Qwen3-8B base model are quantized and frozen using 4-bit normal floating-point (NF4) technology, greatly compressing the base model size; second, a small number of trainable low-rank adapter (LoRA) parameters are introduced onto the frozen base model, and only these adapter parameters are updated during training. This affects the original weights... Change It can be formed by two smaller matrices. and To approximate the product When the base model performs forward propagation, an input... The calculation process consists of two parts: the frozen Qwen3-8B parameters and the adapter. Its mathematical expression is as follows:

[0197] .

[0198] This technique enables a performance comparable to full fine-tuning with minimal computational cost, making it a key enabling technology for building multi-agent pools.

[0199] The specific process for generating the final legal consultation response is as follows:

[0200] The collaborative working mechanism of the multi-agent collaborative generation architecture follows a "dynamic parameter loading" principle, which is executed by the scheduling unit in the following steps:

[0201] (1) Global intent analysis: The scheduling unit receives and deeply analyzes the complete context containing the user's original inquiry and all the structured evidence sets retrieved in the early stage, and extracts the user intent features.

[0202] (2) Agent selection decision: Based on the judgment of the nature of the task (such as strategy consultation or legal analysis), the scheduling unit dynamically selects the only most matching target adapter from the storage area (for example, if it is identified as a rights protection practice intention, then the lawyer agent adapter is selected).

[0203] (3) Parameter merging and execution: The generation engine will merge and execute the selected adapter parameters ( Loaded into video memory, along with the frozen base large language model parameters ( Logically merge the data and independently generate all legal consultation responses based on the structured evidence set to complete the final response.

[0204] Through a collaborative working mechanism, we deliver final legal advice responses that are professional, authoritative, and clearly explainable, while ensuring the accuracy of the facts.

[0205] Example 2:

[0206] The present invention also provides a multi-agent legal intelligent question answering system for implementing the legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described in Embodiment 1, including a general agent, a lawyer agent, a judge agent, and an expert agent;

[0207] General-purpose intelligent agent adapter: serving as the foundation of the system, used to handle broad legal knowledge questions and answers that do not require a specific professional perspective;

[0208] Lawyer Intelligent Agent Adapter: Fine-tuned on real-world legal consultation question-and-answer datasets to learn to provide client-centric, practical, and actionable strategy recommendations;

[0209] Judge Agent Adapter: Fine-tuned on a real judicial judgment document dataset to learn to perform rigorous and neutral logical analysis, with a language style close to that of court judgments;

[0210] Expert Agent Adapter: Fine-tuned on a dataset of authoritative legal journal articles to learn in-depth legal analysis and theoretical interpretation, with a more academic and objective perspective.

[0211] As a further embodiment of the present invention, the specific data processing flow for applying the multi-agent legal intelligent question-answering system described above to perform legal intelligent question-answering is as follows:

[0212] ① When the multi-agent legal intelligent question answering system receives the user's original legal consultation request, the workflow first starts the structured decomposition stage. This module calls the pre-set decomposition model, applies the structured task chain mapping logic, deeply analyzes and serializes the unstructured legal questions into a logically independent sub-task queue containing semantic tags of "definition-fact-law-reasoning-action", forming a computer-executable structured task chain.

[0213] ② For each subtask in the task chain, the system launches a dynamically weighted hybrid retrieval enhancement generation system. This system first calculates the feature word weights of the subtask and dynamically adjusts the calling ratio of the lexical retrieval machine and the semantic retrieval machine accordingly. Subsequently, the module performs weighted inverse sorting fusion to accurately match traceable evidence materials from the legal knowledge base and encapsulates these materials into a structured evidence set, thereby providing a solid factual basis for the generation process and effectively suppressing model illusions.

[0214] ③ In the multi-agent collaborative generation phase, the workflow will include the complete context of the original problem and the analysis summary, and will be uniformly delegated to the core scheduling unit;

[0215] The primary responsibility of the scheduling unit is to perform intent feature analysis on the context and, based on the evaluation results, accurately select and activate the target role adapter that best matches the task from the adapter repository.

[0216] The generation engine performs a parameter merging and loading operation, which loads the selected adapter parameters ( ) Loaded into video memory, along with the frozen base model parameters ( Logical merging is performed.

[0217] The activated parameter combination inherits the professional capabilities of a specific role (thanks to its specialized fine-tuning on specific legal corpora), and writes and outputs the final response based on a structured evidence set.

[0218] This professional capability stems from its specialized fine-tuning of specific legal corpora (such as judgments and academic journals), ultimately ensuring that the output content is logically coherent, stylistically consistent, and possesses domain-specific expertise.

[0219] Example 3:

[0220] The present invention also includes a computer device, comprising a memory and a processor;

[0221] The memory is used to store computer programs that can run on the processor;

[0222] When the processor executes the computer program, it implements the steps of the legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described above.

[0223] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the computer device.

[0224] The computer device may be a mobile phone, desktop computer, laptop, handheld computer, or cloud server, etc. The computer device may include, but is not limited to, a processor and memory. For example, the computer device may also include input / output devices, network access devices, buses, etc.

[0225] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the computer device, connecting various parts of the computer device via various interfaces and lines.

[0226] The memory can be used to store the computer program and / or modules. The processor implements the computer program by running or executing the computer program and / or modules stored in the memory, and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0227] Wherein, if the modules / units integrated into the computer device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0228] Example 4:

[0229] The present invention also includes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the legal intelligent question-answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described above.

[0230] Compared to existing technologies, this embodiment provides a legal intelligent question-answering method based on multi-agent dynamic role scheduling and hybrid retrieval. By structurally decomposing complex legal knowledge questions, it ensures a comprehensive and orderly analysis of the questions. The method also improves the accuracy of evidence retrieval through hybrid retrieval enhancement generation, and enhances the domain professionalism, style controllability, and decision interpretability of the final answer by realizing legal knowledge question-answering through multi-agent collaboration.

[0231] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0232] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval, characterized in that, Includes the following steps: Step S1: Input the user's original legal consultation request into the decomposition reasoning cognitive framework. The decomposition reasoning cognitive framework parses and maps the unstructured natural language text in the original legal consultation request into a structured task chain containing multiple sub-tasks to be retrieved. Step S2: For the structured task chain, perform a search on each subtask to be searched, and generate search keywords and search vectors; The query feature word weights for each subtask to be retrieved are calculated using a dynamic weight allocation mechanism based on query specificity quantification. The ratio of lexical retrieval to semantic retrieval is dynamically adjusted according to weights, and evidence data is obtained in parallel from the legal knowledge base to generate a structured evidence set. Step S3: Construct a multi-intelligent collaborative generation architecture; A multi-intelligent collaborative generation architecture is adopted to perform in-depth feature analysis on the structured evidence set and the original legal consultation request, obtain the type features of the original legal consultation request, and dynamically select the target role adapter that matches the type features from multiple role model adapters of the multi-intelligent collaborative generation architecture. The general parameters of the basic large language and large model are merged and loaded with the special parameters of the target role adapter, and legal consultation responses are generated based on the structured evidence set. The multi-intelligent collaborative generation architecture includes a role adapter storage area and a scheduling unit; The role adapter storage area is the foundation of the multi-intelligent collaborative generation architecture, and it stores a general intelligent agent adapter and multiple role intelligent agent adapters. The scheduling unit is the control core of the multi-intelligent collaborative generation architecture. The structured evidence set and the user's original legal consultation request are input into the scheduling unit. The scheduling unit performs deep feature analysis and dynamically selects an optimal target adapter from the role adapter storage area to perform the final parameter merging reasoning task by comprehensively evaluating the type characteristics of the original legal consultation request. The role adapter storage area includes multiple role adapters, and each role adapter includes multiple specialized role adapters. Each specialized role adapter acquires its unique capabilities through specialized fine-tuning on a specific, high-quality legal corpus. Among them, several specialized role adapters include: General-purpose intelligent agent adapter: serving as the foundation of the system, used to handle broad legal knowledge questions and answers that do not require a specific professional perspective; Lawyer Intelligent Agent Adapter: Fine-tuned on real-world legal consultation question-and-answer datasets to learn to provide client-centric, practical, and actionable strategy recommendations; Judge Agent Adapter: Fine-tuned on a real judicial judgment document dataset to learn to perform rigorous and neutral logical analysis, with a language style close to that of court judgments; Expert Agent Adapter: Fine-tuned on a dataset of authoritative legal journal articles to learn in-depth legal analysis and theoretical interpretation, with a more academic and objective perspective.

2. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 1, characterized in that, The specific process of obtaining the structured task chain of multiple subtasks to be retrieved in step S1 is as follows: S1.

1. Perform feature evaluation on the original legal consultation request to obtain the task type of the original legal consultation request; the task type includes direct retrieval tasks or composite analysis tasks; the direct retrieval task refers to a single knowledge point query with a clear objective and no need for multi-step reasoning; the composite analysis task refers to a complex scenario description involving multiple legal relationships, requiring long-chain causal deduction, or involving conflicts in the application of law. S1.2 If it is marked as a direct retrieval task, it will be directly passed to step S2 for regular retrieval; If a task is marked as a composite analysis task, it is input into the decomposition reasoning cognitive framework. The decomposition reasoning cognitive framework performs in-depth decomposition of the composite analysis task based on the structured task chain mapping logic, and obtains semantic category labels containing five consecutive analysis stages: definition, fact, law, reasoning and action, and generates corresponding sub-tasks to be retrieved.

3. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 2, characterized in that, The specific methods for characterizing original legal consultation requests are as follows: By employing prompt word engineering techniques, a single large language model is configured as an evaluation and processing unit by loading a pre-set system instruction set; The evaluation and processing unit uses preset logical judgment rules to perform feature matching on the unstructured natural language text in the original legal consultation request in order to determine the task type.

4. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 3, characterized in that, The logical decision rules include the following computer execution standards: ① Structured identifier detection; The system checks whether the text contains standard legal and regulatory citation formats; if it does, it is classified as a direct search category. ② Define query template detection; The system detects whether the text contains explicit conceptual query sentences; if so, it is classified as a direct retrieval type. ③ Detection of decision-making intentions and narratives; The test text checks whether it contains decision-making words seeking strategic advice, words judging legality, or whether it is a narrative description containing specific case details; if so, it is classified as a composite analysis type.

5. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to any one of claims 1-4, characterized in that, The specific process of generating search keywords and search vectors in step S2 is as follows: A single sub-problem to be retrieved As input, it is fed into the independent lexical and semantic search engines in the dynamically weighted hybrid search enhancement generation system; The lexical search engine and the semantic search engine concurrently execute their respective search algorithms in the legal knowledge base for the received sub-questions to be searched, and obtain search keywords and search vectors.

6. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 5, characterized in that, The specific method for obtaining search keywords is as follows: Using the Chinese word segmentation tool Jieba and loading a legal-specific dictionary, we performed precise word segmentation on the sub-questions to be retrieved and on every piece of text data in the knowledge base. Calculate the subproblem to be retrieved With text data The relevance score, and based on the sub-question to be retrieved. With text data correlation score For text data The search keywords are then filtered to obtain the search terms.

7. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 5, characterized in that, The specific method for obtaining the retrieval vector is as follows: Using a pre-trained language model as the embedding layer, the sub-question to be retrieved is... Transform into a vector of subproblems Text data Convert to text vector ; Compute subproblem vectors and text vector cosine similarity ; Based on cosine similarity To evaluate the subproblem vector and text vector The relevance is used to obtain the retrieval vector.

8. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 6 or 7, characterized in that, The specific process for calculating the query feature word weights for each subtask to be retrieved is as follows: By utilizing the term frequency-inverse text data frequency idea in the dynamic weight allocation mechanism of query specificity quantification, the term frequency and inverse text data frequency of each term in the query feature words of each subtask to be retrieved are quantified; Normalize the word frequencies to obtain the normalized word frequencies. ; Normalization based on word frequency Calculate the sub-problem to be retrieved based on the frequency of inverse text data. Feature word weights .

9. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 8, characterized in that, The specific process of dynamically adjusting the ratio of lexical retrieval to semantic retrieval based on weights in step S2 is as follows: A variant of the Sigmoid function is used as the weight mapping function to construct a continuous weight mapping function; The feature word weights are mapped to values ​​within the interval [0,1], based on the feature word weights. The changes automatically adjust the weights assigned to the lexical search engine. and semantic search engine weight allocation .

10. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 9, characterized in that, The specific method for generating the structured evidence set in step S2 is as follows: A weighted inverse sorting fusion algorithm is used to calculate any text data. Fusion score ; Fusion score The expression is as follows: ; in, For any text data Rank in the lexical sorting list; For any text data Rank in the semantically ordered list; It is a smoothing constant, which reduces the excessive influence of highly ranked text data on the total score and enhances the robustness of the fusion result; The hybrid retrieval-enhanced generation system processes all retrieved text data from the legal knowledge base. Calculate their fusion scores, sort them in descending order of scores, and finally output the top score. The most relevant text data are used as each sub-question to be retrieved. Evidence-based materials; among which, parameters The selection of values ​​follows the principle of evidence integrity, and the range of values ​​is set to... ; The dynamically weighted hybrid retrieval enhancement generation system categorizes and stores the acquired evidence-based materials according to sub-task labels, and calls the underlying large language model to process each sub-question to be retrieved. Generate preliminary analytical responses; All the analytical responses were integrated to form a complete set of structured evidence.

11. An electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs that can run on the processor; When the processor executes the computer program, it implements the steps of the legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described in any one of claims 1-10.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the legal intelligent question-answering method based on multi-agent dynamic role scheduling and hybrid retrieval as described in any one of claims 1-10.

Citation Information

Patent Citations

  • Retrieval optimization method based on dynamic mixed retrieval and adjacent paragraph introduction

    CN120705333A

  • Safety law system intelligent question-answering system based on RAG architecture

    CN120910208A