Consultation method and system based on natural language processing and legal knowledge graph

By employing methods based on natural language processing and legal knowledge graphs, the problem of low efficiency in traditional legal consultation services has been solved. This has enabled efficient conversion of multi-format data and generation of personalized conclusions, thereby improving user experience and service quality.

CN121117239APending Publication Date: 2025-12-12BEIJING INSTITUTE OF TECHNOLOGY (ZHUHAI)

Patent Information

Application Number
CN202511667743.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

Existing legal consulting services are inefficient and unable to cope with massive legal demands. Furthermore, traditional models lack support for heterogeneous data, have insufficient parsing accuracy, lack semantic association analysis, and are not professional or user-friendly enough to be iteratively optimized.

Method used

It adopts a method based on natural language processing and legal knowledge graph, supports multiple input formats such as text, voice, and images, performs accurate retrieval through BERT model and multi-level knowledge graph, generates personalized conclusions by combining graph neural network, and supports user feedback for iterative optimization.

Benefits of technology

It enables efficient conversion and accurate parsing of data in various formats, generates transparent and personalized legal conclusions, lowers the barrier to entry, enhances professionalism and ease of use, and supports continuous optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121117239A_ABST
    Figure CN121117239A_ABST
Patent Text Reader

Abstract

The invention discloses a consultation method and system based on natural language processing and a legal knowledge graph, and relates to the field of data processing, and the method comprises the steps: receiving a multi-format legal consultation demand of a user, converting the multi-format legal consultation demand into a text, inputting the text into a BERT law NLP model, and analyzing key information through word segmentation, intention recognition and entity extraction; based on a pre-constructed multi-level legal knowledge graph, carrying out accurate and fuzzy retrieval and domain filtering in combination with an analysis result, and obtaining an associated law article, a case and a legal relationship; screening conflict law articles and similar cases, and inputting the conflict law articles and the similar cases into a graph neural network reasoning model to generate a preliminary conclusion; the conclusion is converted into a spoken consultation report through a natural language generation module, and output is customized according to a user scene; and if the user feedback satisfaction degree is less than the threshold value, iteratively optimizing the storage data to the historical library. The method has the advantages that accurate retrieval is realized based on the BERT model and the multi-level knowledge graph in the legal field, the oral personalized conclusion combined with the user scene is generated through GNN reasoning, and iterative optimization is performed through user feedback.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data processing, in particular to a consulting method and system based on natural language processing and legal knowledge graph. BACKGROUND

[0002] Current legal consulting services are facing severe challenges. The public is generally faced with the dilemma of lack of legal knowledge, high cost of professional services and uneven distribution of resources. Traditional manual consulting mode is inefficient and difficult to cope with the massive and growing legal needs. At the same time, breakthroughs in the field of artificial intelligence, especially natural language processing technology, provide powerful tools for understanding and analyzing legal problems expressed in natural language by users.

[0003] Current legal consulting methods on the market are mostly limited to text input and lack support for heterogeneous data such as voice, pictures and tables. Users need to manually convert formats, which not only increases the threshold for use, but also easily misses key details such as handwritten notes in pictures and emotional information in voice. The analysis process often relies on general NLP models that have not been deeply fine-tuned for the legal field, which may lead to misunderstandings of terminology and misinterpretations of legal provisions. The accuracy of intent recognition and entity extraction is insufficient. Knowledge retrieval is mostly based on keyword matching, lacking deep semantic correlation analysis, and the knowledge graph is single in level and data verification is not strict, making it difficult to accurately locate related provisions and similar cases, and often ignoring the problem of legal provision conflicts. In terms of reasoning and conclusion generation, most systems use template output without considering specific scenarios such as user identity and subject amount. They are filled with professional terms and lack colloquial explanations, making it difficult for users to understand. The reasoning process is not transparent and lacks explainability. In addition, most systems lack a closed-loop feedback mechanism, making it difficult to iteratively optimize conclusions based on user satisfaction and continuously improve service quality. SUMMARY

[0004] To improve existing methods and systems, a consulting method and system based on natural language processing and legal knowledge graph are provided. The method supports multiple forms of input such as text and voice and converts them into unified text. It relies on legal field BERT models and multi-level knowledge graphs to achieve accurate retrieval, generates colloquial and personalized conclusions based on user scenarios through GNN reasoning, and iteratively optimizes conclusions through user feedback, balancing professionalism and ease of use.

