Legal text BUG semantic map generation and inference chain defect detection method

By constructing a legal semantic graph and applying a broken reasoning chain detection algorithm, the problem of the inability to automatically detect legal reasoning loopholes in existing technologies has been solved. This enables a deep understanding of legal texts and intelligent vulnerability detection, thereby improving the rationality of judicial decisions and the reliability of legal AI.

CN121390073APending Publication Date: 2026-01-23HAINAN UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511408246.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-29
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Existing technologies cannot effectively and automatically detect and correct logical loopholes and defects in reasoning chains in legal reasoning. This can lead to errors in AI-generated legal texts, such as omitting key premises, causing causal jumps, or deviating from the legislative intent, thus affecting the rationality and fairness of judicial decisions.

Method used

We construct a legal semantic graph based on the DIKWP model, reconstruct the reasoning chain of legal texts into a multi-layered semantic graph through five-dimensional semantic representation, and use a broken reasoning chain detection algorithm to identify and label defects such as causal jumps, knowledge mismatches, and purpose biases, thereby achieving deep understanding and automatic detection of legal texts.

Benefits of technology

It significantly improves the intelligence level of legal text review, can automatically discover and mark hidden loopholes in the reasoning chain, safeguard judicial fairness, improve the reliability of legal AI output and the efficiency of manual review, and ensure the rationality and fairness of judgment conclusions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121390073A_ABST
    Figure CN121390073A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of legal artificial intelligence and natural language processing, and particularly discloses a legal text BUG semantic map generation and inference chain defect detection method. The method comprises the steps of performing semantic preprocessing on a legal text, and dividing factors such as facts, legal bases, reasoning processes and conclusions; building five-dimensional semantic representation of data, information, knowledge, wisdom and intention based on a DIKWP model; generating a legal semantic map fused with multi-level semantics, and expressing an inference structure by nodes and edges; utilizing a fracture inference chain detection algorithm to identify logic defects in the inference process, wherein the logic defects comprise three types of BUGs, namely causal jump, knowledge mismatch and target deviation; and finally, positioning and marking the defects and outputting a detection result. According to the method, dominant and automatic vulnerability detection of the legal reasoning process can be realized, and the reasonability and fairness of judicial referees and the reliability of law text generation by AI are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of legal artificial intelligence and natural language processing, and in particular to a system method for performing semantic analysis on legal documents (such as court judgments, legal opinions, etc.) to identify logical bugs (BUG) and reasoning defects. This method integrates semantic graph construction, knowledge graph reasoning, and AI cognitive model technologies to achieve automated integrity detection and defect labeling of legal text reasoning chains. BACKGROUND

[0002] With the explosive growth of judicial cases and legal texts, how to automatically review the correctness and completeness of legal reasoning processes has become a pressing problem. Traditional legal retrieval and expert systems mainly focus on extracting legal basis based on keywords or rules, and cannot deeply identify the implicit logical structure in judgment reasoning. Although large language models (LLM) and other generative AI can produce legal texts that conform to surface syntax, they have obvious shortcomings in rigorous legal reasoning support: on the one hand, they often fail to identify applicable legal contexts and inaccurately track the relationship between facts and legal norms, which may misinterpret the hierarchical structure of judicial reasoning; on the other hand, they tend to give surface- reasonable but lack deep logic conclusions based on text patterns. These limitations lead to AI-generated legal opinions that may miss key premises, jump causally, or deviate from the legislative intent, etc. "BUG" errors.

[0003] In the field of artificial intelligence cognitive theory, the "Data-Information-Knowledge-Wisdom-Intention (DIKWP)" model introduces a classic cognitive chain through the "Purpose" dimension to explicitly consider the target and motivation in the decision-making process. This model constructs a five-layer meshed cognitive system of data, information, knowledge, wisdom, and intention, aiming to make every step of artificial intelligence reasoning and decision-making traceable, understandable, and embedded with human desired goals and values. Based on the DIKWP model, the "consciousness BUG theory" and "consciousness relativity" have also been developed. The "consciousness BUG theory" believes that biases and errors (i.e. "Bug") in the cognitive process are not entirely negative factors, but rather the motivation to introduce higher-level self-monitoring (metacognition). In other words, without "Bug", the system does not need higher-level consciousness to correct it; one important role of consciousness is to discover and correct "Bug" in each level of cognition. This theory suggests that in complex legal reasoning, there may be hidden reasoning chain breaks or biases that need to be detected and corrected.

