Intelligent legal question-answering method and system based on multi-agent dynamic role scheduling and mixed retrieval, electronic equipment and storage medium

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

CN121524312AActive Publication Date: 2026-02-13CENT SOUTH UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202610042917.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-14
Publication Date
2026-02-13
Estimated Expiration
2046-01-14

AI Technical Summary

Technical Problem

Existing legal consultation systems suffer from incomplete structured problem decomposition, insufficient in-depth factual evidence, and inconsistent professional generation when dealing with complex legal issues, making it difficult to guarantee logical rigor and factual accuracy.

Method used

This paper adopts a legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval. By decomposing the reasoning cognitive framework, the consultation request is mapped into a structured task chain. The dynamic weight allocation mechanism is used for hybrid retrieval. Combined with the multi-agent collaborative generation architecture, professional legal answers are generated.

Benefits of technology

It has achieved scenario-based adaptation of legal consultation, low-cost and high-concurrency multi-agent system construction, improved the recall and precision of evidence acquisition, eliminated the "illusion" risk of agent generation, and ensured logical coherence and professionalism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121524312A_ABST
    Figure CN121524312A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence and law crossing, and particularly provides a law intelligent question-answering method and system based on multi-agent dynamic role scheduling and mixed retrieval, electronic equipment and a storage medium, and the method comprises the following steps: 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 adopting a multi-intelligent collaborative generation architecture. According to the method, role adapter scheduling logic is innovatively introduced, the system can firstly analyze whether a user request needs'right protection practical operation ', 'judgment prediction' or'theoretical learning 'like'law partners', and then the corresponding target adapter is dynamically activated. The dynamic scheduling mechanism endows the system with adaptive ability for different legal scenes, ensures that each answer is executed by the most suitable expert role, and significantly improves the professional degree of service.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of artificial intelligence and law, and relates to 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. BACKGROUND

[0002] With the rapid development of large language model technology, it has shown great potential in professional fields such as law with high knowledge intensity and logic requirements, and is regarded as a revolutionary tool to solve complex legal tasks (such as legal document drafting, case opinion generation, judicial decision prediction, etc.).

[0003] With the rapid modernization of the legal system and the growing demand for legal services from the public, it has become an urgent need to develop scalable and reliable automated legal technology. However, when existing technology is directly applied to complex Chinese legal consultation scenarios, its inherent technical defects are highlighted, including: 1. Lack of structured reasoning ability, the model cannot stably reproduce the multi-step logical analysis process required by legal experts (such as fact recognition, rule application, and conclusion formation), and tends to directly give a leap conclusion; 2. Knowledge limitations, on the one hand, the model has an internal "model illusion" problem due to the limitations of its parameterized memory, which may generate and reference completely fabricated or incorrect legal provisions, and on the other hand, it has an external "knowledge obsolescence" problem due to the fact that its knowledge is fixed after pre-training, and it cannot include newly enacted laws or judicial interpretations in time; 3. Lack of domain expertise, the model has not mastered the professional terminology, document paradigm and argument structure unique to the Chinese legal discourse system, and the generated replies are often colloquial, and may even provide incorrect legal advice.

[0004] To solve the above problems, although a variety of legal special models such as LAWGPT, LawyerLLAMA, DISC-LawLLM and ChatLaw have emerged in the field, they generally provide a "fragmented" solution and fail to fundamentally and systematically solve the problem. Specifically, some models that focus on knowledge injection through supervised fine-tuning (SFT) (such as DISC-LawLLM) have mastered the domain knowledge to some extent, but if they lack a powerful and controllable structured reasoning mechanism, their output may still be logically confusing or contradictory; and some models that explore complex workflows or embed legal argumentation paradigms (such as legal syllogism) still rely on general models, which cannot draw truly reliable legal conclusions due to the lack of deep and fine-grained domain knowledge. Although the above models almost all integrate retrieval-augmented generation (RAG) to provide factual basis, for legal problems that require multi-step and complex logical reasoning, a single retrieval-augmented generation (RAG) process is often insufficient to support a complete argument chain.

[0005] In summary, the core technical problem in the current technical field is the "fragmentation" of existing solutions. Specifically, in handling legal consultations, the key links such as structured problem decomposition, deep fact evidence, and specialized generation are often disconnected and optimized independently, failing to form a complete and coherent processing flow from receiving user's original consultation to intermediate logical reasoning and evidence retrieval, and finally generating a professional-level reply. This break in the process directly leads to the difficulty of existing solutions in systematically addressing the multiple high-standard requirements for logical rigor, factual accuracy and domain expertise in legal consultation tasks. SUMMARY

[0006] To solve the deficiencies in the prior art, the present application aims to provide a legal intelligent question and answer method and system based on multi-agent dynamic role scheduling and hybrid retrieval, an electronic device and a storage medium to ensure comprehensive and orderly analysis of the problem.

[0007] The present application provides a legal intelligent question and answer method based on multi-agent dynamic role scheduling and hybrid retrieval, comprising the following steps: Step S1, input the user's original legal consultation request into the decomposition reasoning cognitive framework, and 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 to-be-retrieved sub-tasks; Step S2, for the structured task chain, retrieve each to-be-retrieved sub-task to generate retrieval keywords and retrieval vectors; Step S3, calculate the query feature word weight of each to-be-retrieved sub-task using a query-specific quantification dynamic weight distribution mechanism; According to the dynamic adjustment of the calling ratio of the lexical retrieval and the semantic retrieval according to the weight, evidence data is obtained from the legal knowledge base in parallel to generate a structured evidence set; Step S3, constructing a multi-intelligent collaborative generation architecture; Using the multi-intelligent collaborative generation architecture, the structured evidence set and the original legal consultation request are subjected to deep feature analysis to obtain the type characteristics of the original legal consultation request, and a target role adapter that matches the type characteristics is dynamically selected from the multiple role model adapters of the multi-intelligent collaborative generation architecture; The general parameters of the basic large language model are merged and loaded with the special parameters of the target role adapter, and a legal consultation reply is generated based on the structured evidence set.

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

