Legal consultation service method and system based on multi-agent collaboration and knowledge enhancement
The legal consultation system, which utilizes multi-agent collaboration and knowledge enhancement, automates and coordinates information collection and retrieval, solving the problems of low collaboration efficiency and information omission in existing technologies, and improving the professionalism of legal opinions and responsiveness in high-concurrency scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-04-03
AI Technical Summary
Existing legal consultation systems suffer from problems such as low collaboration efficiency, incomplete information collection, and inaccurate retrieval when dealing with complex legal issues. In particular, resource competition is severe in high-concurrency scenarios, leading to slower response times and information omissions.
By employing a multi-agent collaboration and knowledge enhancement approach, and through intent recognition, multi-turn interaction, vector retrieval, and semantic evaluation using a large language model, the entire process of information collection, retrieval, and generation is automated. Combined with a legal knowledge graph and the FAISS vector index library, resource allocation and information sharing are optimized.
It improves the speed and overall efficiency of handling complex legal issues, enhances the professionalism and credibility of generated legal opinions, supports stable responses in high-concurrency scenarios, lowers the barrier to entry for users, and improves the usability of the service.
Smart Images

Figure CN121786150A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, specifically to a legal consulting service method and system based on multi-agent collaboration and knowledge enhancement. Background Technology
[0002] In recent years, the application of artificial intelligence in the legal field has become increasingly widespread, and numerous patents involving AI-powered legal consultation services have emerged both domestically and internationally. However, existing technologies still have limitations in some key aspects. For example, patent CN202510007910.0 describes a legal assistance method based on a large language model. This method first classifies historical case documents to establish a structured case library, then generates virtual case scenarios based on user needs, and collects records of legal provisions cited by personnel in the scenarios to form a response dataset. The system extracts scenario features to construct a legal provision matching index, then retrieves relevant legal provisions, and verifies the correctness by comparing system recommendations with human answers. However, this method is mainly limited to legal provision matching in a single scenario, failing to fully utilize the active reasoning ability of the large model, and only verifying through simple comparison, lacking an automatic review process; at the same time, the system has weak scalability and does not consider support for multi-role collaboration or high-concurrency scenarios.
[0003] Another patent, CN202411834664.8, proposes a question-answering method based on the MoE model and a legal knowledge graph. Its steps include integrating multi-source legal knowledge to construct a graph, incorporating the MoE architecture into a domain-specific large language model, assigning tasks and processing features through word segmentation and multiple sub-models, then using the knowledge graph to break down complex questions, and having multiple agents collaboratively process and integrate the answers. The main shortcomings of this method are an imperfect agent collaboration mechanism: the division of labor among multiple agents is not clearly defined, easily leading to task allocation conflicts; it also lacks a cross-agent review process, which may result in contradictions or omissions when integrating sub-question results. Furthermore, this patent also fails to address high-concurrency requirements.
[0004] In general, existing legal intelligent agent systems still face several prominent challenges when dealing with complex legal issues: Many systems still rely on single modules to handle tasks, lacking effective collaboration mechanisms between different modules or agents. State and data are difficult to share, easily forming information silos. When dealing with complex cases involving multiple stages and requiring collaboration, this often leads to inefficiency and a lack of context sharing and collaborative reasoning capabilities.
[0005] Faced with the increasing demand for legal services, most existing systems adopt a synchronous processing mode, which is difficult to support high-concurrency scenarios. When multiple users request services at the same time, resource contention and blocking can easily occur, resulting in slower response times and affecting the user experience.
[0006] Current systems often rely on single knowledge bases or models, limiting their ability to deeply understand legal knowledge and comprehensively utilize multi-source information. When generating legal advice, they easily overlook case details or the relevance of legal provisions to the case, resulting in insufficient accuracy and completeness. Furthermore, these systems typically lack automated information review and reflection mechanisms, making it difficult to promptly identify and correct errors or omissions in information collection.
[0007] Existing systems often employ centralized resource allocation, which makes it difficult to achieve efficient utilization of computing resources and easily leads to resource bottlenecks under high concurrency. Task transfer between agents often uses blocking calls, further limiting the system's concurrent processing capabilities and affecting overall performance. Summary of the Invention
[0008] The purpose of this invention is to provide a legal consulting service method and system based on multi-agent collaboration and knowledge enhancement, so as to solve the problems of low collaboration efficiency, incomplete information collection, and inaccurate retrieval in the prior art.
[0009] To achieve the above objectives, the technical solution provided by this invention is: a legal consulting service method based on multi-agent collaboration and knowledge enhancement, comprising the following steps: S1: Receive natural language questions input by the user, create a unique session identifier for the current session, and initialize the agent state to the routing state; S2: Classify the intent of natural language questions based on the intent recognition model; if the classification result is daily dialogue, a lightweight response strategy is used to generate a return reply; if the classification result is legal consultation, the agent state is switched to information collection state, and multi-round interaction is carried out according to the pre-built question tree based on the session identifier to collect case information, while dynamically updating the global context variables associated with the session identifier. S3: When the case information meets the preset completeness conditions, the agent state is switched to the retrieval state, a query vector is generated based on the case information, a similarity retrieval is performed in the vector index library, and the relevance of the retrieval results is evaluated. S4: If the relevance assessment result is lower than the preset threshold, the agent state is switched back to the information collection state to initiate information supplementation. After the information supplementation is completed, return to step S3, regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment; if the relevance assessment result meets the requirements, the agent state is switched to the legal counsel state, integrate the case information and retrieval results, and generate a structured legal opinion.
[0010] To optimize the above technical solution, the specific measures also include: In step S2, the intention classification of natural language questions based on the intention recognition model specifically includes: Calculate the probability distribution of natural language problems falling into two categories: everyday conversation and legal consultation.
[0011] in, For the first Logit score of the class Indicates the first Logit score of the class This indicates that the input text is the first... The probability of a class; Furthermore, based on the calculated probability distribution, the final intent classification result is output.
[0012] In step S2, the step of collecting case information through multiple rounds of interaction according to a pre-constructed question tree specifically includes: Obtain historical dialogue context based on the session identifier; Common case elements extracted from legal knowledge graphs are used to generate guiding questions and collect case information. Furthermore, the global context variables are updated based on the user's response, and the language model is used to determine the completeness of the information collected in order to decide whether to proceed to the next round of interaction or end the collection.
[0013] The process of using a language model to determine the completeness of information collection in order to decide whether to proceed to the next round of interaction or end the collection is as follows: Input the global context variables and a list of key information fields predefined based on the legal knowledge graph into the large language model; Furthermore, the sufficiency of data collection for each key field is assessed using a large language model, and missing or ambiguous case information items are identified. If the case information is deemed sufficient, the data collection process ends; if there are missing or ambiguous items in the case information, targeted questions for the next round of data collection are generated.
[0014] In step S3, the step of generating a query vector based on case information and performing a similarity search in the vector index database specifically includes: The case information is transformed into a high-dimensional vector using an embedding model as the query vector. Furthermore, the query vector is input into a vector index library built on FAISS, and an approximate nearest neighbor search is performed to return the top K legal provisions or case vectors with the highest similarity to the query vector and their corresponding text content.
[0015] In step S3, the relevance assessment of the search results specifically includes: Calculate the cosine similarity between the query vector and the search result vector:
[0016] By inputting the case information and the text content of the search results into a large language model, a semantic association score is obtained through a pre-defined prompt word engineering process. ; Furthermore, the cosine similarity and semantic association score between the query vector and the retrieval result vector are weighted and summed to obtain the final composite relevance score. This composite relevance score is then compared to a preset threshold. The formula for calculating the composite relevance score is as follows:
[0017] in, Represents the query vector; Indicates the first A vector of search results; and Representing vectors respectively sum vector The Euclidean norm; This represents the weighting coefficient.
[0018] In step S4, the process of integrating case information and search results to generate a structured legal opinion is as follows: The complexity of a case is assessed based on the number of information collection rounds, the number of key information fields filled, the length of the case information text, and the entropy value, and then a suitable large language model is scheduled. Furthermore, the integrated case information and search results are filled into the preset legal document generation template to form input prompts; Based on input prompts, the large language model generates a structured legal opinion text containing a heading, factual statements, legal analysis, cited legal provisions, and conclusions and recommendations, and formats it into a downloadable document file.
[0019] As another important technical solution, the present invention also provides a legal consultation service system based on multi-agent collaboration and knowledge enhancement, comprising: The session routing initialization module is used to receive natural language questions input by the user through the client, create a unique session identifier for the current session, and initialize the agent state to the routing state; The intent recognition and classification module is used to classify the intent of natural language questions based on the intent recognition model. If the classification result is a daily conversation, a lightweight response strategy is used to generate and return a reply. If the classification result is a legal consultation, the agent state is switched to the information collection state, and based on the session identifier, multiple rounds of interaction are performed according to the pre-built question tree to collect case information. At the same time, the global context variables associated with the session identifier are dynamically updated. The information retrieval and evaluation module is used to switch the agent's state to retrieval state when the case information meets the preset completeness conditions, generate a query vector based on the case information, perform similarity retrieval in the vector index library, and evaluate the relevance of the retrieval results. The quality assessment and process control module is used to switch the agent's state back to the information collection state to initiate supplementary information collection if the relevance assessment result is lower than the preset threshold. After the supplementary information collection is completed, it returns to the information retrieval and assessment module to regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment. If the relevance assessment result meets the requirements, the agent's state is switched to the legal counsel state, and the case information and retrieval results are integrated to generate a structured legal opinion.
[0020] The present invention also proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described above.
[0021] The present invention also proposes a computer-readable storage medium storing a computer program that enables a computer to execute a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described above.
[0022] Compared with the prior art, the beneficial effects of the present invention are: This invention, through a multi-agent collaborative mechanism and a state-driven workflow, can automatically identify user intent, dynamically collect case information, and automate the entire process of retrieval, evaluation, and generation. The states of each agent are clear and their collaboration is orderly, avoiding information silos and process blockages inherent in traditional single-module processing models, significantly improving the processing speed and overall efficiency of complex legal issues.
[0023] This invention combines a legal knowledge graph to construct a question tree to guide information collection, and employs a dual relevance judgment mechanism of vector retrieval and semantic evaluation using a large language model to ensure that the retrieved legal provisions and cases are highly relevant to the case. Through a dynamic assessment of information completeness and a feedback supplementation mechanism, it effectively reduces information omissions and ambiguous expressions, thereby enhancing the professionalism and credibility of the final legal opinion.
[0024] This invention relies on a lightweight response strategy, asynchronous task scheduling, and efficient vector retrieval based on FAISS. The system can rationally allocate computing resources and avoid unnecessary model calls and retrieval overhead. Even in multi-user concurrent scenarios, the system maintains a stable response, effectively alleviating the performance bottleneck of traditional centralized systems under high loads.
[0025] This invention maintains contextual coherence through multi-turn dialogues and, combined with natural language understanding and generation technologies, enables guided information collection, lowering the barrier to entry for users. The resulting structured legal opinion is formatted correctly, contains complete content, and supports document export, further enhancing the service's usability and user satisfaction.
[0026] The system architecture of this invention features a clear modular design, allowing for flexible configuration of agent states and processes. This facilitates the subsequent integration of new legal knowledge sources, optimization of retrieval models, or expansion of consultation scenarios. Through case complexity assessment and differentiated large language model scheduling, the system can achieve a dynamic balance between resources and effectiveness, adapting to legal service needs of varying complexity. Attached Figure Description
[0027] Figure 1 : A schematic diagram of the process in an embodiment of the present invention. Detailed Implementation The present invention will be further described in detail below through specific embodiments, but it should not be construed as limiting the scope of the subject matter of the present invention to the following embodiments. All technologies implemented based on the above content of the present invention fall within the scope of the present invention.
[0028] The following is an explanation of some of the terms used in this invention: Vector retrieval: Based on text or semantic content, documents are converted into vectors, and the most relevant documents are quickly found through similarity matching.
[0029] Large Language Model (LLM): refers to a natural language processing model based on deep learning that can understand, generate, and process complex language tasks.
[0030] FAISS (Facebook AI Similarity Search): A high-efficiency vector index library for quickly searching high-dimensional vector data, improving document retrieval efficiency.
[0031] Multi-turn dialogue: continuous interaction between the agent and the user, maintaining contextual information to obtain complete document content.
[0032] Intelligent agent: refers to a software entity or system that can perceive its environment, make autonomous decisions, and execute actions. Intelligent agents possess a certain degree of autonomy, responsiveness, goal orientation, and sociality, and can interact with other intelligent agents or users in a specific environment to complete specific tasks.
[0033] The technical solution of the present invention will be further described in detail below with reference to specific embodiments: In some implementations, such as Figure 1As shown, this invention provides a legal consulting service method based on multi-agent collaboration and knowledge enhancement, comprising the following steps: S1: Receive natural language questions input by the user, create a unique session identifier for the current session, and initialize the agent state to the routing state; S2: Classify the intent of natural language questions based on the intent recognition model; if the classification result is daily dialogue, a lightweight response strategy is used to generate a return reply; if the classification result is legal consultation, the agent state is switched to information collection state, and multi-round interaction is carried out according to the pre-built question tree based on the session identifier to collect case information, while dynamically updating the global context variables associated with the session identifier. S3: When the case information meets the preset completeness conditions, the agent state is switched to the retrieval state, a query vector is generated based on the case information, a similarity retrieval is performed in the vector index library, and the relevance of the retrieval results is evaluated. S4: If the relevance assessment result is lower than the preset threshold, the agent state is switched back to the information collection state to initiate information supplementation. After the information supplementation is completed, return to step S3, regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment; if the relevance assessment result meets the requirements, the agent state is switched to the legal counsel state, integrate the case information and retrieval results, and generate a structured legal opinion.
[0034] In some implementations, the intent recognition model is a large language model, with a linear layer added as a Softmax classification head to output the intent category probability; the Softmax layer maps the model's output logits to a probability distribution, in the form of:
[0035] in, For the first Logit score of the class Indicates the first Logit score of the class This indicates that the input text is the first... The probability of a class; Based on the calculated probability distribution, the final intent classification result is output.
[0036] In some implementations, the intent classification results are {daily conversation: 0.12; legal consultation: 0.88}, and the decision threshold and confidence level are set accordingly to distinguish between daily conversation and legal consultation. After three rounds of model fine-tuning, the F1-score on the validation set reaches 95.6%, showing stable performance.
[0037] Preferably, when the system determines that the current user input is a non-legal-related daily conversation (such as greetings, small pleasantries, invalid text, etc.), the system will not schedule subsequent intelligent processing modules, but will adopt a lightweight response strategy, specifically: enter the case information collection process; do not enable vector calculation, text embedding generation, and vector library retrieval; only call the large language model once to reply to the user's question, which greatly reduces the system resource consumption and avoids computationally intensive operations such as multiple large model inferences, vector retrieval, and context processing.
[0038] In step S2, multiple rounds of interaction are conducted according to the pre-built question tree to collect case information, specifically including: Obtain historical dialogue context based on the session identifier; Extract common case elements from legal knowledge graphs, generate guiding questions (such as the time of the dispute, whether there is evidence, etc.), and collect case information; In some implementations, custom Prompt-guided dialogue generation is used (a summary of the current context is embedded in the Prompt), the model is a general question-and-answer format, and a self-developed Prompt library is used.
[0039] The global context variables are updated based on the user's response, and the language model is used to determine the completeness of the information collected in order to decide whether to proceed to the next round of interaction or end the collection.
[0040] The completeness of information collection is determined using a language model to decide whether to proceed to the next round of interaction or end the collection process. The specific process is as follows: Input the global context variables and a list of key information fields predefined based on the legal knowledge graph into the large language model; The sufficiency of data collection for each key field was assessed using a large language model, and missing or ambiguous case information items were identified. If the case information is deemed sufficient, the data collection process ends; if there are missing or ambiguous items in the case information, targeted questions for the next round of data collection are generated.
[0041] In step S3, a query vector is generated based on the case information, and a similarity search is performed in the vector index library, specifically including: The case information is transformed into a high-dimensional vector using an embedding model as the query vector. Input the query vector into a vector index library built on FAISS, perform an approximate nearest neighbor search, and return the top K legal provisions or case vectors with the highest similarity to the query vector and their corresponding text content.
[0042] In some implementations, the vector index library built on FAISS uses Product Quantization (PQ) to decompose the high-dimensional legal text vector space into the Cartesian product of low-dimensional subspaces; by establishing a multi-level quantized index structure (IVF-PQ), coarse-grained clustering (Inverted File System) is performed first, followed by fine-grained quantization; a typical configuration adopts an index structure of IVF4096, PQ64x8 to balance retrieval accuracy and efficiency.
[0043] After preprocessing (word segmentation, noise reduction, etc.) the legal provisions (40k+ clauses) and cases (100k+ precedents), semantic vector representations are generated using high-performance Chinese language models such as BGE-large. FAISS can be used to build vector index structures adapted to different scenarios (such as IndexFlatIP) to support fast k-nearest neighbor (k-NN) queries on large-scale data. Preferably, during the query phase, the user's case summary is also embedded as a query vector, which is input into the vector index library built by FAISS, and the legal provisions or case entries corresponding to the top-k similar vectors are returned.
[0044] In step S3, the relevance of the search results is evaluated, specifically including: Calculate the cosine similarity between the query vector and the search result vector:
[0045] By inputting case information and the text content of search results into a large language model, a semantic relevance score is obtained through pre-defined prompt word engineering. ; The cosine similarity and semantic association score between the query vector and the retrieval result vector are weighted and summed to obtain the final composite relevance score. This composite relevance score is then compared to a preset threshold. The formula for calculating the composite relevance score is as follows:
[0046] in, Represents the query vector; Indicates the first A vector of search results; and Representing vectors respectively sum vector The Euclidean norm; This represents the weighting coefficient.
[0047] In some implementations... , The semantic association score given to the large language model is obtained as follows: The user's case summary is concatenated with the legal provisions or case text to be evaluated and input into a large language model. Using pre-defined prompts, the large language model performs a comprehensive analysis across multiple predefined dimensions, including consistency of cause of action, similarity of key facts, and logical coherence of legal application. It then outputs a comprehensive score between 0 and 100 as a semantic relevance score, with scores closer to 100% indicating higher similarity. The final result... A larger value indicates a stronger match. In some implementations, it is set to: Composite relevance score = 0.7 × vector similarity + 0.3 × semantic association score Preferably, the composite correlation score is less than the threshold (0.6), which triggers information feedback.
[0048] In step S4, the process of integrating case information and search results to generate a structured legal opinion is as follows: The complexity of a case is assessed based on the number of information collection rounds, the number of key information fields filled, the length of the case information text, and the entropy value, and then a suitable large language model is scheduled. In some implementations, the system first extracts key indicators from the information collection process, including the number of information collection rounds, the number and completeness of key information fields filled, the total length of the case description text, and the text information entropy value. Then, a pre-defined weighted scoring model normalizes these indicators into a comprehensive case complexity score. Based on the predefined range of this score (e.g., simple, moderately complex, highly complex), the system intelligently schedules large language model instances with different parameter sizes: for simple cases (low scores), models with smaller parameter sizes and faster reasoning speeds (e.g., 7B parameter models) are scheduled to conserve resources; for moderately complex cases, balanced models (e.g., 14B parameter models) are scheduled; and for highly complex cases (high scores), models with the largest parameter sizes and strongest professional knowledge and reasoning capabilities (e.g., 32B or higher parameter models) are scheduled to achieve precise matching of computing resources and task requirements.
[0049] The integrated case information and search results are then filled into the preset legal document generation template to generate input prompts; Based on input prompts, the large language model generates a structured legal opinion text containing a heading, factual statements, legal analysis, cited legal provisions, and conclusions and recommendations, and formats it into a downloadable document file.
[0050] In another embodiment of the present invention, a legal consultation service system based on multi-agent collaboration and knowledge enhancement is proposed, comprising: The session routing initialization module is used to receive natural language questions input by the user through the client, create a unique session identifier for the current session, and initialize the agent state to the routing state; The intent recognition and classification module is used to classify the intent of natural language questions based on the intent recognition model. If the classification result is a daily conversation, a lightweight response strategy is used to generate and return a reply. If the classification result is a legal consultation, the agent state is switched to the information collection state, and based on the session identifier, multiple rounds of interaction are performed according to the pre-built question tree to collect case information. At the same time, the global context variables associated with the session identifier are dynamically updated. The information retrieval and evaluation module is used to switch the agent's state to retrieval state when the case information meets the preset completeness conditions, generate a query vector based on the case information, perform similarity retrieval in the vector index library, and evaluate the relevance of the retrieval results. The quality assessment and process control module is used to switch the agent's state back to the information collection state to initiate supplementary information collection if the relevance assessment result is lower than the preset threshold. After the supplementary information collection is completed, it returns to the information retrieval and assessment module to regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment. If the relevance assessment result meets the requirements, the agent's state is switched to the legal counsel state, and the case information and retrieval results are integrated to generate a structured legal opinion.
[0051] In another embodiment of the present invention, an electronic device is proposed, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described above.
[0052] In another embodiment of the present invention, a computer-readable storage medium is provided storing a computer program that enables a computer to execute a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described above.
[0053] In the embodiments disclosed in this application, a computer storage medium may be a tangible medium that may contain or store programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of computer storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0054] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications, equivalent substitutions, and improvements made by those skilled in the art to the above embodiments without departing from the scope of the technical solution of the present invention, based on the technical essence of the present invention, shall still fall within the protection scope of the technical solution of the present invention.
Claims
1. A legal consultation service method based on multi-agent collaboration and knowledge enhancement, characterized in that, Includes the following steps: S1: Receive natural language questions input by the user, create a unique session identifier for the current session, and initialize the agent state to the routing state; S2: Intent classification for natural language questions based on intent recognition models; If the classification result is daily conversation, a lightweight response strategy will be used to generate a response. If the classification result is legal consultation, the agent state is switched to information collection state. Based on the session identifier, multiple rounds of interaction are carried out according to the pre-built question tree to collect case information, while the global context variable associated with the session identifier is dynamically updated. S3: When the case information meets the preset completeness conditions, the agent state is switched to the retrieval state, a query vector is generated based on the case information, a similarity retrieval is performed in the vector index library, and the relevance of the retrieval results is evaluated. S4: If the relevance assessment result is lower than the preset threshold, the agent state is switched back to the information collection state to initiate information supplementation. After the information supplementation is completed, return to step S3, regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment; if the relevance assessment result meets the requirements, the agent state is switched to the legal counsel state, integrate the case information and retrieval results, and generate a structured legal opinion.
2. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 1, characterized in that: In step S2, the intention classification of natural language questions based on the intention recognition model specifically includes: Calculate the probability distribution of natural language problems falling into two categories: everyday conversation and legal consultation. in, For the first Logit score of the class Indicates the first Logit score of the class This indicates that the input text is the first... The probability of a class; Based on the calculated probability distribution, the final intent classification result is output.
3. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 1, characterized in that: In step S2, the step of collecting case information through multiple rounds of interaction according to a pre-constructed question tree specifically includes: Obtain historical dialogue context based on the session identifier; Common case elements extracted from legal knowledge graphs are used to generate guiding questions and collect case information. The global context variables are updated based on the user's response, and the language model is used to determine the completeness of the information collected in order to decide whether to proceed to the next round of interaction or end the collection.
4. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 3, characterized in that: The process of using a language model to determine the completeness of information collection in order to decide whether to proceed to the next round of interaction or end the collection is as follows: Input the global context variables and a list of key information fields predefined based on the legal knowledge graph into the large language model; The sufficiency of data collection for each key field was assessed using a large language model, and missing or ambiguous case information items were identified. If the case information is deemed sufficient, the data collection process ends; if there are missing or ambiguous items in the case information, targeted questions for the next round of data collection are generated.
5. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 1, characterized in that: In step S3, the step of generating a query vector based on case information and performing a similarity search in the vector index database specifically includes: The case information is transformed into a high-dimensional vector using an embedding model as the query vector. Input the query vector into a vector index library built on FAISS, perform an approximate nearest neighbor search, and return the top K legal provisions or case vectors with the highest similarity to the query vector and their corresponding text content.
6. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 1, characterized in that: In step S3, the relevance assessment of the search results specifically includes: Calculate the cosine similarity between the query vector and the search result vector: By inputting the case information and the text content of the search results into a large language model, a semantic association score is obtained through a pre-defined prompt word engineering process. ; The cosine similarity and semantic association score between the query vector and the retrieval result vector are weighted and summed to obtain the final composite relevance score. This composite relevance score is then compared to a preset threshold. The formula for calculating the composite relevance score is as follows: in, Represents the query vector; Indicates the first A vector of search results; and Representing vectors respectively sum vector The Euclidean norm; This represents the weighting coefficient.
7. The legal consulting service method based on multi-agent collaboration and knowledge enhancement according to claim 1, characterized in that: In step S4, the process of integrating case information and search results to generate a structured legal opinion is as follows: The complexity of a case is assessed based on the number of information collection rounds, the number of key information fields filled, the length of the case information text, and the entropy value, and then a suitable large language model is scheduled. The integrated case information and search results are then filled into the preset legal document generation template to generate input prompts; Based on input prompts, the large language model generates a structured legal opinion text containing a heading, factual statements, legal analysis, cited legal provisions, and conclusions and recommendations, and formats it into a downloadable document file.
8. A legal consultation service system based on multi-agent collaboration and knowledge enhancement, characterized in that, include: The session routing initialization module is used to receive natural language questions input by the user through the client, create a unique session identifier for the current session, and initialize the agent state to the routing state; The intent recognition and classification module is used to classify the intent of natural language questions based on the intent recognition model; if the classification result is a daily conversation, a lightweight response strategy is used to generate and return a reply. If the classification result is legal consultation, the agent state is switched to information collection state, and based on the session identifier, multiple rounds of interaction are carried out according to the pre-built question tree to collect case information, while the global context variable associated with the session identifier is dynamically updated. The information retrieval and evaluation module is used to switch the agent's state to retrieval state when the case information meets the preset completeness conditions, generate a query vector based on the case information, perform similarity retrieval in the vector index library, and evaluate the relevance of the retrieval results. The quality assessment and process control module is used to switch the agent's state back to the information collection state to initiate supplementary information collection if the relevance assessment result is lower than the preset threshold. After the supplementary information collection is completed, it returns to the information retrieval and assessment module to regenerate the query vector based on the updated case information, perform similarity retrieval and relevance assessment. If the relevance assessment result meets the requirements, the agent's state is switched to the legal counsel state, and the case information and retrieval results are integrated to generate a structured legal opinion.
9. An electronic device, characterized in that, include: The invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program enables the computer to execute a legal consulting service method based on multi-agent collaboration and knowledge enhancement as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Law assistance method based on large language model
CN119397297A
MoE model-based legal knowledge graph question and answer method and system
CN119740664A