Language model online hallucination processing method and device, equipment and readable storage medium

By performing assertion-level parsing and binding relationship determination on the incremental output of the language model, combined with multi-perspective risk scoring and graded intervention, the illusion problem of the language model is solved, achieving accurate and interpretable suppression of online illusions, which is applicable to highly compliant scenarios such as finance and healthcare.

CN122365286APending Publication Date: 2026-07-10CHINA ELECTRONICS RELIABILITY AND ENVIRONMENTAL TESTING INSTITUTE ((THE FIFTH INSTITUTE OF ELECTRONICS MINISTRY OF INDUSTRY AND INFORMATION TECHNOLOGY) (CHINA SAIBAO LABORATORY)

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA ELECTRONICS RELIABILITY AND ENVIRONMENTAL TESTING INSTITUTE ((THE FIFTH INSTITUTE OF ELECTRONICS MINISTRY OF INDUSTRY AND INFORMATION TECHNOLOGY) (CHINA SAIBAO LABORATORY)
Filing Date
2026-04-29
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing language models suffer from illusions in practical applications, leading to system reliability and usability issues. Furthermore, existing methods lack a unified online illusion handling mechanism.

Method used

By performing assertion-level atomization parsing on incremental outputs in real time, the binding relationship between assertion atoms and evidence sets and tool receipt sets is determined, multi-perspective illusion risk scores are calculated, and graded intervention actions are triggered based on risk levels, including lightweight decoding convergence, targeted evidence reinforcement, tool replay, and high-risk downgrading.

Benefits of technology

It achieves precise, interpretable, and low-latency online suppression of hallucinations, integrates the model's internal state with external signals, provides objective risk scores and calculable intervention decisions, and meets the high compliance requirements of finance, healthcare, and other industries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122365286A_ABST
    Figure CN122365286A_ABST
Patent Text Reader

Abstract

This application relates to an online hallucination processing method, apparatus, device, and readable storage medium for language models. The method includes: in the process of text generation by the language model, performing assertion-level atomization parsing on the incremental output in real time to obtain assertion atoms; for each assertion atom, retrieving data from evidence services and tool receipt storage services to determine the binding relationship between the assertion atom and the candidate evidence set and tool receipt set; determining a multi-perspective hallucination risk score for each assertion atom based on the binding relationship, the internal state of the language model, and external environmental signals, and determining a global risk score based on the multi-perspective hallucination risk score of each assertion atom; matching the intervention action corresponding to the risk level from a preset intervention strategy graph according to the risk level of the global risk score, and executing the intervention action. This enables accurate, interpretable, and low-latency unified suppression of multiple types of hallucinations without relying on model retraining.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for online illusion processing using a language model. Background Technology

[0002] With the rapid development of large language models and intelligent agent technologies, language models have been widely deployed in complex application scenarios such as knowledge question answering, tool invocation, task planning, and multi-agent collaboration. In practical deployments, language models are typically combined with retrieval enhancement generation, workflow orchestration, and external tool invocation to execute long-chain tasks, significantly improving the automation and intelligence level of the system.

[0003] Currently, language models still face significant reliability and controllability issues in practical applications, with the most representative being the "illusion" phenomenon. Illusion refers to the model generating content inconsistent with facts, known constraints, or tool execution results when there is insufficient evidence, an incomplete inference chain, or abnormal external services. In agent-based scenarios, illusions not only manifest as factual errors but can also present as complex forms such as tool parameter illusions, action illusions, and misjudgments of task solvability. Furthermore, once it occurs in an intermediate step, it often propagates along the task chain, severely impacting the system's reliability and availability.

[0004] Therefore, there is an urgent need for an online illusion processing solution that can achieve fine-grained, low-latency, and interpretable processing during the language model generation process. Summary of the Invention

[0005] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for online hallucination processing of language models that can achieve fine-grained, low-latency, and interpretable online hallucination relief during the language model generation process, in response to the above-mentioned technical problems.

[0006] Firstly, this application provides an online illusion processing method for language models, the method comprising:

[0007] During the process of generating text by the language model, the incremental output is parsed in real time at the assertion level to obtain at least one assertion atom.

[0008] For each assertion atom, a search is performed in the evidence service and tool receipt storage service to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set;

[0009] Based on the binding relationship, the internal state of the language model, and external environmental signals, determine the multi-perspective illusion risk score for each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score for each assertion atom;

[0010] Based on the risk level of the global risk score, the intervention action corresponding to the risk level is matched from the preset intervention strategy map and the intervention action is executed.

[0011] In one embodiment, the assertion atom includes at least one of the following types: fact assertion, reference assertion, tool parameter assertion, and action assertion;

[0012] The tool receipts in the tool receipt set include at least one of the following: tool identifier, parameter digest hash, result digest hash, source identifier, status code, timestamp, and time-to-live (TTL).

[0013] Determining the binding relationship between the assertion atom and the candidate evidence set and tool receipt set includes:

[0014] For factual assertions and / or cited assertions, at least one of the following should be retrieved from the evidence service as a candidate evidence set: textual evidence, structured knowledge, and retrieval fragments.

[0015] For tool parameter assertions and / or action assertions, at least one of the following should be retrieved from the tool receipt storage service: tool receipt, execution log, status snapshot, and interface response, as the tool receipt set.

[0016] In one embodiment, determining the multi-perspective hallucination risk score for each assertion atom based on the binding relationship, the internal state of the language model, and external environmental signals includes:

[0017] The generation uncertainty of the assertion atom is obtained, which is derived from the ratio of the current lexical distribution entropy to the maximum entropy of the vocabulary;

[0018] The inter-layer fact deviation of the assertion atom is obtained, which is obtained by the JS divergence or KL divergence of the distribution of projected words in the later layer and the distribution of projected words in the earlier layer of the language model.

[0019] The evidence support degree of the assertion atom is obtained, which is obtained by weighting the semantic similarity, textual implication and evidence freshness between the assertion atom and its candidate evidence set.

[0020] The tool consistency of the assertion atom is obtained based on the parameter pattern matching degree between the assertion atom and its tool response set.

[0021] Obtain the environmental landing degree of the assertion atom, which is used to measure the consistency between the assertion atom and the current runtime environment state;

[0022] The multi-perspective illusion risk score of the assertion atom is obtained by weighting and summing the generation uncertainty, inter-layer fact deviation, evidence support, tool consistency, and environmental implementation.

[0023] In one embodiment, the intervention action includes a tiered intervention action, which includes at least one of the following: lightweight decoding convergence, targeted evidence reinforcement, tool replay, verification chain verification, and high-risk downgrade;

[0024] The step of matching the intervention action corresponding to the risk level from a preset intervention strategy map based on the risk level of the global risk score, and executing the intervention action, includes:

[0025] If the global risk score is lower than the first threshold, normal generation will continue;

[0026] If the global risk score is greater than or equal to the first threshold and lower than the second threshold, lightweight decoding convergence is performed.

[0027] If the global risk score is greater than or equal to the second threshold and lower than the third threshold, targeted evidence reinforcement shall be performed.

[0028] If the global risk score is greater than or equal to the third threshold and lower than the fourth threshold, the tool will replay or verify the chain check.

[0029] If the global risk score is greater than or equal to the fourth threshold, a high-risk downgrade is performed.

[0030] In one embodiment, the lightweight decoding convergence includes at least one of: reducing the sampling temperature, narrowing the kernel sampling parameters, and enabling inter-layer contrast decoding;

[0031] The targeted evidence reinforcement includes: generating search queries and supplementing evidence only for high-risk assertion atoms;

[0032] The tool replay or verification chain verification includes: re-invoking the tool or generating verification questions and comparing the returned results;

[0033] The high-risk downgrade includes: providing evidence for a refusal to answer, providing a conservative answer, clarifying the question, or transferring the issue to a human operator.

[0034] In one embodiment, after performing the intervention, the method further includes:

[0035] The target assertion obtained after intervention is bound to its corresponding evidence identifier or tool receipt identifier to generate an auditable output structure;

[0036] For assertion atoms that cannot be adequately supported, perform at least one of the following actions: delete, rewrite as an indeterminate expression, explicitly label, or reject output.

[0037] In one embodiment, after performing the intervention, the method further includes:

[0038] Record the risk trajectory, trigger threshold, intervention actions, evidence coverage and final judgment results during the current task execution process to form a feedback sample. The final judgment results include manual feedback results and / or automatic verification results.

[0039] The weight parameters, risk thresholds, and intervention strategy diagrams of the multi-perspective hallucination risk score are iteratively updated using the feedback samples.

[0040] Secondly, this application also provides an online illusion processing device for language models, the device comprising:

[0041] The assertion parsing module is used to perform assertion-level atomic parsing on the incremental output in real time during the text generation process of the language model, so as to obtain at least one assertion atom.

[0042] The binding module is used to retrieve data from the evidence service and tool receipt storage service for each assertion atom to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set.

[0043] The risk scoring module is used to determine the multi-perspective illusion risk score of each assertion atom based on the binding relationship, the internal state of the language model and external environmental signals, and to determine the global risk score based on the multi-perspective illusion risk score of each assertion atom.

[0044] The graded intervention module is used to match the intervention action corresponding to the risk level from a preset intervention strategy map based on the risk level of the global risk score, and execute the intervention action.

[0045] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0046] During the process of generating text by the language model, the incremental output is parsed in real time at the assertion level to obtain at least one assertion atom.

[0047] For each assertion atom, a search is performed in the evidence service and tool receipt storage service to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set;

[0048] Based on the binding relationship, the internal state of the language model, and external environmental signals, determine the multi-perspective illusion risk score for each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score for each assertion atom;

[0049] Based on the risk level of the global risk score, the intervention action corresponding to the risk level is matched from the preset intervention strategy map and the intervention action is executed.

[0050] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0051] During the process of generating text by the language model, the incremental output is parsed in real time at the assertion level to obtain at least one assertion atom.