[0009] Further, the specific way of performing feature evaluation on the original legal consultation request is as follows: Using the prompt word engineering technology, a single large language model is configured as an evaluation processing unit by loading a pre-set system instruction set; Using the evaluation processing unit, the non-structured natural language text in the original legal consultation request is subjected to feature matching based on pre-set logical judgment rules to determine the task type.

[0010] Further, the logical judgment rules include the following computer execution standards: ①, structured identifier detection; Detecting whether the text contains a standard legal regulation citation format; if it does, it is inclined to be determined as a direct retrieval type; ②, definition query template detection; Detecting whether the text contains an explicit concept inquiry sentence; if it does, determining that it is a direct retrieval type; ③, decision intention and narrative detection; Detecting whether the text contains decision words seeking strategic advice, legality judgment words, or whether the text is a narrative description containing specific case details; if it does, determining that it is a complex analysis type.

[0011] Further, the specific process of generating retrieval keywords and retrieval vectors in step S2 is: The single sub-problem to be retrieved is input into the lexically and semantically independent word retrieval and semantic retrieval of the dynamic weighted hybrid retrieval enhancement generation system; The word retrieval and semantic retrieval receive the sub-problem to be retrieved and concurrently execute their respective retrieval algorithms in the legal knowledge base to obtain retrieval keywords and retrieval vectors.

[0012] Further, the specific way to obtain retrieval keywords is: Use the Chinese word segmentation tool Jieba and load the legal field special dictionary to accurately segment the sub-problem to be retrieved and each piece of text data in the knowledge base; Calculate the relevance score of the sub-problem to be retrieved to the text data , and filter the text data based on the relevance score of the sub-problem to be retrieved to the text data to obtain retrieval keywords.

[0013] Further, the specific way to obtain retrieval vectors is: Use a pre-trained language model as an embedding layer to convert the sub-problem to be retrieved into a sub-problem vector , and convert the text data into a text vector ; Calculate the cosine similarity of the sub-problem vector and the text vector ; Based on the cosine similarity , evaluate the relevance of the sub-problem vector and the text vector to obtain the retrieval vector.

[0014] Further, the specific process of calculating the query feature word weight of each sub-problem to be retrieved is: ​The term frequency-inverse text data frequency idea in the dynamic weight distribution mechanism of query specificity quantification is used to quantify the term frequency and inverse text data frequency of each word in the query characteristic words of each sub-retrieval task; The term frequency is normalized to obtain the normalized term frequency ; Based on the normalized term frequency and the inverse text data frequency, the characteristic word weight of the sub-retrieval problem is calculated

[0015] Further, the specific process of dynamically adjusting the calling ratio of lexical retrieval and semantic retrieval according to the weight 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 characteristic word weight is mapped to a value in the interval [0, 1], and the weight allocated to the lexical retriever and the weight allocated to the semantic retriever are automatically adjusted according to the change of the characteristic word weight .

[0016] Further, the specific way of generating a structured evidence set in step S2 is as follows: A weighted inverse ranking fusion algorithm is used to calculate the fusion score of any text data ; The expression of the fusion score is as follows: ; Wherein, is the ranking of any text data in the lexical ranking list; is the ranking of any text data in the semantic ranking list; is a smoothing constant, which reduces the excessive influence of text data with extremely high ranking on the total score and enhances the robustness of the fusion result; The hybrid retrieval enhancement generation system calculates the fusion score of all retrieved text data in the legal knowledge base and ranks them in descending order of score, and finally outputs the top most relevant text data as the evidence-based materials for each sub-retrieval problem ; wherein the value of the parameter follows the principle of evidence completeness, and the value range is set to ; ​The dynamic weighted hybrid retrieval enhancement generation system classifies and stores the obtained evidence-based materials according to sub-task labels, calls a bottom large language model to generate preliminary analysis answers for each sub-problem to be retrieved generates preliminary analysis answers; integrates all analysis answers to form a complete structured evidence set.

[0017] Further, the multi-intelligent collaborative generation architecture includes a role adapter storage area and a scheduling unit. The role adapter storage area is the basis of the multi-intelligent collaborative generation architecture, and stores a general intelligent agent adapter and a plurality of role intelligent agent adapters. The scheduling unit is the control core of the multi-intelligent collaborative generation architecture, and 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, comprehensively evaluates the type characteristics of the original legal consultation request, and dynamically selects an optimal target adapter from the role adapter storage area to perform the final parameter merging reasoning task.

[0018] Further, the role adapter storage area includes a plurality of role adapters, and a single role adapter includes a plurality of specialized role adapters. Each specialized role adapter obtains its unique ability by being fine-tuned on specific high-quality legal corpus. The plurality of patentization role adapters include: General intelligent agent adapter: as the base of the system, used for processing relatively broad legal knowledge questions and answers that do not require specific professional perspectives; Lawyer intelligent agent adapter: fine-tuned on real legal consultation question and answer data sets to learn to provide strategies and suggestions that are centered on the party, practical and operable; Judge intelligent agent adapter: fine-tuned on real judicial adjudication document data sets to learn to perform rigorous and neutral logical analysis, with a language style close to court judgments; Expert intelligent agent adapter: fine-tuned on authoritative law journal article data sets to learn to perform in-depth legal reasoning and theoretical interpretation, with a more academic and objective perspective.