[0004] Currently, there is a lack of effective tools in judicial practice to assist judges and legal workers in finding semantic loopholes in judgment reasoning. For example, some judgments may be formally in line with the law, but the actual reasoning process may be "formally legal but substantially unfair", that is, the conclusion may be formally in line with the legal provisions, but it violates the deeper legislative purpose and the value of fairness. For another example, the differences in the positions and understandings of different parties (plaintiff, defendant, prosecutor) in a case may lead to a biased judgment result towards a certain perspective and ignore the key information of the other party. These are all "bugs" in legal reasoning. Therefore, a new technical solution is urgently needed to enable deep understanding of legal texts based on semantic level, reconstruct the reasoning process, and automatically detect defects in the reasoning chain (such as causal jump, knowledge mismatch, purpose deviation, etc.) to improve the rationality and fairness of judicial adjudication. SUMMARY

[0005] The present application provides a legal text BUG semantic atlas generation and reasoning chain defect detection method, which aims to solve the problem that the prior art cannot automatically find legal reasoning loopholes. By constructing a legal semantic tensor structure (semantic atlas) containing five elements of data, information, knowledge, wisdom and intention, the method can reconstruct the reasoning chain in the legal judgment or opinion, and use the broken reasoning chain detection algorithm to accurately identify the breakpoints and logical defects in the reasoning process, including causal jump, knowledge mismatch, purpose deviation and other types of "legal BUG".

[0006] The method of the application comprises the following steps: 1. Legal text semantic preprocessing: obtaining the legal text (such as court judgment or legal opinion) to be analyzed, segmenting and dividing semantic units, and dividing the text content into elements such as fact statement, evidence material, legal basis, reasoning process and conclusion. 2. DIKWP five-dimensional semantic representation construction: based on the DIKWP model, the above elements are mapped into the five semantic levels of data (Data), information (Information), knowledge (Knowledge), wisdom (Wisdom) and purpose (Purpose). For example, the fact evidence belongs to the data layer (objective original fact), the case plot and context belong to the information layer (structured description of data), the legal provisions and precedents belong to the knowledge layer (universal legal principles), the judge's discretion and value judgment belong to the wisdom layer (comprehensive decision), and the legislative purpose or judicial policy behind the judgment corresponds to the purpose layer (purpose-oriented decision). Through the above mapping, a five-dimensional semantic tensor representation of the legal text is constructed, that is, a semantic network in five levels. 3. Legal BUG semantic graph generation: the five-level semantic elements are assembled into an integrated legal semantic graph (Legal Semantic Graph). The graph presents the judgment reasoning chain in the form of nodes and associations: nodes represent facts, legal provisions, reasoning steps, etc., and nodes of different DIKWP levels have different identifiers; the edge represents the reasoning relationship or causal association (for example, "evidence A supports fact B", "fact B meets legal requirement C", "legal requirement C deduces conclusion D"). Unlike traditional linear reasoning, the semantic graph generated by the application is a networked multi-layer structure, allowing bidirectional feedback verification between different levels. This ensures that even if the reasoning chain spans multiple semantic levels, it can still remain coherent in the graph. 4. Broken reasoning chain detection algorithm: a reasoning chain integrity detection algorithm is run on the generated semantic graph. The algorithm traces from the fact node to the judgment conclusion node along the reasoning path in the graph, checks whether the semantic connection between each two adjacent reasoning is sufficient and effective, and if a broken chain (i.e. the lack of necessary intermediate logic between premise and conclusion) is found, it is determined that there is a "reasoning bug" at that place. Specifically, the application focuses on identifying the following defects: causal jump: the reasoning process jumps across the necessary causal link, directly from the cause to the result, lacking intermediate deduction. For example, the judgment directly deduces "the defendant has the intention to commit the crime" from "the defendant appears at the crime scene", which lacks supporting evidence for the intention, which is a causal jump type bug. Knowledge mismatch: the applicable legal provisions or knowledge premises are incorrect, resulting in a reasoning chain built on incorrect basis. For example, using a legal provision that is not applicable to the case plot is a knowledge level mismatch bug. Purpose deviation: the judgment conclusion deviates from the purpose and value orientation behind the legal provisions. That is, the form is legal but the substance violates the legislative intent, which can be regarded as a purpose deviation type bug.(Break detection algorithm has different judgment strategies for each type of defect, which is not described in detail and can be seen in the embodiments.)5. BUG positioning and marking: once the reasoning chain break or BUG is detected, the method will mark the corresponding nodes and relationships in the semantic graph. For example, highlight the missing premises or the reasoning steps with deviations on the semantic graph. At the same time, record the type and location of the BUG, which provides the basis for subsequent classification and error correction.6. Output the detection results: the system outputs include: the semantic graph representation of the legal text, and the marked BUG defect location list. The results can be further viewed and analyzed by judges, lawyers or AI review modules.