[0052] For each assertion atom, a search is performed in the evidence service and tool receipt storage service to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set;

[0053] Based on the binding relationship, the internal state of the language model, and external environmental signals, determine the multi-perspective illusion risk score for each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score for each assertion atom;

[0054] Based on the risk level of the global risk score, the intervention action corresponding to the risk level is matched from the preset intervention strategy map and the intervention action is executed.

[0055] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0056] During the process of generating text by the language model, the incremental output is parsed in real time at the assertion level to obtain at least one assertion atom.

[0057] For each assertion atom, a search is performed in the evidence service and tool receipt storage service to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set;

[0058] Based on the binding relationship, the internal state of the language model, and external environmental signals, determine the multi-perspective illusion risk score for each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score for each assertion atom;

[0059] Based on the risk level of the global risk score, the intervention action corresponding to the risk level is matched from the preset intervention strategy map and the intervention action is executed.

[0060] The aforementioned online hallucination processing method, device, computer equipment, computer-readable storage medium, and computer program product using language models perform real-time assertion-level atomization parsing on incremental output during the text generation process of the language model, obtaining at least one assertion atom. This refines hallucination detection from coarse-grained whole-segment text to assertion-level atomic units, enabling precise location and early detection of high-risk content. For each assertion atom, the binding relationship between the assertion atom and the candidate evidence set and tool receipt set is determined by searching evidence services and tool receipt storage services. This establishes a traceable support chain between each assertion and external evidence and tool receipts, extending hallucination judgment from internal model perception to alignment with external facts. Based on the binding relationship, the internal state of the language model, and external environmental signals, a multi-perspective hallucination risk score is determined for each assertion atom, and a global risk score is determined based on the multi-perspective hallucination risk score of each assertion atom. This allows for the fusion of the model's internal state and multi-source external signals for comprehensive quantitative scoring, providing objective and calculable risk basis for intervention decisions. By matching the intervention action corresponding to the risk level from a preset intervention strategy map based on the global risk score, and executing the intervention action, a progressive intervention from light to heavy intensity can be triggered according to the risk level, achieving online suppression with minimal necessary cost between control effect and operating cost. This embodiment elevates hallucination mitigation from offline posterior correction to online runtime control. Through a closed-loop mechanism of "assertion localization—evidence binding—multi-modal scoring—tiered intervention," it can achieve accurate, interpretable, and low-latency unified suppression of multiple types of hallucinations without relying on model retraining. Attached Figure Description

[0061] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0062] Figure 1 This is a flowchart illustrating an online illusion processing method using a language model in one embodiment.

[0063] Figure 2 This is a flowchart illustrating the online illusion processing method using a language model in another embodiment;

[0064] Figure 3 This is a flowchart illustrating the online illusion processing method for a language model in yet another embodiment;