[0019] The application also provides an electronic device including a memory and a processor. The memory is used to store a computer program executable on the processor. The processor is used to execute the computer program to implement the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and hybrid retrieval as described above.

[0020] The application further provides a computer readable storage medium, and a computer program is stored on the computer readable storage medium, and the computer program realizes the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval when executed by a processor.

[0021] Compared with the prior art, the application has the following beneficial effects: (1) A dynamic role scheduling mechanism based on intention recognition is constructed, and scene adaptation of legal services is realized; The prior art usually uses a single model to deal with all consultations, and lacks flexibility; 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 activates 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 matching degree of the service.

[0022] (2) The parameter decoupling technology is used to realize the construction of a low-cost and high-concurrency multi-agent system; Building a multi-agent system usually faces huge memory and computing power challenges; the application uses QLoRA low-rank fine-tuning technology to encapsulate the professional capabilities of lawyers, judges, experts and other different roles into independent lightweight adapter files. This parameter-level decoupling design allows the system to not need to load multiple full-size models at the same time, and only needs to dynamically combine a small number of parameters during reasoning to realize role switching. This not only greatly reduces the deployment threshold of the multi-agent system, but also ensures the efficiency of the system response in a high-concurrency scenario.

[0023] (3) The structured task chain is used to realize the collaborative division of labor and logical control among agents; The application analyzes complex legal problems into a structured task chain, and essentially constructs an agent collaboration protocol. By decomposing the task into standardized nodes such as "definition", "fact" and "reasoning", the system can guide different functional processing units (such as retrieval units and reasoning units) to cooperate in sequence. This design converts abstract legal thinking into a workflow that can be strictly executed by a computer, effectively solving the common problems of task target drift and logical discontinuity in multi-agent collaboration.

[0024] (4) The dual-channel mixed retrieval capability is given to the agent, and the recall rate and precision rate of evidence acquisition are improved; In order to provide accurate basis for the decision of the agent, the dynamic weight dual-channel retrieval module is designed as the core tool of the agent. The system can automatically judge whether to call the "accurate law searching" ability or the "fuzzy case searching" ability according to the characteristic word weight of the subtask. This mechanism is equivalent to endowing the agent with the ability of self-adaptive adjustment, and ensures that the agent can obtain high-quality structured evidence support when processing different types of legal information.

[0025] (5) The strong constraint generation mechanism based on the evidence set is established, and the risk of "free play" of the agent is eliminated. In view of the common problem that the large model agent is easy to produce "illusion", the structured evidence set constraint is introduced in the generation stage. The system forcibly requires that the parameter reasoning process of the agent must be strictly anchored on the retrieved real-time evidence when generating the answer. This mechanism adds a "safety lock" to the multi-agent system, which not only retains the reasoning ability of the agent, but also fundamentally eliminates the risk of fabricating law, and solves the problem of outdated knowledge.

[0026] In addition to the purposes, characteristics and advantages described above, the present application has other purposes, characteristics and advantages. The present application will be further described below with reference to the drawings. BRIEF DESCRIPTION OF DRAWINGS

[0027] The accompanying drawings, which form a part of this application, are included to provide a further understanding of the application, and are incorporated in and constitute a part of this specification. The illustrations in the drawings for the purpose of explaining the application, do not limit the application in an inappropriate manner. Figure 1 is a flowchart of a legal intelligent question and answer method based on multi-agent dynamic role scheduling and hybrid retrieval in an embodiment of the present application; Figure 2 is an operation flowchart of a legal intelligent question and answer method based on multi-agent dynamic role scheduling and hybrid retrieval in an embodiment of the present application; Figure 3 is Figure 2 is a flowchart of a dynamic weighting hybrid retrieval enhanced generation system in the embodiment. DETAILED DESCRIPTION

[0028] In order to make the above-mentioned purposes, features and advantages of the present application more clear and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings. It should be noted that the drawings of the present application are all simplified and use non-accurate proportions, and are only used to facilitate and clearly assist in explaining the implementation of the present application; the number of several mentioned in the present application is not limited to the specific number in the example of the drawings; the directions or position relationships mentioned in the present application, such as 'front','middle','rear', 'left', 'right', 'top', 'bottom', 'top', 'bottom','middle', are all based on the directions or position relationships shown in the drawings of the present application, and do not indicate or imply that the devices or parts referred to must have a specific direction, nor can it be understood as a limitation on the present application.

[0029] Embodiment 1: Referring to Figures 1 to 3 As shown in the drawings, the legal intelligent question and answer method provided by the present application based on multi-agent dynamic role scheduling and mixed retrieval includes the following steps: Step one, input the original legal consultation request of the user into the decomposition-reasoning cognitive framework (DRCF), and 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 to-be-retrieved sub-tasks.

[0030] Preferably, the specific process of obtaining the structured task chain of multiple to-be-retrieved sub-tasks is as follows: S1.1, perform feature evaluation on the original legal consultation request to determine whether it is a direct retrieval type task or a composite analysis type task; the direct retrieval type task refers to a single knowledge point query with clear target and no need for multi-step reasoning; the composite analysis type task refers to a complex scene description involving multiple legal relationships, long-chain causal deduction or legal application conflict; S1.2, if it is marked as a direct retrieval type task, it is directly passed to step S2 for regular retrieval; If it is marked as a composite analysis type task, it is input into the decomposition-reasoning cognitive framework, which performs deep decomposition on the composite analysis type task based on the structured task chain mapping logic to obtain semantic category labels of five consecutive analysis stages including definition, fact, law, reasoning and action, and generates corresponding to-be-retrieved sub-tasks.