[0005] To achieve the above purposes, the technical solution adopted by the present application is as follows: The consulting method based on natural language processing and legal knowledge graph comprises: receiving a legal consulting demand initiated by a user, the demand input form including text, voice, pictures and tables, and converting the input data in non-text form into a unified format to obtain an initial consulting text in a unified format; The initial consultation text is input into a pre-trained natural language processing model for the legal domain based on the BERT architecture. After word segmentation, the initial consultation text is used for legal intent recognition and legal entity extraction. A multi-level legal knowledge graph, including an ontology layer, an instance layer, and an association layer, is constructed. Data obtained from official legal databases is verified and then imported into the graph for knowledge graph initialization. Knowledge graph retrieval is performed based on legal intent and legal entities obtained through NLP parsing. Through precise and fuzzy retrieval, and combined with legal domain categories, candidate instances are filtered by domain to obtain a set of target legal provisions, a set of target cases, and a set of target legal relationships related to the consultation needs. Based on the target legal provisions set, target case set, and target legal relationship set, the conflicts of legal provisions in the target legal provisions set are screened, and reference cases similar to the consultation needs are selected from the target case set. The screened legal provisions, reference cases, and legal relationships are input into a legal reasoning model based on graph neural network, and the reasoning process and preliminary legal conclusions are output. Based on the reasoning results, personalized consultation conclusions are generated in combination with the specific scenario of the user's consultation. The structured reasoning results are converted into natural language text through a natural language generation model, and professional legal terms are explained in colloquial language. Receive user feedback. If user satisfaction is lower than a preset threshold, repeat the above steps to iteratively optimize the original consultation conclusion. If the user confirms that there is no objection to the conclusion, store the consultation data in the consultation history database.

[0006] Preferably, the process of receiving legal consultation requests initiated by users includes receiving input in the form of text, voice, images, and tables. Converting non-text input data to obtain an initial consultation text in a unified format specifically includes: Voice input is converted into text data using an automatic speech recognition model based on the Transformer architecture. The text information in the image is extracted by using a convolutional neural network to extract image text features, and combined with an optical character recognition model of long short-term memory network to extract and convert the image text into structured text; A table parsing algorithm that integrates rules and deep learning is used to identify the logical relationships between rows and columns of a table and convert the table data into structured data in key-value pair format. By integrating the converted audio text, extracted text from images, and structured data from tables, a unified initial consultation text is generated.

[0007] Preferably, the step of inputting the initial consultation text into a pre-trained legal domain natural language processing model based on the BERT architecture, and performing legal intent recognition and legal entity extraction after word segmentation of the initial consultation text specifically includes: The initial consultation text is input into a pre-trained legal domain natural language processing model, which is based on BERT and segments the initial consultation text by calling a legal domain-specific lexicon. The segmented text is classified using a softmax classifier to obtain legal domain categories and demand types, and to identify legal intent. Extract key legal entities from the text, including legal subjects, legal objects, legal time, legal location, and key legal clause numbers.

[0008] Preferably, the construction of a multi-level legal knowledge graph, including an ontology layer, an instance layer, and an association layer, involves importing data obtained from official legal databases into the graph after verification, and the knowledge graph initialization specifically includes: Construct a multi-level legal knowledge graph including an ontology layer, an instance layer, and an association layer; Define the core concepts of legal subjects, legal acts, legal relationships, legal responsibilities, legal provisions, and cases at the ontology level; The instance layer retrieves specific legal provisions, judgment cases, and legal document template instance data from the legal database. The acquired instance data is initially cleaned to remove duplicate and invalid data and correct format errors; Based on the citation relationship between legal provisions and cases, and the similarity relationship between cases, the association between instances is established in the association layer. Ontology concepts, instance data, and association relationships are imported into the corresponding layers to complete the initialization of the legal knowledge graph.

[0009] Preferably, the knowledge graph retrieval based on the legal intent and legal entities obtained through NLP parsing, and the domain filtering of candidate instances through precise and fuzzy retrieval combined with legal domain categories, to obtain the target legal provisions set, target case set, and target legal relationship set associated with the consultation needs, specifically includes: The acquired legal intent and legal entities are integrated to generate a knowledge graph retrieval request. The extracted legal entities are converted into SPARQL query statements and matched in the instance layer of the legal knowledge graph to quickly locate the corresponding original legal text and complete case document data. Legal intent and legal entities are converted into semantic vectors using the Word2Vec model. By introducing semantic weights in the legal domain, the cosine similarity between the vectors and the semantic vectors of instances in the graph is calculated, and candidate instances are selected. Based on NLP parsing of legal domain categories, candidate instances are filtered by domain, irrelevant domain data is removed, and target legal provisions, target cases, and target legal relationships are formed.