[0065] Figure 4This is a structural block diagram of an online illusion processing device for a language model in one embodiment;

[0066] Figure 5 This is a structural block diagram of the online illusion processing device for the language model in another embodiment;

[0067] Figure 6 This is a structural block diagram of the online illusion processing device for the language model in another embodiment;

[0068] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0069] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0070] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0071] To facilitate understanding of the technical solutions in the various embodiments of this application, the technical terms that may appear in the various embodiments of this application will be briefly explained first.

[0072] 1) Cloud-Native: A software deployment approach oriented towards containers, microservices, elastic orchestration, and continuous delivery.

[0073] 2) Agent: A software entity with a large language model at its core that can plan, call tools, access external services, maintain task state, and complete complex tasks.

[0074] 3) Transformer: A neural network structure with self-attention mechanism at its core, it is the mainstream basic architecture of current large language models.

[0075] 4) Hallucination: The phenomenon that the content generated by the model is inconsistent with the facts, evidence or known constraints, which can be misleading, especially in scenarios such as question answering, summarizing, and agent task planning.

[0076] 5) Tool Invocation: Actions taken by an agent during operation to invoke external capabilities such as retrieval, databases, search, application programming interfaces (APIs), and executors.

[0077] 6) Tool receipt: A structured record generated by runtime for a single tool call, including at least the tool identifier, parameter summary, return summary, timestamp, status code, source identifier, and expiration date.

[0078] 7) Assertion: The smallest verifiable unit formed by the model in the output, which can be a fact assertion, numerical assertion, reference assertion, tool parameter assertion, or action assertion.

[0079] 8) Hallucination Risk Score: A quantitative result of the risk of hallucination occurring at the current generation location or the current assertion.

[0080] 9) Intervention strategy diagram: A set of control rules for selecting different online intervention actions according to risk level.

[0081] With the rapid development of cloud-native architecture, service-oriented deployment of large language models, and intelligent agent applications, intelligent agent models have been widely embedded in knowledge question answering, tool invocation, task planning, automated report generation, and multi-agent collaborative processes. In cloud-native systems, intelligent agents are typically deployed as microservices, combining retrieval-augmented generation (RAG), workflow orchestration, external tool invocation, and multi-turn session memory to perform complex tasks. While these systems significantly improve automation capabilities, their reliability and controllability issues are becoming increasingly prominent, the most typical being the illusion problem: the model may generate seemingly reasonable but inconsistent content when there is insufficient evidence, the tool returns anomalies, or the inference chain is incomplete.

[0082] Meanwhile, intelligent agent systems are expanding from single-round question-and-answer sessions to long-chain task flows of "planning—retrieval—tool invocation—execution—feedback." In tool-enhanced and intelligent agent scenarios, models not only suffer from factual illusions but also more complex problems such as parameter illusions, tool intent illusions, and misjudgments of task solvability; and once these problems occur in intermediate steps, they often propagate along the task chain. Existing methods generally lack a unified runtime control mechanism to determine whether the model output is truly constrained by retrieved evidence, tool feedback, service status, and external environment.

[0083] Existing research mainly focuses on the following three technical approaches:

[0084] First: Detection method based on uncertainty: using semantic entropy and internal state of the model for hallucination detection.

[0085] Second: Fact completion method based on retrieval enhancement: supplementing factual evidence by retrieving external knowledge bases.

[0086] Third: Inference-phase correction methods based on verification chains, self-reflection, or comparative decoding: correcting the generated content during the model inference process.

[0087] Specifically, the first technical approach mentioned above employs a contrastive decoding method: by comparing the logical differences between the later and earlier layers of the large model projected onto the vocabulary space, the next lexical distribution is constructed, thereby improving factual accuracy without relying on external retrieval or additional fine-tuning. Its core principle is to leverage the phenomenon that "factual knowledge is often localized to a specific Transformer layer," obtaining a new next lexical distribution through inter-layer comparison to reduce the generation of erroneous facts.

[0088] Specifically, the second technical approach mentioned above adopts a post-hoc correction approach: first, an initial answer and corresponding reasoning process are generated based on the initial input; then, the initial question-answer pair is judged to be an illusion. If it is judged that an illusion may exist, the initial answer is corrected and output by combining the evidence set with the reasoning process. This approach is essentially a post-hoc correction scheme of "generate first—judge later—correct later" and is closely related to Retrieval-Augmented Generation (RAG) optimization.

[0089] Overall, most existing methods only cover one dimension of hallucination mitigation and have not yet formed a systematic online mitigation mechanism for cloud-native intelligent agent scenarios, which includes "assertion extraction, evidence binding, risk fusion, and tiered intervention".

[0090] To address the problems existing in the prior art, this application aims to provide an online illusion processing method for language models. This method can extract assertions and tool intents in real time during the model generation process, bind them with retrieval evidence, tool execution receipts, and environmental states, calculate multi-perspective illusion risk scores, and trigger graded interventions based on risk levels, so as to achieve unified online suppression of factual illusions, parametric illusions, and action illusions.

[0091] In one exemplary embodiment, such as Figure 1 As shown, an online hallucination processing method using a language model is provided. The method in this embodiment may include the following steps S101 to S104. Wherein:

[0092] Step S101: During the process of generating text by the language model, assertion-level atomization is performed on the incremental output in real time to obtain at least one assertion atom.

[0093] Assertion atoms include at least one of the following types: factual assertions, reference assertions, tool parameter assertions, and action assertions. Factual assertions can include verifiable factual statements such as entities, attributes, time, values, and causal relationships. Reference assertions can include statements with source claims, such as "derived from a document / webpage / database." Tool parameter assertions can include parameter information related to tool calls, such as API names, parameter names, and parameter values. Action assertions can include statements describing system behavior or state changes, such as "an operation will be performed" or "the system has completed a step."

[0094] In this step, by transforming the coarse-grained question of "whether the entire text is an illusion" into the fine-grained question of "whether a verifiable assertion lacks support", the smallest control unit can be provided for subsequent online intervention.

[0095] For example, when the language model of a cloud-native intelligent agent generates output text word by word, an assertion parser performs real-time parsing on a portion of the output at time t, dividing the continuous incremental output into the smallest verifiable unit—the assertion atom—thereby obtaining the assertion set at time t. .

[0096] in, For a moment The set of assertions; For the first An assertion atom.