[0031] Among them, the five consecutive analysis stages are: ① Definition: eliminate semantic ambiguity in the query and establish a concept basis without ambiguity for subsequent analysis; ② Fact: accurately extract and structure the core fact elements of the case from the user's narrative; ③, Law: Accurately map the sorted fact elements to specific legal norms; ④, Reasoning: Build a logical bridge from facts to conclusions by raising core analytical questions; ⑤, Action: Convert abstract legal analysis into specific, user-executable policy recommendations.

[0032] The output of the decomposition processing unit is strictly controlled to be a standardized JSON object representation (JavaScript Object Notation), which is a digital carrier for structured task chains, to ensure the structured integrity of the data and the automation and robustness of the subsequent process.

[0033] Further preferably, the specific way of evaluating the characteristics of the original legal consultation request is: Using prompt engineering technology, a single large language model is configured as an evaluation processing unit by loading a pre-set system instruction set. The pre-set system instruction set rules include logical decision rule definition, few-sample guidance, and output format constraint, wherein: ①, Logical decision rule definition; A set of logical decision criteria is pre-set for feature matching and type preliminary screening of input text; ②, Few-sample guidance; By providing several groups of pre-set "legal task consultation type" comparison examples, i.e. input-output result pairs containing "original consultation request" and "type determination result", the model is guided to identify whether the task belongs to direct retrieval type or composite analysis type, thereby achieving accurate classification of task type.

[0034] ③, Output format constraint; The model is required to output the determination result in a reconstructed data format (JSON) to ensure the automatic processing of the subsequent process.

[0035] The evaluation processing unit does not rely on subjective judgment, but is based on pre-set system instruction set to match the characteristics of unstructured natural language text in the original legal consultation request to determine the task type; Specifically, the logical decision rule includes the following computer execution standards: ①, Structured identifier detection; Detect whether the text contains a standard legal regulation reference format (such as "Article 1077 of the Civil Code"); If it does, it is inclined to be determined as a direct retrieval type; ②, Definition query template detection; Detecting whether the text contains an explicit concept inquiry sentence (such as "What is the apparent agency"); if it does, it is inclined to be determined as a direct retrieval type; ③, decision intention and narrative detection; Detecting whether the text contains decision words seeking strategic advice (such as "What should I do"), legality judgment words (such as "Is this legal"), or whether the text is a narrative description containing specific case details (time, place, and characters); if it does, it is inclined to be determined as a complex analysis type.

[0036] Further preferably, referring to the structured task chain mapping logic shown in Table 1, which is applied to a decomposition example in the "labor contract dispute" scenario, the user's original legal question is "The company said that the efficiency was bad and fired me. Is this legal? What should I do?" Since the question hits the "decision intention and narrative detection" rule (contains "whether it is legal", "what to do" and the narrative of the company's dismissal), the system determines it as a complex analysis type task and decomposes it as follows: Table 1: Decomposition example applied to "labor contract dispute" scenario

[0037] Step two, for the structured task chain, retrieve each sub-task to be retrieved, generate retrieval keywords and retrieval vectors; According to the retrieval keywords and retrieval vectors, calculate the feature word weight of each sub-task to be retrieved; According to the weight, dynamically adjust the calling ratio of lexical retrieval and semantic retrieval, obtain evidence data from the legal knowledge base in parallel, and generate a structured evidence set.

[0038] Preferably, in this embodiment, a dual-channel retrieval module is used to retrieve each sub-task to be retrieved to generate retrieval keywords and retrieval vectors.

[0039] Preferably, before retrieving each sub-task to be retrieved, in order to achieve complementary advantages, a dynamic weighted hybrid retrieval enhancement generation system is used to perform parallel execution of the dual-channel retrieval strategy to construct a comprehensive candidate set; the specific process is as follows: The same sub-problem to be retrieved As input, and simultaneously input into the lexical retriever and semantic retriever of the dynamic weighted hybrid retrieval enhancement generation system which are independent of each other; The lexical retriever and the semantic retriever perform respective retrieval algorithms in the legal knowledge base concurrently on the received sub-problems to be retrieved, and obtain retrieval keywords and retrieval vectors after the retrieval is completed. The lexical retriever obtains the retrieval keywords after the retrieval is completed, and the semantic retriever obtains the retrieval vectors after the retrieval is completed. The retrieval keywords and the retrieval vectors jointly constitute a comprehensive candidate set for the next stage of fusion ranking, ensuring that the subsequent processing can utilize both the accurate matching information of the keywords and the deep semantic association information.

[0040] The legal knowledge base refers to a database composed of a series of authoritative legal texts (the legal texts include current effective laws, administrative regulations, judicial interpretations, etc. obtained from official channels). Further preferably, in order to facilitate subsequent accurate retrieval and processing, the legal texts are standardized preprocessed text data; specifically, the legal original texts are systematically divided into independent text data in units of individual articles. The knowledge base provides a unified and reliable data source for lexical and semantic retrieval.