[0007] Through the above technical solutions, the present application can make the implicit legal reasoning process explicit and structured, automatically find logical loopholes that are difficult for artificial review and timely detection. This not only provides an intelligent checking means for the judicial trial process, but also lays a foundation for subsequent generation of error correction suggestions and explanation. Figure 1 The flowchart of the method of the present application is shown in the accompanying Figure 2 The detection and marking of the reasoning chain break BUG in the semantic graph are illustrated. BRIEF DESCRIPTION OF DRAWINGS

[0008] Figure 1 The flowchart of the legal text BUG semantic graph generation and reasoning chain defect detection method is shown.

[0009] Figure 2 The example of the legal semantic graph and reasoning chain BUG detection is shown. DETAILED DESCRIPTION

[0010] Example 1: legal judgment reasoning chain BUG detection. Take a simple criminal case judgment as an example to show the implementation process of the method of the present application. First, the judgment text is preprocessed to extract the key facts: for example, "the defendant appeared at the scene of the case" "the DNA of the victim was detected on the clothes of the defendant" and the like; extract the legal basis: "Article X of the Criminal Law on the constitutive elements of the crime of intentional injury"; extract the judgment conclusion: "sentence the defendant to Y years of imprisonment for the crime of intentional injury". Then, the semantic layer is labeled according to the DIKWP model: the fact evidence corresponds to the data layer, the case process and the like correspond to the information layer, the criminal law provisions and judicial interpretation correspond to the knowledge layer, the judge's judgment on the subjective evil of the defendant corresponds to the wisdom layer, and the social purpose of punishment and education corresponds to the intention layer. Then, the method constructs a semantic graph: the nodes include "the defendant appeared on the scene" "the DNA evidence on the clothes" (data layer node), "the case process" (information layer node), "the legal elements of the crime of intentional injury" (knowledge layer node), "the subjective evil of the defendant" (wisdom layer node), "the purpose of judicial justice" (intention layer node), etc., and the nodes are connected by directed edges to form a reasoning path network, for example: (causal reasoning relationship from fact to conclusion), (classification reasoning relationship from knowledge to conclusion), etc.