[0010] Preferably, the step of filtering legal conflicts in the target legal provisions set, the target case set, and the target legal relationship set, selecting reference cases similar to the consultation needs from the target case set, and inputting the filtered legal provisions, reference cases, and legal relationships into a legal reasoning model based on a graph neural network to output the reasoning process and preliminary legal conclusions specifically includes: The target legal provisions are screened based on pre-defined rules for resolving legal conflicts, eliminating provisions with lower validity and those in conflict. Based on the three dimensions of case factual elements, points of contention, and key points of judgment, the similarity between the case and the consultation needs is calculated. Highly similar reference cases with a similarity of up to the preset standard are selected, and the judgment reasoning and judgment results of the cases are extracted as the basis for reasoning. The selected priority legal provisions, reference cases, and analyzed legal relationships are input into a legal reasoning model based on graph neural networks. The model learns the relationship between concepts and instances in the knowledge graph to obtain a complete reasoning process and preliminary legal conclusions.

[0011] Preferably, the step of generating personalized consultation conclusions based on the reasoning results and the specific scenario of the user's consultation, and converting the structured reasoning results into natural language text through a natural language generation model, and providing colloquial explanations of professional legal terms, specifically includes: Collect and obtain specific scenario information of user consultations, including user identity, amount of dispute, whether there is a willingness to settle, and correlate it with the results of legal logical reasoning; Based on the associated results, the core content of the consultation conclusion is generated, with the source, effective status and specific clauses of the core legal provisions cited. The case summary covers the basic facts, points of contention, court opinions and judgment results. By using natural language generation models, structured reasoning results are converted into plain text, technical terms are explained in conversational language, and a final personalized consultation conclusion is formed.

[0012] Preferably, the step of receiving user feedback information, if the user satisfaction is lower than a preset threshold, involves repeating the above steps to iteratively optimize the original consultation conclusion. If the user confirms that there is no objection to the conclusion, storing the consultation data in the consultation history database specifically includes: Based on the generated personalized consultation conclusions, user feedback data is received, including satisfaction scores, supplementary consultation content, and information correction requests; If the user satisfaction score is lower than the preset threshold or a supplementary requirement or correction request is made, the conclusion iteration process is triggered to correct the deviation of the original conclusion and supplement the legal provisions and cases corresponding to the new requirement. If the score is higher than the preset threshold and there is no additional feedback, record the entire consultation process data and store it in the consultation history database.

[0013] Furthermore, a consultation system based on natural language processing and legal knowledge graphs is proposed, including: Input processing module: Converts heterogeneous data such as voice, images, and tables into structured text, generating initial consultation text in a unified format; Legal NLP parsing module: Implements word segmentation, intent recognition, and legal entity extraction using a BERT model in the legal domain; Knowledge graph construction module: Constructs a multi-level knowledge graph consisting of an ontology layer, an instance layer, and a relationship layer, and completes data cleaning and initialization; Intelligent search module: It integrates SPARQL precise search and semantic vector fuzzy search, and combines domain filtering to output target legal provisions, cases, and legal relationship sets.

[0014] Legal reasoning module: Generates preliminary legal conclusions with reasoning processes through conflicting legal provisions screening, similar case matching, and GNN model; Conclusion generation module: Generates personalized conclusions based on user scenarios and uses the NLG model to transform technical terms into colloquial explanatory text; Feedback and storage module: Triggers iterative optimization or stores consultation data to the historical database based on user satisfaction. Processor: The processor is used to handle the calculation process of each formula and the construction calculation process of each model.

[0015] Compared with the prior art, the advantages of the present invention are: The system accepts input in multiple formats, including text, voice, images, and tables. It utilizes technologies such as automatic speech recognition and optical character recognition to convert non-textual data into unified structured text, significantly lowering the barrier to entry for users. Leveraging a pre-trained BERT model in the legal field, it accurately performs word segmentation, legal intent recognition, and entity extraction, avoiding the professional biases of general-purpose models. A multi-level legal knowledge graph integrates and verifies official legal data, combining SPARQL precise retrieval and semantic vector fuzzy retrieval to quickly filter irrelevant information and locate target legal provisions, cases, and legal relationships, ensuring data authority and accuracy. Simultaneously, it uses graph neural network models to handle legal conflicts, match similar cases, and output a transparent reasoning process. It also generates personalized conclusions based on user identity, subject matter, and other scenarios, and explains professional terminology in colloquial language to improve comprehension. Furthermore, it supports feedback and iteration; unsatisfactory conclusions can be optimized, and consultation data is stored for continuous improvement, achieving a highly efficient balance between professionalism and ease of use. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the method proposed in this invention; Figure 2 This is a schematic diagram illustrating the method for obtaining initial consultation text as proposed in this invention; Figure 3 This is a schematic diagram of the word segmentation process proposed in this invention; Figure 4 This is a schematic diagram of the knowledge graph initialization proposed in this invention; Figure 5 This is a schematic diagram illustrating the acquisition of the target legal provisions set, target case set, and target legal relationship set proposed in this invention; Figure 6 This is a schematic diagram illustrating the reasoning process and preliminary legal conclusions proposed in this invention; Figure 7 This is a schematic diagram illustrating the generation of personalized consultation conclusions proposed in this invention; Figure 8 This is a schematic diagram of the user feedback proposed in this invention. Detailed Implementation