[0041] The lexical retriever (Lexical Retriever) is responsible for accurate retrieval based on keyword matching, and its technical core is the Okapi BM25 algorithm, which is a more advanced probability ranking model than the traditional TF-IDF model. The superiority of BM25 lies in the introduction of two key concepts: term frequency saturation (Term Frequency Saturation) and text data length normalization (Document Length Normalization). The former solves the score bias problem caused by linear growth of term frequency, and the latter provides a more fair comparison benchmark between different lengths of text data.

[0042] The semantic retriever (Semantic Retriever) aims to achieve recall based on deep semantic understanding; its technical principle is the vector space model (Vector Space Model), which maps unstructured text to a high-dimensional, continuous semantic vector space. In this space, the similarity of semantics is quantified as the spatial distance between vectors.

[0043] Further preferably, the specific process of obtaining retrieval keywords based on the lexical retriever is as follows: Before applying the lexical retriever for retrieval, first use the Chinese word segmentation tool Jieba (jieba is a high-efficiency Chinese word segmentation library in Python) and load the legal field special dictionary to perform accurate word segmentation on the sub-problems to be retrieved and each text data in the knowledge base; then, calculate the relevance scores of the sub-problems to be retrieved with the text data , and based on the sub-problems to be retrieved correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data

[0044] correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data

[0045] correlation score of the text data correlation score of the text data

[0046] correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data correlation score of the text data

[0047] correlation score of the text data correlation score of the text data ; wherein, is the dimension of the vector; when the value is closer to 1, the semantics thereof are more relevant.

[0048] As a further embodiment of the present application, to efficiently perform the above-mentioned similarity search in a large-scale legal knowledge base, the semantic retriever adopts the FAISS (Facebook AISimilarity Search) vector retrieval engine to build an index. This index structure supports Approximate Nearest Neighbor (ANN) search, which can reduce the search time from linear complexity to logarithmic level at the expense of very small accuracy, thus meeting the real-time retrieval requirement. In addition, in view of the characteristics of legal texts, the retriever also adopts a conditional blocking strategy to process long text data, which maximizes the semantic integrity of individual articles and other short texts while ensuring the processability of the texts.

[0049] As a further scheme of the present embodiment, to solve the preference difference of different types of queries on the retrieval strategy, the present application further proposes a dynamic weight distribution mechanism based on query specificity quantification to calculate the feature word weight of each to-be-retrieved subtask.

[0050] Specifically, the core of the dynamic weight distribution mechanism based on query specificity quantification is to calculate a query specificity score, the principle of which is to quantify the term frequency and inverse document frequency of each term in the query feature words of each to-be-retrieved subtask by using the Term Frequency-Inverse Document Frequency (TF-IDF) idea; then calculate the feature word weight of the to-be-retrieved subtask .

[0051] wherein, Term Frequency (TF) represents the frequency of a word in the text data ; to avoid long text data bias, the term frequency is usually normalized; the expression of the normalized term frequency is as follows: ; wherein: IDF represents the number of times a word appears in a query , IDF represents the total number of times all words in the query appear; Inverse Document Frequency (IDF) is used to measure the importance of a word of general importance; a word appears in more text data , the lower its inverse text data frequency value is; inverse text data frequency value is expressed as follows: ; wherein, denotes the total number of documents in the legal knowledge base, denotes the number of documents containing the word ; In summary, the system calculates the feature word weight of the sub-problem to be searched, i.e. the average TF-IDF value of all word items in the query; the expression of the feature word weight is as follows: ; wherein, denotes the set of word items contained in the query.

[0052] Preferably, the specific process of generating the structured evidence set is as follows: A variant of the Sigmoid function is adopted as the weight mapping function to construct a continuous weight mapping function, so as to realize smooth transition and automatic adjustment of the retrieval strategy; the feature word weight is mapped to a value in the interval [0, 1], so as to dynamically assign weights to the lexical retriever and the semantic retriever ; wherein: the sum of the weight assigned to the lexical retriever and the weight assigned to the semantic retriever is: ; The calculation formula of the weight of the lexical retriever is as follows: ; wherein, is a specificity reference threshold, is an adjustment coefficient, is a natural constant.

[0053] The calculation formula of the weight assigned to the semantic retriever is as follows: .

[0054] Through the above continuous mapping mechanism, the present application can dynamically adjust the weights of the lexical retriever ​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.

[0055] 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.

[0056] Preferably, the specific method for generating a structured evidence set is as follows: 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.

[0057] 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.