[0097] Step S102: For each assertion atom, retrieve data from the evidence service and tool receipt storage service respectively to determine the binding relationship between the assertion atom and the candidate evidence set and tool receipt set.

[0098] In this embodiment, for each assertion atom Candidate support sets were retrieved from the evidence service and tool receipt storage services, respectively. With tool receipt collection .

[0099] in, , ; This represents the j-th candidate piece of evidence for the i-th assertion. This represents the k-th tool response for the i-th assertion.

[0100] The tool receipts in the tool receipt set include at least one of the following: tool identifier, parameter digest hash, result digest hash, source identifier, status code, timestamp, and time to live (TTL). This information is used to uniquely identify a tool call and its execution result, and supports the determination of the result's validity period.

[0101] For example, for factual assertions and / or cited assertions, at least one of the following is preferentially retrieved from the evidence service as a candidate evidence set: textual evidence, structured knowledge, and retrieval fragments. The evidence service is responsible for retrieving information from knowledge bases, search engines, enterprise knowledge sources, or other trusted data sources to provide factual support for the assertions.

[0102] For example, for tool parameter assertions and / or action assertions, at least one of the following is retrieved from the tool receipt storage service as a tool receipt set: tool receipt, execution log, status snapshot, and interface response. The tool receipt storage service specifically records tool calls and their structured results, providing engineering-side signals for judging parameter consistency and action implementation.

[0103] In this step, by establishing a "one-to-one binding between output content and supporting objects", a traceable support chain is created for each assertion, which makes it easier to determine "what this statement is based on" online.

[0104] Step S103: Based on the binding relationship, the internal state of the language model and the external environment signal, determine the multi-perspective illusion risk score of each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score of each assertion atom.

[0105] In this embodiment, a multi-perspective fusion approach can be adopted to calculate five risk components for each assertion atom, namely: generation uncertainty, inter-layer factual deviation, evidence support, tool consistency, and environmental implementation.

[0106] For example, firstly, the generation uncertainty of the assertion atom is obtained, which is derived from the ratio of the current lexical distribution entropy to the maximum entropy of the vocabulary; secondly, the inter-layer fact deviation of the assertion atom is obtained, which is derived from the JS divergence (Jensen-Shannon divergence) or KL divergence (Kullback-Leibler divergence) between the distribution of projected words in the later layers and the distribution of projected words in the earlier layers of the language model; thirdly, the evidence support of the assertion atom is obtained, which is derived from the weighted sum of semantic similarity, textual implication, and evidence freshness between the assertion atom and its candidate evidence set; fourthly, the tool consistency of the assertion atom is obtained, which is derived from the parameter pattern matching degree between the assertion atom and its tool response set; fifthly, the environmental context of the assertion atom is obtained, which measures the consistency between the assertion atom and the current runtime environment state; finally, the generation uncertainty, inter-layer fact deviation, evidence support, tool consistency, and environmental context are weighted and summed to obtain the multi-perspective illusion risk score of the assertion atom.

[0107] Regarding the generation uncertainty It can be obtained by normalizing the current next-token distribution entropy or the window average entropy, and is used to characterize the degree of hesitation of the model at the current position:

[0108]

[0109] in, Indicates time The probability distribution of lexical terms, Represents information entropy. Indicates the size of the vocabulary.

[0110] Regarding the deviation of facts between layers The difference between the logits distribution of the later layer and the logits distribution of the earlier layer can be used to characterize whether the model deviates from its more robust tendency to represent facts. KL divergence, JS divergence, or equivalent measures can be used.

[0111]

[0112] in, Indicates the distribution of words in the subsequent projection. This represents the distribution of the projected words in the previous layer, and JS represents the JS divergence.

[0113] Regarding the degree of support of evidence It can be used to measure the match, implication, and coverage between assertions and candidate evidence:

[0114]

[0115] in, Indicates semantic similarity; Indicates the textual implication or factual support level; The first value represents the freshness of the evidence; α represents the semantic similarity weight coefficient, which measures how close the "assertion" and "evidence" are in terms of semantic content; β represents the implied support weight coefficient, which measures whether the evidence can directly support, infer, or prove the assertion; and γ represents the freshness of the evidence weight coefficient, which measures whether the evidence is new enough and whether it is still valid.

[0116] Regarding tool consistency It can be used to measure whether an assertion is consistent with the current runtime environment state, such as whether a cache has expired, whether an interface has succeeded, whether a resource exists, or whether a service is reachable.

[0117] Ultimately, an assertion-level hallucination risk score was obtained. The calculation formula is as follows:

[0118]