[0017] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.

[0018] Consultation systems based on natural language processing and legal knowledge graphs include: Input processing module: Converts heterogeneous data such as voice, images, and tables into structured text, generating initial consultation text in a unified format; Legal NLP parsing module: Implements word segmentation, intent recognition, and legal entity extraction using a BERT model in the legal domain; Knowledge graph construction module: Constructs a multi-level knowledge graph consisting of an ontology layer, an instance layer, and a relationship layer, and completes data cleaning and initialization; Intelligent search module: It integrates SPARQL precise search and semantic vector fuzzy search, and combines domain filtering to output target legal provisions, cases, and legal relationship sets.

[0019] Legal reasoning module: Generates preliminary legal conclusions with reasoning processes through conflicting legal provisions screening, similar case matching, and GNN model; Conclusion generation module: Generates personalized conclusions based on user scenarios and uses the NLG model to transform technical terms into colloquial explanatory text; Feedback and storage module: Triggers iterative optimization or stores consultation data to the historical database based on user satisfaction. Processor: The processor is used to handle the calculation process of each formula and the construction calculation process of each model.

[0020] See Figure 1As shown, the consultation methods based on natural language processing and legal knowledge graphs include: Step 1: Receive legal consultation requests from users. The input formats include text, voice, images, and tables. Convert the format of non-text input data to obtain an initial consultation text in a unified format. Step 2: Input the initial consultation text into a pre-trained legal domain natural language processing model based on the BERT architecture. After word segmentation, the initial consultation text is used for legal intent recognition and legal entity extraction. Step 3: Construct a multi-level legal knowledge graph including an ontology layer, an instance layer, and an association layer. Data obtained from the official legal database will be imported into the graph after verification to initialize the knowledge graph. Step 4: Based on the legal intent and legal entities obtained from NLP parsing, perform knowledge graph retrieval. Through precise retrieval and fuzzy retrieval, and combined with legal domain categories, filter candidate instances to obtain the target legal provisions set, target case set, and target legal relationship set associated with the consultation needs. Step 5: Based on the target legal provisions set, target case set, and target legal relationship set, filter the legal provisions conflicts in the target legal provisions set, select reference cases similar to the consultation needs from the target case set, input the selected legal provisions, reference cases, and legal relationships into the legal reasoning model based on graph neural network, and output the reasoning process and preliminary legal conclusions; Step Six: Based on the reasoning results and the specific scenario of the user's consultation, generate personalized consultation conclusions. Use a natural language generation model to convert the structured reasoning results into natural language text and provide colloquial explanations for professional legal terms. Step 7: Receive user feedback. If user satisfaction is lower than the preset threshold, repeat the above steps to iteratively optimize the original consultation conclusion. If the user confirms that there is no objection to the conclusion, store the consultation data in the consultation history database.

[0021] See Figure 2 As shown, the system receives legal consultation requests from users. Input formats include text, voice, images, and tables. Non-text input data is converted to a uniform initial consultation text. Specifically, this includes: Voice input is converted into text data using an automatic speech recognition model based on the Transformer architecture. The text information in the image is extracted by using a convolutional neural network to extract image text features, and combined with an optical character recognition model of long short-term memory network to extract and convert the image text into structured text; A table parsing algorithm that integrates rules and deep learning is used to identify the logical relationships between rows and columns of a table and convert the table data into structured data in key-value pair format. By integrating the converted audio text, extracted text from images, and structured data from tables, a unified initial consultation text is generated.

[0022] See Figure 3 As shown, the initial consultation text is input into a pre-trained legal domain natural language processing model based on the BERT architecture. After word segmentation of the initial consultation text, legal intent recognition and legal entity extraction are performed, specifically including: The initial consultation text is input into a pre-trained legal domain natural language processing model, which is based on BERT and segments the initial consultation text by calling a legal domain-specific lexicon. The segmented text is classified using a softmax classifier to obtain legal domain categories and demand types, and to identify legal intent. Extract key legal entities from the text, including legal subjects, legal objects, legal time, legal location, and key legal clause numbers.