[0058] A further optimized process for generating a structured evidence set is as follows: ① Using a weighted inverse sorting fusion algorithm, calculate the fusion of 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 (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.

[0059] ② 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; 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.

[0060] ③, the dynamic weighted hybrid retrieval enhancement generation system classifies and stores the obtained evidence-based materials according to sub-task labels (such as "definition", "fact", "law"), calls the underlying large language model to solve each sub-problem to be retrieved generates a preliminary analysis answer.

[0061] ④, all analysis answers are integrated to form a complete structured evidence set.

[0062] Step three, build 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 reply.

[0063] The multi-intelligent collaborative generation architecture takes the structured evidence set generated in the previous stage and the original legal consultation request as the complete context, and uses a multi-role generation module to perform the final reasoning generation. This module analyzes the user's intent, dynamically loads the pre-installed role model adapter, combines the base capabilities of the general large model with the professional parameters of the specific role, and generates a final legal reply with a specific professional perspective and logically coherent. This generation architecture aims to solve the problem that a single language model cannot effectively carry multiple professional roles in the legal field. By dividing the overall capability into multiple independent role adapters, it achieves deep encapsulation of specific professional "personality" and high controllability of output style.

[0064] Preferably, the fundamental reason for building a multi-intelligent collaborative generation architecture is that a single language model cannot effectively carry multiple professional roles in the legal field, even with conflicting views. The present invention solves this problem by dividing the overall capability into multiple independent role model adapters, which achieves deep encapsulation of professional knowledge and avoids the problem of "averaging" knowledge that may occur when a single model learns multiple conflicting styles. At the same time, by deterministically selecting an adapter, the output style is highly controllable.

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

[0066] ①, role adapter storage area; The role adapter storage area is the basis of the multi-intelligent collaborative generation architecture, and it stores general intelligent agent adapters and multiple role intelligent agent adapters. Each adapter file corresponds to a specific legal professional role. The professional capabilities of these adapters are not from the general model, but are independent parameter files trained through low-rank fine-tuning technology (QLoRA).

[0067] ②, scheduling unit; The scheduling unit is the control core of the multi-intelligent collaborative generation architecture. The input of the scheduling unit is the structured evidence set generated in the previous stage, which contains all the evidence materials, and the original legal consultation request of the user. The core task of the scheduling unit is to perform deep feature analysis on the structured evidence set and the original legal consultation request, and dynamically select 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 user's intention of the input original legal consultation request (the type characteristics of the user's intention include rights protection operation and judgment prediction, etc.).

[0068] Preferably, the role adapter storage area includes a plurality of role adapters, and each role adapter includes a plurality of specialized role adapters, each of which obtains its unique ability by specialized fine-tuning on a specific, high-quality legal corpus. Specifically, the plurality of specialized role adapters includes: General agent adapter: as the base of the system, used for processing relatively broad legal knowledge questions and answers that do not require specific professional perspectives; Lawyer agent adapter: fine-tuned on real legal consultation question and answer data sets to learn to provide party-centered, practical and operable strategy suggestions; Judge agent adapter: fine-tuned on real judicial adjudication document data sets to learn to conduct rigorous and neutral logical analysis, with a language style close to court judgments; Expert agent adapter: fine-tuned on authoritative law journal article data sets to learn to conduct in-depth legal reasoning and theoretical interpretation with a more academic and objective perspective.

[0069] Further preferably, in order to efficiently train the above-mentioned multiple specialized agents under limited computing resources, the present application adopts the QLoRA (Quantized Low-Rank Adaptation) high-efficiency parameter fine-tuning technology. Compared with full-parameter fine-tuning which requires updating all parameters and consumes huge computing resources, and standard LoRA which reduces the training parameters but still needs to load the complete precision (such as 16-bit) base model, resulting in high memory usage, QLoRA reduces the memory usage of the base model through quantization technology, thereby making it possible to train super-large-scale models on a single standard GPU without sacrificing fine-tuning performance.

[0070] In the embodiment, the pre-trained base model is specifically selected as a Qwen3-8B large language model. QLoRA makes it possible to train and deploy the super-large-scale model on a single standard GPU. The implementation principle is as follows: first, the main weights of the Qwen3-8B base model are quantized and frozen by 4-bit normal floating point (NF4) technology, which greatly compresses the volume of the base model; second, a small number of trainable low-rank adapter (LoRA) parameters are introduced on the frozen base model, and only these adapter parameters are updated during training. The change of the original weight can be approximated by the product of two smaller matrices . When the base model is forward propagated, the calculation process of an input is composed of the frozen Qwen3-8B parameters and the adapter, and the mathematical expression is as follows: .

[0071] Through this technology, the method realizes the performance comparable to full-scale fine-tuning at a very small computational cost, which is a key enabling technology for building a multi-agent pool.

[0072] The specific process of generating the final legal consultation reply is as follows: The collaborative working mechanism of the multi-agent collaborative generation architecture follows a "dynamic parameter loading" principle, which is executed by the scheduling unit according to the following steps: (1) Global intention analysis: the scheduling unit receives and deeply analyzes the complete context containing the user's original consultation and the previously retrieved structured evidence set, and extracts the user's intention features.

[0073] (2) Agent selection decision: based on the judgment of the task nature (such as strategic consultation or legal reasoning), the scheduling unit dynamically selects a unique target adapter from the storage area that best matches the task (for example, if it is identified as a rights protection operation intention, the lawyer agent adapter is selected).

[0074] (3) Parameter merging and execution: the generation engine loads the selected adapter parameters ( ) to the video memory, logically merges them with the frozen base large language model parameters ( ), and independently completes the generation of the final reply based on the structured evidence set.

[0075] Through the collaborative working mechanism, the final legal consultation reply with a specific role, professional perspective, authoritative tone, and clear explainability is output under the premise of ensuring the accuracy of the facts.

[0076] Embodiment 2: ​The application also provides a multi-agent legal intelligent question and answer system for implementing the legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval as described in Embodiment 1, comprising a general agent, a lawyer agent, a judge agent and an expert agent. The general agent adapter is used as a base of the system and is used for processing relatively wide legal knowledge questions and answers which do not require specific professional perspectives. The lawyer agent adapter is fine-tuned on a real legal consultation question and answer data set to learn to provide party-centered, practical and operable strategy suggestions. The judge agent adapter is fine-tuned on a real judicial adjudication document data set to learn to perform rigorous and neutral logical analysis, and the language style is close to a court judgment. The expert agent adapter is fine-tuned on an authoritative law journal article data set to learn to perform in-depth legal reasoning and theoretical interpretation, and the perspective is more academic and objective.