[0119] in, , , , , Each corresponds to one of the five weight parameters ( This represents the generation uncertainty weighting coefficient; This represents the weighting coefficient for the degree of factual deviation between layers; Indicates the risk weighting coefficient for insufficient evidence; Indicates the risk weighting coefficient for inconsistency in instruments; (representing the environmental mismatch risk weighting coefficient), and satisfying .

[0120] Furthermore, overall risk The calculation formula is as follows:

[0121]

[0122] Step S104: Based on the risk level of the global risk score, match the intervention action corresponding to the risk level from the preset intervention strategy map and execute the intervention action.

[0123] The intervention actions include tiered intervention actions, which include at least one of the following: lightweight decoding convergence, targeted evidence reinforcement, tool replay, verification chain verification, and high-risk downgrade.

[0124] As an alternative example, multiple threshold levels can be pre-set, and an intervention strategy graph can be constructed.

[0125] For example, when the global risk score is below a first threshold In the case of a global risk score greater than or equal to the first threshold, maintain normal generation; And below the second threshold In the case of convergence of lightweight decoding, the global risk score is greater than or equal to the second threshold. And below the third threshold In cases where targeted evidence reinforcement is performed; when the global risk score is greater than or equal to the third threshold. And below the fourth threshold In cases where the execution tool replays or verifies the chain of checks, and the global risk score is greater than or equal to the fourth threshold, the execution tool will replay or verify the chain of checks. In such cases, implement a high-risk downgrade.

[0126] In the above embodiments, lightweight decoding convergence includes at least one of the following: reducing sampling temperature, narrowing kernel sampling parameters (top-p parameters, which are sampling strategy parameters used when the language model generates text), and enabling inter-layer contrastive decoding; targeted evidence reinforcement includes: generating retrieval queries and supplementing evidence only for high-risk assertion atoms; tool replay or verification chain verification includes: re-calling the tool or generating verification questions and comparing the returned results; high-risk downgrading includes: outputting evidence-based rejections, conservative answers, clarification questions, or transferring to human intervention.

[0127] This embodiment avoids the high-latency approach of "repeated RAG / multiple rounds of verification for all problems" by adopting the strategy of "taking the minimum necessary intervention according to risk". It intervenes as soon as a high-risk assertion is formed, thus achieving a balance between cost and effectiveness.

[0128] In the aforementioned online hallucination processing method using language models, at least one assertion atom is obtained by real-time atomization parsing of the incremental output during the text generation process of the language model. This refines hallucination detection from coarse-grained whole-segment text to assertion-level atomic units, enabling precise location and early detection of high-risk content. For each assertion atom, the binding relationship between the assertion atom and the candidate evidence set and tool receipt set is determined by searching the evidence service and tool receipt storage service. This establishes a traceable support chain between each assertion and external evidence and tool receipts, extending hallucination judgment from internal model perception to alignment with external facts. Based on the binding relationship, the internal state of the language model, and external environmental signals, a multi-perspective hallucination risk score is determined for each assertion atom, and a global risk score is determined based on the multi-perspective hallucination risk score of each assertion atom. This allows for the fusion of the model's internal state and multi-source external signals for comprehensive quantitative scoring, providing objective and calculable risk basis for intervention decisions. By matching the intervention action corresponding to the risk level from a preset intervention strategy map based on the global risk score, and executing the intervention action, a progressive intervention from light to heavy intensity can be triggered according to the risk level, achieving online suppression with minimal necessary cost between control effect and operating cost. This embodiment elevates hallucination mitigation from offline posterior correction to online runtime control. Through a closed-loop mechanism of "assertion localization—evidence binding—multi-modal scoring—tiered intervention," it can achieve accurate, interpretable, and low-latency unified suppression of multiple types of hallucinations without relying on model retraining.

[0129] In another exemplary embodiment, such as Figure 2 As shown, an online hallucination processing method using a language model is provided. The method in this embodiment may include the following steps S201 to S206. Wherein:

[0130] Step S201: During the process of generating text by the language model, assertion-level atomization is performed on the incremental output in real time to obtain at least one assertion atom.

[0131] Step S202: For each assertion atom, retrieve data from the evidence service and tool receipt storage service respectively to determine the binding relationship between the assertion atom and the candidate evidence set and tool receipt set.

[0132] Step S203: Based on the binding relationship, the internal state of the language model and the external environment signal, determine the multi-perspective illusion risk score of each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score of each assertion atom.

[0133] Step S204: Based on the risk level of the global risk score, match the intervention action corresponding to the risk level from the preset intervention strategy map and execute the intervention action.

[0134] For the specific implementation process and technical effects of steps S201 to S204 in this embodiment, please refer to [link / reference]. Figure 1 The relevant descriptions of steps S101 to S104 in the method embodiment shown will not be repeated here.

[0135] Step S205: Bind the target assertion obtained after intervention to its corresponding evidence identifier or tool receipt identifier to generate an auditable output structure.

[0136] In this embodiment, after the graded intervention is completed, the language model has performed corresponding intervention actions (such as lightweight decoding convergence, targeted evidence reinforcement, tool replay, or high-risk downgrading) for assertion atoms of different risk levels. At this point, it is also necessary to structure and organize the assertions that have been confirmed as credible after intervention to form an auditable and traceable final output.

[0137] For example, for each high-confidence assertion retained after intervention (i.e., assertion atoms with risk scores below the threshold and verified by intervention), i.e., the target assertion, it is bound one-to-one with evidence identifiers or tool feedback identifiers supporting the assertion to form a structured output unit. The final output can be represented as follows: :

[0138]

[0139] in, This represents the i-th objective assertion; This indicates the evidence citation identifier or tool receipt identifier corresponding to the i-th target assertion.

[0140] In this embodiment, "whether the result is credible" is transformed into "whether the result is traceable, explainable, and auditable", so that users or downstream systems can clearly understand the information source of each output assertion and meet the auditability requirements of scenarios with high compliance requirements such as finance, healthcare, and government affairs.

[0141] Step S206: For assertion atoms that cannot be adequately supported, perform at least one of the following actions: delete, rewrite as an indeterminate expression, explicitly label, or reject output.

[0142] In this embodiment, some assertion atoms may fall into the following categories: evidence support is below a preset threshold, tool consistency is mismatched, environmental implementation verification fails, or sufficient external support cannot be obtained even after intervention. For these assertion atoms that cannot obtain sufficient support, the unverified original content is not directly output; instead, at least one of the following preset security processing methods is executed:

[0143] 1) Deletion: Remove assertion atoms that cannot be supported directly from the output. This is suitable for scenarios where the assertion atom is redundant information, non-core content, or where deletion does not affect the overall semantic coherence. For example, if the model generates "This product is priced at 99 yuan and is currently available in red and blue," where "red and blue" cannot be supported, then the phrase should be deleted, and the output should be "This product is priced at 99 yuan."

[0144] 2) Rewrite as an uncertain expression: Rewrite a definitive assertion as an expression with uncertainty, such as adding modifiers like "maybe," "it is speculated," or "not yet confirmed." For example, if the original assertion is "Beijing will be sunny tomorrow," and it is determined that there is insufficient support for it, it can be rewritten as "Beijing may be sunny tomorrow" or "It is currently impossible to confirm the weather in Beijing tomorrow."

[0145] 3) Explicit Labeling: Add explicit labeling information after the assertion atom to inform the user that the content is unverified or has low confidence. Labeling methods may include: adding a "Pending Verification" label, using special symbols (such as asterisks or question marks), changing font color, or adding footnotes. For example, output "This drug is effective in 80% of patients" and add a footnote stating "This data source has not been independently verified."

[0146] 4) Reject Output: For high-risk assertion atoms that cannot be supported, directly reject the output of the assertion, and optionally provide a rejection explanation. This is suitable for scenarios where the assertion is a core conclusion, its semantics are incomplete after deletion, and rewriting or labeling may still mislead users. For example, if the model is asked "What is the maximum power of this device?", if the relevant assertion cannot be supported, reject the output of the assertion and output "This information cannot be confirmed; it is recommended to consult the official technical specifications."

