Legal consultation methods, devices, electronic equipment and storage media
By constructing a dynamically updated two-layer knowledge graph, the shortcomings of legal consultation agents in cross-conversation memory and legal reasoning are addressed, enabling long-term case correlation and logically rigorous legal responses, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI IFLYTEK INTELLIGENT SYST
- Filing Date
- 2026-01-22
- Publication Date
- 2026-06-02
AI Technical Summary
Existing legal consultation AI agents lack the ability to connect case details across long-term sessions when faced with complex scenarios. They are prone to context loss and logical gaps, and are also prone to creating legal illusions. Lacking logical support, they cannot meet users' long-term and complex legal consultation needs.
We construct a dynamically updated two-layer knowledge graph of facts and legal principles. Through node mapping relationships, we accurately anchor users' colloquial case descriptions to the legal system, enabling long-term memory and logical reasoning, and generating responses that are strictly based on legal provisions and logic.
It achieves long-term memory capabilities across sessions, avoids legal illusions, provides accurate and comprehensive legal services, enhances user experience, and endows the system with proactive logical thinking capabilities similar to those of a lawyer.
Smart Images

Figure CN122132571A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a legal consultation method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the improvement of the rule of law environment, the demand for professional legal advice from enterprises and individuals has risen sharply. Small and medium-sized enterprises seek low-cost and efficient services, and citizens are increasingly aware of their rights in areas such as labor disputes and marriage and family matters, and their willingness to resolve issues through legal means is becoming stronger.
[0003] Currently, the development of large-scale model technology has given rise to legal consultation agents with multi-turn dialogue capabilities. However, these agents still have many problems when facing complex scenarios. On the one hand, they lack the ability to connect case details across long-term conversations, and multiple conversations or interruptions and restarts can easily lead to loss of context and logical gaps, requiring users to repeat their statements. On the other hand, they are prone to generating legal illusions during the service process, and their output responses often lack logical support and legal basis, failing to meet users' long-term and complex legal consultation needs. Summary of the Invention
[0004] This invention provides a legal consultation method, apparatus, electronic device, and storage medium to address the problems of the lack of long-term cross-conversation case correlation capabilities and the tendency to generate legal illusions in the prior art.
[0005] This invention provides a legal consultation method, comprising: Obtain the user's current conversation information; Based on the current dialogue information, the pre-constructed two-layer knowledge graph of facts and legal principles is updated to obtain an updated two-layer knowledge graph; Based on the updated two-layer knowledge graph, a legal consultation response is generated for the user. The two-layer knowledge graph is constructed based on the user's historical dialogue information; the two-layer knowledge graph includes a dynamically updated fact layer graph and a legal layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal nodes in the legal layer graph.
[0006] According to a legal consultation method provided by the present invention, the step of updating a pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information to obtain an updated two-layer knowledge graph includes: Entity extraction is performed on the current dialogue information to obtain new fact nodes and the first association relationship between the new fact nodes; The new fact node and the first association are merged into the fact layer graph to obtain an updated fact layer graph; Based on the node mapping relationship and the updated fact layer graph, the legal layer graph in the two-layer knowledge graph is updated to obtain the updated two-layer knowledge graph.
[0007] According to a legal consultation method provided by the present invention, the step of updating the legal reasoning layer graph in the two-layer knowledge graph based on the node mapping relationship and the updated fact layer graph to obtain the updated two-layer knowledge graph includes: Identify the target fact node in the updated fact layer graph that has been updated; The target fact node is mapped to the legal layer graph, and a second association relationship is established between the target fact node and the corresponding legal node in the mapped legal layer graph to obtain the updated two-layer knowledge graph.
[0008] According to a legal consultation method provided by the present invention, the step of generating a legal consultation response for the user based on the updated two-layer knowledge graph includes: Based on the updated two-layer knowledge graph and the historical dialogue information, graph reasoning information is generated; Based on the graph reasoning information, the completeness of the case information in the fact layer graph of the updated two-layer knowledge graph is judged to obtain the completeness judgment result; Based on the completeness judgment result, the graph reasoning information, and the current dialogue information, a legal consultation response is generated for the user.
[0009] According to a legal consultation method provided by the present invention, generating a legal consultation response for the user based on the completeness judgment result, the graph reasoning information, and the current dialogue information includes: If the completeness judgment result is incomplete, based on the graph reasoning information, determine the fact nodes of missing elements in the fact layer graph of the updated two-layer knowledge graph; Based on the contextual features in the current dialogue information, follow-up questions are generated for the missing factual nodes, and these follow-up questions are used as the legal consultation response.
[0010] According to a legal consultation method provided by the present invention, the step of generating graph reasoning information based on the updated two-layer knowledge graph and the historical dialogue information includes: Traverse the updated two-layer knowledge graph and, based on the node mapping relationship, compare the fact nodes in the fact layer graph with the legal nodes in the legal layer graph. Based on the comparison results, the fact nodes of missing elements and / or legal fact paths to be confirmed in the fact layer graph of the updated two-layer knowledge graph are determined. Based on the historical dialogue information, the fact nodes of the missing elements, and / or the legal fact paths to be confirmed, the graph reasoning information is generated.
[0011] According to a legal consultation method provided by the present invention, generating a legal consultation response for the user based on the completeness judgment result, the graph reasoning information, and the current dialogue information includes: If the completeness judgment result is complete, a complete reasoning path is determined based on the graph reasoning information. The complete reasoning path includes interrelated fact nodes, legal concepts, legal provisions, and typical cases. The fact nodes include event nodes and evidence nodes. Based on the complete reasoning path and the contextual features in the current dialogue information, a legal consultation response is generated that includes at least one of legal basis, operational suggestions, and evidence preparation.
[0012] The present invention also provides a legal consultation device, comprising: The acquisition unit is used to acquire the user's current conversation information; The update unit is used to update the pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information, so as to obtain an updated two-layer knowledge graph. The generation unit is used to generate legal consultation responses for the user based on the updated two-layer knowledge graph; The two-layer knowledge graph is constructed based on the user's historical dialogue information; the two-layer knowledge graph includes a dynamically updated fact layer graph and a legal layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal nodes in the legal layer graph.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the legal consultation method as described above.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the legal consultation method as described above.
[0015] The legal consultation method, device, electronic device, and storage medium provided by this invention construct a dynamically updated two-layer knowledge graph of facts and legal principles. Utilizing the node mapping relationships within this graph, it accurately anchors users' everyday case descriptions to the standardized legal system. This ensures that the generated legal consultation responses are strictly based on legal provisions and logical reasoning, effectively avoiding the legal illusion problem that easily arises from general large models. Simultaneously, by using the graph structure to structurally store historical dialogue information, the system possesses long-term memory capabilities. No matter how long the interval between user inquiries, the system can instantly recall previous case details based on the graph, eliminating the need for user repetition and greatly enhancing the user experience. Furthermore, the two-layer architecture design endows the system with proactive logical thinking capabilities similar to a lawyer, actively guiding users to supplement key information based on missing paths in the graph, thereby providing more accurate and comprehensive legal services. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the legal consultation method provided by the present invention; Figure 2 This is an example diagram of the knowledge system of the two-layer knowledge graph provided by the present invention; Figure 3 This is a flowchart of the update process for the two-layer knowledge graph provided by the present invention; Figure 4 This is an example diagram of the guided questioning process provided by the present invention; Figure 5 This is an example diagram illustrating the legal advice generation process provided by this invention; Figure 6 This is an overall architecture diagram of the legal consultation system provided by the present invention; Figure 7 This is a schematic diagram of the structure of the legal consultation device provided by the present invention; Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0020] In recent years, with the continuous improvement of the domestic legal environment, the demand for professional legal advice from enterprises and individuals has surged. Whether it's small and medium-sized enterprises seeking low-cost, efficient services, or citizens with increasing awareness of their rights in areas such as labor disputes, marriage and family matters, and consumer rights protection, the willingness to resolve issues through legal channels has significantly increased. Against this backdrop, large-scale modeling technology has given rise to a number of intelligent legal advisors. These advisors typically possess multi-turn dialogue, language understanding, and logical reasoning abilities, enabling them to automatically collect case information and provide legal advice.
[0021] However, legal consultation has its unique characteristics. Taking labor dispute consultation as an example, in real-world scenarios, users typically provide information in stages, from the initial confirmation of the employment relationship to subsequent abnormal wage payments, and finally to the submission of evidence for rights protection. This process involves the collection and verification of a large amount of information, and can span from a single conversation to several weeks. Therefore, an ideal intelligent legal consultation system must possess a powerful memory mechanism, capable of dynamically processing continuously input user information and case facts to meet users' long-term, complex consultation needs.
[0022] Current legal consultation systems typically employ a multi-turn dialogue architecture. Its core processes include intent recognition, element extraction and slot filling, and dialogue state management. Specifically, the legal consultation agent in the system first identifies the input from the first few rounds of dialogue, determining the legal cause of the user's inquiry, such as a labor dispute. Then, it uses a large model to extract entity content from the user's input and fills pre-defined case element slots, such as the contract signing date. To achieve a certain length of dialogue memory, a Long Short-Term Memory (LSTM) network combined with an attention mechanism is commonly used to maintain the multi-turn dialogue state. For example, LSTM can support approximately 30 rounds of historical dialogue encoding, focusing on unfilled case information within this range, thus achieving intent tracking and information supplementation in real-time dialogue to a certain extent. Finally, based on the collected case information, the system calls relevant prompts, such as the Prompt command, or a knowledge base to generate legal opinions.
[0023] However, the above solutions still have the following significant shortcomings when facing complex real-world legal consultation scenarios: First, the system lacks the ability to maintain long-term case information connections across multiple sessions. While existing legal consultation systems can maintain a certain length of memory within the current session, such as 30 rounds of historical dialogue, in actual legal consultations, users often restart sessions multiple times over several weeks to supplement case information or continue the consultation. However, existing solutions based on limited context windows or LSTM do not yet possess the ability to maintain long-term case information connections across multiple sessions. If too many dialogue rounds occur or a session is interrupted and restarted, context loss or logical breaks are highly likely, causing the legal consultation agent to forget previous key information and requiring the user to repeat it.
[0024] Secondly, they are prone to creating legal illusions and lack logical support. Specifically, when generating responses, general models often struggle to accurately match the colloquial, everyday facts provided by users with rigorous, abstract legal principles. Due to the lack of a structured fact-to-law mapping mechanism, suggestions generated by existing systems may appear fluent but lack concrete legal basis, or even generate illusory content that does not conform to legal provisions. Furthermore, lacking the rigorous legal reasoning ability of a lawyer, existing systems often appear mechanical and untargeted when guiding users to provide complete information, resulting in insufficient or off-topic information collection and difficulty in generating high-quality legal advice.
[0025] In response, this invention provides a legal consultation method that aims to construct a two-layer dynamic knowledge graph structure that integrates facts and legal principles. By utilizing the mapping relationships between nodes, it bridges the gap between specific case facts and abstract legal principles. Through the structured storage characteristics of the graph, it achieves long-term memory across sessions, enabling dynamic updates of case understanding based on user history and current input. Based on this, it generates legally grounded and logically rigorous legal consultation responses, thereby effectively solving the current problems of missing cross-session memories and illusions of legal reasoning.
[0026] Figure 1 This is a flowchart illustrating the legal consultation method provided by the present invention. This method can be applied to legal consultation systems, intelligent lawyer assistant terminals, cloud servers, etc. Figure 1 As shown, the method includes: Step 110: Obtain the user's current conversation information; Step 120: Based on the current dialogue information, update the pre-constructed two-layer knowledge graph of facts and legal principles to obtain the updated two-layer knowledge graph; Step 130: Generate legal consultation responses for users based on the updated two-layer knowledge graph; The two-layer knowledge graph is constructed based on users' historical dialogue information. It includes a dynamically updated fact layer graph and a legal layer graph, with a node mapping relationship established between fact nodes in the fact layer graph and legal nodes in the legal layer graph.
[0027] Specifically, in response to the problems of cross-conversation memory loss and the tendency to generate legal illusions in existing legal consultation systems, this embodiment of the invention constructs a two-layer knowledge graph that connects specific case details with abstract legal principles, thereby achieving long-term case memory and accurate legal reasoning.
[0028] In detail, in practical applications, legal consultation typically involves a lengthy interactive process. To accurately capture the user's current intentions and the progress of the case, in this embodiment of the invention, the legal consultation system first needs to receive the content input by the user during the current interaction, i.e., the user's current dialogue information. This information may involve new developments in the case, such as received judgments, supplementary evidence, new demands raised by the user, etc. This information, together with the historical dialogue information previously stored in the system based on past interactions, constitutes a complete case background.
[0029] After obtaining the current dialogue information, the system does not directly provide a text-based response. Instead, it inputs the information into a structured knowledge base for processing. This knowledge base is a pre-built two-layer knowledge graph of facts and legal principles. This two-layer knowledge graph is gradually constructed based on the user's historical dialogue information, and it includes a fact layer graph and a legal principle layer graph that are dynamically updated as the dialogue progresses.
[0030] Specifically, during the update process, the system first parses the current dialogue information, extracts specific case elements, and updates these elements into fact nodes in the fact layer graph. These fact nodes can include subject nodes representing the parties involved in the case, such as the consulting user, the defendant company, and relevant third parties; event nodes representing specific case events, such as "signing a contract," "damaged goods," and "unpaid wages"; and evidence nodes representing materials that can prove the case, such as "chat logs," "lawyer's letters," and "contract documents."
[0031] At the same time, the system will search for corresponding legal bases in the jurisprudential layer graph based on the updated fact nodes. This jurisprudential layer graph is a standardized knowledge base pre-built by legal experts. The jurisprudential nodes in it can include legal concepts such as "sales contract disputes" and "liability for breach of contract," specific legal provisions such as specific clauses of the Civil Code, and relevant typical cases.
[0032] To more clearly illustrate the internal structure and logical continuity of the two-layer knowledge graph in the embodiments of the present invention, the knowledge system of the two-layer knowledge graph is described in detail here: Figure 2 This is an example diagram of the knowledge system of the two-layer knowledge graph provided by the present invention, such as... Figure 2 As shown, the legal nodes in the jurisprudential hierarchy include legal concepts, legal provisions, and typical precedents. Legal concepts include subject types (such as individuals, organizations, etc.), event types (such as wage arrears, divorce, etc.), and cause-of-fact types (such as labor disputes, labor contract disputes, prenuptial property disputes, etc.). There is a hierarchical relationship between legal concepts; for example, "labor dispute" is a subordinate concept to "labor contract dispute," while "labor contract dispute" is a higher-level concept.
[0033] Legal provisions include the names of laws and regulations and specific regulations. For example, Article 30 of the *Labor Contract Law of the People's Republic of China* states, "Employers shall pay employees their wages in a timely and full manner in accordance with the labor contract and national regulations." There is a relationship between legal concepts and legal provisions. For instance, the legal concept of "wage arrears" is related to the aforementioned Article 30 of the *Labor Contract Law of the People's Republic of China*.
[0034] Typical precedents refer to specific and relatively typical cases, including case descriptions and judgment results. There is an applicability and correlation between legal provisions and typical precedents, used to clarify the application standards of legal provisions in actual judgments. At the same time, legal concepts are also related to typical precedents.
[0035] In contrast to the relatively static legal layer (legal layer graph), the factual layer (factual layer graph) is constructed entirely based on user dialogue information, aiming to reconstruct the full picture of the case. The factual nodes in the factual layer include subject nodes, event nodes, and evidence nodes. The type of subject node (subject type) is actually defined by the legal concepts of the legal layer. Different subject types have different sets of attributes; for example, an individual's attributes include name, gender, and ID number; an organization's attributes include unified social credit code and address. Furthermore, specific legal or social relationships exist between subject nodes, such as relatives, friends, colleagues, or partners. For example, there is a "work" relationship between "Zhang San" and "Company A." The type of event node (event type) is also defined by the legal concepts of the legal layer. Different event types have different sets of attributes; for example, the event type "wage arrears" includes attributes such as the duration of arrears and the amount of wages owed. Furthermore, different factual nodes have logical relationships such as causality and sequence; for example, there may be a causal relationship between "wage arrears" and "physical conflict." Simultaneously, legal relationships such as parties, victims, and third parties exist between subject nodes and factual nodes.
[0036] Evidence nodes have an inclusion relationship with event nodes. They mainly contain the evidence materials involved in the event nodes. That is, an event type may contain several pieces of evidence supporting it. For example, "wage arrears" may involve evidence materials such as "chat records" and "employment contracts".
[0037] Furthermore, it should be noted that the factual nodes at the factual level and the legal nodes at the jurisprudential level are closely anchored through specific rules. That is, there is a relationship of belonging between the subject nodes at the factual level and the legal concepts at the jurisprudential level, a relationship of association between the event nodes and the legal provisions, and a relationship of similarity between the event nodes and typical precedents.
[0038] The relationship between the fact nodes in the factual layer and the legal nodes in the legal layer described above is shown in the table below: Table of Relationship Types of Nodes in a Two-Layer Knowledge Graph of Facts and Legal Theories In the interaction between the factual and legal layers, the establishment and maintenance of node mapping relationships are crucial. That is, the system precisely maps specific factual nodes, such as "the boss doesn't pay wages," to abstract legal nodes, such as "unpaid wages" and corresponding legal provisions, thereby bridging the gap between real-world case facts and legal regulations. Therefore, in this embodiment of the invention, when updating the two-layer knowledge graph using current dialogue information, it not only updates the factual nodes at the factual layer but also recalculates and establishes the latest mapping connections between the factual nodes and the legal nodes in the legal layer graph based on the latest factual state, thus obtaining an updated two-layer knowledge graph that reflects the latest case facts and legal status.
[0039] Furthermore, once the two-layer knowledge graph is updated, the system will generate legal consultation responses for users based on the complete structured paths within the updated graph. This process is not simply text generation, but rather a reasoning process based on the updated knowledge graph. The system traverses the updated graph, checking the completeness of the path from fact nodes to legal nodes. If the graph shows missing key information, such as a legal node requiring "evidence" for a lawsuit, but the corresponding evidence node in the fact layer is empty, the system will generate a guiding follow-up question, such as "Do you have any relevant evidence?". Conversely, if the graph path is complete and the evidence chain is closed, the system will generate legal consultation opinions including legal basis, operational suggestions, and evidence preparation, thus ensuring the professionalism and logic of the response.
[0040] The legal consultation method provided by this invention constructs a dynamically updated two-layer knowledge graph of facts and legal principles. Utilizing the node mapping relationships within this graph, it accurately anchors users' colloquial and everyday case descriptions to the standardized legal system. This ensures that the generated legal consultation responses are strictly based on legal provisions and logical reasoning, effectively avoiding the legal illusion problem that often arises with generalized large models. Simultaneously, by using the graph structure to structurally store historical dialogue information, the system possesses long-term memory capabilities. No matter how long the interval between user inquiries, the system can instantly recall previous case details based on the graph, eliminating the need for users to repeat themselves and greatly enhancing the user consultation experience. Furthermore, the two-layer architecture design endows the system with proactive logical thinking capabilities similar to a lawyer, enabling it to proactively guide users to supplement key information based on missing paths in the graph, thereby providing more accurate and comprehensive legal services.
[0041] Based on the above embodiments, step 120 includes: Entity extraction is performed on the current dialogue information to obtain new fact nodes and the first association between the new fact nodes; The new fact nodes and the first association are merged into the fact layer graph to obtain the updated fact layer graph; Based on node mapping relationships and the updated fact layer graph, the legal layer graph in the two-layer knowledge graph is updated to obtain the updated two-layer knowledge graph.
[0042] Specifically, the process of updating the two-layer knowledge graph of facts and legal principles based on the current dialogue information can include: Figure 3 This is a flowchart of the update process for the two-layer knowledge graph provided by the present invention, such as... Figure 3 As shown, in the specific graph update process, the system first needs to transform the user input into structured data that the computer can understand. This process involves entity extraction from the current dialogue information to obtain new fact nodes and the first relationships between these new fact nodes. Specifically, the system uses natural language processing techniques, such as named entity recognition and relation extraction, to perform semantic analysis on the user input. For example, when the user inputs "I have sent a lawyer's letter to Company B," the system identifies "lawyer's letter" (evidence node in the fact node) and "Company B" (subject node in the fact node), which are the new fact nodes. Simultaneously, the system parses the logical connections between these new fact nodes within the current statement, such as the "sending" action between "I" and "lawyer's letter," and the "receiving" object relationship between "lawyer's letter" and "Company B." These local connections existing only within the current input constitute the first relationships.
[0043] After acquiring fragmented new knowledge, the system needs to connect it to the overall case context. This involves merging new fact nodes and primary relationships into a pre-constructed fact layer graph, resulting in an updated fact layer graph. This process is not a simple addition but includes entity alignment and subgraph fusion. Specifically, the system compares the newly extracted micro-subgraphs (new fact nodes and primary relationships) with the existing fact layer graph to find connection points. For example, if the existing fact layer graph contains an event node of "damaged goods," the system, based on contextual reasoning, will establish a connection between the newly extracted evidence node "lawyer's letter" and the historical event node "damaged goods," thus weaving isolated new clues into a complete case network, forming an expanded fact layer graph—the updated fact layer graph.
[0044] After the factual layer is updated, to provide legal basis for these factual nodes, the system updates the existing legal theory layer graph based on the node mapping relationship and the updated factual layer graph, resulting in an updated two-layer knowledge graph. Here, updating the existing legal theory layer graph mainly involves activating legal knowledge paths related to the new factual nodes. That is, the system automatically scans the updated factual layer graph using preset node mapping relationships; once an updated factual node is detected, the mapping mechanism is triggered to find the corresponding legal concepts, legal provisions, and typical precedents in the legal theory layer graph, and to establish or activate connections between the new factual node and these legal theory nodes. Through this process, the system not only records "what happened" (factual layer) but also understands in real time "what legal consequences this means" (legal theory layer), thus completing the update of the entire two-layer knowledge graph and obtaining the updated two-layer knowledge graph.
[0045] In this embodiment of the invention, through progressive processing of entity extraction, graph fusion, and legal mapping, unstructured user speech is transformed into structured two-layer graph data in real time. This not only accurately captures subtle changes in the case during the current dialogue, but also automatically links these fragmented pieces of information to the historical case context and further automatically matches the corresponding legal norms. This ensures that the system's understanding of the case is dynamic and always has a legal perspective, thus laying a solid data foundation for generating accurate legal advice in the future.
[0046] Based on the above embodiments, the legal layer graph in the two-layer knowledge graph is updated based on the node mapping relationship and the updated fact layer graph, resulting in an updated two-layer knowledge graph, including: Identify the target fact node in the updated fact layer graph that has been updated; The target fact node is mapped to the legal layer graph, and a second association relationship is established between the target fact node and the corresponding legal node in the mapped legal layer graph, thus obtaining an updated two-layer knowledge graph.
[0047] Specifically, in order to ensure that the legal layer can reflect the latest changes in the factual layer in real time and accurately, while avoiding redundant calculations on the full graph, an incremental mapping update strategy is adopted in this embodiment of the invention.
[0048] In detail, during the update process of the two-layer knowledge graph, the system first needs to identify the target fact nodes that have been updated in the fact layer graph. Here, "target fact node" is a specific concept related to the dynamic changes in the graph; it does not refer to all nodes in the graph, but specifically to the fact nodes that have been updated in this interaction, such as newly extracted fact nodes or existing fact nodes whose attributes have changed. By locking onto these changed "active" nodes, the system can accurately pinpoint the key issues in the case that require legal characterization.
[0049] After identifying these changing nodes, the system maps the target fact nodes to the legal principle layer graph and establishes a second association between the target fact nodes and their corresponding legal principle nodes in the mapped legal principle layer graph, thereby updating the two-layer knowledge graph. During this process, the system uses pre-defined node mapping relationships to find the corresponding legal principle nodes in the legal principle layer graph for each target fact node, and establishes or activates connections between these target fact nodes and their corresponding legal principle nodes—the second association. Unlike the first association, which exists only within the fact layer, this second association spans the data layer and connects facts and legal principles; it manifests as a belonging relationship, an association relationship, or a similarity relationship. By establishing this cross-layer second association, the system successfully translates real-world changes into the legal rule system, thus completing the update of the entire two-layer knowledge graph.
[0050] In this embodiment of the invention, the graph is updated through an incremental mapping mechanism, so that the system does not need to recalculate the legal relationships of the entire graph in each round of interaction, but only needs to focus on the latest developments of the case, thus achieving optimized allocation of computing resources. At the same time, by establishing a clear second relationship between facts and legal principles, the system can anchor each specific case detail to a precise legal concept or legal provision. This verifiable and structured connection provides a solid underlying logical support for the subsequent generation of logically rigorous and illusory legal advice.
[0051] Based on the above embodiments, step 130 includes: Generate graph reasoning information based on updated two-layer knowledge graph and historical dialogue information; Based on graph reasoning information, a completeness judgment is made on the case information in the fact layer graph of the updated two-layer knowledge graph, and a completeness judgment result is obtained. Based on the completeness judgment result, graph reasoning information, and current dialogue information, a legal consultation response is generated for the user.
[0052] Specifically, after updating the two-layer knowledge graph, the system possesses the latest complete picture of the case and the legal mapping status. Based on this, in order to generate intelligent and professional responses, this embodiment of the invention employs a phased reasoning and decision-making mechanism.
[0053] In detail, when generating legal consultation responses based on the updated two-layer knowledge graph, the system does not simply statically read the graph. Instead, it performs in-depth analysis in conjunction with the context. Specifically, the system first generates graph reasoning information based on the updated two-layer knowledge graph and historical dialogue information. This graph reasoning information is an intermediate state of data generated by the system after logical operations. It not only includes nodes and edges (relationships) in the graph but also integrates the system's comprehensive understanding of historical dialogue information, i.e., the user's long-term statements. Specifically, the system compares fact nodes in the fact layer of the updated two-layer knowledge graph with legal nodes in the legal layer, thereby generating a comprehensive reasoning report that includes "confirmed facts," "derived legal relationships," and "potential missing elements." For example, the graph reasoning information might indicate that "although the breach of contract has been confirmed, there is currently a lack of evidence nodes regarding the calculation of compensation amounts."
[0054] Next, the system uses this comprehensive reasoning report to assess the current consultation status. Specifically, based on the graph reasoning information, it performs a completeness judgment on the case information in the factual layer of the updated two-layer knowledge graph, obtaining a completeness judgment result. This process essentially verifies whether the case information in the factual layer graph is sufficient to support a complete legal conclusion. Specifically, the system checks whether there are key "empty slots" in the graph reasoning information. For example, for a legal concept like "labor arbitration," the jurisprudential layer requires the factual layer to have three core factual nodes: "proof of employment relationship," "tort facts," and "arbitration claim." If the graph reasoning information shows that only the first two are present in the factual layer of the updated two-layer knowledge graph, the system determines that the case information is incomplete, resulting in a completeness judgment result indicating incompleteness. Conversely, if all key legal elements have corresponding factual nodes in the factual layer, the system outputs a completeness judgment result indicating completeness.
[0055] Following this, the system will determine the strategy and content of its response based on the completeness assessment result. Specifically, it will generate a legal consultation response tailored to the user based on the completeness assessment result, graph reasoning information, and the current dialogue information. In this process, the current dialogue information plays a role in adjusting the context and tone, the graph reasoning information provides the core logical material for the response, and the completeness assessment result determines the type of response. For example, if the completeness assessment result is incomplete, the system will combine the missing items indicated by the graph reasoning information, such as the missing "pay slip," and generate guiding follow-up questions in accordance with the current dialogue context. If the completeness assessment result is complete, the system will generate definitive legal advice based on the complete chain of evidence in the graph reasoning information.
[0056] In this embodiment of the invention, through the graph reasoning information generation and completeness judgment mechanism, the system can move beyond the simple keyword matching mode and instead simulate the lawyer's thought process. It first comprehensively considers the whole case to make inferences, then assesses whether the current information is sufficient to draw a conclusion, and finally provides a response. This not only ensures that the system can proactively and accurately guide users to supplement key details when information is insufficient, avoiding ineffective generalities, but also ensures that when providing legal advice, the advice is based on a sufficient and complete factual foundation, thereby greatly enhancing the system's intelligent interaction capabilities and users' trust in the consultation results.
[0057] Based on the above embodiments, and based on the completeness judgment result, graph reasoning information, and current dialogue information, a legal consultation response is generated for the user, including: If the completeness judgment result is incomplete, based on the graph reasoning information, determine the fact nodes of missing elements in the fact layer graph of the two-layer knowledge graph to update; Based on the contextual features of the current dialogue information, follow-up questions are generated for the missing factual nodes, and these follow-up questions are used as legal consultation responses.
[0058] Specifically, Figure 4 This is an example diagram of the guided questioning process provided by the present invention, such as... Figure 4 As shown, after the system evaluates the current case information, if the completeness judgment result is incomplete, it means that the current factual layer map does not yet contain all the key elements sufficient to support a specific legal conclusion. At this time, the system will enter the active information collection mode to generate guiding follow-up questions.
[0059] In detail, under this model, the system first needs to accurately pinpoint what is missing. Specifically, based on graph reasoning information, it can determine the missing fact nodes in the fact layer of the two-layer knowledge graph that are being updated. During this process, the system deeply analyzes the graph reasoning information, which, by comparing the differences between the fact layer and the legal layer, clearly identifies breakpoints in the legal logic chain. The system will then identify these breakpoints as fact nodes representing missing elements. For example, when handling a "debt dispute," the legal layer shows that "winning" usually depends on key evidence such as "IOUs" or "transfer records," while the graph reasoning information shows that these fact nodes in the fact layer are empty. In this case, the system will identify "IOUs" or "transfer records" as the missing fact nodes that need to be supplemented.
[0060] After clarifying "what to ask," the system then needs to address "how to ask." That is, based on the contextual features of the current dialogue, it generates follow-up questions targeting the missing factual elements and presents these follow-up questions as legal consultation responses to the user. Specifically, the system doesn't mechanically throw out the missing factual elements directly, such as simply replying "IOU?". Instead, it extracts contextual features from the current dialogue, such as the user's emotions, the current focus of the conversation, and language style. Combining these contextual features, it packages the inquiry about the missing factual elements into natural and fluent follow-up questions. For example, if the user just said, "He keeps delaying paying back the money, and I'm very angry," the system will generate a response that both soothes the user's emotions and guides the conversation: "I understand how you feel. In order to help you recover the debt through legal means, do you have a written IOU or records of the transfers between the two parties?" Ultimately, this sentence is output as a legal consultation response.
[0061] The following example illustrates the process of generating guiding follow-up questions: Suppose the user (Company A) interacted with the system in multiple rounds, and the dialogue log is as follows: "1. User (Company A): Hello, we have signed a long-term sales contract with Company B. Company B regularly supplies us with glass. Recently, a batch of goods we received was mostly damaged. I want to sue Company B." 2. System: Understood. What is your request? 3. User (Company A): Demanding compensation for losses... 4. System: Please provide the contract you signed with the other party at the time so that I can better analyze the problem for you; 5. ... 6. User (Company A): Hello, please review this contract for me; 7. User (Company A): [Document] Contract Contents... 8. System: Okay, please wait; 9. System: Hello, your contract has been reviewed and completed. Please download and view it. 10. User (Company A): Hello, I want to sue Company B directly. The evidence materials have been sent in the previous lawyer's letter; 11. System: Okay, please confirm that the delivery receipt and proof of receipt for the lawyer's letter are complete. 12. User (Company A): Yes, the other party has signed for the lawyer's letter; 13. System: Thinking...
[0062] In the above dialogue log, 1 to 4 are historical dialogue information (long-term memory part), 6 to 9 are other tasks inserted in between, and 10 to 13 are current dialogue information.
[0063] Based on the above information, the system updates the two-layer knowledge graph and generates the following graph reasoning information (for simplicity, only the main content is shown): "
main body
event
evidence
[0064] Based on the aforementioned graph reasoning information, the system will perform a completeness check. When the "claim" in the latest "lawsuit (EVENT-004)" event is found to be "null," the completeness check result is determined to be incomplete. Further analysis by the system reveals that although the user had previously requested "compensation of 200,000 yuan" in the "sending a lawyer's letter (EVENT-003)" event, considering that a period of time has passed since the user sent the lawyer's letter (June 30, 2025) to the present (July 5, 2025), and based on common legal knowledge, delayed performance usually incurs interest losses.
[0065] Based on this, the system, considering the current context, generates a follow-up question addressing this missing element (a more precise request), namely: "13. System: Okay, our core claim remains that Company B should compensate us for the direct economic losses caused by the damage to the goods. In addition to the principal amount of the goods loss, should we also claim overdue payment interest or losses due to the other party's delay in fulfilling its compensation obligations?"
[0066] Through this process, the system successfully transformed the missing "demand" into a professional legal inquiry, demonstrating its proactive guidance capabilities.
[0067] In this embodiment of the invention, by accurately locating the factual nodes of missing elements and generating follow-up questions in combination with the context, the rigidity of traditional fill-in-the-blank question-and-answer is changed. This allows the system to be like an experienced lawyer, keenly discovering evidentiary loopholes or information gaps in the case, and guiding users to supplement key information in a way that fits the current dialogue context. This not only ensures that subsequent legal advice is based on complete facts, but also effectively avoids erroneous judgments caused by missing information, greatly improving the success rate of information collection and the user's consultation experience, and significantly optimizing the system's interaction efficiency and anthropomorphism.
[0068] Based on the above embodiments, graph reasoning information is generated based on the updated two-layer knowledge graph and historical dialogue information, including: The two-layer knowledge graph is traversed and updated. Based on the node mapping relationship, the fact nodes in the fact layer graph are compared with the legal nodes in the legal layer graph. Based on the comparison results, the fact nodes of missing elements and / or legal fact paths to be confirmed in the fact layer graph of the updated two-layer knowledge graph are identified. Based on historical dialogue information, as well as fact nodes with missing elements and / or legal fact paths to be confirmed, graph reasoning information is generated.
[0069] Specifically, the process of generating graph reasoning information based on updating the two-layer knowledge graph and historical dialogue information can include: In detail, the system first needs to conduct a comprehensive examination of the entire knowledge system, that is, to traverse and update the two-layer knowledge graph. Based on the node mapping relationship, it compares the fact nodes in the fact layer graph with the legal nodes in the legal layer graph. In this process, the system will follow the structural path of updating the two-layer knowledge graph, using the preset node mapping relationship as a bridge, and check one by one whether the existing fact nodes in the fact layer graph meet the logical requirements of the corresponding legal nodes in the legal layer graph. For example, the "work injury compensation" node in the legal layer graph has three necessary subordinate nodes: "employment relationship," "work injury certificate," and "medical expense receipts." The system will check whether these three specific fact nodes are also mapped in the fact layer graph.
[0070] Through comprehensive comparison, the system can generate a detailed discrepancy report. Based on the comparison results, it identifies missing fact nodes and / or pending legal fact paths in the fact layer of the two-layer knowledge graph. Missing fact nodes refer to nodes that must exist in the jurisprudential layer but have not yet been filled in the fact layer. Pending legal fact paths refer to paths where nodes exist, but their attributes or connections are unclear, making it impossible to deduce a precise legal consequence. For example, although the fact layer graph contains a "contract" node, its "validity" attribute is unknown, making it impossible to establish the complete legal path from "contract validity to breach of contract liability."
[0071] Following this, the system integrates the aforementioned structured missing and unconfirmed items with historical dialogue information. Specifically, it generates graph reasoning information based on historical dialogue information, fact nodes of missing elements in the fact-layer graph, and / or legal fact paths to be confirmed. Since simple missing graph nodes may be implicitly mentioned or corroborated in historical dialogue information, the system will combine the user's past statements to correct or annotate simple missing graph items. For example, although the "evidence" node in the graph may be empty, if the user mentioned "I have a photo" in a historical dialogue, the graph reasoning information will mark it as "evidence node missing, but historical mention of a photo, needs confirmation." The final generated graph reasoning information not only includes hard missing items at the graph level but also soft clues based on historical dialogue information, thus providing a high-information-density basis for subsequent decision-making.
[0072] In this embodiment of the invention, through full-map comparison and deep integration with historical dialogue information, extremely high-precision legal logic reasoning is achieved. It can not only accurately identify specific evidence gaps and logical breaks in the case, but also intelligently verify these gaps in combination with the historical dialogue context. This avoids the system repeatedly asking questions about information that the user has already mentioned but has not yet structured, so that the final generated graph reasoning information is a comprehensive report that combines legal rigor with a sense of dialogue context. This allows the system to formulate the most reasonable next step strategy based on a comprehensive understanding of the case details and legal requirements, just like a professional lawyer.
[0073] Based on the above embodiments, and based on the completeness judgment result, graph reasoning information, and current dialogue information, a legal consultation response is generated for the user, including: If the completeness assessment result is complete, a complete reasoning path is determined based on the graph reasoning information. The complete reasoning path includes interrelated fact nodes, legal concepts, legal provisions, and typical cases; fact nodes include event nodes and evidence nodes. Based on the complete reasoning path and the contextual features in the current dialogue information, a legal consultation response is generated that includes at least one of the following: legal basis, operational suggestions, and evidence preparation.
[0074] Specifically, Figure 5 This is an example diagram of the legal advice generation process provided by the present invention, such as... Figure 5 As shown, after the system evaluates the current case information, if the completeness judgment result is complete, it means that the case information provided by the user has formed a closed loop, which is sufficient to support the system to give a definite legal opinion. At this time, the system enters the suggestion generation mode to generate legal suggestions for the user.
[0075] In detail, under this model, the system first needs to construct a logically rigorous chain of legal argumentation, that is, a complete reasoning path. This complete reasoning path is the core basis for generating high-quality responses. It is a structured link that runs through and updates the two-layer knowledge graph, containing interrelated factual nodes, legal concepts, legal provisions, and typical precedents.
[0076] Specifically, the system extracts confirmed event nodes (such as "goods damaged in transit") and evidence nodes (such as "transportation contract," "damage photos," etc.) from the graph reasoning information, and then finds the corresponding legal nodes (such as the legal concept of "risk transfer rule," Article 604 of the Civil Code, and the typical case of "a certain sales contract dispute") by following the node mapping relationship. This path fully demonstrates the logical process of "what event happened, what legal provisions were followed, what precedents were referenced, and therefore what conclusion was reached."
[0077] Next, the system needs to translate this complete reasoning path into natural language that is easy for the user to understand. This involves generating a legal consultation response based on the complete reasoning path and the contextual features of the current dialogue. In this process, the system not only cites legal provisions and typical precedents from the complete reasoning path as legal basis, but also considers the contextual features of the current dialogue (such as whether the user is asking "What should I do?" or "Do I have a chance of winning?") to provide targeted operational suggestions, such as "We suggest you directly sue the seller." Simultaneously, the response will also provide specific evidence (such as shipping contracts or waybills, post-arrival inspection records, photos, acceptance forms, etc.) to enhance the persuasiveness of the advice.
[0078] To illustrate the above process more intuitively, this embodiment of the invention uses a specific example to explain the process of generating legal advice: Continuing from the previous example, the following is a further transcript of the conversation: "... 13. System: Okay, our core claim remains that Company B should compensate us for the direct economic losses caused by the damaged goods. Besides the principal amount of the lost goods, should we also claim overdue payment interest or losses due to the other party's delayed fulfillment of its compensation obligations? 14. User (Company A): Yes. However, there's a problem. They believe the damage to the goods was caused by the transportation company and want us to contact them, claiming the responsibility doesn't lie with Company B. Is that correct? 15. System: Thinking... In the above dialogue log, number 14 is a question raised by the user regarding the attribution of legal responsibility. At this point, the system determines to enter suggestion generation mode. That is, the system first needs to trace back the historical dialogue information and locate the evidence node "Contract" that is strongly related to the "lawsuit (EVENT-004)" event. The system reads the detailed attributes of this evidence node, namely the clause in the contract regarding liability for breach of contract: "Party B is responsible for packaging and transportation, and all risks until the goods are unloaded from Party A's warehouse shall be borne by Party B."
[0079] Based on this key factual node, the system can construct a complete reasoning path, namely, from the "contractual risk clause" to the "sales contract risk transfer rules", and then link to the logically rigorous legal argumentation chain of "Articles 603, 604 and 512 of the Civil Code of the People's Republic of China".
[0080] Finally, based on the current dialogue information (the user's question about who to seek compensation from), the system generated the following legal consultation response, which includes legal basis, operational suggestions, and evidence preparation, based on the complete reasoning path described above: "15. System: Okay, I understand your concerns. I noticed that the contract clearly stipulates that 'Party B is responsible for packaging and transportation, and all risks until the goods are unloaded from Party A's warehouse shall be borne by Party B.' According to Articles 603, 604, and 512 of the Civil Code of the People's Republic of China, you have the full right to directly claim compensation from Company B. If the seller seeks to hold the carrier liable, that is a matter of internal settlement and recourse, and is unrelated to the buyer's direct claim."
[0081] Operation suggestions: Target of letter or lawsuit: You can directly state in the complaint "Request the seller to bear the liability for compensation for damage caused during transportation"; Evidence preparation: A transport contract or waybill (proving that the seller is liable for transport); Inspection records, photos, and acceptance forms upon arrival (proving the fact and extent of damage); The basis for loss calculation includes invoices, quotations, and details of repurchase or repair costs.
[0082] In this embodiment of the invention, by constructing a complete reasoning path that includes facts, concepts, legal provisions, and precedents, and generating responses in conjunction with context, the professionalism and interpretability of legal consultation advice are achieved. Unlike traditional large-scale models that generate responses based solely on probability, each response generated in this embodiment is anchored to a specific graph path, ensuring the accurate citation of legal basis and the rigor of logical deduction, greatly eliminating legal illusions. Simultaneously, the response content integrates legal basis, practical advice, and evidence preparation, allowing users not only to know what (operational advice) but also why (legal basis), providing a detailed and well-founded legal consultation service like that of a professional lawyer.
[0083] The system architecture of the legal consultation system provided by this invention will be described below: Figure 6 This is an overall architecture diagram of the legal consultation system provided by the present invention, as shown below. Figure 6 As shown, the system mainly consists of a dialogue management agent, a knowledge graph agent, and a core two-layer knowledge graph of facts and legal principles. The dialogue management agent, as the front-end interaction hub, is responsible for controlling the dialogue flow, maintaining long and short-term memory, extracting and judging the completeness of information, and generating the final legal consultation response. The knowledge graph agent, as the back-end intelligent brain, focuses on managing the lifecycle of the two-layer knowledge graph, including real-time dynamic updates, precise alignment of fact nodes and legal principle nodes, and generating in-depth graph reasoning information.
[0084] During the collaborative operation of the system, a unique dual-graph-driven mechanism is employed. On the one hand, a dynamically constructed fact-layer graph captures the micro-details of individual cases and connects historical memories across conversations to ensure that the case is "not forgotten." On the other hand, a jurisprudential-layer graph provides macro-level legal norms and logical templates to ensure that the reasoning is "accurate." Through the close collaboration of the two agents on the dual-layer knowledge graph, the system can transform the user's unstructured natural language into a structured legal reasoning path. This enables legal consultation services with long-term memory capabilities, proactive guidance capabilities, and rigorous legal logic in complex and long-term legal consultation scenarios.
[0085] The legal consultation device provided by the present invention is described below. The legal consultation device described below can be referred to in correspondence with the legal consultation method described above.
[0086] Figure 7 This is a schematic diagram of the legal consultation device provided by the present invention, as shown below. Figure 7 As shown, the device includes: Acquisition unit 710 is used to acquire the user's current dialogue information; The updating unit 720 is used to update the pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information, so as to obtain an updated two-layer knowledge graph; The generation unit 730 is used to generate a legal consultation response for the user based on the updated two-layer knowledge graph; The two-layer knowledge graph is constructed based on the user's historical dialogue information; the two-layer knowledge graph includes a dynamically updated fact layer graph and a legal layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal nodes in the legal layer graph.
[0087] The legal consultation device provided by this invention constructs a dynamically updated two-layer knowledge graph of facts and legal principles. Utilizing the node mapping relationships within this graph, it accurately anchors users' colloquial and everyday case descriptions to the standardized legal system. This ensures that the generated legal consultation responses are strictly based on legal provisions and logical reasoning, effectively avoiding the legal illusion problem that often arises with generic large models. Simultaneously, by using the graph structure to structurally store historical dialogue information, the system possesses long-term memory capabilities. No matter how long the interval between user inquiries, the system can instantly recall previous case details based on the graph, eliminating the need for users to repeat themselves and greatly enhancing the user consultation experience. Furthermore, the two-layer architecture design endows the system with proactive logical thinking capabilities similar to a lawyer, enabling it to proactively guide users to supplement key information based on missing paths in the graph, thereby providing more accurate and comprehensive legal services.
[0088] Based on the above embodiments, the updating unit 720 is used for: Entity extraction is performed on the current dialogue information to obtain new fact nodes and the first association relationship between the new fact nodes; The new fact node and the first association are merged into the fact layer graph to obtain an updated fact layer graph; Based on the node mapping relationship and the updated fact layer graph, the legal layer graph in the two-layer knowledge graph is updated to obtain the updated two-layer knowledge graph.
[0089] Based on the above embodiments, the updating unit 720 is used for: Identify the target fact node in the updated fact layer graph that has been updated; The target fact node is mapped to the legal layer graph, and a second association relationship is established between the target fact node and the corresponding legal node in the mapped legal layer graph to obtain the updated two-layer knowledge graph.
[0090] Based on the above embodiments, the generation unit 730 is used for: Based on the updated two-layer knowledge graph and the historical dialogue information, graph reasoning information is generated; Based on the graph reasoning information, the completeness of the case information in the fact layer graph of the updated two-layer knowledge graph is judged to obtain the completeness judgment result; Based on the completeness judgment result, the graph reasoning information, and the current dialogue information, a legal consultation response is generated for the user.
[0091] Based on the above embodiments, the generation unit 730 is used for: If the completeness judgment result is incomplete, based on the graph reasoning information, determine the fact nodes of missing elements in the fact layer graph of the updated two-layer knowledge graph; Based on the contextual features in the current dialogue information, follow-up questions are generated for the missing factual nodes, and these follow-up questions are used as the legal consultation response.
[0092] Based on the above embodiments, the generation unit 730 is used for: Traverse the updated two-layer knowledge graph and, based on the node mapping relationship, compare the fact nodes in the fact layer graph with the legal nodes in the legal layer graph. Based on the comparison results, the fact nodes of missing elements and / or legal fact paths to be confirmed in the fact layer graph of the updated two-layer knowledge graph are determined. Based on the historical dialogue information, the fact nodes of the missing elements, and / or the legal fact paths to be confirmed, the graph reasoning information is generated.
[0093] Based on the above embodiments, the generation unit 730 is used for: If the completeness judgment result is complete, a complete reasoning path is determined based on the graph reasoning information. The complete reasoning path includes interrelated fact nodes, legal concepts, legal provisions, and typical cases. The fact nodes include event nodes and evidence nodes. Based on the complete reasoning path and the contextual features in the current dialogue information, a legal consultation response is generated that includes at least one of legal basis, operational suggestions, and evidence preparation.
[0094] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8As shown, the electronic device may include a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, communications interface 820, and memory 830 communicate with each other via the communication bus 840. The processor 810 can invoke logical instructions in the memory 830 to execute a legal consultation method, which includes: acquiring the user's current dialogue information; updating a pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information to obtain an updated two-layer knowledge graph; and generating a legal consultation response for the user based on the updated two-layer knowledge graph. The two-layer knowledge graph is constructed based on the user's historical dialogue information. The two-layer knowledge graph includes a dynamically updated fact layer graph and a legal principle layer graph, and a node mapping relationship is established between fact nodes in the fact layer graph and legal principle nodes in the legal principle layer graph.
[0095] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0096] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the legal consultation method provided by the above methods, the method comprising: obtaining the user's current dialogue information; updating a pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information to obtain an updated two-layer knowledge graph; generating a legal consultation response for the user based on the updated two-layer knowledge graph; wherein the two-layer knowledge graph is constructed based on the user's historical dialogue information; the two-layer knowledge graph includes a dynamically updated fact layer graph and a legal principle layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal principle nodes in the legal principle layer graph.
[0097] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the legal consultation method provided by the methods described above. The method includes: acquiring the user's current dialogue information; updating a pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information to obtain an updated two-layer knowledge graph; and generating a legal consultation response for the user based on the updated two-layer knowledge graph. The two-layer knowledge graph is constructed based on the user's historical dialogue information. The two-layer knowledge graph includes a dynamically updated fact layer graph and a legal principle layer graph, and a node mapping relationship is established between fact nodes in the fact layer graph and legal principle nodes in the legal principle layer graph.
[0098] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0099] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A legal consultation method, characterized in that, include: Obtain the user's current conversation information; Based on the current dialogue information, the pre-constructed two-layer knowledge graph of facts and legal principles is updated to obtain an updated two-layer knowledge graph; Based on the updated two-layer knowledge graph, a legal consultation response is generated for the user. The two-layer knowledge graph is constructed based on the user's historical dialogue information; The two-layer knowledge graph includes a dynamically updated fact layer graph and a legal layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal nodes in the legal layer graph.
2. The legal consultation method according to claim 1, characterized in that, The step of updating the pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information to obtain an updated two-layer knowledge graph includes: Entity extraction is performed on the current dialogue information to obtain new fact nodes and the first association relationship between the new fact nodes; The new fact node and the first association are merged into the fact layer graph to obtain an updated fact layer graph; Based on the node mapping relationship and the updated fact layer graph, the legal layer graph in the two-layer knowledge graph is updated to obtain the updated two-layer knowledge graph.
3. The legal consultation method according to claim 2, characterized in that, The step of updating the legal layer graph in the two-layer knowledge graph based on the node mapping relationship and the updated fact layer graph to obtain the updated two-layer knowledge graph includes: Identify the target fact node in the updated fact layer graph that has been updated; The target fact node is mapped to the legal layer graph, and a second association relationship is established between the target fact node and the corresponding legal node in the mapped legal layer graph to obtain the updated two-layer knowledge graph.
4. The legal consultation method according to any one of claims 1 to 3, characterized in that, The process of generating legal consultation responses for the user based on the updated two-layer knowledge graph includes: Based on the updated two-layer knowledge graph and the historical dialogue information, graph reasoning information is generated; Based on the graph reasoning information, the completeness of the case information in the fact layer graph of the updated two-layer knowledge graph is judged to obtain the completeness judgment result; Based on the completeness judgment result, the graph reasoning information, and the current dialogue information, a legal consultation response is generated for the user.
5. The legal consultation method according to claim 4, characterized in that, The process of generating a legal consultation response for the user based on the completeness judgment result, the graph reasoning information, and the current dialogue information includes: If the completeness judgment result is incomplete, based on the graph reasoning information, determine the fact nodes of missing elements in the fact layer graph of the updated two-layer knowledge graph; Based on the contextual features in the current dialogue information, follow-up questions are generated for the missing factual nodes, and these follow-up questions are used as the legal consultation response.
6. The legal consultation method according to claim 4, characterized in that, The generation of graph reasoning information based on the updated two-layer knowledge graph and the historical dialogue information includes: Traverse the updated two-layer knowledge graph and, based on the node mapping relationship, compare the fact nodes in the fact layer graph with the legal nodes in the legal layer graph. Based on the comparison results, the fact nodes of missing elements and / or legal fact paths to be confirmed in the fact layer graph of the updated two-layer knowledge graph are determined. Based on the historical dialogue information, the fact nodes of the missing elements, and / or the legal fact paths to be confirmed, the graph reasoning information is generated.
7. The legal consultation method according to claim 4, characterized in that, The process of generating a legal consultation response for the user based on the completeness judgment result, the graph reasoning information, and the current dialogue information includes: If the completeness judgment result is complete, a complete reasoning path is determined based on the graph reasoning information. The complete reasoning path includes interrelated fact nodes, legal concepts, legal provisions, and typical cases. The fact nodes include event nodes and evidence nodes. Based on the complete reasoning path and the contextual features in the current dialogue information, a legal consultation response is generated that includes at least one of legal basis, operational suggestions, and evidence preparation.
8. A legal consultation device, characterized in that, include: The acquisition unit is used to acquire the user's current conversation information; The update unit is used to update the pre-constructed two-layer knowledge graph of facts and legal principles based on the current dialogue information, so as to obtain an updated two-layer knowledge graph. The generation unit is used to generate legal consultation responses for the user based on the updated two-layer knowledge graph; The two-layer knowledge graph is constructed based on the user's historical dialogue information; The two-layer knowledge graph includes a dynamically updated fact layer graph and a legal layer graph, and a node mapping relationship is established between the fact nodes in the fact layer graph and the legal nodes in the legal layer graph.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the legal consultation method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the legal consultation method as described in any one of claims 1 to 7.