[0077] As a further embodiment of the application, the specific data processing flow of the multi-agent legal intelligent question and answer system described above for legal intelligent question and answer is as follows: ① When the multi-agent legal intelligent question and answer system receives a user inputted original legal consultation request, the workflow first starts a structured decomposition stage, the module calls a preset decomposition model, applies a structured task chain mapping logic, deeply analyzes and serializes an unstructured legal problem into a logical independent sub-task queue containing semantic tags of “definition-fact-law-reasoning-action”, and forms a computer executable structured task chain.

[0078] ② For each sub-task in the task chain, the system starts a dynamically weighted mixed retrieval enhancement generation system, which first calculates the feature word weight of the sub-task, and dynamically adjusts the calling proportion of the morphological retriever and the semantic retriever. Subsequently, the module performs weighted inverse order sorting fusion, accurately matches traceable evidence materials from the legal knowledge base, and encapsulates these materials as a structured evidence set, thereby providing a solid fact basis for the generation process and effectively suppressing model hallucination.

[0079] ③ In the multi-agent collaborative generation stage, the workflow unifies the delegation of the complete context containing the original question and the analysis summary to the core scheduling unit. The primary responsibility of the scheduling unit is to analyze the intention characteristics of the context, and according to the evaluation results, accurately select and activate a target role adapter of the most matched task from the adapter repository. The generation engine performs parameter merging and loading operations, loads the selected adapter parameters (adapter parameters) to the video memory, and merges and loads the frozen base model parameters (base model parameters) to the video memory. The generation engine performs parameter merging and loading operations, loads the selected adapter parameters (adapter parameters) to the video memory, and merges and loads the frozen base model parameters (base model parameters) to the video memory. ) logical merging is performed.

[0080] The activated parameter combination inherits the professional ability of a specific role (benefiting from its specialized fine-tuning on a specific legal corpus), writes and outputs the final answer based on the structured evidence set.

[0081] This professional ability, benefiting from its specialized fine-tuning on a specific legal corpus (such as judicial documents, academic journals), ultimately ensures that the output is logically coherent, stylistically uniform, and domain-specific.

[0082] Embodiment 3: The application also includes a computer device comprising a memory and a processor; The memory is used to store a computer program that can run on the processor; The processor is used to implement the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval as described above when the computer program is executed.

[0083] Illustratively, the computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the application. The one or more modules / units can be a series of computer program instruction segments that can complete a specific function, which are used to describe the execution process of the computer program in the computer device.

[0084] The computer device can be a mobile phone, a desktop computer, a notebook, a palm computer, and a cloud server, etc. The computer device can include, but is not limited to, a processor, a memory. For example, the computer device can also include an input / output device, a network access device, a bus, etc.

[0085] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The processor is the control center of the computer device, which connects all parts of the computer device through various interfaces and lines.

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

[0087] The modules / units integrated in the computer device, if realized in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of the above-mentioned various method embodiments can be realized. The computer program includes computer program code, which can be in the form of source code, object code, an executable file, or some intermediate form. The computer readable medium can include any entity or device capable of carrying the computer program code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the computer readable medium can include or exclude contents according to the requirements of legislation and patent practice in a jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.

[0088] Embodiment 4: The application further includes a computer readable storage medium, and the computer readable storage medium stores a computer program. When the processor executes the computer program, the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and hybrid retrieval are realized.

[0089] Compared with the prior art, the embodiment provides a legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval, complex legal knowledge problems are processed through structured decomposition, ensuring that the problems are analyzed comprehensively and orderly, the accuracy of evidence retrieval is improved through mixed retrieval and generation enhancement, and the field professionalism, style controllability and decision explainability of the final reply are improved through multi-agent cooperation to realize legal knowledge question and answer.

[0090] It should be noted that the device embodiments described above are only schematic, and the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. In addition, the connection relationship between the modules in the device embodiment provided by the application indicates that there is a communication connection between them, which can be realized as one or more communication buses or signal lines. Those skilled in the art can understand and implement it without creative labor.

[0091] The above only describes the preferred embodiments of the application and is not intended to limit the application. For those skilled in the art, the application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the application shall be included in the protection scope of the application.

Claims

1. A legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval, characterized in that, Comprising the following steps: Step S1, input the user's original legal consultation request into the decomposition reasoning cognitive framework, and 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 to-be-retrieved subtasks; Step S2, for the structured task chain, each to-be-retrieved subtask is retrieved to generate a retrieval keyword and a retrieval vector; The query-specific quantification dynamic weight distribution mechanism is used to calculate the query feature word weight of each to-be-retrieved subtask; According to the weight, the calling ratio of morphological retrieval and semantic retrieval is dynamically adjusted, and evidence data is obtained from the legal knowledge base in parallel to generate a structured evidence set; Step S3, construct a multi-intelligent collaborative generation architecture; Using the multi-intelligent collaborative generation architecture, the structured evidence set and the original legal consultation request are subjected to deep feature analysis to obtain the type characteristics of the original legal consultation request, and a target role adapter that matches the type characteristics is dynamically selected from the multiple role model adapters of the multi-intelligent collaborative generation architecture; The general parameters of the basic large language model are merged and loaded with the special parameters of the target role adapter, and a legal consultation reply is generated based on the structured evidence set.

2. The legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval according to claim 1, characterized in that, The specific process of obtaining the structured task chain of multiple to-be-retrieved subtasks 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 type task or composite analysis type task; the direct retrieval type task refers to a single knowledge point query with clear target and no need for multi-step reasoning; the composite analysis type task refers to a complex scenario description involving multiple legal relationships, long-chain causal deduction, or legal application conflicts; S1.2, if it is marked as a direct retrieval type task, it is directly passed to step S2 for regular retrieval; If it is marked as a composite analysis type task, it is input into the decomposition reasoning cognitive framework, which performs deep decomposition on the composite analysis type task based on the structured task chain mapping logic to obtain semantic category labels of five consecutive analysis stages including definition, fact, law, reasoning and action, and generates corresponding to-be-retrieved subtasks.