[0023] Specifically, the legal terminology database includes: first, legal professional terms, covering core terms in multiple fields such as civil, commercial, administrative, and criminal law, with the corresponding legal field indicated; second, industry-specific vocabulary, adapted to the consultation scenarios of users in different industries; and third, a table of correspondence between vague expressions and precise terms. Two key operations are performed simultaneously during word segmentation: stop word filtering and fuzzy expression replacement. When word segmentation detects that the user is using a fuzzy expression, it automatically matches the precise terms in the corresponding table and marks the confidence level. If there are multiple possible corresponding terms, it lists and marks the applicable scenarios of each term to provide a reference for subsequent intent recognition. A hierarchical approach combining basic recognition and user profile fusion is adopted to accurately pinpoint user inquiry intent. Basic intent recognition inputs the segmented text into a softmax classifier. The classifier, through legal scenario features learned during pre-training, outputs results in two dimensions: first, legal domain categories, covering 12 core domains including contract disputes, tort liability, marriage and family, labor disputes, intellectual property, and corporate affairs, with each domain further subdivided into secondary categories; second, demand types, including 5 categories such as legal provisions search, case reference, risk assessment, solution suggestions, and document templates.

[0024] See Figure 4 As shown, a multi-level legal knowledge graph is constructed, including an ontology layer, an instance layer, and an association layer. Data obtained from official legal databases is imported into the graph after verification. The initialization of the knowledge graph specifically includes: Construct a multi-level legal knowledge graph including an ontology layer, an instance layer, and an association layer; Define the core concepts of legal subjects, legal acts, legal relationships, legal responsibilities, legal provisions, and cases at the ontology level; The instance layer retrieves specific legal provisions, judgment cases, and legal document template instance data from the legal database. The acquired instance data is initially cleaned to remove duplicate and invalid data and correct format errors; Based on the citation relationship between legal provisions and cases, and the similarity relationship between cases, the association between instances is established in the association layer. Ontology concepts, instance data, and association relationships are imported into the corresponding layers to complete the initialization of the legal knowledge graph.

[0025] Specifically, the ontology-level concept system is constructed using a combination of legal norms-oriented and scenario-demand-oriented approaches: The first step is core concept extraction, which involves identifying general and specific legal concepts. General concepts include natural persons and legal persons, while specific concepts include apparent agency and bona fide acquisition, ensuring the accuracy and authority of the concepts. The second step is concept hierarchy, organizing concepts through a parent-child hierarchical structure. For example, legal liability serves as the parent class, with subclasses for civil liability, administrative liability, and criminal liability. Civil liability is further subdivided into breach of contract liability, tort liability, and pre-contractual liability. The hierarchy depth is controlled to 3-4 levels to avoid decreased search efficiency due to excessive depth. The third step is concept attribute definition, adding legal attributes to each core concept. For example, attributes for natural persons include age, civil capacity, and role; attributes for legal provisions include legal name, chapter number, effective date, and validity status. Attribute definitions must align with common query dimensions in legal consultations. Conceptual relationship modeling needs to focus on the relevance of legal logic and ensure that the relationship definition complies with the rules of applicable law. This includes three aspects: basic relationships, special relationships, and relationship constraint definitions. After completing the definition of concepts and relationships, a formal description is performed, and concepts, attributes, and relationships are encoded in the OWL language to form a standardized ontology file.

[0026] See Figure 5 As shown, knowledge graph retrieval is performed based on the legal intent and legal entities obtained through NLP parsing. Through precise and fuzzy retrieval, combined with legal domain categories, candidate instances are filtered by domain to obtain the target legal provisions set, target case set, and target legal relationship set associated with the consultation needs. Specifically, these include: The acquired legal intent and legal entities are integrated to generate a knowledge graph retrieval request. The extracted legal entities are converted into SPARQL query statements and matched in the instance layer of the legal knowledge graph to quickly locate the corresponding original legal text and complete case document data. Legal intent and legal entities are converted into semantic vectors using the Word2Vec model. By introducing semantic weights in the legal domain, the cosine similarity between the vectors and the semantic vectors of instances in the graph is calculated, and candidate instances are selected. Based on NLP parsing of legal domain categories, candidate instances are filtered by domain, irrelevant domain data is removed, and target legal provisions, target cases, and target legal relationships are formed.

[0027] Specifically, precise retrieval targets specific entities explicitly provided by the user. Its core lies in achieving accurate positioning of knowledge graph instance layers through structured queries. First, the system rigorously converts the user-input entity information into a standardized query language, precisely matching the specific attributes of corresponding nodes. After retrieving a matching instance, it performs dual checks: one is data consistency verification to ensure the internal logic of the instance is self-consistent; the other is requirement relevance verification to ensure that the core content of the search results is directly related to the user's deeper needs. If necessary, it supplements and extracts related instance information to strengthen the relevance. The ultimate goal is to obtain unbiased, highly relevant, and complete information about the entities the user requires. Fuzzy search addresses situations where user needs are vaguely expressed or lack precise entities. Its core principle is flexible matching through legal semantic understanding. This involves creating legally specific semantic vector models of the user's intent text, generating vectors that fit the legal context through domain segmentation and terminology weighting. Cosine similarity is used to initially screen candidate instances at the knowledge graph instance layer, followed by a first-round filtering based on legal timeliness, user identity matching, and instance validity. Semantic deepening matching is then performed on candidate instances, with multi-dimensional secondary verification based on legal logic: legal provisions verify the consistency between the applicable legal relationship and the intent; cases comprehensively evaluate similarity across three dimensions: factual elements, points of contention, and judicial reasoning; and legal relationships verify whether the chain of responsibility and remedies align with the user's implicit demands. Through this layered, refined matching of semantics and legal logic, candidate instances that highly align with the user's vague intent at the legal level are selected.