[0011] After the semantic graph is generated, the algorithm of broken inference chain detection is applied: starting from the fact evidence node, it verifies whether each step of reasoning to the judicial conclusion node is supported by sufficient evidence along multiple reasoning paths. Once it finds that a step has no predecessor support node or improper basis, it determines that there is a broken inference chain (BUG) at this step. In this example, suppose it is detected that "the defendant appeared on the scene" is directly inferred to "the defendant has the intention to harm", but there is a lack of evidence to prove the subjective intention (for example, there is a lack of argument on the defendant's motive for committing the crime), and the algorithm determines that this is a causal jump type BUG: because the subjective intention is directly inferred from the objective appearance on the scene, and there is a lack of logical bridge. The system marks this BUG position in the graph with a flashing red marker and annotates it as "lack of proof of subjective intention, causal jump".

[0012] Further, the system records the type of this BUG as "premise missing / causal jump". If there are other defects, for example, it is found that the judgment conclusion quotes the legal provisions, but does not consider the legislative purpose of the provisions (such as the judgment is too mechanically severe and violates the principle of proportionality between crime and punishment), then the algorithm will mark it as a "purpose deviation type BUG". For example, the system retrieves similar cases in which the court adopts different handling, but the present case does not explain, and it is marked as a "case deviation type BUG". All these BUG information will be listed in the output results, including the type of BUG, the paragraph or sentence where the BUG is located, a brief explanation, etc.

[0013] Example 2: AI legal opinion reasoning verification. The method of the present application is applied to a legal opinion generated by a large language model to verify the logical reliability of AI-generated content. The legal opinion recommends that the client take certain legal action, citing several regulations and factual basis. First, extract the DIKWP semantic elements, such as "client-provided factual materials" (data layer), "case background description" (information layer), "model-referenced laws and regulations" (knowledge layer), "model-provided analysis reasoning and conclusion recommendations" (wisdom layer), and the implicit model goal (such as "maximize legal risk avoidance", which can be considered as the purpose layer of the model output). Then build a semantic graph and detect the reasoning chain. The result shows that the model's opinion has a knowledge mismatch bug: the model cites a regulation that does not match the actual situation (treats administrative regulations as applicable basis, but in fact it does not apply to this case). The algorithm identifies that the semantic correlation between the legal text node and the case fact node is very low, and there is conflicting information, so it is determined to be a knowledge mismatch. The system indicates in the output: "the cited regulation XX does not match the case situation, which may lead to incorrect application". At the same time, the system also detects that there is inconsistency between the model's recommended action and the client's real intention, and determines it to be a purpose deviation bug, prompting that the opinion may deviate from the fundamental purpose of the party.

[0014] As can be seen from the above examples, the method of the present application is suitable for quality review of legal documents drafted by humans and AI-generated legal texts. Its reasoning chain analysis based on semantic graph enables various implicit vulnerabilities (such as missing evidence chain, knowledge error of using wrong regulations, conclusion deviation from the original intention, etc.) to be automatically discovered and marked.

[0015] The present application significantly improves the intelligence level of legal text review by formalizing the legal reasoning process into a multi-dimensional semantic graph and introducing an automated reasoning chain break detection mechanism. Compared with existing technologies that only perform surface inspection, the present method has the following beneficial effects:

[0016] 1. Comprehensive and in-depth vulnerability detection: With the semantic expression of the DIKWP five-dimensional model, the present method can examine the integrity of legal reasoning from different levels such as data, knowledge, and intention, and can detect reasoning vulnerabilities that are difficult for human reading to detect in a timely manner. For example, the system can detect potential premise missing and reasoning jumps in the adjudication process, making up for the shortcomings of traditional rule checking that only focuses on formal consistency and ignores semantic rationality. This ensures that the adjudication conclusion is not only consistent with the appearance of the law, but also fully supported by facts and logic.

[0017] 2. Ensuring judicial fairness and purpose alignment: By detecting "purpose-biased BUGs", the system can alert the risk of the judgment deviating from the legislative intent or the principle of fairness. This helps to avoid judgments that are "legally correct but unfair", prompting judges to reflect and calibrate their reasoning, so that the conclusion is not only formally legal but also substantially fair. In other words, this method allows the deviation of legal reasoning process from value goals to be quantitatively identified, thereby maintaining judicial fairness at the semantic level.

[0018] 3. Improving the reliability of legal AI output: In the context of AI generating legal documents, this method can serve as a quality control module for large model output. It constructs a visual logical link inside the AI reasoning process, clearly marking any unreasonable places. This transparency makes the AI system easier to debug and improve, and also increases user trust in AI recommendations. In fact, this reflects the application of the "artificial consciousness white box evaluation" idea in the legal field, i.e., measuring the effectiveness of AI cognitive process through interpretable internal representation.

[0019] 4. Assisting human review and decision optimization: The semantic graph and BUG labels output by this method intuitively show the key path and weak link of the judgment reasoning, which is equivalent to providing an intelligent review report for judges and lawyers. Human reviewers can efficiently locate problem paragraphs in the judgment and refer to system prompts for additional evidence, explanations, or correction of reasoning chains. For compliance review personnel, the system can expose logical loopholes in compliance clauses in advance, reducing legal risks. Therefore, this invention can greatly save human review time and improve work accuracy.

[0020] In the end, this invention realizes machine-readable and automatic diagnosis of legal reasoning process, which meets the needs of artificial intelligence enhancing legal practice. It is equivalent to introducing a "meta-cognition" review mechanism for legal decision-making, which is consistent with the idea of "because there is a bug, so there is a purpose". By finding and correcting "bugs" in legal reasoning, this method is expected to significantly improve the quality, transparency, and credibility of judicial decisions and legal AI products, providing strong technical support for building a fair and efficient intelligent judicial system.

Claims

1. A legal text BUG semantic graph generation and reasoning chain defect detection method, characterized in that, The method comprises the following steps: S1, legal text semantic preprocessing: obtaining a legal text to be analyzed, segmenting and dividing the legal text into semantic units, and extracting structured elements including fact statements, evidence materials, legal basis, reasoning process and conclusion; S2, DIKWP five-dimensional semantic representation construction: based on the DIKWP model, the structured elements extracted in step S1 are respectively mapped to the five semantic levels of data (Data), information (Information), knowledge (Knowledge), wisdom (Wisdom) and purpose (Purpose), and a five-dimensional semantic tensor representation of the legal text is constructed; S3, legal BUG semantic graph generation: based on the five-dimensional semantic tensor representation obtained in step S2, an integrated legal semantic graph is constructed; the semantic graph represents semantic elements as nodes and represents reasoning or causal correlation between semantic elements as edges, and identifies the DIKWP semantic level to which the node belongs; S4, broken reasoning chain detection: running a reasoning chain integrity detection algorithm on the legal semantic graph generated in step S3, checking the sufficiency and effectiveness of the semantic connection between adjacent reasoning steps along the reasoning path to identify breakpoints and logical defects in the reasoning chain; S5, BUG positioning and marking: positioning and visually marking the logical defects detected in step S4 in the semantic graph, and recording the type and location information; S6, output the detection result: output the semantic graph with BUG marking and the defect list.

2. The method of claim 1, wherein, The construction of the DIKWP five-dimensional semantic representation in step S2 is as follows: fact evidence is mapped to the data layer (Data); case scenarios and context descriptions are mapped to the information layer (Information); legal provisions, legal provisions and precedents are mapped to the knowledge layer (Knowledge); discretionary judgment and value trade-off are mapped to the wisdom layer (Wisdom); legislative purpose, judicial policy or target-oriented decision are mapped to the purpose layer (Purpose).

3. The method of claim 1, wherein, The legal semantic graph in step S3 is a network multi-layer structure supporting bidirectional feedback verification between nodes of different DIKWP semantic levels.

4. The method of claim 1, wherein, The logical defects in step S4 include at least one of the following types: causal jump: the reasoning process lacks necessary intermediate derivation links, directly jumping from the cause to the conclusion; knowledge mismatch: the legal provisions or knowledge premises relied on by reasoning do not match or are not applicable to the current case situation; purpose deviation: the reasoning conclusion deviates from the legislative purpose or value orientation behind the relevant legal provisions.

5. The method of claim 4, wherein, The broken reasoning chain detection algorithm adopts different judgment strategies for different types of logical defects: for causal jump type defects, whether there is a missing premise node or the correlation strength is lower than the threshold on the reasoning path is detected; for knowledge mismatch type defects, the semantic correlation degree between legal provision nodes and case fact nodes is calculated and compared with conflict information; for purpose deviation type defects, the semantic vectors of the conclusion node and the purpose layer node are compared for similarity, and if the similarity is lower than the threshold, it is determined that there is a deviation.

6. The method of claim 1, wherein, The legal text in step S1 includes a legal opinion generated by an artificial intelligence model, and the logical defects detected in step S4 are used to evaluate the logical reliability of the AI-generated content.

7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method of any one of claims 1 to 6 when executing the program.

8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program implements the steps of the method of any one of claims 1 to 6 when executed by the processor.

Citation Information

Cited By

  • Legal instrument writing guidance processing method and system based on language model

    CN121961784A

  • A legal document drafting guidance processing method and system based on a language model

    CN121961784B