[0147] In this embodiment, through diverse unsupported assertion processing strategies, the availability of the output is ensured while avoiding the direct presentation of unverified hallucination content to the user, thus achieving safe and controllable generation that prioritizes "better to say nothing than to say something wrong".

[0148] In yet another exemplary embodiment, such as Figure 3 As shown, an online hallucination processing method using a language model is provided. The method in this embodiment may include the following steps S301 to S306. Wherein:

[0149] Step S301: During the process of generating text by the language model, assertion-level atomization is performed on the incremental output in real time to obtain at least one assertion atom.

[0150] Step S302: For each assertion atom, retrieve data from the evidence service and tool receipt storage service respectively to determine the binding relationship between the assertion atom and the candidate evidence set and tool receipt set.

[0151] Step S303: Based on the binding relationship, the internal state of the language model and the external environment signal, determine the multi-perspective illusion risk score of each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score of each assertion atom.

[0152] Step S304: Based on the risk level of the global risk score, match the intervention action corresponding to the risk level from the preset intervention strategy map and execute the intervention action.

[0153] For the specific implementation process and technical effects of steps S301 to S304 in this embodiment, please refer to [link / reference]. Figure 1 The relevant descriptions of steps S101 to S104 in the method embodiment shown will not be repeated here.

[0154] Step S305: Record the risk trajectory, trigger threshold, intervention actions, evidence coverage and final judgment result during the current task execution process to form a feedback sample.

[0155] The final judgment result includes the results of manual feedback and / or automatic verification.

[0156] In this embodiment, after steps S301 to S304 (including assertion parsing, evidence binding, risk scoring, graded intervention, auditable output generation, and unsupported assertion processing) are completed, the key data in the current task execution process can be recorded throughout the entire process through the observability export service to form feedback samples that can be used for subsequent iterative optimization.

[0157] For example, a risk trajectory refers to a complete risk evolution sequence recorded from the start to the end of a task, including the risk score of each assertion atom at the time of generation, the specific values ​​of risk components (generation uncertainty, inter-layer factual deviation, evidence support, tool consistency, and environmental applicability), and the curve of the global risk score changing over time. For example, in a weather query task, the risk trajectory is recorded as follows: "t=1 second, assertion 'Beijing weather is sunny,' risk score 0.2; t=2 seconds, assertion 'temperature 25°C,' risk score 0.75, with evidence support of only 0.3; t=3 seconds, the global risk score rises to 0.75, triggering..." Level intervention.

[0158] For example, the trigger threshold refers to: the risk threshold configuration actually used in this task ( , , , The specific numerical values), as well as the threshold range into which the global risk score falls and the corresponding intervention level.

[0159] For example, an intervention action refers to: recording the type and details of the actual intervention action performed, including but not limited to: specific parameter adjustments for lightweight decoding convergence (e.g., temperature decreasing from 0.8 to 0.5, top-p narrowing from 0.95 to 0.7), retrieval queries for targeted evidence reinforcement and the number of returned results, the number of times the tool replay was called and the response time, and the output type for high-risk downgrades (refusal to answer / conservative answer / clarification of questions / transfer to human intervention). For example, "Triggering targeted evidence reinforcement intervention, generating a retrieval query 'Beijing weather temperature on January 1, 2025', the retrieval returned 3 pieces of evidence, of which 2 support 'sunny' and 0 support '25°C'."

[0160] For example, evidence coverage refers to the binding status of assertion atoms with evidence / receipts in this task, including: the total number of assertions, the number of assertions successfully bound to evidence, the number of assertions successfully bound to tool receipts, the number of unsupported assertions, and the processing methods taken (deletion / rewriting / annotation / rejection). For example, "Total assertions: 5; Fact assertions: 3 (2 bound to evidence, 1 unsupported assertion deleted); Tool assertions: 2 (2 bound to receipts); Evidence coverage: 80%."

[0161] For example, the final judgment result refers to the recorded judgment result of the user or system on the quality of the final output. The final judgment result includes the manual feedback result and / or the automatic verification result. The manual feedback result refers to the user's satisfaction evaluation of the output content, error correction annotation, likes / dislikes, manual review approval / rejection, etc. For example, the user clicks the "helpful answer" button, or the reviewer marks "assertion A is not supported enough and the search needs to be optimized" in the system. The automatic verification result refers to the post-evaluation of the output through preset automatic verification rules, such as offline comparison with authoritative knowledge bases, consistency test through multi-model voting, and accuracy calculation using reserved test sets. For example, the system automatically compares the output assertions with authoritative databases and generates labels such as "assertion correct / incorrect / partially correct". For example, "Manual feedback: The user marks 'temperature 25°C' in the output as an error. Automatic verification: Compared with the meteorological bureau API, the actual temperature is 18°C, and the assertion is determined to be incorrect."

[0162] This embodiment transforms risk and intervention information during each task execution into structured feedback samples through end-to-end data recording, providing a data foundation for subsequent adaptive optimization and realizing the capability evolution from "one-time use" to "continuous accumulation".

[0163] Step S306: Iteratively update the weight parameters, risk threshold, and intervention strategy diagram of the multi-perspective hallucination risk score using feedback samples.

[0164] In this embodiment, the configurable parameters in the hallucination relief framework can be periodically or triggered and updated using accumulated feedback samples and offline or online learning methods, thereby adapting to different business scenarios, data distributions and user needs.

[0165] For example, by analyzing the correlation between the risk components recorded in the feedback samples and the final judgment result (human / automatic verification labels), the weight coefficients of each risk component are adjusted to maximize the correlation between the risk score and the risk of true illusion. For instance, if a large number of feedback samples show that "a high proportion of assertions with low evidence support are marked as incorrect," the weight coefficient for insufficient evidence risk is appropriately increased; if "the correlation between generation uncertainty and final correctness is weak," the weight coefficient for generation uncertainty is appropriately decreased. Gradient descent, Bayesian optimization, or simple incremental adjustment strategies can be used for weight updates.

[0166] For example, the actual effects of different intervention levels can be analyzed through feedback samples (such as post-intervention assertion accuracy, user satisfaction, system latency, etc.), and the four-level threshold can be dynamically adjusted to optimize the balance between accuracy and efficiency. For instance, if "targeted evidence reinforcement" is performed when the global risk score is between the second and third thresholds in a large number of tasks, but subsequent human feedback shows that the accuracy is already high enough, it indicates that the second threshold may be set too low, leading to unnecessary intervention and increased latency. In this case, the second threshold should be appropriately increased. Conversely, if the accuracy is still low after intervention in this range, the second threshold should be lowered to intervene earlier.

