A hallucination detection method and device for a large language model based on multi-view challenge and graph reasoning
By employing multi-perspective questioning and graph reasoning methods, a consistency graph is constructed for large language model illusion detection. This solves the illusion phenomenon in the content generated by the large language model, achieving efficient and accurate illusion risk identification and interpretable detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-11
- Publication Date
- 2026-07-03
AI Technical Summary
Existing large language models are prone to illusions when generating content, making it difficult to effectively identify and verify the accuracy of facts. Traditional methods cannot accurately locate errors and are computationally expensive, making it difficult to meet the strict requirements for the accuracy of generated content.
By employing multi-perspective questioning and graph reasoning methods, a multi-perspective cue set is generated, a consistency graph is constructed for consistency inference, hallucination risks are identified and proactive questions are generated until an adaptive stopping condition is met, and a hallucination risk report is output.
It achieves fine-grained hallucination detection, accurately identifies unstable fact atoms, provides interpretable detection results, dynamically balances detection accuracy and cost, and improves the comprehensiveness and efficiency of hallucination risk identification.
Smart Images

Figure CN122334462A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large-scale illusion detection technology, specifically to a method and apparatus for detecting large-scale language model illusions based on multi-perspective questioning and graph reasoning. Background Technology
[0002] Large language models are artificial intelligence models based on deep learning technology and centered on the Transformer architecture. Trained on massive amounts of text data, they possess powerful natural language understanding and generation capabilities, capturing semantic relationships, grammatical rules, and knowledge information within text to achieve natural language interaction with humans. These models, with their strong generalization and wide applicability, have been widely applied in various fields, including intelligent question answering, content creation, code generation, knowledge graph construction, customer service, and educational assistance. They provide users with efficient text generation, information retrieval, and question-answering services, greatly improving information processing efficiency in production and daily life. However, the "illusion phenomenon" of large language models refers to the phenomenon where the content generated by the model does not conform to objective facts, lacks true evidence, or contains logical contradictions. Specifically, it manifests as fabricating non-existent facts, data, events, or relationships, distorting or falsifying existing facts, incorrectly associating attributes or relationships between different subjects, or generating ambiguous statements that cannot be verified.
[0003] The phenomenon of illusion in traditional large language models stems from several factors: First, the limitations of the training data. The training data may contain inaccurate, incomplete, outdated, or contradictory information, making it difficult for the model to completely distinguish between valid and noisy information during the learning process, leading to the acquisition of incorrect knowledge. Second, the characteristics of the model's generation mechanism. Large language models generate text based on probability and statistics, prioritizing grammatical fluency and semantic coherence over factual accuracy. When faced with unseen queries or knowledge boundary issues, they may generate seemingly coherent but factual content through "reasonable inference." Third, the model's ability to understand and remember context is insufficient. In the processing of long texts, contextual information is easily lost or confused, leading to inconsistencies between subsequent generated content and preceding facts. Fourth, the lack of an effective fact verification mechanism. The model does not connect with real-world knowledge sources for verification during the generation process, making it impossible to correct erroneous statements in a timely manner.
[0004] To address the phenomenon of hallucinations, traditional large language models primarily employ the following measures: optimizing training data quality during the training phase by reducing the impact of low-quality information through data cleaning, deduplication, and filtering; introducing knowledge graphs or structured knowledge bases to perform simple knowledge matching during the generation process; adopting a single-round fact-checking mechanism to compare the generated content with a pre-set knowledge base; or improving the factual consistency of the generated content by adjusting model parameters and optimizing training objectives.
[0005] However, these traditional measures have obvious drawbacks: optimizing training data can only reduce errors introduced during the training phase and cannot solve the problem of real-time fact bias in the model generation process; simple knowledge matching and single-round fact checking lack fine granularity, making it difficult to cover complex factual associations and multi-dimensional semantic relationships, and unable to accurately locate specific factual errors; the method of relying on the adjustment of internal model parameters lacks universality, and the optimization effect of different models varies greatly; most traditional methods cannot provide interpretable detection evidence, and the credibility of the detection results is insufficient; at the same time, these measures often fail to balance detection quality and computational cost, either pursuing accuracy leading to excessive computation or sacrificing detection effect to control costs, and cannot meet the strict verification requirements for the factual accuracy of generated content.
[0006] In summary, a method and apparatus for hallucination detection based on a large language model using multi-perspective questioning and graph reasoning is needed to solve the above problems. Summary of the Invention
[0007] The purpose of this invention is to provide a method and apparatus for detecting hallucinations in a large language model based on multi-perspective questioning and graph reasoning, so as to solve the problems mentioned in the background art.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] This invention proposes a large language model hallucination detection method based on multi-perspective questioning and graph reasoning, the method comprising the following steps:
[0010] S1: Receive the problem information, context information, and detection configuration information to be detected;
[0011] S2: Without changing the core query intent, generate a multi-perspective suggestion set, and send a query to the large language model service to obtain a multi-round response set;
[0012] S3: Segment each round response in the multi-round response set into independent statements, extract fact statements from the independent statements, perform structured processing on each fact statement to obtain fact atoms, and normalize the fact atoms;
[0013] S4: Construct a consistency graph based on fact atoms. The consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges. Perform consistency inference on the consistency graph.
[0014] S5: Calculate the illusion risk score for each fact atom based on the consistency graph, identify unstable fact atoms by calculating the risk concentration, generate proactive challenges and add query rounds until the adaptive stopping condition is met;
[0015] S6: Output a hallucination risk report.
[0016] In step S1, the problem information to be detected, context information, and detection configuration information are received.
[0017] In step S2, without changing the core query intent, a multi-perspective hint set is generated, and the multi-perspective hint set is used to query the large language model service to obtain a multi-round response set.
[0018] The generation methods for multi-perspective prompt sets include sentence transformation, role setting, and constraint reinforcement.
[0019] The set of multi-perspective hints includes at least two types of hints that prioritize evidence, hints that limit citation, hints that suggest the role of the skeptic, and hints that constrain time and space.
[0020] The multi-perspective hint set is queried to the large language model service, and the responses obtained in each round of query constitute a multi-round response set.
[0021] In step S3, each round of response in the multi-round response set is segmented into independent statements, fact statements are extracted from the independent statements, each fact statement is structured to obtain fact atoms, and the fact atoms are normalized.
[0022] Sentence segmentation includes preliminary segmentation based on punctuation marks, followed by precise segmentation using a semantic boundary detection algorithm to obtain independent sentences;
[0023] Extracting factual statements involves extracting factual statements for each individual statement using a subject-verb-object / subject-verb-complement structure extraction algorithm, while filtering out exclamatory, interrogative, and imperative non-factual statements.
[0024] Structured processing involves mapping each fact statement to a four-tuple structured fact atom, in the format: subject S, relation R, object O, and set of structured constraints C;
[0025] Normalization processing includes entity alias normalization, time format normalization, and numerical unit normalization.
[0026] Entity alias normalization involves mapping aliases to standard entity names using a combination of string matching and semantic similarity verification, based on a pre-built entity alias dictionary. Semantic similarity is calculated using the cosine similarity formula.
[0027]
[0028] In the formula, The word vectors are the entity alias and the standard entity name, respectively. When the semantic similarity is greater than or equal to the first preset threshold, they are determined to be the same entity and normalization is performed.
[0029] Time format normalization includes converting all time representations into a standard format, and for ambiguous times, determining the specific time interval based on contextual information and converting it into the interval's start time.
[0030] Numerical unit normalization includes establishing a unit conversion mapping table based on the International System of Units (SI) to uniformly convert different units into standard units. The conversion formula is as follows:
[0031]
[0032] In the formula, The normalized standard value, These are the original values. This is the unit conversion factor.
[0033] In step S4, a consistency graph is constructed based on fact atoms. The consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges. Consistency inference is then performed on the consistency graph.
[0034] Each processed fact atom is treated as an independent node. The node attributes include quadruple information and occurrence round index. Edges are constructed based on the semantic relationships between fact atoms. A consistency graph is constructed through nodes and edges.
[0035] A depth-first search algorithm is used to traverse the consistency graph and find conflicting paths. A conflicting path is a node-connected path that contains at least one conflicting edge.
[0036] The minimum-size atomic subset of facts that contains contradictory paths and cannot be further reduced is found using the minimum subset covering algorithm:
[0037]
[0038] In the formula, A collection of testimonies of contradictions For the size of the set, Given a set of contradictory edges, the final output is the set of all minimum contradictory witnesses and their corresponding contradictory paths.
[0039] In step S5, the illusion risk score of each fact atom is calculated based on the consistency graph. Unstable fact atoms are identified by calculating the risk concentration. Active challenges are generated and additional query rounds are added until the adaptive stopping condition is met.
[0040] The hallucination risk score is obtained by weighting and combining stability, contradiction, drift and evidence deficiency indicators.
[0041] The stability index is obtained by calculating the frequency of occurrence of fact atoms in multiple rounds of response, and the formula is:
[0042]
[0043] In the formula, For the atom of facts The number of times it appears in the multi-round response set The total number of rounds in a multi-round response;
[0044] The contradiction index is obtained by calculating the proportion of edges that have contradictory relationships with fact atoms to all associated edges of the fact atom. The formula is as follows:
[0045]
[0046] For the atom of facts The number of conflicting edges associated in a consistent graph. For the atom of facts Total number of edges in the association;
[0047] The drift index is obtained by calculating the degree of semantic change of fact atoms in multiple rounds of response, and the formula is:
[0048]
[0049] In the formula, For the atom of facts The baseline form in the first round of response, For the first In the round response and Related drift edge associated atoms, To and The total number of atoms with drift edge associations. The semantic similarity between the baseline atom and the drifting atom;
[0050] The evidence missingness index is obtained by calculating the alignment between fact atoms and contextual evidence, and the formula is:
[0051]
[0052] In the formula, The set of context information to be detected. For a single piece of evidence in the context information, For the atom of facts With evidence fragments semantic similarity;
[0053] The hallucination risk score is obtained based on a weighted combination of the above indicators, using the following formula:
[0054]
[0055] In the formula, As the indicator weight, satisfying .
[0056] Risk concentration is obtained by calculating the proportion of the illusion risk score of a single node in the consistency graph to the total illusion risk score of the entire graph, using the following formula:
[0057]
[0058] In the formula, The set of all nodes in the consistency graph;
[0059] Fact atoms that satisfy the condition that the illusion risk score of a single node is greater than the second preset threshold and the risk concentration is greater than the third preset threshold are selected as unstable fact atoms.
[0060] The questioning prompts are aimed at at least one of the following types of inquiry prompts: questioning the generation of evidence from unstable fact atoms, questioning the isolation of facts, and questioning the negation of duality;
[0061] The challenge prompt is sent to the large language model service to initiate an additional query, obtain a new response, and merge the new response into the multi-round response set. Steps S3-S5 are repeated until the adaptive stopping condition is met.
[0062] Furthermore, the process for determining the adaptive stopping condition is as follows:
[0063] Adaptive stopping conditions include at least one of the following: risk target achievement condition, convergence condition, and budget exhaustion condition;
[0064] The risk threshold is met when the illusion risk score of all unstable fact atoms is less than or equal to the second preset threshold.
[0065] The convergence condition is that the change in risk in the consistency graph is lower than the fourth preset threshold. The change in risk is calculated as follows:
[0066]
[0067] In the formula, For the first The set of nodes in the consistency graph after round of queries. For the first Risk score of the round, This is the corresponding value from the previous round;
[0068] The budget exhaustion condition is that the cumulative number of query rounds reaches the fifth preset threshold;
[0069] When any of the stopping conditions is met, the query process terminates and enters the output stage.
[0070] In step S6, an illusion risk report is output.
[0071] The hallucination risk report includes an overall hallucination risk score, factual atomic-level risk information, highlighted original text excerpts, a minimal set of contradictory testimonies, and a conservatively revised answer.
[0072] The overall illusion risk score is obtained by weighting and combining the illusion risk scores of all fact atoms, as shown in the formula:
[0073]
[0074] In the formula, The importance weight of the fact atom in the original answer is determined based on the proportion of the text length corresponding to that fact atom in the original answer.
[0075]
[0076] In the formula, For the atom of facts The corresponding text length in the original answer;
[0077] The fact-atom-level risk information includes the quadruple information, stability index, contradiction index, drift index, evidence missing index, illusion risk score and risk level of each fact atom. The risk level is based on the preset risk assessment rules. According to the illusion risk score, each fact atom is classified into high risk, medium risk and low risk categories, with the risk level decreasing in that order.
[0078] The original text segment location and highlighting involves using a text matching algorithm to determine the corresponding segments of high-risk fact atoms in the original answer text, recording the start and end positions, and marking them as highlighted;
[0079] The minimum set of contradictory witnesses includes contradictory atomic pairs, contradictory edge types, and contradictory paths;
[0080] The conservative revised answer involves selecting low-consensus fact atoms from low-risk fact atoms whose stability index is less than the sixth preset threshold, revising low-risk low-consensus fact atoms, medium-risk and high-risk fact atoms, and forming a revised answer text.
[0081] This invention also proposes a large language model illusion detection device based on multi-perspective questioning and graph reasoning, comprising the following modules:
[0082] Receiving module: Receives the problem information, context information, and detection configuration information to be detected;
[0083] Multi-perspective suggestion module: Without changing the core query intent, it generates a set of multi-perspective suggestions and sends the set of multi-perspective suggestions to the large language model service to obtain a set of multi-round responses;
[0084] The fact atomization module: It segments each round response in the multi-round response set into independent statements, extracts fact statements from the independent statements, performs structured processing on each fact statement to obtain fact atoms, and performs normalization processing on the fact atoms;
[0085] Consistency Graph Module: Constructs a consistency graph based on fact atoms. The consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges, and performs consistency inference on the consistency graph.
[0086] The proactive challenge module calculates the illusion risk score for each fact atom based on the consistency graph, identifies unstable fact atoms by calculating the risk concentration, generates proactive challenges and adds query rounds until the adaptive stopping condition is met.
[0087] Output module: Output hallucination risk report.
[0088] Compared with the prior art, the beneficial effects of the present invention are:
[0089] This invention decomposes text into structured fact units and unifies the format of key information by performing fact atomization and normalization on the output of large models, thereby achieving fine-grained illusion detection and eliminating interference from differences in information expression.
[0090] By constructing a consistency graph containing multiple semantic relationship edges and performing consistency inference, a network of connections between fact atoms is established and contradictory relationships are mined, accurately identifying unstable fact atoms and providing traceable evidence of contradictions.
[0091] By initiating multiple rounds of queries through multi-perspective prompt generation technology, the model response distribution across perspectives is obtained, comprehensively capturing the consistency characteristics of factual statements and improving the comprehensiveness of hallucination risk identification;
[0092] By screening unstable fact atoms based on the risk concentration of consistency graphs and generating targeted proactive questions, targeted stress tests are conducted on high-risk facts to enhance the detection depth of high-risk areas and reduce the risk of missing illusions.
[0093] By using adaptive stopping rules to terminate the process early when the detection quality meets the requirements, the detection accuracy and query rounds are dynamically balanced, effectively controlling computational costs and improving detection efficiency.
[0094] It also integrates multi-dimensional detection results and clarifies risk locations and evidence by outputting an illusion risk report that includes factual atomic-level risk scores, original text location, and minimal contradictory witness set. This makes the detection results interpretable and auditable and helps users quickly locate and correct illusion information. Attached Figure Description
[0095] Figure 1This is a flowchart illustrating a large language model illusion detection method based on multi-perspective questioning and graph reasoning proposed in this invention. Detailed Implementation
[0096] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0097] This invention proposes a large language model hallucination detection method based on multi-perspective questioning and graph reasoning, comprising the following steps:
[0098] like Figure 1 As shown, in step S1, the problem information to be detected, context information, and detection configuration information are received;
[0099] like Figure 1 As shown, in step S2, without changing the core query intent, a multi-perspective hint set is generated, and the multi-perspective hint set is used to query the large language model service to obtain a multi-round response set.
[0100] The implementation process of step S2 is as follows:
[0101] Without changing the core query intent, a set of rules for generating multi-perspective prompts is generated through sentence transformation, role setting, and constraint reinforcement.
[0102] Multi-perspective hints include at least two of the following types: evidence priority hints, citation restriction hints, skeptic role hints, and spatiotemporal constraint hints.
[0103] Evidence-first prompt: Explicitly require the large language model to generate a response based on contextual information or known evidence, for example: "Based on the provided contextual information, answer the following question using only the evidence explicitly stated therein: [Question information]";
[0104] Citation restriction hint: The large language model is required to annotate the source of factual content in the output. Example: "Answer the following questions and annotate the specific location or basis of each factual statement from the context: [Question information]";
[0105] Skeptic Role Hint: Setting up a skeptical role guides the model to output rigorously. Example: "Suppose you need to verify the accuracy of the answer, please answer the following question from the perspective of a skeptic, avoiding unverified statements: [Question Information]"
[0106] Spatiotemporal constraint hint: Add time and space range limits, for example: "Within [time range / space range], answer the following questions. Information outside this range should be clearly marked: [Question information]";
[0107] The generated multi-perspective prompt set is queried to the large language model service in a sequential or random order. Each round of query obtains 1 response, and a total of N rounds of responses are obtained, where N≥3, preferably N=5, to form a multi-round response set.
[0108] like Figure 1 As shown, in step S3, each round response in the multi-round response set is segmented into independent statements, factual statements are extracted from the independent statements, each factual statement is structured to obtain factual atoms, and the factual atoms are normalized.
[0109] The implementation process of step S3 is as follows:
[0110] Based on punctuation marks, including periods, question marks, exclamation marks, and semicolons, preliminary segmentation is performed, followed by precise segmentation using a semantic boundary detection algorithm based on a BERT pre-trained sentence segmentation model, resulting in independent sentences.
[0111] For each independent statement, factual statements are extracted using a subject-verb-object / subject-verb-complement structure extraction algorithm, while exclamatory, interrogative, and imperative non-factual statements are filtered out.
[0112] Structured Fact Atom Mapping: Maps each fact statement to a four-tuple of structured fact atoms, in the format: Subject S, Relation R, Object O, Set of Structured Constraints C, C={q1,q2,…,qk}, where each constraint is:
[0113] qi=(type,value,norm_value,scope_id,confidence,source_span);
[0114] Among them, type includes time, location, quantity, degree, modality, negation, etc., scope_id indicates the scope of the qualifier, and source_span is the location of the original evidence;
[0115] Each fact atom is assigned a unique event_id. For nested structures, they are split into multiple fact atoms and concatenated using a "structure-connected-facts" approach, such as:
[0116] e1,has_condition,e2,C_link);
[0117] Where e1 is the main fact event_id, e2 is the nested fact event_id, and C_link is the connection constraint;
[0118] in:
[0119] Subject S: The core object of the factual description (people, events, things, concepts);
[0120] Relationship R: The way in which a subject and an object are associated (action, attribute, affiliation);
[0121] Object O: The object of the relational action;
[0122] Structured constraint set C: supplementary constraints on facts (time, space, quantity, degree);
[0123] Normalization of fact atoms includes:
[0124] Entity alias normalization involves using a pre-built entity alias dictionary (containing general aliases and domain-specific aliases) and a combination of string matching and semantic similarity verification to uniformly map aliases to standard entity names. Semantic similarity is calculated using the cosine similarity formula.
[0125]
[0126] In the formula, The word vectors of entity aliases and standard entity names generated by pre-trained language models are respectively used. When the semantic similarity is greater than or equal to a first preset threshold, they are determined to be the same entity and normalization is performed. Preferably, the first preset threshold is 0.85.
[0127] Time format normalization includes converting all time representations into the ISO8601 standard format (YYYY-MM-DDHH:MM:SS), and for ambiguous times (such as "last year" or "next month"), determining the specific time interval based on the context and then converting it into the start time of the interval.
[0128] Numerical unit normalization includes establishing a unit conversion mapping table based on the International System of Units (SI) to uniformly convert different units into standard units (e.g., length units are unified to "meter" and weight units to "kilogram"). The conversion formula is as follows:
[0129]
[0130] In the formula, The normalized standard value, These are the original values. This refers to the unit conversion factor, such as 1 kilometer → 1000 meters. ;
[0131] like Figure 1As shown, in step S4, a consistency graph is constructed based on fact atoms. The consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges, and consistency inference is performed on the consistency graph.
[0132] The implementation process of step S4 is as follows:
[0133] The consistency graph construction involves treating each normalized fact atom as an independent node. Node attributes include fact atom quadruple information and occurrence round index. Edges are constructed based on the semantic relationships between fact atoms, and edge types include:
[0134] Price edge (E): Two facts have completely identical atomic semantics and satisfy... ( (This is for fact-based semantic similarity, calculated based on the overall word vector of the quadruples).
[0135] Implied edge (I): Fact atom The semantics can be used to deduce fact atoms. The semantics, satisfying (This is an implication relation judgment function, implemented based on a logical reasoning rule base).
[0136] Contradictory edge (C): Two fact atoms have conflicting semantics, satisfying True, Contradict is the function for judging contradictions, based on a joint judgment of contradiction rules and semantic similarity. And they are logically contradictory;
[0137] Drift edge (D): Two fact atoms are semantically related but differ, satisfying And it is not an implication relationship;
[0138] Uncertain edge (U): The semantic relationship cannot be clearly determined, satisfying... However, it does not meet the equivalence standard, or its semantics are ambiguous and cannot be classified;
[0139] Performing consistency inference on a consistency graph includes:
[0140] The consistency graph is traversed using the depth-first search (DFS) algorithm:
[0141] Consistency graph nodes contain fact atom quadruples, (event_id) and occurrence round index, and edge types include equivalent edges, implied edges, contradictory edges, drift edges, and uncertain edges;
[0142] The semantic relationship judgment adopts a two-level judgment mechanism of L rule engine + NLI model + confidence calibration: The rule engine first matches high-precision rule entries. The rule entry format is <trigger condition, constraint type, judgment result, confidence / priority, applicable scope>. The constraint type covers negation / modality, quantity / range, time, and mutually exclusive categories. If a match is found, it is directly judged as implication or contradiction.
[0143] When a rule is not matched, an NLI model trained on the SNLI / MultiNLI / ANLI dataset is invoked:
[0144] Input is the factual, linearized text:
[0145] T(f) = "S <r>The concatenation of "O|time=...;loc=...;qty=...;modality=...;neg=..." outputs a three-class classification result mapped to edge type;
[0146] The NLI output probability is calibrated by temperature scaling. If max(p_E,p_C)≥τ_high, it is considered an implication / contradiction; if τ_low≤max(...)<τ_high, it is considered an uncertain edge with confidence; and if it is lower than τ_low, it is considered a low-confidence uncertain edge.
[0147] Consistency inference employs depth-first search to find contradictory paths, uses Allen's interval algebra as the theoretical basis for temporal relationship reasoning, and extracts the minimum contradictory witness set through the minimum subset covering algorithm.
[0148] Training data is generated through structured adversarial transformations, including numerical perturbations, time shifts, mutually exclusive entity replacements, and negation flips. The NLI model is then fine-tuned or a dedicated relation determiner is trained. High-confidence decision samples are mined as new rule templates and fed back into the rule base.
[0149] Find contradictory paths, which are defined as connected paths between nodes that contain at least one contradictory edge;
[0150] The minimum subset covering algorithm extracts the minimum contradictory witness set. The algorithm aims to find the smallest subset of fact atoms such that contradictory relationships exist within the subset and cannot be further reduced. Mathematically, this can be described as follows:
[0151]
[0152] In the formula, A collection of testimonies of contradictions For the size of the set, For the set of contradictory edges;
[0153] Finally, output the set of all minimal contradictory witnesses and their corresponding contradictory paths;
[0154] like Figure 1 As shown, in step S5, the illusion risk score of each fact atom is calculated based on the consistency graph, unstable fact atoms are identified by calculating the risk concentration, active challenges are generated and additional query rounds are added until the adaptive stopping condition is met;
[0155] The implementation process for calculating the illusion risk score for each fact atom in step S5 is as follows:
[0156] The stability index is obtained by calculating the frequency of occurrence of fact atoms in multiple rounds of response, reflecting their degree of consistency. The formula is:
[0157]
[0158] In the formula, For the atom of facts The number of times it appears in the multi-round response set (counts of atoms that are determined to be the same after normalization). The total number of rounds in a multi-round response;
[0159] A larger value indicates greater stability.
[0160] The contradiction index is obtained by calculating the proportion of edges that have contradictory relationships with fact atoms to all associated edges of the fact atom. The formula is as follows:
[0161]
[0162] In the formula, For the atom of facts The number of conflicting edges associated in a consistent graph. For the atom of facts Total number of associated edges (including all edge types);
[0163] A larger value indicates more contradictions;
[0164] The drift index is obtained by calculating the degree of semantic change of fact atoms in multiple rounds of response, and the formula is:
[0165]
[0166] In the formula, For the atom of facts The baseline form in the first round of response, For the first In the round response and Related drift edge associated atoms, To and The total number of atoms with drift edge associations. The semantic similarity between the baseline atom and the drifting atom;
[0167] A larger value indicates a more drastic semantic change.
[0168] The evidence missingness index is obtained by calculating the alignment between fact atoms and contextual evidence, and the formula is:
[0169]
[0170] In the formula, Context is the set of context information to be detected. For a single piece of evidence in the context information, For the atom of facts With evidence fragments semantic similarity;
[0171] A larger value indicates a lack of supporting contextual evidence;
[0172] The hallucination risk score is obtained based on a weighted combination of the above indicators, using the following formula:
[0173]
[0174] In the formula, As the indicator weight, satisfying Preferably, the value is [value]. ;
[0175] A higher value indicates a higher risk of hallucination.
[0176] The implementation process for identifying unstable fact atoms and generating proactive challenges in step S5 is as follows:
[0177] Risk concentration is obtained by calculating the proportion of the illusion risk score of a single node in the consistency graph to the total illusion risk score of the entire graph, thus filtering out unstable fact atoms. The formula is:
[0178]
[0179] In the formula, The set of all nodes in the consistency graph;
[0180] Fact atoms that satisfy the condition that the illusion risk score of a single node is greater than a second preset threshold and the risk concentration is greater than a third preset threshold are selected as unstable fact atoms. Preferably, the second preset threshold is 0.3 and the third preset threshold is 0.05.
[0181] This questioning prompt targets at least one of the following types of inquiry: probing for evidence generated from unstable fact atoms, probing for isolation, and probing for denial duality.
[0182] Evidence inquiry requires the model to provide factual basis, for example: "Please provide the specific source of evidence or reasoning process for the statement you mentioned '[Fact Atom Quadruple Summary]'".
[0183] Isolate and probe to remove contextual interference and verify facts in isolation. Example: "Ignoring the previous dialogue context, answer based solely on objective facts: Is [the core content of the fact] true? Please explain your reasoning."
[0184] Negational duality probing verifies the stability of facts through negation. Example: "Assuming that '[the core content of the fact]' is not true, please explain the possible reasons."
[0185] If you believe this assumption is incorrect, please refute it and provide evidence.
[0186] The challenge prompts are sent to the large language model service for additional queries. One response is obtained in each round of challenges. The new response is merged into the multi-round response set. Steps S3-S5 are repeated until the adaptive stopping condition is met.
[0187] The process for determining adaptive stopping conditions is as follows:
[0188] Adaptive stopping conditions include at least one of the following: risk attainment condition, convergence condition, and budget exhaustion condition:
[0189] The risk threshold is that the illusion risk scores of all unstable fact atoms are less than or equal to a second preset threshold, preferably, the second preset threshold is 0.3;
[0190] The convergence condition is that the change in risk in the consistency graph is lower than a fourth preset threshold. Preferably, the fourth preset threshold is 0.05. The change in risk is calculated as follows:
[0191]
[0192] In the formula, For the first The set of nodes in the consistency graph after round of queries. For the first Risk score of the round, This is the corresponding value from the previous round;
[0193] The budget exhaustion condition is that the cumulative number of query rounds (initial rounds + additional challenge rounds) reaches the fifth preset threshold. Preferably, the fifth preset threshold is 10, which can be adjusted by detecting configuration information.
[0194] When any of the stopping conditions is met, the query process terminates and proceeds to the result output stage;
[0195] like Figure 1 As shown, in step S6, a hallucination risk report is output;
[0196] The implementation process for outputting the hallucination risk report in step S6 is as follows:
[0197] The overall illusion risk score is obtained by weighting the risk scores of all fact atoms, as shown in the formula:
[0198]
[0199] In the formula, The importance weight of the fact atom in the original answer is determined based on the proportion of the text length corresponding to that fact atom in the original answer.
[0200]
[0201] In the formula, For the atom of facts The corresponding text length in the original answer;
[0202] The fact-atom-level risk information includes the quadruple information, stability index, contradiction index, drift index, evidence missing index, illusion risk score, and risk level of each fact atom. The risk level is based on a preset risk assessment rule. According to the illusion risk score, each fact atom is classified into high-risk, medium-risk, and low-risk categories, with the risk level decreasing sequentially. Preferably, the threshold division of the risk level adopts the ternary equal interval method, which evenly divides the value range of the risk score [0,1] into three intervals: high risk: R(F)≥0.6, medium risk: 0.3≤R(F)<0.6, and low risk: R(F)<0.3.
[0203] The original text segment location and highlighting involves using a text matching algorithm to determine the corresponding segments of high-risk fact atoms in the original answer text, recording the start and end positions, and marking them as highlighted;
[0204] The minimum set of contradictory witnesses includes contradictory atomic pairs, contradictory edge types, and contradictory paths;
[0205] The conservative revision of the answer includes screening low-consensus fact atoms from low-risk fact atoms whose stability index is less than the sixth preset threshold. Preferably, the sixth preset threshold is 0.7. The low-risk low-consensus fact atoms, medium-risk and high-risk fact atoms are revised to form the revised answer text.
[0206] Specifically, the original text of low-risk, high-consensus fact atoms is retained. For low-risk, low-consensus fact atoms, the original text is retained but a note is added stating "This information appears with a low frequency in multiple rounds of verification, and further verification is recommended." For medium-risk fact atoms, an explanation of uncertainty is added. For high-risk fact atoms, the statement "This part of the information has a high risk of illusion, and its accuracy cannot be confirmed at the moment" is replaced to form the revised answer text. The original text of low-risk fact atoms is retained.
[0207] This invention also provides a large language model illusion detection device based on multi-perspective questioning and graph reasoning, comprising the following modules:
[0208] Receiving module: Receives the problem information, context information, and detection configuration information to be detected;
[0209] Multi-perspective suggestion module: Without changing the core query intent, it generates a set of multi-perspective suggestions and sends the set of multi-perspective suggestions to the large language model service to obtain a set of multi-round responses;
[0210] The fact atomization module: It segments each round response in the multi-round response set into independent statements, extracts fact statements from the independent statements, performs structured processing on each fact statement to obtain fact atoms, and performs normalization processing on the fact atoms;
[0211] Consistency Graph Module: Constructs a consistency graph based on fact atoms. The consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges, and performs consistency inference on the consistency graph.
[0212] The proactive challenge module calculates the illusion risk score for each fact atom based on the consistency graph, identifies unstable fact atoms by calculating the risk concentration, generates proactive challenges and adds query rounds until the adaptive stopping condition is met.
[0213] Output module: Output hallucination risk report.
[0214] The large language model illusion detection device based on multi-perspective questioning and graph reasoning proposed in this invention corresponds one-to-one with the above-mentioned large language model illusion detection method based on multi-perspective questioning and graph reasoning in terms of operation process and functional effect. Therefore, the structure and operation process of the large language model illusion detection device based on multi-perspective questioning and graph reasoning will not be described again.
[0215] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can be implemented in the form of a computer program product on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0216] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Other embodiments may also be used. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / r>
Claims
1. A method for hallucination detection based on a large language model using multi-perspective questioning and graph reasoning, characterized in that, Includes the following steps: S1: Receive the problem information, context information, and detection configuration information to be detected; S2: Without changing the core query intent, generate a multi-perspective hint set, and send the multi-perspective hint set to the large language model service to obtain a multi-round response set; S3: Segment each round response in the multi-round response set into independent statements, extract fact statements from the independent statements, perform structured processing on each fact statement to obtain fact atoms, and perform normalization processing on the fact atoms; S4: Construct a consistency graph based on fact atoms, wherein the consistency graph uses fact atoms as nodes and semantic relationships between fact atoms as edges, and perform consistency inference on the consistency graph; S5: Calculate the illusion risk score for each fact atom based on the consistency graph, identify unstable fact atoms by calculating the risk concentration, generate proactive challenges and add query rounds until the adaptive stopping condition is met; S6: Output a hallucination risk report.
2. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S2, The generation methods of the multi-perspective prompt set include sentence transformation, role setting, and constraint reinforcement. The multi-perspective hint set includes at least two types of hints: evidence priority hints, citation restriction hints, skeptic role hints, and spatiotemporal constraint hints. The multi-perspective hint set is queried to the large language model service, and the responses obtained in each round of query constitute a multi-round response set.
3. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S3, The sentence segmentation includes preliminary segmentation based on punctuation marks, followed by precise segmentation using a semantic boundary detection algorithm to obtain independent sentences; The extraction of factual statements includes extracting factual statements for each independent statement using a subject-verb-object / subject-verb-complement structure extraction algorithm, and filtering out exclamatory, interrogative, and imperative non-factual statements; The structured processing includes mapping each fact statement to a four-tuple structured fact atom, in the format: subject S, relation R, object O, and set of structured constraints C; The normalization process includes normalizing entity aliases, time formats, and numerical units.
4. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 3, characterized in that, The entity alias normalization includes mapping aliases to standard entity names using a combination of string matching and semantic similarity verification based on a pre-built entity alias dictionary. Semantic similarity is calculated using the cosine similarity formula. In the formula, The word vectors are the entity alias and the standard entity name, respectively. When the semantic similarity is greater than or equal to the first preset threshold, they are determined to be the same entity and normalization is performed. The time format normalization includes converting all time representations into a standard format, and for fuzzy times, determining the specific time interval based on the context information and then converting it into the interval start time. The numerical unit normalization includes establishing a unit conversion mapping table based on the International System of Units (SI) to uniformly convert different units into standard units. The conversion formula is as follows: In the formula, The normalized standard value, These are the original values. This is the unit conversion factor.
5. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S4: Each processed fact atom is treated as an independent node. The node attributes include quadruple information and occurrence round index. Edges are constructed based on the semantic relationships between fact atoms. A consistency graph is constructed through the nodes and edges. A depth-first search algorithm is used to traverse the consistency graph to find conflicting paths, where a conflicting path is a node-connected path containing at least one conflicting edge. The minimum-size subset of facts that contains the contradictory path and cannot be further reduced is found using the minimum subset covering algorithm: In the formula, A collection of testimonies of contradictions For the size of the set, Given a set of contradictory edges, the final output is the set of all minimum contradictory witnesses and their corresponding contradictory paths.
6. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S5, The hallucination risk score is obtained by weighting and combining stability, contradiction, drift and evidence deficiency indices. The stability index is obtained by calculating the frequency of occurrence of fact atoms in multiple rounds of response, as shown in the formula: In the formula, For the atom of facts The number of times it appears in the multi-round response set The total number of rounds in a multi-round response; The contradiction index is obtained by calculating the proportion of edges that have contradictory relationships with the fact atom to all associated edges of the fact atom, using the following formula: For the atom of facts The number of conflicting edges associated in a consistent graph. For the atom of facts Total number of edges in the association; The drift index is obtained by calculating the degree of semantic change of fact atoms in multiple rounds of response, and the formula is: In the formula, For the atom of facts The baseline form in the first round of response, For the first In the round response and Related drift edge associated atoms, To and The total number of atoms with drift edge associations. The semantic similarity between the baseline atom and the drifting atom; The evidence missingness index is obtained by calculating the alignment degree between fact atoms and contextual evidence, and the formula is as follows: In the formula, Context is the set of context information to be detected. For a single piece of evidence in the context information, For the atom of facts With evidence fragments semantic similarity; The hallucination risk score is obtained based on a weighted combination of the above indicators, using the following formula: In the formula, As the indicator weight, satisfying .
7. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S5, The risk concentration is obtained by calculating the proportion of the illusion risk score of a single node in the consistency graph to the total illusion risk score of the entire graph, using the following formula: In the formula, The set of all nodes in the consistency graph; Fact atoms that satisfy the condition that the illusion risk score of a single node is greater than the second preset threshold and the risk concentration is greater than the third preset threshold are selected as unstable fact atoms. The questioning prompts are aimed at at least one of the following types: questioning of unstable fact atoms, evidence generation questioning, isolation questioning, and denial dual questioning. The challenge prompt is sent to the large language model service to initiate an additional query, a new response is obtained, and the new response is merged into the multi-round response set. Steps S3-S5 are repeated until the adaptive stopping condition is met.
8. The method for detecting hallucinations based on a large language model using multi-perspective questioning and graph reasoning as described in claim 7, characterized in that, The process for determining the adaptive stopping condition is as follows: The adaptive stopping condition includes at least one of the following: risk target achievement condition, convergence condition, and budget exhaustion condition; The risk threshold condition is that the illusion risk scores of all unstable fact atoms are less than or equal to the second preset threshold. The convergence condition is that the risk change in the consistency graph is lower than a fourth preset threshold. The risk change is calculated as follows: In the formula, For the first The set of nodes in the consistency graph after round of queries. For the first Risk score of the round, This is the corresponding value from the previous round; The budget exhaustion condition is when the cumulative number of query rounds reaches the fifth preset threshold. When any of the stopping conditions is met, the query process terminates and enters the output stage.
9. The hallucination detection method based on a large language model using multi-perspective questioning and graph reasoning as described in claim 1, characterized in that, In step S6, The hallucination risk report includes an overall hallucination risk score, factual atomic-level risk information, highlighted original text excerpts, a minimal set of contradictory testimonies, and a conservative revised answer. The overall hallucination risk score is obtained by weighted combination of the hallucination risk scores of all fact atoms, as shown in the formula: In the formula, The importance weight of the fact atom in the original answer is determined based on the proportion of the text length corresponding to that fact atom in the original answer. In the formula, For the atom of facts The corresponding text length in the original answer; The fact-atom-level risk information includes the quadruple information, stability index, contradiction index, drift index, evidence missing index, illusion risk score, and risk level of each fact atom. The risk level is based on a preset risk assessment rule. According to the illusion risk score, each fact atom is classified into high-risk, medium-risk, and low-risk categories, with the risk level decreasing in that order. The original text segment location and highlighting includes determining the corresponding segments of high-risk fact atoms in the original answer text through a text matching algorithm, recording the start and end positions, and marking them as highlighted; The minimum set of contradictory witnesses includes contradictory atomic pairs, contradictory edge types, and contradictory paths; The conservative revised answer includes screening low-consensus fact atoms from low-risk fact atoms whose stability index is less than a sixth preset threshold, revising low-risk low-consensus fact atoms, medium-risk and high-risk fact atoms, and forming a revised answer text.
10. A large language model illusion detection device based on multi-perspective questioning and graph reasoning, characterized in that, Includes the following modules: Receiving module: Receives the problem information, context information, and detection configuration information to be detected; Multi-perspective suggestion module: Without changing the core query intent, generate a set of multi-perspective suggestions, and send the set of multi-perspective suggestions to the large language model service to obtain a set of multi-round responses; Fact Atomization Module: Segment each round response in the multi-round response set into independent statements, extract fact statements from the independent statements, perform structured processing on each fact statement to obtain fact atoms, and perform normalization processing on the fact atoms; Consistency Graph Module: Constructs a consistency graph based on the fact atoms, with fact atoms as nodes and semantic relationships between fact atoms as edges, and performs consistency inference on the consistency graph; The proactive questioning module calculates the illusion risk score for each fact atom based on the consistency graph, identifies unstable fact atoms by calculating the risk concentration, generates proactive questions and adds query rounds until the adaptive stopping condition is met. Output module: Output hallucination risk report.