[0028] See Figure 6 As shown, based on the target legal provisions set, target case set, and target legal relationship set, the conflicts of legal provisions in the target legal provisions set are screened, and reference cases similar to the consultation needs are selected from the target case set. The screened legal provisions, reference cases, and legal relationships are input into a legal reasoning model based on a graph neural network, and the output reasoning process and preliminary legal conclusions specifically include: The target legal provisions are screened based on pre-defined rules for resolving legal conflicts, eliminating provisions with lower validity and those in conflict. Based on the three dimensions of case factual elements, points of contention, and key points of judgment, the similarity between the case and the consultation needs is calculated. Highly similar reference cases with a similarity of up to the preset standard are selected, and the judgment reasoning and judgment results of the cases are extracted as the basis for reasoning. The selected priority legal provisions, reference cases, and analyzed legal relationships are input into a legal reasoning model based on graph neural networks. The model learns the relationship between concepts and instances in the knowledge graph to obtain a complete reasoning process and preliminary legal conclusions.

[0029] Specifically, the input layer constructs a graph of target legal provisions, highly relevant cases, and legal relationships linked by subject, behavior, and responsibility, transforming them into graph nodes and edges. User consultation features are also embedded. The Generative Neural Network (GNN) learns implicit connections between nodes through multi-layer convolutions and, combined with the priority of legal provisions / cases determined by rule-based reasoning, constructs a reasoning path encompassing the consultation scenario, legal relationships, legal provisions, cases, and conclusion. The output is a conclusion with a complete chain, annotated with the sources of the legal provisions and cases. Finally, dual verification is performed: logical consistency verification ensures the chain is intact; legal compliance verification checks whether the conclusion conforms to current laws and guiding cases, automatically replacing repealed legal provisions and re-reasoning; high-risk conclusions undergo manual review, ultimately generating a logically rigorous and compliant preliminary legal conclusion.

[0030] See Figure 7 As shown, based on the reasoning results and the specific scenario of the user's consultation, personalized consultation conclusions are generated. A natural language generation model is used to convert the structured reasoning results into natural language text, and colloquial explanations are provided for professional legal terms, specifically including: Collect and obtain specific scenario information of user consultations, including user identity, amount of dispute, whether there is a willingness to settle, and correlate it with the results of legal logical reasoning; Based on the associated results, the core content of the consultation conclusion is generated, with the source, effective status and specific clauses of the core legal provisions cited. The case summary covers the basic facts, points of contention, court opinions and judgment results. By using natural language generation models, structured reasoning results are converted into plain text, technical terms are explained in conversational language, and a final personalized consultation conclusion is formed.

[0031] Specifically, personalized services begin with precise scenario identification. Through preset fields and interactive questions, the system systematically collects information from three core dimensions: user identity, dispute details, and needs and preferences. Secondly, it dynamically maps the collected elements to legal reasoning results, identifying and marking scenario-reasoning deviations to ensure subsequent solutions are highly targeted and explain potential conflicts. Elements are weighted according to urgency and legal relevance, with high-weight elements driving the presentation priority of the core conclusion section, while low-weight information is placed in supplementary explanations, ensuring users efficiently obtain key information. Based on the integrated scenario, highly adapted content is generated according to a four-layer structure: 3-5 carefully selected current and effective legal provisions are identified, their sources and effective status are clearly stated, and scenario-based application instructions are added; local recent similar cases with a scenario similarity of ≥85% are accurately selected, key judgment points are summarized, and differences are highlighted; a three-dimensional system of advantage probability, risk point, and risk level is constructed to provide avoidance suggestions for high risks; suggestions are customized according to four paths: negotiation, mediation, arbitration, and litigation, clarifying each process, materials, time cost, economic cost, applicable scenario, and success rate prediction based on cases, to assist users in deciding the optimal path.