[0167] For example, the mapping relationship in the intervention strategy graph can be optimized based on the effectiveness evaluation of different intervention actions in the feedback samples (such as the success rate of "tool replay", the impact of "lightweight decoding convergence" on latency, and the user acceptance of "high-risk downgrade"). This can even lead to the introduction of new intervention actions or the removal of inefficient ones. For instance, if feedback data shows that the success rate of "tool replay" (i.e., the assertion being verified as correct after replay) is consistently below 20% in the third and fourth threshold ranges, the intervention action in that range can be adjusted to directly perform "high-risk downgrade" or "verification chain verification". Conversely, if "lightweight decoding convergence" has limited improvement in accuracy but significantly increases latency in the first and second threshold ranges, the intervention action in that range can be changed to "maintain regular generation".

[0168] Alternatively, an offline update method can be adopted. For example, after accumulating a batch of feedback samples (such as weekly / monthly), batch calculations can be performed in the background, the configuration can be updated, and then redeployed.

[0169] Optionally, an online update method can be adopted to incrementally update based on the latest feedback samples in real time or near real time, thereby achieving rapid adaptation.

[0170] Optionally, a comparative experiment can be conducted in the production environment to test the configurations before and after the update, and the full rollout can be completed only after confirming the improvement.

[0171] This embodiment uses a feedback-driven closed-loop optimization mechanism to enable the hallucination mitigation system to continuously adapt to changes in user needs, data distribution, and business scenarios, avoiding performance degradation caused by static configuration and achieving an evolvable adaptive security mechanism.

[0172] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0173] Based on the same inventive concept, this application also provides a language model online illusion processing device for implementing the above-described language model online illusion processing method. The solution provided by this device is similar to the implementation described in the above-described method; therefore, the specific limitations of the one or more language model online illusion processing device embodiments provided below can be found in the limitations of the language model online illusion processing method described above, and will not be repeated here.

[0174] In one exemplary embodiment, such as Figure 4 As shown, an online hallucination processing device based on a language model is provided, comprising: an assertion parsing module 401, a binding module 402, a risk scoring module 403, and a graded intervention module 404, wherein:

[0175] The assertion parsing module 401 is used to perform assertion-level atomic parsing on the incremental output in real time during the process of language model generating text, so as to obtain at least one assertion atom.

[0176] Binding module 402 is used to retrieve data from the evidence service and tool receipt storage service for each assertion atom to determine the binding relationship between the assertion atom and the candidate evidence set and tool receipt set;

[0177] The risk scoring module 403 is used to determine the multi-perspective illusion risk score of each assertion atom based on the binding relationship, the internal state of the language model and external environmental signals, and to determine the global risk score based on the multi-perspective illusion risk score of each assertion atom.

[0178] The graded intervention module 404 is used to match the intervention action corresponding to the risk level from the preset intervention strategy map according to the risk level of the global risk score, and execute the intervention action.

[0179] In some embodiments, assertion atoms include at least one of the following types: fact assertion, reference assertion, tool parameter assertion, and action assertion;

[0180] The tool receipts in the tool receipt set include at least one of the following: tool identifier, parameter digest hash, result digest hash, source identifier, status code, timestamp, and time-to-live (TTL).

[0181] In some embodiments, the binding module 402 is specifically used to: for fact assertions and / or reference assertions, preferentially retrieve at least one of textual evidence, structured knowledge, and retrieval fragments from the evidence service as a candidate evidence set; for tool parameter assertions and / or action assertions, preferentially retrieve at least one of tool receipts, execution logs, status snapshots, and interface responses from the tool receipt storage service as a tool receipt set.

[0182] In some embodiments, the risk scoring module 403 is specifically used to: obtain the generation uncertainty of the assertion atom, which is obtained by the ratio of the current lexical distribution entropy to the maximum entropy of the vocabulary; obtain the inter-layer factual deviation of the assertion atom, which is obtained by the JS divergence or KL divergence between the distribution of projected words in the later layers of the language model and the distribution of projected words in the earlier layers; obtain the evidence support of the assertion atom, which is obtained by the weighted sum of semantic similarity, textual implication, and evidence freshness between the assertion atom and its candidate evidence set; obtain the tool consistency of the assertion atom, which is obtained by the parameter pattern matching degree between the assertion atom and its tool response set; obtain the environmental implementation degree of the assertion atom, which is used to measure the consistency between the assertion atom and the current runtime environment state; and perform a weighted summation of the generation uncertainty, inter-layer factual deviation, evidence support, tool consistency, and environmental implementation degree to obtain the multi-perspective illusion risk score of the assertion atom.

[0183] In some embodiments, the intervention action includes a tiered intervention action, which includes at least one of the following: lightweight decoding convergence, targeted evidence reinforcement, tool replay, verification chain verification, and high-risk downgrade.

[0184] In some embodiments, the tiered intervention module 404 is specifically configured to: maintain normal generation when the global risk score is below a first threshold; perform lightweight decoding convergence when the global risk score is greater than or equal to the first threshold and lower than a second threshold; perform targeted evidence reinforcement when the global risk score is greater than or equal to the second threshold and lower than a third threshold; perform tool replay or verification chain verification when the global risk score is greater than or equal to the third threshold and lower than a fourth threshold; and perform high-risk downgrading when the global risk score is greater than or equal to the fourth threshold.

[0185] In some embodiments, lightweight decoding convergence includes at least one of: reducing sampling temperature, narrowing kernel sampling parameters, and enabling inter-layer contrastive decoding; targeted evidence reinforcement includes: generating retrieval queries and supplementing evidence only for high-risk assertion atoms; tool replay or verification chain verification includes: re-invoking the tool or generating verification questions and comparing the returned results; high-risk degradation includes: outputting evidence-based rejections, conservative answers, clarification questions, or transferring to human intervention.

[0186] In another exemplary embodiment, such as Figure 5 As shown, an online illusion processing device based on a language model is provided. Figure 4 Based on the device shown, the device in this embodiment may further include:

