Causal double chain-based large language model illusion detection method and intelligent question answering method
By employing a causal dual-chain joint entropy detection method, the reasoning chain and causal chain of a large language model are extracted, and conditional entropy and mutual information are calculated. This solves the problem of recognizing complex hallucinations, achieves accurate detection of logical breaks and causal mismatches, and improves the reliability of large language models in complex decision-making scenarios.
Patent Information
- Application Number
- CN202511415732.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-09-30
AI Technical Summary
Existing hallucination detection methods struggle to effectively identify complex hallucinations in complex reasoning and decision-making scenarios using large language models, especially logical breaks and causal mismatches, leading to high-risk decision-making errors.
A joint entropy detection method based on causal dual chains is adopted. Response sets are generated through multiple rounds of sampling, inference chains and causal chains are extracted, conditional entropy and mutual information are calculated, a collaborative verification mechanism is constructed, and logical consistency is quantified to achieve multi-dimensional identification of complex hallucinations.
It significantly improves the sensitivity and robustness of detecting logical breaks and causal mismatch illusions, and can achieve accurate identification and graded risk management of complex illusions under a zero-resource framework.
Smart Images

Figure CN120892928B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of natural language processing, and particularly relates to a hallucination detection method for a large language model based on a causal double chain and an intelligent question and answer method. BACKGROUND
[0002] The statements in this section merely provide background information related to the present application and do not necessarily constitute prior art.
[0003] Large language models (LLM) are a class of natural language processing (NLP) models based on deep learning, which can understand, generate and process natural language through training on large-scale text data.
[0004] In recent years, large language models have shown significant potential in complex decision support scenarios such as financial analysis, legal reasoning and medical diagnosis. However, when generating complex reasoning and decisions, large language models generally have a complex hallucination problem. Hallucination refers to the generation of content by large language models that does not conform to actual facts or is completely fabricated. These contents may be incorrect information, irrelevant details or fabricated facts generated by large language models based on training data, and are usually difficult to judge by surface fluency. Unlike traditional factual errors, complex hallucinations often involve logical breaks, causal mismatches and missing evidence chains, making the answers appear coherent but with serious logical flaws.
[0005] Existing hallucination detection methods mainly include the following three types: end-to-end classification models can achieve overall discrimination, but are difficult to capture long-distance logical dependencies and implicit contradictions; statistical anomaly detection methods can detect explicit distribution anomalies, but lack sensitivity to deep semantics and causal rationality; rule or template-based matching methods have certain domain explainability, but have poor adaptability in complex or emerging scenarios.
[0006] Therefore, these methods mostly stay at the single-point fact verification level and cannot effectively verify the overall consistency of multi-step reasoning chains and causal networks.
[0007] Taking financial risk assessment as an example, a large language model may correctly point out that "interest rate hikes lead to capital outflows", but if it ignores the key regulatory variable "foreign exchange reserve adequacy", the conclusion will have a directional error. Such implicit hallucinations are much more harmful than general factual biases in high-risk decision-making fields, and there is an urgent need for a new detection method that can deal with complex hallucinations. SUMMARY
[0008] In order to solve the technical problems in the background art, the present application provides a large language model hallucination detection method based on causal double chains and an intelligent question and answer method, which proposes a black box large language model hallucination detection based on causal double chain joint entropy in a zero resource framework, and realizes multi-dimensional accurate identification of complex hallucinations through the construction of a reasoning chain and a cooperative verification mechanism of a causal chain.
[0009] In order to achieve the above-mentioned purpose, the present application adopts the following technical solutions:
[0010] The first aspect of the present application provides a large language model hallucination detection method based on causal double chains, which comprises:
[0011] For each input question, multiple rounds of independent sampling are initiated to form a response set containing multiple sampling responses;
[0012] For the response set, the reasoning chain and the causal chain are extracted, and the reasoning chain conditional entropy, the causal chain conditional entropy and the mutual information of the reasoning chain and the causal chain are calculated, and the weighted sum of the reasoning chain conditional entropy, the causal chain conditional entropy and the mutual information of the reasoning chain and the causal chain is taken as the hallucination score.
[0013] Further, the extraction step of the reasoning chain comprises:
[0014] For each sampling response, dependency syntax analysis is performed to obtain a dependency syntax tree;
[0015] For each sampling response, the explicit identifiers are identified, and the shortest path length of the two explicit identifiers on the dependency syntax tree is calculated, and the explicit identifiers with a shortest path length less than a distance threshold are filtered out to identify the explicit steps;
[0016] For the text segment without explicit identifiers in the sampling response, the predicate-argument pairs are identified;
[0017] Based on the explicit steps and the predicate-argument pairs, the reasoning chain is constructed.
[0018] Further, the extraction step of the causal chain comprises:
[0019] For the response set, a preliminary causal semantic network is constructed through dependency syntax analysis;
[0020] Based on the preliminary causal semantic network, dynamic template matching and semantic similarity verification are combined to extract causal pairs;
[0021] Based on the extracted causal pairs, a causal co-occurrence matrix is constructed, and after being sparsified, it is concatenated into a causal chain in the order of text logic.
[0022] Further, the causal weight in the causal co-occurrence matrix is:
[0023] ;
[0024] where, is the frequency value of cause-effect pair ij, N is the total number of samples, and are the number of occurrences of cause i and effect j, respectively, denotes the maximum value of the frequency value of cause-effect pair, denotes the field weight parameter.
[0025] Further, the reasoning chain conditional entropy is:
[0026] ;
[0027] where, denotes the contradiction probability of the jth step of reasoning; the weight coefficient and the semantic depth have the relationship ; m denotes the total number of adjacent step pairs, R and Q represent the reasoning chain and the question, respectively.
[0028] Further, the causal chain conditional entropy is:
[0029] ;
[0030] where, is the normalized frequency of the kth cause-effect relationship, N is the total number of samples, denotes the frequency of the kth cause-effect relationship; K is the total number of non-zero elements in the co-occurrence matrix; C and Q represent the causal chain and the question, respectively.
[0031] Further, the mutual information between the reasoning chain and the causal chain is:
[0032] ;
[0033] ;
[0034] where, is the minimum value; denotes the frequency of the appearance of the reasoning chain R and the causal chain C in the sampling response; denotes the joint probability of the reasoning chain R and the causal chain C under the condition of a given question Q; is the corrected joint probability; and are obtained by summing the rows and columns of , respectively.
[0035] Further, when the combination (R, C) of the reasoning chain R and the causal chain C does not appear in the sampling response, the replacement value is used instead of :
[0036] ;
[0037] wherein, is the frequency of combination (R, C) in the sampling response, is a smoothing factor, is the number of (R, C) combinations, and N is the total number of sampling times.
[0038] The second aspect of the present application provides an intelligent question and answer method, comprising:
[0039] For an input question, a hallucination score is obtained by a hallucination detection method based on a causal double chain of a large language model as described above;
[0040] When the hallucination score is less than a first threshold value, an answer is output.
[0041] Further, when the hallucination score is greater than the first threshold value and less than a second threshold value, a structured report is generated; and when the hallucination score is greater than the second threshold value, a logical break link is located using an attention weight positioning technology.
[0042] Compared with the prior art, the beneficial effects of the present application are:
[0043] The present application proposes a hallucination detection method for a black box large language model based on a causal double chain combined entropy under a zero resource framework, and through the construction of a collaborative verification mechanism of a reasoning chain and a causal chain, multi-dimensional accurate identification of complex hallucinations is realized.
[0044] Compared with the prior art, the present application can simultaneously capture deep-level implicit hallucinations such as logical breaks and causal mismatches, and use improved conditional entropy and mutual information to calculate and quantify causal consistency, thereby significantly improving the sensitivity and robustness of detection. BRIEF DESCRIPTION OF DRAWINGS
[0045] The drawings accompanying the specification of the present application form part of the present application and serve to provide a further understanding of the present application, the illustrative embodiments of the present application and their description serve to explain the present application and do not constitute an improper limitation of the present application.
[0046] Figure 1 is a flowchart of a hallucination detection method for a large language model based on a causal double chain of the first embodiment of the present application;
[0047] Figure 2 is a flowchart of a causal chain extraction and processing process of the first embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application.
[0049] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the present application. Unless otherwise indicated, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs.
[0050] Term explanation:
[0051] Zero-resource framework refers to a technical architecture that does not rely on external annotated data or knowledge base, and completes tasks through existing models, algorithms or internal mechanisms, avoiding additional data costs.
[0052] Reasoning chain refers to the logical step sequence exhibited by large language models when answering questions, usually composed of explicit logical markers (such as "first step", "therefore") and implicit logical transitions (dependent on context inference), and is used to reveal the logical path of the conclusion output by the large language model.
[0053] Causal chain refers to a series of events or variables connected by cause and effect, where the previous event directly affects the subsequent event; a sequence of cause-effect predicates (such as "cause" "trigger") and arguments (reason, result) in the text; used to assess whether the output of the large language model has reasonable causal support.
[0054] Conditional entropy refers to an information theory index that quantifies the degree of uncertainty or contradiction in the reasoning chain or causal chain under given input conditions.
[0055] Mutual information refers to an index that measures the correlation between two variables, used to assess the consistency or coupling degree between the reasoning chain and the causal chain.
[0056] Causal co-occurrence matrix refers to a matrix structure used to store the frequency and weight of different cause-effect pairs, optimized by combining TF-IDF and domain weight to highlight key causal relationships and suppress high-frequency noise.
[0057] Laplace smoothing refers to a probability smoothing method used to handle the zero probability problem caused by sparse sample data, which is used in the present application to optimize the causal co-occurrence matrix.
[0058] TF-IDF (Term Frequency-Inverse Document Frequency), refers to a commonly used text weighting method for measuring the importance of a word in a document collection. In the process of constructing the causal co-occurrence matrix in S404, the improved TF-IDF algorithm not only retains the advantages of traditional methods in measuring the importance of causal relationships, but also dynamically adapts to different domain characteristics, effectively reducing the interference of high-frequency false causality on the detection results, and improving the accuracy and robustness of illusion detection.
[0059] Embodiment one
[0060] The embodiment provides a large language model illusion detection method based on causal double chains.
[0061] In the reasoning and decision support of large language models, complex illusions have become a prominent problem that needs to be solved, among which the logical break of causality and the contradiction of reasoning chain are the most typical. Complex illusions mainly include two categories: one is structural illusion, which is characterized by logical discontinuity or causal absence between reasoning steps (such as implicit discontinuity between premises and conclusions in multi-step reasoning or incomplete evidence chain); the other is relational illusion, which is characterized by false construction of causal relationship or misjudgment of statistical correlation as causal relationship (such as false attribution in complex systems). Compared with traditional factual errors or semantic contradictions, these two types of illusions are more hidden and belong to deep cognitive bias, and they require higher sensitivity and robustness of detection methods. However, existing methods based on answer consistency (such as semantic similarity comparison and answer clustering analysis) cannot identify illusions involving multi-step reasoning and complex causal networks. In critical fields such as finance and medicine, such illusions are easily misjudged as reliable conclusions, thereby causing serious decision-making risks. Therefore, how to effectively detect complex illusions has become a key problem in improving the reliability and credibility of large language models.
[0062] The large language model illusion detection method based on causal double chains provided by the embodiment can realize quantitative evaluation of reasoning chain self-consistency and causal chain rationality and calculation of the coupling degree of the two under the zero-resource framework through multi-round differential sampling and dynamic weighting joint entropy modeling. With this mechanism, it can effectively identify implicit illusions (such as logical jumps or strong conclusions supported by weakly associated relationships) that are difficult to detect by traditional methods, and implement graded risk control according to the detection results, thereby significantly improving the logical robustness and application credibility of large language models in complex decision-making scenarios.
[0063] The large language model illusion detection method based on causal double chains provided by the embodiment, as shown in Figure 1 includes the following steps:
[0064] Step 1: Obtain a large language model, the content to be detected, and perform preprocessing, including instruction injection enhancement, semantic role labeling, and domain guide injection.
[0065] wherein the large language model is a pre-trained generative model based on a Transformer architecture (such as the GPT series).
[0066] wherein the content to be detected refers to the original input question that needs to be processed through multiple rounds of sampling.
[0067] The input content to be detected is subjected to structured preprocessing operations, including: first, using regular expressions to unify the format of reasoning predicates (such as replacing words such as "analyze" and "explain" with a uniform "REASON" label, where REASON represents reason); second, using a semantic role labeling tool (LTP) to identify core predicates and their argument structures, and assigning functional labels to each semantic unit (such as "QUERY", "CONTEXT", and "CONSTRAINT"), and recording the dependency path length and syntactic distance between arguments to capture potential logical dependencies; finally, using a dynamic template matching mechanism to inject domain-specific prefixes into the input text, such as adding "MEDICAL_ANALYSIS_REQUIRED" in a medical context, to enhance domain adaptability.
[0068] Step 2: Perform multiple rounds of differentiated sampling and response generation based on the large language model on the preprocessed data.
[0069] Specifically, for each input question, initiate multiple independent sampling requests through a concurrent interface, and during the sampling process, set the temperature parameter (T can be set between 0.5 and 0.9) and Top-p sampling (core sampling) strategy (P can take 0.9) to ensure the diversity and coverage of the generated results, ultimately forming a response set containing multiple sampling responses.
[0070] For example, for the input question "I received a clothes with a hook, want to change a new one, how to operate?", 3 rounds of independent sampling are performed, and the large language model generates 3 sampling responses:
[0071] Sampling response 1 (T=0.5, P=0.9): "You can first apply for'replacement' after-sales, upload the hook photo, then wait for the audit to pass, and follow the prompt to return the goods, we will send new goods after receiving them";
[0072] Sampling response 2 (T=0.7, P=0.9): "Please first initiate a replacement application on the order page, upload a clear picture of the hook on the clothes, then wait for the audit to pass, and after the audit passes, there will be a return address, after returning, we will arrange to send new clothes as soon as possible";
[0073] Sampling response 3 (T=0.9, P=0.9): "First go to the order and select 'after-sales' option'replacement', take 2-3 photos of the place where the hook is uploaded, then wait for the customer service to review (usually within 1 day), and after the review, send it back to the address given, and we will send a new one when we receive the goods."
[0074] Step 3: Extraction and processing of reasoning chain based on dependency relationship.
[0075] Specifically, the extraction and processing of reasoning chain adopts a multi-level parsing module driven by semantic roles, which realizes the comprehensive capture of explicit and implicit reasoning logic: for explicit reasoning steps, through the dual-channel matching of regular expressions and dependency rules, the structured logic identifiers (such as "first", "second", "then", "first", "later", etc.) are accurately identified, and the corresponding reasoning fragments are extracted; for implicit logical transition, the reasoning predicate-argument relationship graph is constructed by combining dependency distance calculation and semantic role labeling, where the dependency distance is used to quantify the path length between nodes (threshold set to ≤3 to filter remote interference), and the semantic role labeling identifies the core reasoning predicate (such as "cause") and its associated roles (Cause / Effect) through tools (LTP); finally, based on the fusion results of the above explicit and implicit information, the reasoning nodes are dynamically assembled to form a hierarchical tree-shaped reasoning structure, and they are connected in series according to the text logical order to form a reasoning chain.
[0076] Further, the extraction and processing of reasoning chain are realized through the following steps:
[0077] S301: Text segmentation and explicit identification scanning of sampling response.
[0078] First, for the response text generated by multiple rounds of sampling, first call the dependency syntax analysis tool (spaCy) to perform dependency syntax analysis on the whole response text to obtain the dependency syntax tree; at the same time, traverse the dependency syntax tree, take the root node as the depth 1, calculate the longest path length from each token (node) to the root node as the maximum depth of the token and save it;
[0079] Subsequently, structured segmentation is performed by a multi-stage text processing engine, specifically: (1) a pre-defined regular rule library is loaded to scan and identify structured logical identification words (such as "first", "second", "therefore") in the response text; (2) the boundaries of these identifiers (structured logical identifiers) are accurately located, that is, by calculating the shortest path length of two explicit identifiers (i.e., structured logical identifiers) on the dependency syntax tree, the text boundaries of the explicit reasoning steps are divided according to the dependency distance threshold (default ≤ 3, which can be dynamically adjusted), to obtain the explicit reasoning steps, avoiding the mistake of mistakenly recognizing such close explicit markers as "first, most importantly" as two independent steps; (3) remove the modifying insertions (such as "it is worth noting that") and retain the core logical components; (4) for each explicit step, assign a unique identifier (such as STEP1 (step 1), STEP2 (step 2)) and record its dependency tree depth as a basis for subsequent weighted calculation.
[0080] Among them, the regular rule library stores a series of pre-defined regular expression pattern strings, each pattern is specially used to match an "explicit logical identification word" or its common variants, for example: r"(first|second|therefore|last)\s*[,]", where r represents the prefix, \s represents the metacharacter, and * is the quantifier.
[0081] S302: Implicit logical transition construction.
[0082] Specifically, based on the S301 processing result (generated explicit step node and dependency syntax tree information), implicit logical transition construction is performed, specifically:
[0083] For text segments that lack explicit identifiers in S301, a semantic role labeling tool (LTP) is called to perform in-depth analysis to identify core reasoning predicate nodes (such as "think", "see", "open") and their associated semantic roles (including input arguments and output arguments, such as content, perceiver, and recipient), obtaining reasoning predicate-argument pairs, connecting reasoning predicate-argument pairs with a confidence level ≥ 0.6 and a dependency path length ≤ 3 to avoid incorrect connection of irrelevant reasoning predicates.
[0084] S303: Construction of reasoning chain structure.
[0085] (1) Construct a reasoning tree according to the text order: take the artificial virtual node STEP0 as the root of the reasoning tree (only for the completeness of the tree structure, not corresponding to the original text content); directly hang the explicit steps into the reasoning tree as explicit step nodes according to the text sequence; for each reasoning predicate-argument pair, as an implicit node, it is hung into the reasoning tree, specifically, first determine the input argument and output argument of the predicate-argument pair, and compare them in reverse order with the already hung nodes:
[0086] If the result argument of a certain hanging node is the same as the argument, and the shortest path on the dependency tree is ≤ 3, the reasoning predicate-argument pair is hung as a child node to the hanging node;
[0087] If the argument does not match but the distance is still ≤ 3, the reasoning predicate-argument pair is hung to a new branch of the root node;
[0088] If the distance is > 3, it is also hung to a new branch of the root node, thereby ensuring clear hierarchy and chain priority.
[0089] (2) Depth-first traversal of the entire reasoning tree is adopted to generate unique step numbers by level (implicit node numbering continues S301, ensuring that the entire reasoning chain numbering is globally unique), and to extract the semantic elements of predicate, input parameter, output parameter, and dependency depth, finally serialized to JSON output, obtaining a hierarchical tree-shaped reasoning chain.
[0090] S304: Dynamic calculation of contradiction probability.
[0091] Specifically, a pre-trained text encoder (DeBERTa-v3 model) is used to perform contradiction detection tasks.
[0092] Among them, the DeBERTa-v3 model inputs the paired adjacent step texts in the reasoning chain, analyzes the semantic consistency through the self-attention mechanism; the output layer uses the softmax (exponential normalization) activation function to generate contradiction probability values ( ), quantifying the degree of logical conflict between adjacent steps.
[0093] S305: Visual traceability trigger mechanism.
[0094] Specifically, when the reasoning chain conditional entropy H(R|Q) is greater than the preset threshold (default 0.3, adaptive adjustment), the attention heat map generation module is activated.
[0095] The attention heat map generation module first constructs the sample with abnormal entropy value (input question Q and reasoning chain R) into an input sequence of "[CLS] question: Q [SEP] reasoning: R [SEP]", inputs the DeBERTa-v3 model for forward propagation, and extracts the last layer attention weight (weight matrix of all attention heads) of the DeBERTa-v3 model; then, focusing on the attention distribution of the [CLS] label representing the overall semantics, locating its high attention area (i.e., the steps and words in the reasoning chain R with attention exceeding the threshold), if a reasoning step is highly focused by [CLS] but its own attention lacks effective connection with the key premise or supporting evidence in the question (manifested as scattered weights, pointing to irrelevant words or contradictions), then this step is located as the key suspect of logical breakage; a visual report is generated, highlighting the conflict points with red and yellow colors, and accompanying with natural language diagnosis suggestions, the report is pushed to the artificial review queue, supporting viewing of the original attention distribution data.
[0096] Wherein, [CLS] is a mark used at the beginning of an input sequence; [SEP] is used for text segmentation.
[0097] For example:
[0098] Question Q: "Will artificial intelligence lead to massive unemployment?";
[0099] Abnormal reasoning step: STEP3 "It is clear that humans will completely lose employment opportunities in the next ten years";
[0100] The attention detection information obtained is:
[0101] [CLS] gives 0.38 high attention to STEP3 as a whole (step interval average attention ≥ 1.5 times the average attention of the whole sentence); and among them, the attention weight of "completely lose" is only 0.02, the attention weight of "future ten years" is 0.05, and the core word "employment opportunity" has a weight of only 0.03, the weight is scattered and points to irrelevant words (the core word weight is less than 1 / 2 of the non-core word weight); there is no "completely lose" in the question, i.e., lacking effective connection;
[0102] Generation target: mark this step as a key suspect of logical breakage, and prompt the missing "completely lose" premise;
[0103] Positioning result: STEP3 is marked red, accompanied by the diagnosis "the conclusion 'completely lose employment opportunities' has no premise support in the question, which is a model strong reasoning hallucination".
[0104] Step 4: Causal chain extraction and processing of the sampled response based on dependency analysis and dynamic template library.
[0105] Specifically, first, the causal predicate and its arguments are located by dependency syntax analysis, and the explicit causal expressions are matched combined with the dynamic template library to identify common causal relationship patterns. For ambiguous or implicit causal relationships (such as missing trigger words or cross-sentence dependencies), Sentence-BERT is further called to calculate semantic similarity and verify whether there is a causal connection combined with the dependency path, thereby improving the ability to capture non-explicit causality. When there is inconsistency in the causal judgments obtained by different causal extraction paths, the dependency analysis results are preferred, and the context features and multiple retry mechanisms are used for resolution and optimization. Finally, a normalized domain-specific causal co-occurrence matrix is constructed (combined with domain weight calculation element value), and the causal pairs filtered by weight are concatenated into causal chains in the order of text appearance. In addition, through the double-channel mechanism of false positive feedback and new causal frequency statistics, the template library is dynamically updated to realize adaptive closed-loop optimization of causal extraction capability.
[0106] As shown in Figure 2 Step 4 specifically includes the following steps:
[0107] S401: Constructing a preliminary causal semantic network based on dependency syntax analysis.
[0108] Specifically, based on the sampled response text, deep syntax analysis is performed, and a pre-trained dependency analysis tool (spaCy) is used to automatically identify causal predicate nodes (such as "cause" and "trigger") and extract their associated argument components (such as cause entities and result entities) to construct a preliminary causal semantic network.
[0109] Specifically, through dependency analysis, causal predicate nodes and their associated argument components, i.e., cause entities (usually the subject of the causal predicate) and result entities (usually the object of the causal predicate), are identified. Subsequently, a directed edge is created for each causal relationship in the preliminary causal semantic network, with the cause entity as the starting point and the result entity as the endpoint. The attributes of the edge include the causal predicate and the confidence level (given by dependency analysis). Finally, all nodes and edges are combined into a graph structure to form a preliminary causal semantic network, providing a basis for subsequent causal relationship extraction and analysis.
[0110] It should be noted that the preliminary causal semantic network is a graph structure, but not fully connected, and each node does not have an edge with all other nodes.
[0111] S402: Causal pair extraction based on the preliminary causal semantic network combined with dynamic template matching and semantic similarity verification.
[0112] (1) First, explicit cause-effect discovery is performed on the basis of the preliminary causal semantic network: directly use the identified causal predicate nodes and their connected cause entities and result entities in the preliminary causal semantic network to generate candidate causal pairs; to deal with the typical patterns that may be missed in the preliminary causal semantic network, based on the response text, scan the pre-defined explicit causal template library (such as "because X, therefore Y") through a regular engine to obtain explicit causal pairs, and merge and compare the matched explicit causal pairs with the candidate causal pairs in the preliminary causal semantic network, fill in the missing entity nodes (cause entities or result entities) into the preliminary causal semantic network, and simultaneously establish the corresponding causal edges.
[0113] Among them, the explicit causal template library stores a series of regular expression patterns, including: pre-defined causal relationship matching patterns, cause acquisition rules, result acquisition rules, and confidence weight.
[0114] (2) Perform implicit cause-effect discovery based on semantics: combine all cause entities and result entities in the preliminary causal semantic network, remove the causal pairs that already have causal edges, and obtain a set of unconnected entity pairs; then, for the unconnected entity pairs, use the Sentence-BERT (fast sentence similarity calculation twin network) model to generate text vectors and calculate the cosine similarity: If the semantic similarity exceeds the dynamic threshold , it is determined that there is an implicit causal relationship, and an implicit causal pair is obtained, wherein the basic threshold can be updated adaptively based on historical verification results (such as 80% quantile based on the verification set), is the domain weight coefficient (such as 1.15 for finance and 0.92 for medical treatment).
[0115] (3) Combine dependency path verification to filter surface relevance: for explicit causal pairs and implicit causal pairs, extract their dependency paths in the dependency syntax tree; if the dependency path contains a causal predicate marker or a pre-defined pattern, the verification is passed; otherwise, make a final judgment in combination with local features such as negation words or modifier positions.
[0116] Understandably, this step integrates syntax structure, rule pattern and semantic information, which complement and verify each other, and together refine a more reliable and complete causal pair set from the preliminary causal network.
[0117] S403: Build conflict resolution and decay retry mechanism.
[0118] Specifically, when there is inconsistency in the causal judgments obtained from different analysis paths, a three-layer conflict resolution is started.
[0119] The inconsistency includes: internal inconsistency between the preliminary causal semantic network extraction result and the regular template matching result on the judgment of the causal relationship of the same pair of entities; external inconsistency between the preliminary causal semantic network extraction result and the implicit causal discovery result on the judgment of the causal relationship of the same pair of entities.
[0120] Prioritize dependency analysis in conflict resolution: if the dependency analysis confidence is greater than 0.6 (dynamically set), forcibly adopt its dependency extraction result and discard the explicit and implicit causal judgments that conflict with it; if the dependency analysis confidence is less than 0.6, then:
[0121] Retry operation for implicit causality: gradually reduce the similarity threshold (reduce by 10% each time, at most 3 times), and perform Top-p filtering to reduce noise interference;
[0122] For explicit causality and implicit causality that still conflicts after retrying, combine the local features of the context (such as negation words or modifier positions) to make a final judgment, and if it passes, add nodes and edges, and if it fails, discard it.
[0123] S404: Causal co-occurrence matrix establishment and weight calculation.
[0124] Specifically, based on the confirmed causal pairs, a domain-specific causal co-occurrence matrix is constructed, the matrix row represents the set of cause items (sorted by domain frequency after deduplication), the list represents the set of result items (synonym merging processing), and the element value stores the causal weight.
[0125] Among them, the causal weight is calculated by an improved TF-IDF method:
[0126] ;
[0127] Among them, is the frequency value of the causal pair ij, N is the total number of samples, and are the number of occurrences of the cause i and the result j, respectively, represents the maximum value of the frequency value of the causal pair, represents the domain weight parameter.
[0128] After weight calculation, perform row normalization (row sum is 1) and global scaling (Min-Max normalization), remove low-confidence causal pairs (weight distribution 10% quantile) to obtain a sparse matrix, and at the same time, concatenate the remaining causal pairs into a causal chain according to the text logical order.
[0129] S405: Realize closed-loop optimization and self-learning.
[0130] Specifically, continuous optimization is achieved through a double-channel feedback mechanism: when the frequency of new causal pairs exceeds 5 and the average confidence is ≥ 0.7, the predicate library is automatically expanded; when false positive cases occur more than three times in a row, the template library is retrained; the final optimization results are fed back to S401 to form a closed-loop iterative mechanism, gradually improving detection accuracy and robustness.
[0131] Step 5: Based on the coupling of reasoning chain and causal chain information, calculate the quantitative evaluation index of logical consistency.
[0132] Specifically, based on the reasoning chain and causal chain information obtained in the above steps, the logical consistency index is calculated.
[0133] (1) Reasoning chain conditional entropy H(R|Q): using the contradiction detection model (DeBERTa), combined with semantic depth weighting, the contradiction probability of the reasoning chain is calculated:
[0134] ;
[0135] wherein, represents the contradiction probability of the jth reasoning, and the weight coefficient is related to the semantic depth The relationship is , and the semantic depth of the jth reasoning step is The semantic depth is calculated by dependency analysis tree level number: the root node depth is set to 1, and the depth of each additional child node is increased by 1; m represents the total number of adjacent step pairs divided by the reasoning chain; R represents the reasoning chain; Q represents the question; H(R|Q) represents the uncertainty of the reasoning chain given the question.
[0136] (2) Causal chain conditional entropy H(C|Q): based on the causal co-occurrence matrix, the improved Gini coefficient is used to evaluate the causal dispersion:
[0137] ;
[0138] wherein, is the normalized frequency of the kth causal relationship (causal pair), freq ( k ) represents the frequency of the kth causal relationship, N is the total sample number, and K is the total number of non-zero elements in the co-occurrence matrix; C represents the causal chain; Q represents the question; H ( C | Q ) represents the uncertainty of the causal chain given the question.
[0139] (3) Mutual information I(R;C|Q) of reasoning chain and causal chain.
[0140] The reasoning chain instance R and the causal chain instance C extracted from each sample response are serialized into JSON respectively, and the SHA-256 (256-bit encryption hash algorithm) fingerprint is calculated, and a sparse matrix M is constructed with the fingerprint as the row and column index, and the element M(R,C) is the frequency of the combination of R and C appearing in the sample response.
[0141] First, the joint probability of the reasoning chain R and the causal chain C under the condition of a given problem Q is calculated P ( R , C | Q ):
[0142] ;
[0143] Where N is the total number of samples;
[0144] To reduce the impact of sparsity, the joint probability is smoothed:
[0145] ;
[0146] In the formula, P ( R , C | Q ) represents the joint probability of the reasoning chain R and the causal chain C under the condition of a given problem Q.
[0147] Then, the sum probability normalization is performed, that is, the sum of all (R,C) combination probability values is calculated, and then each probability value is divided by the sum to obtain the normalized probability distribution, which ensures that the sum of the probability distribution is 1, meeting the basic requirements of information theory.
[0148] Finally, the mutual information is calculated:
[0149] ;
[0150] Where, 、 is obtained by summing (i.e., marginalizing) the rows or columns of ; P(R|Q) and P(C|Q) are the marginal probabilities of R and C under the condition of problem Q, which can be obtained by marginalizing the joint distribution.
[0151] (4) Finally, the comprehensive score, i.e., the logical consistency index, is calculated as:
[0152] ;
[0153] Where the coefficients α 、 β and gamma are based on the problem complexity (number of reasoning steps The number of causal types can be dynamically adjusted, and the comparability and stability of scores can be guaranteed through normalization constraints.
[0154] It should be noted that when certain (R,C) combinations do not appear in the sampling, Laplace smoothing is introduced, using... replace To avoid computational interruptions due to zero probability:
[0155] ;
[0156] in, Let (R,C) be the frequency of the (R,C) combination in the sampled response. Smoothing factor ( Take it here ), Let R be the total number of categories for all possible (R,C) combinations. This represents the total number of samples.
[0157] Understandably, by multiplying conditional entropy and mutual information into a tripartite framework, a multidimensional evaluation of logical consistency is achieved: Capture explicit and implicit breaks in the reasoning chain. To assess the reasonableness of causal distribution, Assess the consistency between reasoning and causality. A low overall score or an abnormality in a single indicator can indicate potential hallucinations. Dynamic smoothing factor. Used to mitigate the extreme effects of low-frequency combinations, while the Laplace smoothing factor This is used to ensure the non-zero probability of no combination occurring. The two complement each other, alleviating sparsity and neighborhood bias, and ensuring the stability and interpretability of the detection results.
[0158] Step 6: Implement hierarchical response control based on hallucination scores (i.e., comprehensive scores) to achieve dynamic risk management from direct output to blocking and tracing the source.
[0159] Specifically, based on quantitative hallucination ratings ( Establish a three-tiered response mechanism: low-risk response ( (This allows direct output of content.) The first threshold, The second threshold; medium-risk response ( This generates structured reports (such as "Inference Chain STEP2 and Causal Chain [CAUSE] Policy → Insufficient Inflation Support"), which are then pushed to the manual review queue; high-risk response ( If the output is rejected, the source analysis module is activated to accurately locate logical breakpoints (such as reasoning steps or contradictory arguments indicating causal gaps) based on attention weight positioning technology.
[0160] It can be understood that, in addition to the comprehensive score, high-risk response is triggered based on single indicator exception: when the reasoning chain conditional entropy H(R|Q) or the causal chain conditional entropy H(C|Q) is significantly high or the mutual information I(R;C|Q) is significantly low, exceeding the preset threshold, even if the total score does not reach , it can also directly enter the high-risk processing flow to avoid missing implicit hallucinations. The single threshold can be set based on the percentile of the historical distribution of each indicator, for example, taking the 90th percentile as the upper threshold of H(R|Q) and H(C|Q), and taking the 10th percentile as the lower threshold of I(R;C|Q), and using Min-Max normalization to ensure comparability between different indicators before statistics.
[0161] It should be noted that, in actual operation, the risk threshold and can be adjusted adaptively according to the application field, task complexity or historical statistical characteristics, taking into account the detection sensitivity and false positive rate. In some high-risk application scenarios (such as medical diagnosis, financial risk assessment), the decision condition can be made more stringent by reducing or reducing , so as to reduce the potential risk of missing.
[0162] Step 7: A dual-channel self-learning mechanism based on false positive feedback and causal discovery is used to realize dynamic optimization of the template library.
[0163] Specifically, a dual-channel feedback mechanism is designed: in the false positive correction channel, when the false positive cases annotated by humans appear continuously for multiple times (here, 3 times are set), the dynamic threshold mechanism is triggered to automatically update or reduce the weight of the inefficient template, and if necessary, the template is removed to reduce the false positive rate; in the new causal discovery channel, when the frequency of the newly discovered causal relationship exceeds the preset threshold (for example, 5 times), the predicate stem and semantic role label are extracted based on dependency analysis to automatically generate matching rules and include them in the dynamic predicate library, and the feedback result is fed back to the causal matrix in real time.
[0164] It can be understood that the output results of the above-mentioned dual channels are fed back to the template matching system to form a self-adaptive closed-loop optimization mechanism, which not only gradually reduces false positives, but also continuously expands the causal knowledge base, thereby significantly enhancing the accuracy and self-learning ability of detection.
[0165] The hallucination detection method based on causal double-chain large language model provided in the embodiment proposes a black-box large language model hallucination detection based on causal double-chain joint entropy under a zero-resource framework, and realizes multi-dimensional accurate identification of complex hallucinations by constructing a collaborative verification mechanism of reasoning chain and causal chain.
[0166] Compared with existing methods that only rely on fact-checking or semantic similarity, the embodiment can simultaneously capture deep implicit hallucinations such as logical breaks and causal mismatches, and use improved conditional entropy and mutual information calculation to quantify causal consistency, significantly improving the sensitivity and robustness of detection.
[0167] In addition, the embodiment introduces a dynamic hierarchical risk management strategy, which can realize flexible responses from direct output to manual review to automatic blocking according to the hallucination score, and accurately locate the logical break link combined with attention visualization technology, thereby providing a complete and traceable evidence chain.
[0168] Through the double-channel self-learning closed-loop optimization mechanism of false positive correction and new causal storage, the embodiment has the ability to continuously evolve, can continuously reduce the false positive rate and improve the adaptability in emerging fields, and is especially suitable for financial, medical, legal and other application scenarios that require high reliability and explainability, significantly enhancing the credibility and practical value of large language model assisted decision-making.
[0169] Embodiment two
[0170] The embodiment provides an intelligent question answering method, which comprises:
[0171] For the input question, a hallucination score is obtained by the large language model hallucination detection method based on causal double chain described in embodiment one.
[0172] When the hallucination score is less than a first threshold value, the answer is output; when the hallucination score is greater than the first threshold value and less than a second threshold value, a structured report is generated and pushed to a manual review queue; and when the hallucination score is greater than the second threshold value, the answer is refused to be output, and the logical break link is accurately located based on attention weight positioning technology.
[0173] It should be noted that each module in the embodiment corresponds to each step in embodiment three one by one, and the specific implementation process is the same, which will not be repeated here.
[0174] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A hallucination detection method for a causal two-chain-based large language model, characterized in that, The method comprises the following steps: For each input question, initiate multiple rounds of independent sampling to form a response set containing multiple sampled responses; For the response set, extract the inference chain and the causal chain, and calculate the inference chain conditional entropy, the causal chain conditional entropy, and the mutual information of the inference chain and the causal chain, and take the weighted sum of the inference chain conditional entropy, the causal chain conditional entropy, and the mutual information of the inference chain and the causal chain as the hallucination score; the mutual information of the inference chain and the causal chain is: ; ; wherein, is a minimum value; denotes the frequency of occurrence of the reasoning chain R and the causal chain C in the sampled responses; denotes the joint probability of the reasoning chain R and the causal chain C given the problem Q; is the revised joint probability; and are obtained by summing the rows and columns of respectively.
2. The method of claim 1, wherein the causal double chain-based large language model hallucination detection method is characterized by, The extraction step of the inference chain comprises: For each sampled response, perform dependency syntax analysis to obtain a dependency syntax tree; For each sampled response, identify explicit markers and calculate the shortest path length of two explicit markers on the dependency syntax tree, and filter out explicit markers with a shortest path length less than a distance threshold to identify explicit steps; For the text segment without explicit markers in the sampled response, identify the predicate-argument pair; Based on the explicit steps and the predicate-argument pair, construct the inference chain.
3. The method of claim 1, wherein the method is based on a causal two-chain large language model hallucination detection method. The extraction step of the causal chain comprises: For the response set, construct a preliminary causal semantic network through dependency syntax analysis; Based on the preliminary causal semantic network, combine dynamic template matching and semantic similarity verification to extract causal pairs; Based on the extracted causal pairs, construct a causal co-occurrence matrix, and after sparsification, concatenate it into a causal chain in the order of text logic.
4. The method of claim 3, wherein the method is based on a causal double chain large language model hallucination detection method. The causal weight in the causal co-occurrence matrix is: ; wherein, is the frequency value for cause-effect pair ij, N is the total number of samples, and are the number of occurrences of cause i and effect j, respectively, denotes the maximum value of the frequency value for a cause-effect pair, denotes the domain weight parameter.
5. The method of claim 1, wherein the method is based on a causal double chain large language model hallucination detection method. The inference chain conditional entropy is: ; wherein, represents the contradiction probability of the jth step of reasoning; the weight coefficient and the semantic depth are related as ; m represents the total number of adjacent step pairs, and R and Q represent the reasoning chain and the question, respectively.
6. The method of claim 1, wherein the method is based on a causal two-chain large language model hallucination detection method. The causal chain conditional entropy is: ; wherein, is the normalized frequency of the kth cause-effect relationship, N is the total number of samples, represents the frequency of the kth cause-effect relationship; K is the total number of non-zero elements in the co-occurrence matrix; C and Q represent the cause-effect chain and the question, respectively.
7. The method of claim 1, wherein the method is based on a causal two-chain large language model hallucination detection method. When the reasoning chain R combined with the causal chain C (R,C) does not occur in the sampled response, a replacement value is used instead of : ; wherein, is the frequency of occurrence of the combination (R, C) in the sampled response, is a smoothing factor, is the number of (R, C) combinations, and N is the total number of samples.
8. An intelligent question answering method, characterized by, The method comprises the following steps: For the input question, use the hallucination detection method based on the causal double-chain large language model according to any one of claims 1-7 to obtain a hallucination score; When the hallucination score is less than a first threshold, output the answer.
9. The intelligent question answering method of claim 8, wherein, When the hallucination score is greater than the first threshold and less than a second threshold, generate a structured report; when the hallucination score is greater than the second threshold, use attention weight positioning technology to locate the logical break link.
Citation Information
Patent Citations
Chinese large language model hallucination detection technology combining information graph and causal reasoning
CN119740665A
Intelligent dialogue method, system and device based on big language model illusion relief and medium
CN120258156A