[0032] See Figure 8 As shown, the system receives user feedback. If user satisfaction is lower than a preset threshold, the above steps are repeated to iteratively optimize the original consultation conclusion. If the user confirms the conclusion without objection, the consultation data is stored in the consultation history database. Specifically, this includes: Based on the generated personalized consultation conclusions, user feedback data is received, including satisfaction scores, supplementary consultation content, and information correction requests; If the user satisfaction score is lower than the preset threshold or a supplementary requirement or correction request is made, the conclusion iteration process is triggered to correct the deviation of the original conclusion and supplement the legal provisions and cases corresponding to the new requirement. If the score is higher than the preset threshold and there is no additional feedback, record the entire consultation process data and store it in the consultation history database.

[0033] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0034] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0035] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A consultation method based on natural language processing and legal knowledge graphs, characterized in that: include: It receives legal consultation requests from users, including text, voice, images, and tables. It converts non-text input data to obtain an initial consultation text in a unified format. The initial consultation text is input into a pre-trained natural language processing model for the legal domain based on the BERT architecture. After word segmentation, the initial consultation text is used for legal intent recognition and legal entity extraction. Based on a combination of legal norms-oriented and scenario-demand-oriented approaches, a multi-level legal knowledge graph including an ontology layer, an instance layer, and an association layer is constructed. Data obtained from official legal databases is verified and then imported into the graph for knowledge graph initialization. Knowledge graph retrieval is performed based on legal intent and legal entities obtained through NLP parsing. Through precise and fuzzy retrieval, and combined with legal domain categories, candidate instances are filtered by domain to obtain a set of target legal provisions, a set of target cases, and a set of target legal relationships related to the consultation needs. Based on the target legal provisions set, target case set, and target legal relationship set, the conflicts of legal provisions in the target legal provisions set are screened, and reference cases similar to the consultation needs are selected from the target case set. The screened legal provisions, reference cases, and legal relationships are input into a legal reasoning model based on graph neural network, and the reasoning process and preliminary legal conclusions are output. Based on the reasoning results, personalized consultation conclusions are generated in combination with the specific scenario of the user's consultation. The structured reasoning results are converted into natural language text through a natural language generation model, and professional legal terms are explained in colloquial language. Receive user feedback. If user satisfaction is lower than a preset threshold, repeat the above steps to iteratively optimize the original consultation conclusion. If the user confirms that there is no objection to the conclusion, store the consultation data in the consultation history database.

2. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The process of receiving legal consultation requests initiated by users includes input formats such as text, voice, images, and tables. For non-text input data, format conversion is performed to obtain an initial consultation text in a unified format. Specifically, this includes: Voice input is converted into text data using an automatic speech recognition model based on the Transformer architecture. The text information in the image is extracted by using a convolutional neural network to extract image text features, and combined with an optical character recognition model of long short-term memory network to extract and convert the image text into structured text; A table parsing algorithm that integrates rules and deep learning is used to identify the logical relationships between rows and columns of a table and convert the table data into structured data in key-value pair format. By integrating the converted audio text, extracted text from images, and structured data from tables, a unified initial consultation text is generated.

3. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The process of inputting the initial consultation text into a pre-trained legal domain natural language processing model based on the BERT architecture, performing word segmentation on the initial consultation text, and then identifying legal intent and extracting legal entities specifically includes: The initial consultation text is input into a pre-trained legal domain natural language processing model, which is based on BERT and segments the initial consultation text by calling a legal domain-specific lexicon. The segmented text is classified using a softmax classifier to obtain legal domain categories and demand types, and to identify legal intent. Extract key legal entities from the text, including legal subjects, legal objects, legal time, legal location, and key legal clause numbers.

4. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The method of constructing a multi-level legal knowledge graph, including an ontology layer, an instance layer, and a relationship layer, based on a combination of legal norms-oriented and scenario-demand-oriented approaches, involves importing data obtained from official legal databases into the graph after verification and performing knowledge graph initialization, specifically including: Construct a multi-level legal knowledge graph including an ontology layer, an instance layer, and an association layer; Define the core concepts of legal subjects, legal acts, legal relationships, legal responsibilities, legal provisions, and cases at the ontology level; The instance layer retrieves specific legal provisions, judgment cases, and legal document template instance data from the legal database. The acquired instance data is initially cleaned to remove duplicate and invalid data and correct format errors; Based on the citation relationship between legal provisions and cases, and the similarity relationship between cases, the association between instances is established in the association layer. Ontology concepts, instance data, and association relationships are imported into the corresponding layers to complete the initialization of the legal knowledge graph.

5. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The knowledge graph retrieval based on legal intent and legal entities obtained through NLP parsing, through precise and fuzzy retrieval, combined with domain filtering of candidate instances by legal domain categories, specifically includes: a set of target legal provisions, a set of target cases, and a set of target legal relationships associated with the consultation needs. The acquired legal intent and legal entities are integrated to generate a knowledge graph retrieval request. The extracted legal entities are converted into SPARQL query statements and matched in the instance layer of the legal knowledge graph to quickly locate the corresponding original legal text and complete case document data. Legal intent and legal entities are converted into semantic vectors using the Word2Vec model. By introducing semantic weights in the legal domain, the cosine similarity between the vectors and the semantic vectors of instances in the graph is calculated, and candidate instances are selected. Based on NLP parsing of legal domain categories, candidate instances are filtered by domain, irrelevant domain data is removed, and target legal provisions, target cases, and target legal relationships are formed.

6. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The process involves filtering for conflicts among legal provisions in the target legal provisions set, selecting reference cases similar to the consultation needs from the target case set, and inputting the filtered legal provisions, reference cases, and legal relationships into a graph neural network-based legal reasoning model. The output of the reasoning process and preliminary legal conclusions specifically includes: The target legal provisions are screened based on pre-defined rules for resolving legal conflicts, eliminating provisions with lower validity and those in conflict. Based on the three dimensions of case factual elements, points of contention, and key points of judgment, the similarity between the case and the consultation needs is calculated. Highly similar reference cases with a similarity of up to the preset standard are selected, and the judgment reasoning and judgment results of the cases are extracted as the basis for reasoning. The selected priority legal provisions, reference cases, and analyzed legal relationships are input into a legal reasoning model based on graph neural networks. The model learns the relationship between concepts and instances in the knowledge graph to obtain a complete reasoning process and preliminary legal conclusions.

7. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, The process of generating personalized consultation conclusions based on reasoning results and the specific context of user consultation, and converting structured reasoning results into natural language text using a natural language generation model, while providing colloquial explanations of professional legal terms, specifically includes: Collect and obtain specific scenario information of user consultations, including user identity, amount of dispute, whether there is a willingness to settle, and correlate it with the results of legal logical reasoning; Based on the associated results, the core content of the consultation conclusion is generated, with the source, effective status and specific clauses of the core legal provisions cited. The case summary covers the basic facts, points of contention, court opinions and judgment results. By using natural language generation models, structured reasoning results are converted into plain text, technical terms are explained in conversational language, and a final personalized consultation conclusion is formed.

8. The consultation method based on natural language processing and legal knowledge graph according to claim 1, characterized in that, If the user's satisfaction level is lower than a preset threshold, the above steps are repeated to iteratively optimize the original consultation conclusion. If the user confirms that they have no objection to the conclusion, the consultation data is stored in the consultation history database. This specifically includes: Based on the generated personalized consultation conclusions, user feedback data is received, including satisfaction scores, supplementary consultation content, and information correction requests; If the user satisfaction score is lower than the preset threshold or a supplementary requirement or correction request is made, the conclusion iteration process is triggered to correct the deviation of the original conclusion and supplement the legal provisions and cases corresponding to the new requirement. If the score is higher than the preset threshold and there is no additional feedback, record the entire consultation process data and store it in the consultation history database.

9. A consultation system based on natural language processing and legal knowledge graph, used to implement the consultation method based on natural language processing and legal knowledge graph as described in any one of claims 1-8, characterized in that, include: Input processing module: Converts heterogeneous data such as voice, images, and tables into structured text, generating initial consultation text in a unified format; Legal NLP parsing module: Implements word segmentation, intent recognition, and legal entity extraction using a BERT model in the legal domain; Knowledge graph construction module: Constructs a multi-level knowledge graph consisting of an ontology layer, an instance layer, and a relationship layer, and completes data cleaning and initialization; Intelligent search module: integrates SPARQL precise search and semantic vector fuzzy search, and combines domain filtering to output target legal provisions, cases, and legal relationship sets; Legal reasoning module: Generates preliminary legal conclusions with reasoning processes through conflicting legal provisions screening, similar case matching, and GNN model; Conclusion generation module: Generates personalized conclusions based on user scenarios and uses the NLG model to transform technical terms into colloquial explanatory text; Feedback and storage module: Triggers iterative optimization or stores consultation data to the historical database based on user satisfaction. Processor: The processor is used to handle the calculation process of each formula and the construction calculation process of each model.

Citation Information

Patent Citations

  • Online inquiry data processing method and device and computer equipment

    CN112035615A

  • Legal consultation report generation system and method based on legal knowledge graph

    CN117033721A

  • French shield AI intelligent case handling all-in-one machine system based on large language model

    CN120851814A

Cited By

  • Legal search matching method and system and storage medium

    CN121524329A

  • A legal search matching method, system and storage medium

    CN121524329B

  • Multi-modal cognition-based aging-suitable video script generation method and system

    CN121885231A

  • Law and regulation retrieval processing method and device for large language model

    CN122153134A

  • Intelligent legal consultation question and answer method based on knowledge graph

    CN122154951A