[0187] Output module 405 is used to bind the target assertion obtained after intervention with its corresponding evidence identifier or tool receipt identifier to generate an auditable output structure; for assertion atoms that cannot obtain sufficient support, at least one of the following processes is performed: deletion, rewriting to an uncertain expression, explicit annotation, or rejection of output.

[0188] In yet another exemplary embodiment, such as Figure 5 As shown, an online illusion processing device based on a language model is provided. Figure 4 Based on the device shown, the device in this embodiment may further include:

[0189] The recording module 406 is used to record the risk trajectory, trigger threshold, intervention actions, evidence coverage and final judgment results during the current task execution process, forming feedback samples. The final judgment results include manual feedback results and / or automatic verification results.

[0190] The update module 407 is used to iteratively update the weight parameters, risk thresholds, and intervention strategy diagrams of the multi-perspective hallucination risk score based on feedback samples.

[0191] The modules in the aforementioned online illusion processing device for language models can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0192] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements an online illusion processing method for a language model. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0193] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0194] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method steps described in the various embodiments above.

[0195] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method steps of the various embodiments described above.

[0196] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the method steps of the various embodiments described above.

[0197] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0198] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0199] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0200] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for online hallucination processing using a language model, characterized in that, The method includes: During the process of generating text from the language model, the incremental output is parsed in real time at the assertion level to obtain at least one assertion atom. For each assertion atom, a search is performed in the evidence service and tool receipt storage service to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set; Based on the binding relationship, the internal state of the language model, and external environmental signals, determine the multi-perspective illusion risk score for each assertion atom, and determine the global risk score based on the multi-perspective illusion risk score for each assertion atom; Based on the risk level of the global risk score, the intervention action corresponding to the risk level is matched from the preset intervention strategy map and the intervention action is executed.

2. The method according to claim 1, characterized in that, The assertion atom includes at least one of the following types: fact assertion, reference assertion, tool parameter assertion, and action assertion; The tool receipts in the tool receipt set include at least one of the following: tool identifier, parameter digest hash, result digest hash, source identifier, status code, timestamp, and time-to-live (TTL). Determining the binding relationship between the assertion atom and the candidate evidence set and tool receipt set includes: For factual assertions and / or cited assertions, at least one of the following should be retrieved from the evidence service as a candidate evidence set: textual evidence, structured knowledge, and retrieval fragments. For tool parameter assertions and / or action assertions, at least one of the following should be retrieved from the tool receipt storage service: tool receipt, execution log, status snapshot, and interface response, as the tool receipt set.

3. The method according to claim 1, characterized in that, The step of determining the multi-perspective hallucination risk score for each assertion atom based on the binding relationship, the internal state of the language model, and external environmental signals includes: The generation uncertainty of the assertion atom is obtained, which is derived from the ratio of the current lexical distribution entropy to the maximum entropy of the vocabulary; The inter-layer fact deviation of the assertion atom is obtained, which is obtained by the JS divergence or KL divergence of the distribution of projected words in the later layer and the distribution of projected words in the earlier layer of the language model. The evidence support degree of the assertion atom is obtained, which is obtained by weighting the semantic similarity, textual implication and evidence freshness between the assertion atom and its candidate evidence set. The tool consistency of the assertion atom is obtained based on the parameter pattern matching degree between the assertion atom and its tool response set. Obtain the environmental landing degree of the assertion atom, which is used to measure the consistency between the assertion atom and the current runtime environment state; The multi-perspective illusion risk score of the assertion atom is obtained by weighting and summing the generation uncertainty, inter-layer fact deviation, evidence support, tool consistency, and environmental implementation.

4. The method according to claim 1, characterized in that, The intervention actions include tiered intervention actions, which include at least one of the following: lightweight decoding convergence, targeted evidence reinforcement, tool replay, verification chain verification, and high-risk downgrade. The step of matching the intervention action corresponding to the risk level from a preset intervention strategy map based on the risk level of the global risk score, and executing the intervention action, includes: If the global risk score is lower than the first threshold, normal generation will continue; If the global risk score is greater than or equal to the first threshold and lower than the second threshold, lightweight decoding convergence is performed. If the global risk score is greater than or equal to the second threshold and lower than the third threshold, targeted evidence reinforcement shall be performed. If the global risk score is greater than or equal to the third threshold and lower than the fourth threshold, the tool will replay or verify the chain check. If the global risk score is greater than or equal to the fourth threshold, a high-risk downgrade is performed.

5. The method according to claim 4, characterized in that, The lightweight decoding convergence includes at least one of the following: reducing sampling temperature, narrowing kernel sampling parameters, and enabling inter-layer contrast decoding. The targeted evidence reinforcement includes: generating search queries and supplementing evidence only for high-risk assertion atoms; The tool replay or verification chain verification includes: re-invoking the tool or generating verification questions and comparing the returned results; The high-risk downgrade includes: providing evidence for a refusal to answer, providing a conservative answer, clarifying the question, or transferring the issue to a human operator.

6. The method according to any one of claims 1 to 5, characterized in that, After performing the intervention, the method further includes: The target assertion obtained after intervention is bound to its corresponding evidence identifier or tool receipt identifier to generate an auditable output structure; For assertion atoms that cannot be adequately supported, perform at least one of the following actions: delete, rewrite as an indeterminate expression, explicitly label, or reject output.

7. The method according to any one of claims 1 to 5, characterized in that, After performing the intervention, the method further includes: Record the risk trajectory, trigger threshold, intervention actions, evidence coverage and final judgment results during the current task execution process to form a feedback sample. The final judgment results include manual feedback results and / or automatic verification results. The weight parameters, risk thresholds, and intervention strategy diagrams of the multi-perspective hallucination risk score are iteratively updated using the feedback samples.

8. An online illusion processing device for language models, characterized in that, The device includes: The assertion parsing module is used to perform assertion-level atomic parsing on the incremental output in real time during the text generation process of the language model, so as to obtain at least one assertion atom. The binding module is used to retrieve data from the evidence service and tool receipt storage service for each assertion atom to determine the binding relationship between the assertion atom and the candidate evidence set and the tool receipt set. The risk scoring module is used to determine the multi-perspective illusion risk score of each assertion atom based on the binding relationship, the internal state of the language model and external environmental signals, and to determine the global risk score based on the multi-perspective illusion risk score of each assertion atom. The graded intervention module is used to match the intervention action corresponding to the risk level from a preset intervention strategy map based on the risk level of the global risk score, and execute the intervention action.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.