3. The legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval according to claim 2, characterized in that, The specific way of performing feature evaluation on the original legal consultation request is: Using prompt word engineering technology, a single large language model is configured as an evaluation processing unit by loading a pre-set system instruction set; Using the evaluation processing unit, the unstructured natural language text in the original legal consultation request is subjected to feature matching based on pre-set logical judgment rules to determine the task type.

4. The legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval according to claim 3, characterized in that, The logical judgment rules include the following computer execution standards: ①, structured identifier detection; Detect whether the text contains a standard legal regulation citation format; if it does, it is determined to be a direct retrieval type; ②, definition query template detection; Detect whether the text contains an explicit concept inquiry sentence; if it does, it is determined to be a direct retrieval type; ③, decision intent and narrative detection; If the text contains decision words seeking strategic suggestions, legitimacy judgment words, or if the text is a narrative description containing specific case details, it is determined to be a composite analysis type.

5. The legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed 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: identifying individual sub-questions to be retrieved As input, the input to the dynamically weighted hybrid retrieval augmentation generation system of the mutually independent lexical retriever and semantic retriever; The lexical retriever and the semantic retriever perform their respective retrieval algorithms in the legal knowledge base on the received sub-problems to be searched, obtaining search keywords and search vectors.

6. The legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval according to claim 5, characterized in that, The specific way to obtain search keywords is as follows: Use the Chinese word segmentation tool Jieba and load the legal field special dictionary to perform accurate word segmentation on the sub-problems to be searched and each 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 way to obtain search vectors is as follows: adopting a pre-trained language model as an embedding layer, converting the sub-questions to be searched into sub-question vectors , converting text data into text vectors ; cosine similarity of the computed sub-problem vector and the text vector ;​ Based on cosine similarity to evaluate sub-question vectors and text vectors to obtain a search 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 of calculating the query feature word weight of each sub-task to be searched is as follows: Use the term frequency-inverse text data frequency idea in the dynamic weight distribution mechanism of query-specific quantification to quantify the term frequency and inverse text data frequency of each term in the query feature words of each sub-task to be searched. The word frequency is normalized to obtain normalized word frequency ; Normalizing based on word frequency and inverse text data frequency, to compute feature word weights for the sub-questions to be retrieved .​ 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 calling ratio of lexical retrieval and semantic retrieval according to the weight 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. mapping the feature word weights to values in the interval [0, 1] automatically adjusts the weights assigned by the lexical retriever and the semantic retriever based on the changes in the feature word weights .​​ 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 way to generate a structured evidence set in step S2 is as follows: The weighted inverse ranking fusion algorithm is used to calculate the fusion score of any text data ;​ Fusion score The expression of the fusion score is as follows: ; wherein, is any text data a rank in the lexicographic ordered list; is any text data a rank in the semantic ordered list; is a smoothing constant, which serves to reduce the excessive influence of the text data with extremely high ranks 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 stores the obtained evidence-based materials according to subtask labels, calls a bottom large language model to generate a preliminary analysis answer for each to-be-retrieved subproblem ​ Integrate all analysis answers to form a complete structured evidence set.

11. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 9 or 10, characterized in that, The multi-intelligent collaborative generation architecture includes a role adapter storage area and a scheduling unit. The role adapter storage area is the basis of the multi-intelligent collaborative generation architecture, and 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 input the scheduling unit. The scheduling unit performs deep feature analysis, 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.

12. The legal intelligent question answering method based on multi-agent dynamic role scheduling and hybrid retrieval according to claim 11, characterized in that, The role adapter storage area includes multiple role adapters, and a single role adapter includes multiple specialized role adapters. Each specialized role adapter obtains its unique ability by being fine-tuned on specific, high-quality legal corpus. Among them, the multiple patentization role adapters include: General intelligent agent adapter: as the base of the system, used to handle relatively broad legal knowledge questions and answers that do not require specific professional perspectives; Lawyer intelligent agent adapter: fine-tuned on real legal consultation question and answer data sets to learn to provide people-centered, practical, and operable strategic suggestions; Judge intelligent agent adapter: fine-tuned on real judicial documents data sets to learn to perform rigorous and neutral logical analysis, with a language style close to court judgments; Expert intelligent agent adapter: fine-tuned on authoritative law journal article data sets to learn to perform in-depth legal analysis and theoretical interpretation with a more academic and objective perspective.

13. An electronic device, comprising: It includes a memory and a processor; The memory is used to store a computer program that can run on the processor; The processor is used to execute the computer program to realize the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval as claimed in any one of claims 1-12.

14. A computer-readable storage medium, characterized in that, The computer readable storage medium has a computer program stored thereon, and the computer program is executed by the processor to realize the steps of the legal intelligent question and answer method based on multi-agent dynamic role scheduling and mixed retrieval as claimed in any one of claims 1-12.

Citation Information

Patent Citations

  • Chinese legal consultation framework based on large-model multi-agent cooperation

    CN119941458A

  • Intelligent question and answer method and system, intelligent equipment and storage medium

    CN120031125A

  • 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

  • Intelligent questioning and answering method and equipment for legal knowledge and medium

    CN121029961A