Risk-aware dual counterfactual decoding method for visual large model hallucination mitigation

By constructing language priors and visually weakened counterfactual branches, and adaptively adjusting the correction intensity, the illusion problem in the generation process of large visual language models is solved, achieving effective illusion mitigation and preservation of object coverage without training.

CN123161035APending Publication Date: 2026-11-24NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611674054.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Large visual language models are prone to generating content inconsistent with image evidence during the generation process. Existing hallucination mitigation methods suffer from high training costs, difficulty in determining the source of token support, inability of a single correction strength to adapt to changes in risk during the decoding step, and decreased object coverage due to excessive suppression.

Method used

The system constructs a prior counterfactual branches for language and a visually weakened counterfactual branch. It calculates multiple counterfactual probes by acquiring image and text inputs, adaptively adjusts the correction intensity, and combines the original multimodal branches for gating fusion to generate a token.

Benefits of technology

It can effectively alleviate hallucinations, reduce object co-occurrence bias errors, maintain object coverage, and adapt to risk changes in different decoding steps without requiring model retraining.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123161035A_ABST
    Figure CN123161035A_ABST
Patent Text Reader

Abstract

This invention discloses a risk-perception dual-antifactual decoding method for mitigating hallucinations in large visual models, specifically relating to the field of large language model technology. The method involves inputting the image input, text prompts, and generated token sequences of the current decoding step into the original multimodal branch, outputting the original logits; the language prior counterfactual branch does not accept image input, applies a text Boolean attention mask to the text tokens, and generates language prior logits; the visual weakening counterfactual branch retains the image input and applies a visual Boolean attention mask to the image tokens, generating visual weakening logits; a risk signal is calculated based on the three logits to determine the gating correction strength, and a correction score is obtained through gating comparison fusion; the token for the current decoding step is generated based on the correction score, and if the stopping condition is not met, the current token is merged into the generated sequence, and the process proceeds to the next decoding step.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large language model technology, and more specifically to a risk perception dual-fact decoding method for mitigating visual large model illusions. Background Technology

[0002] Large-scale visual language models can process both image and text inputs simultaneously and generate natural language output based on visual content and text prompts. These models are widely used for tasks such as image captioning, visual question answering, multimodal dialogue, multimodal instruction following, data annotation, and assisted perception.

[0003] However, large vision language models are prone to generating content inconsistent with image evidence during the generation process. For example, the model may describe objects that do not exist in the image, generate incorrect attributes, or give object relationships that are not supported by the image. This problem is often referred to as large vision language model illusion. Illusion reduces the reliability of the model in assisted perception, automatic annotation, content moderation, robot interaction, and security-sensitive scenarios.

[0004] The causes of hallucinations are not singular. In autoregressive decoding, a high probability for a candidate token does not necessarily mean it is adequately supported by visual evidence. The token may be primarily supported by textual priors from the language model, contextual continuation bias, object co-occurrence bias, or non-robust visual statistical relevance. For example, when describing a bathroom image, the model may generate objects such as "bottle" or "cup" that do not exist in the image due to linguistic co-occurrence relationships.

[0005] Existing hallucination mitigation methods can be broadly categorized into training-based methods and inference-based methods. Training-based methods modify model parameters through additional data, preference optimization, reinforcement learning, negative sample construction, or instruction fine-tuning, typically requiring additional training costs, data resources, and access to model weights. Inference-based methods do not change model parameters but adjust the token distribution during the decoding phase. Some inference-based methods employ a single visual perturbation branch, attention correction, fixed-intensity contrast decoding, or other single auxiliary signals.

[0006] The aforementioned reasoning methods still have shortcomings: First, it is difficult to determine the source of token support using only the original multimodal distribution; second, a single counterfactual branch cannot simultaneously cover both linguistic priors and unstable visual evidence risks; third, a fixed correction strength cannot adapt to risk changes in different decoding steps; fourth, excessive suppression may reduce object coverage, causing the model to superficially reduce illusions by generating fewer objects.

[0007] Therefore, there is a need for a large visual language model illusion mitigation scheme that does not require model retraining, can construct multiple counterfactual probes during decoding, and adaptively adjusts the correction intensity according to the current risk. Summary of the Invention

[0008] Therefore, the present invention provides a risk perception dual-reverse fact decoding method for mitigating visual large-scale model hallucinations, in order to solve the problems mentioned in the background art.

[0009] To achieve the above objectives, the present invention provides the following technical solution: a risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations, comprising the following steps:

[0010] Step S101: Input the image input, text prompt, and generated token sequence corresponding to the current decoding step into the original multimodal branch to obtain the original logits of the current decoding step;

[0011] Step S102: Construct a language prior counterfactual branch and a visual weakened counterfactual branch. The language prior counterfactual branch does not accept image input and applies a text-side Boolean attention mask to the text token. Based on the text prompt, the generated token sequence, and the branch's independent key-value cache state, language prior logits are obtained. The visual weakened counterfactual branch retains image input and applies a visual-side Boolean attention mask to the image token. Based on the image input, text prompt, the generated token sequence, and the branch's independent key-value cache state, visual weakened logits are obtained. The original multimodal branch, language prior counterfactual branch, and visual weakened counterfactual branch maintain temporal alignment using a jointly generated token sequence in the same decoding step. The language prior logits and visual weakened logits are used for subsequent risk signal calculation and gating fusion, and are not used separately as hallucination judgment results.

[0012] Step S103: Calculate the risk signal for the current decoding step based on the original logits, language prior logits, and visually weakened logits; and determine the gating correction strength based on the risk signal.

[0013] Step S104: Based on the gating correction intensity, perform gating comparison and fusion on the original logits, language prior logits, and visually weakened logits to obtain the correction score;

[0014] Step S105: Generate the token for the current decoding step based on the correction score, and determine whether the stopping condition is met; if not, proceed to the next decoding step; and add the token for the current decoding step to the generated token sequence.

[0015] Preferably, step S101 specifically involves: inputting the image input, text prompts, and the generated token sequence into the original multimodal branch to obtain the original logits of the current decoding step.

[0016] ;

[0017] in, Indicates the original multimodal branch in the th... The unnormalized token scores output by each decoding step, i.e., the original logits; for a single sample, When the batch size is hour, , This represents the vocabulary used by the word segmenter in the basic visual language model. With vocabulary The candidate tokens in the text correspond one-to-one; the original multimodal branch, the language prior counterfactual branch, and the visual weakened counterfactual branch share the same word segmenter and vocabulary, and the dimensions and lexical indexes have the same meaning;

[0018] This refers to the pixel tensor obtained by the image processor; the image processor is an external preprocessing module for the model. This represents a basic visual language model consisting of a visual encoder, a visual projection layer, and a decoder-only autoregressive language model. The internal visual encoder and visual projection layer convert the pixel tensor into a visual token sequence; the subsequent visual side mask is applied to the position corresponding to the visual token sequence without directly modifying the original pixel image. The token index sequence represents the tokens obtained by the word segmenter from text prompts or user instructions, rather than pre-generated text features; the token index sequence is converted into text representation by the word embedding layer of the basic visual language model;

[0019] Indicates the first The token index sequence generated before each decoding step is not the token embedding vector; each token index is encoded by the same word embedding layer and appended to the end of the prompt sequence of each branch in the order of generation, as the input for autoregressive decoding; Indicates the original multimodal branch in the th... The key-value cache state used in each decoding step; the visual token, text prompt token, and generated token form the decoder input of the decoder-only autoregressive language model in the order specified by the model dialogue template.

[0020] The original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch share the basic model parameters, text prompts, dialogue templates, and generated token sequences, and each maintains the original multimodal branch's parameters at the specified time. Key-value cache state corresponding to each decoding step The language a priori counterfactual branch in the first The independent key-value cache state used in each decoding step and visual weakening counterfactual branch in the first The independent key-value cache state used in each decoding step .

[0021] The The pre-defined attention layer index in the basic visual language model is the layer selection hyperparameter of this method; [the parameter is then determined]. At that time, masks can be generated in the candidate attention layer set and the stability of branch output, target evaluation index and computational cost on the verification sample can be compared and verified. The layer that meets the preset performance and computational constraints can be selected and kept unchanged in the same implementation process or the same set of experiments.

[0022] Preferably, step S102 specifically includes: calculating language prior logits through the language prior counterfactual branch:

[0023] ;

[0024] in, The language prior counterfactual branch uses the same text prompts and generated token sequences as the original multimodal branch, with no image input and no image token block. This represents a Boolean attention mask on the text side. The language prior counterfactual branch is represented in the 1st... Each decoding step uses an independent key-value cache state. In the first decoding step, the language prior counterfactual branch is constructed independently based on the text-side sequence without image input; in subsequent decoding steps, the language prior counterfactual branch uses its current latent state. Perform forward computation on the jointly generated token and update it to obtain the hidden state at the next time step. ; Instead of directly copying from the original multimodal branch, its timing alignment with other branches is achieved through the same decoding steps. And the jointly generated token sequence guarantees; The language prior logits represent the output of the language prior counterfactual branch.

[0025] Language a priori counterfactual branch in the 1st Each decoding step performs a text-side Boolean attention mask. No additional risk triggering conditions are set; the number of valid tokens on the text side is set to... Based on the attention scores obtained within the language prior counterfactual branches, in ascending order, the branch with the lowest attention score is selected. The set consists of the positions of the text tokens. ;

[0026] In the first branch of language a priori counterfactual Each decoding step originates from a pre-defined attention layer within that branch. Get the current query token position Attention weights for each text token position, and for The average of the attention points is used to obtain the text token position. Corresponding attention score :

[0027] ;

[0028] in, The first branch of the language prior counterfactual Layer The first point of attention, the first The query location corresponding to the token to be generated in each decoding step. For the position of the text token Attention weights;

[0029] No. The actual number of text tokens retained per decoding step for:

[0030] ;

[0031] in, Minimum number of text tokens to retain, a positive integer; To round down; This is represented as the increment in the number of text tokens. ; The growth rate of the number of text tokens. ; Represents the natural exponential function; A function to find the minimum value; a set The position within the text-side Boolean attention mask The center position is set to 1, and the remaining text positions are set to 0, meaning the position with the lowest attention score is retained. One text token is used for attention calculation, while the rest of the text tokens are ignored.

[0032] Preferably, step S102 specifically includes: calculating visual weakening logits through the visual weakening counterfactual branch:

[0033] ;

[0034] in, This represents the visual weakening logits output by the visual weakening counterfactual branch; In the first decoding step, it is constructed independently based on the image-text input and the visual side mask; in the second... In each decoding step, the visually weakened counterfactual branch utilizes its own hidden state. Perform forward computation on the jointly generated token and update it to obtain the hidden state at the next time step. ;

[0035] Both the visual token and text token key-value caches are updated based on the forward computation results of the visual weakened counterfactual branch, and are not copied from the original branch. The original multimodal branch, the language prior counterfactual branch, and the visual weakened counterfactual branch maintain temporal alignment through the same decoding step and the jointly generated token sequence, but their cache values ​​are not required to be the same. Visual weakened logits are used for subsequent risk calculation and gating fusion, and are not used as the hallucination determination result alone.

[0036] The visual weakening counterfactual branch performs visual token masking in each decoding step, without setting additional risk triggering conditions; let the set of image token locations be... The number of image tokens is The number to be retained is:

[0037] ;

[0038] in, Indicates the first The actual number of visual tokens retained per decoding step; This indicates rounding down, and Select the lowest attention score in ascending order. The set consists of image token locations. It generates a visual sidemask, while keeping the text token and other non-image locations visible:

[0039]

[0040] ;

[0041] in, This indicates that it belongs to all image tokens, but the positions of those image tokens within the set are no longer retained;

[0042] Visual token retention quantity According to the current decoding step Total number of image tokens and the visual token retention ratio in the t-th decoding step. The decision shall not exceed the current total number of image tokens;

[0043] No. Visual token retention ratio per decoding step Based on the preset minimum retention ratio Proportional increment and growth rate Dynamically determined:

[0044] .

[0045] Preferably, step S103 specifically includes: converting the unnormalized logits output from the original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch into a probability distribution:

[0046] ;

[0047] in, , and Let represent the lexical probability distributions of the original multimodal branch, the linguistic prior counterfactual branch, and the visual weakening counterfactual branch, respectively; softmax converts the logits of each candidate token in the vocabulary into probabilities that sum to 1, and the normalized entropy of the original multimodal branch is:

[0048] ;

[0049] in, Represents a vocabulary set, Indicates vocabulary size, This represents candidate tokens in the vocabulary. Represents the natural logarithm; when At that time, it was agreed .use After normalization, The range of values ​​is ;through The normalized Jensen-Shannon divergence is defined as:

[0050] ;

[0051] Based on the original multimodal branch With two counterfactual branches and The probability distribution calculation of the branch difference term:

[0052] ;

[0053] in, The value range is [0,1]; the larger the value, the greater the difference between the two probability distributions; the original multimodal branch uncertainty is reduced. The branch differences are combined to form the risk signal for the current decoding step:

[0054] ;

[0055] in, Indicates the first A risk signal for each decoding step is used to adjust the strength of the logits correction operation in the current decoding step. It is only used for logits correction and does not interfere with the mask generation of language prior counterfactual branches and visually weakened counterfactual branches, the number of tokens retained, or the key-value cache update. Representing the uncertainty term and branch differences The weighting coefficients between them, and .

[0056] Preferably, when the probability of the maximum candidate token in the original multimodal branch satisfies At that time, a confidence rollback is performed, using the original branch's logits as the correction score, i.e., letting The counterfactual fusion correction is not implemented; among them, This represents the confidence backoff threshold with a value range of [0,1]. The original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch still complete the forward calculation before the confidence backoff judgment.

[0057] When the confidence backoff condition is not met, perform reasonable truncation on the original multimodal branch logits:

[0058] ;

[0059] in, and Both represent vocabulary sets. Candidate token index in This represents the original branch `logits` after reasonable truncation. This represents the maximum logits of the original branch across all candidate tokens. This represents the reasonable cutoff strength parameter, and Candidate tokens that do not meet the truncation condition have their corresponding logits set to 0. ;when , At that time, only the maximum logits among all candidate tokens are retained. Equivalent greedy decoding retains only one finite number of candidate logits, which is then set to... The logits, after being processed by softmax, have a probability of 0 and will not be selected by the greedy decoding or sampling process.

[0060] Preferably, when the confidence backoff condition is not triggered, step S104 is executed; step S104 specifically includes:

[0061] The original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch each yield unnormalized logits. , and The following calculations are performed separately during the fusion phase:

[0062] ;

[0063] ;

[0064] ;

[0065] in, , and Let these represent the log probabilities of the truncated original branch, the linguistic prior counterfactual branch, and the visual weakening counterfactual branch, respectively. The linguistic prior correction term is constructed from the original branch and the linguistic prior counterfactual branch.

[0066] ;

[0067] The time weights that vary with the decoding step are:

[0068] ;

[0069] in, The parameter representing the non-negative time-weighted rate of change is used to map the risk signal to the gating correction strength via the Sigmoid function.

[0070] ;

[0071] in, Indicates the minimum correction strength. Indicates the basic correction strength, and ; This indicates a preset risk threshold. This indicates a temperature parameter greater than 0. This represents the sigmoid monotonic mapping function; temperature parameter. Control risk signals Mapped to gated correction strength via Sigmoid function The smoothness of the process is ultimately adjusted to the following score:

[0072] ;

[0073] Among them, the same gating correction strength Simultaneously affects the language prior modification term. Log probability of visual weakening branch ; This indicates a language prior modification term enhanced by risk gating. This indicates that support in the visually weakened branch is subtracted according to the same gating strength. Used to generate the token for the current decoding step.

[0074] The present invention has the following advantages:

[0075] This invention eliminates the need to retrain the large visual language model and can be directly deployed as a decoding method in the inference stage. It simultaneously constructs linguistic prior counterfactual branches and visually weakened counterfactual branches, enabling the detection of non-visual or visually unstable support for candidate tokens from different perspectives. Through risk signals and gating mechanisms, it adaptively adjusts the correction strength, making it more suitable for risk variations in different generation steps compared to fixed-strength contrastive decoding. By employing confidence backoff and reasonableness truncation, it reduces excessive intervention in high-confidence normal tokens. It can reduce erroneous object affirmations caused by linguistic priors and object co-occurrence biases while maintaining non-degenerate object coverage capabilities. Attached Figure Description

[0076] Figure 1 The flowchart of the risk perception double anti-fact decoding method provided in the embodiments of the present invention is shown.

[0077] Figure 2 This is a schematic diagram of a three-branch decoding structure provided in an embodiment of the present invention.

[0078] Figure 3 This is a schematic diagram illustrating the comparison and fusion of risk estimation and gating provided in an embodiment of the present invention.

[0079] Figure 4 This is a schematic diagram of the risk perception dual-fact decoding device provided in an embodiment of the present invention.

[0080] Figure 5 This is a schematic diagram illustrating object illusion suppression and failure cases provided in an embodiment of the present invention.

[0081] Figure 6 This is a schematic diagram illustrating the changes in different behavioral indicators of POPE provided in an embodiment of the present invention.

[0082] Figure 7 This is a schematic diagram of POPE transfer gain on different basic visual language models provided in the embodiments of the present invention. Detailed Implementation

[0083] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. 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.

[0084] This embodiment evaluates the invention (EDGE) on the basic visual language model LLaVA-1.5-7B and uses Qwen2.5-VL-7B-Instruct as a transfer test for the second model. The paired experiments in this embodiment use the same checkpoints, cue templates, data partitioning, evaluation scripts, and greedy decoding for both the original decoding and the invention. This embodiment evaluates POPE on the official POPE-COCO random, popular, and adversarial partitions, CHAIR on COCO-style open-ended descriptions, and MME-H on the four illusion-oriented categories of MME—presence, count, location, and color. Table 1 shows references marked with † to indicate literature background values ​​used for comparison: VCD, OPERA, and AGLA follow AGLA; ONLY follows ONLY; they are not greedy decoding reproductions on the same runner. This embodiment explicitly retains this distinction because decoding details, answer parsing methods, and descriptive cue words can affect absolute scores even if the backbone model and dataset are nominally the same.

[0085] Table 1. POPE-COCO results (%) on LLaVA-1.5

[0086]

[0087] Combination Figure 6 This embodiment compares the behavior of the method of the present invention relative to the original decoding in POPE random, popular, and adversarial partitioning. In the figure, blue bars represent the gain in precision relative to the original decoding, purple bars represent the gain in F1 score relative to the original decoding, and red bars represent the decrease in the proportion of "yes" answers relative to the original decoding. In random partitioning, precision and F1 score increase by 3.33 and 0.16 percentage points, respectively, while the proportion of "yes" answers decreases by 3.24 percentage points. In popular partitioning, precision and F1 score increase by 2.80 and 0.08 percentage points, respectively, while the proportion of "yes" answers decreases by 3.27 percentage points. In adversarial partitioning, precision and F1 score increase by 4.59 and 1.36 percentage points, respectively, while the proportion of "yes" answers decreases by 5.10 percentage points. As object co-occurrence interference increases, the suppression effect of the present invention on unfounded affirmative answers becomes more significant, and the F1 gain is greatest in adversarial partitioning.

[0088] Combination Figure 7This embodiment compares the POPE transfer gain of the method of the present invention on two basic visual language models, LLaVA-1.5 and Qwen2.5-VL. In the figure, the vertical axis represents the F1 gain of the method of the present invention relative to the original decoding of the corresponding model, and the horizontal axis represents the POPE random, popular, and adversarial partitions. For LLaVA-1.5, the present invention improves the F1 score by 0.16, 0.08, and 1.36 percentage points on the three partitions, respectively; for Qwen2.5-VL, the present invention improves the F1 score by 5.48, 5.35, and 4.83 percentage points on the three partitions, respectively. The above results show that the present invention can improve the F1 score of the POPE object affirmative task on both basic visual language models. However, the gain magnitude varies across different models and data partitions. Therefore, these results are used to illustrate the transfer phenomenon on the POPE task and do not indicate that the present invention can achieve the same level of improvement on all open description or visual reasoning tasks.

[0089] This embodiment employs a basic visual language model comprising a visual encoder, a visual projection layer, and a decoder-only autoregressive language model. At each decoding step, a raw multimodal branch, a linguistic prior counterfactual branch, and a visual weakening counterfactual branch are executed. These three branches share model parameters, text prompts, and a jointly generated token sequence, but each maintains an independent key-value cache state. The attention mask is generated using the multi-head average attention score of the current query token in layer 2. The sampler of this invention performs three forward passes for each lexical unit across the raw, linguistic prior, and visual weakening branches. , , , =0.05、 , , =0.1 and All three branches complete their forward computation before the confidence backoff decision; therefore, the confidence backoff controls whether the final distribution is modified without skipping auxiliary branch computation. Text and visual masks use aggregated attention from layer 2 and retain at least 50 selected terms.

[0090] Combination Figure 1 In this embodiment, a bathroom image and a text prompt describing the image are used as input. The basic visual language model generates candidate tokens such as "toilet," "bathtub," "bottle," and "cup" in the current decoding step. The original multimodal branch calculates the original logits based on the complete image, text prompt, and the generated token sequence. The language prior counterfactual branch computes language prior logits without receiving image input and with a text-side Boolean attention mask applied. The visual weakening counterfactual branch calculates the visual weakening logits while preserving the image input and weakening some visual tokens. In the diagram, "toilet" and "bathtub" have high support in the original multimodal branch, while "bottle" and "cup" still receive high auxiliary support in the linguistic prior counterfactual branch or the visual weakening counterfactual branch, and are therefore considered high-risk candidate tokens requiring stronger correction. Original branch uncertainty. Distribution differences between the three branches The input risk estimation process yields an adaptive gating strength used to adjust the correction intensity. Specifically, when the risk is low, the correction strength is reduced and the original output is retained preferentially; when the risk is high, the correction strength is increased and counterfactual comparison correction is strengthened. The gated comparison fusion process is based on... , , and The corrected next token distribution is generated, thus preserving visually supported tokens like "toilet" and "bathtub," while suppressing tokens like "bottle" and "cup," which are primarily supported by auxiliary branches. Solid boxes in the diagram represent visually supported candidate tokens that are preserved, while dashed boxes represent higher-risk candidate tokens that need to be suppressed. Figure 1 The right side further illustrates that the original greedy decoding might generate "bottles" and "cups" that are not present in the image. This invention retains visually valid content through adaptive gating correction. Without adaptive gating and with fixed or overly strong correction, only "toilet" might be retained, resulting in reduced object coverage. Risk signals and gating strength are only used to adjust the correction level and are not used alone as a classification result for whether a candidate token belongs to a hallucination.

[0091] Combination Figure 2 In the In this embodiment, the image input is obtained through a decoding step. Text prompts Token sequence already generated And the key-value cache states maintained by the three branches respectively. , and The original multimodal branch receives the complete image, text hints, and the generated token sequence, and caches the state using the original branch key-value pair. Output raw logits The language prior counterfactual branch does not accept image input and applies a text-side Boolean attention mask to the text token. and uses the key-value cache state maintained independently by this branch. Output language prior logits The visual weakening counterfactual branch preserves the image input and applies a visual-side Boolean attention mask to the image token. and uses the key-value cache state maintained independently by this branch. Output visually weakened logits The three branches share the model parameters of the underlying visual language model, text prompts, and a jointly generated token sequence, performing the same decoding steps. While maintaining temporal alignment, each branch maintains and updates its own key-value cache state independently. The logits output from the three branches are used for subsequent risk estimation and gated contrast fusion; the language prior logits and visual weakening logits are not used separately as hallucination judgment results.

[0092] Combination Figure 3 raw logits Language priors logits and visually weakened logits Each is converted into a probability distribution using the softmax function. , and And convert it to log probability using the log-softmax function. , and The risk estimation process is based on the original branch probability distribution. Calculate normalized entropy The branch difference term is calculated based on the normalized Jensen-Shannon divergence between the original branch and the two counterfactual branches. And then according to Obtain the risk signal for the current decoding step. Risk signals Converted to gated correction strength via the Sigmoid monotonic mapping function This allows lower-risk decoding steps to use smaller correction strengths, and higher-risk decoding steps to use larger correction strengths. The language prior correction process is based on the logarithmic probability of the original branches. Language prior branch log probability and time weight Constructing language prior modification terms The three-way gate fusion process is carried out according to... Obtain the final corrected score This is used to generate the current token. When the probability of the largest candidate token in the original branch exceeds the confidence backoff threshold... When the original branch's output is used directly, counterfactual fusion correction is not performed; when the confidence backoff condition is not met, risk estimation, dynamic gating, and three-way fusion are performed.

[0093] Combination Figure 4 The risk-aware dual-fact decoding device in this embodiment includes an input state acquisition module, a parallel branch calculation module, a risk estimation module, a dynamic gating module, a correction term construction module, a three-way fusion correction module, and a token generation module. The input state acquisition module is used to acquire image input. Text prompts Token sequence already generated Current decoding step and the three-way key-value cache state , and The parallel branching module utilizes shared model parameters to calculate the original branch, the linguistic prior counterfactual branch, and the visual weakening counterfactual branch, outputting three logits, probability distributions, and log probabilities. The risk estimation module calculates the normalized entropy based on the three probability distributions. Branch Difference Items and risk signals The dynamic gating module will detect risk signals. Mapped to gated correction strength The correction term construction module calculates the prior correction term based on the three-way logarithmic probability calculation language. And retain the log probability of visually weakened branches. For fusion use. The three-way fusion correction module is based on... , and Calculate the corrected score The token generation module selects or samples the current token based on the corrected score, appends the token to the common generation sequence, and updates the key-value cache state of the three branches respectively to enter the next decoding step, until the stopping condition is met.

[0094] Combination Figure 5This embodiment presents three application results of the method of the present invention in open image description. The first set of images shows a metal park bench next to a sidewalk. The original decoder incorrectly added "someone is nearby" to the description. The method of the present invention suppresses this co-occurrence illusion and retains visually supported content such as "park bench," "concrete sidewalk," and "grass area." The second set of images shows a scene of two cats on a sofa. The original decoder incorrectly generated objects supported by prior language of the indoor scene, such as "chair" and "book." The method of the present invention suppresses these objects and retains visible content in the image, such as "two cats," "sofa," and "newspaper." The third set of images shows a scene of two people using a game controller in front of a television. The method of the present invention still confuses baseball-related objects presented on the screen with real objects outside the screen, incorrectly generating "baseball bat" and "baseball glove." This failure case shows that the present invention can alleviate some object co-occurrence bias and object illusion driven by prior language, but it may still produce errors in situations requiring stronger visual recognition capabilities, such as confusion between objects inside and outside the screen.

[0095] This embodiment uses a compact set of metrics to evaluate illusion, capability, and mechanistic behavior. POPE evaluates object illusion in the form of object yes / no detection. This embodiment reports accuracy, precision, recall, F1, the proportion of "yes" answers, and the proportion of unknown answers. CHAIR measures open-ended object illusions in descriptions: CHAIRs is the proportion of descriptions containing at least one illusion object, CHAIRi is the proportion of illusion object mentions, and recall measures object coverage, as shown in Table 2. † indicates literature background values: VCD, OPERA, and AGLA follow AGLA, while MemVR follows MemVR; the original decoder and this invention are from the greedy runner of this embodiment. MME-H is a subset of illusions in MME, consisting of four categories: presence, count, location, and color, as shown in Table 3. For mechanistic analysis, this embodiment reports branch probability, top-k branch support, AUROC, and AUPRC, with the statistical unit being generated object labels, as shown in Table 4.

[0096] Table 2 CHAIR results (%) on LLaVA-1.5

[0097]

[0098] Table 2 compares the original decoding method with the method of this invention. In the CHAIR evaluation, the original decoding achieved CHAIRs, CHAIRi, and object recall rates of 50.2%, 14.0%, and 78.2%, respectively, while the method of this invention achieved 37.6%, 10.5%, and 73.9%, respectively. In the POPE-COCO adversarial partitioning, the accuracy improved from 79.53% to 81.90%, and the F1 score improved from 81.20% to 82.56%. These results demonstrate that the method of this invention can reduce object illusion while preserving most object coverage.

[0099] Table 3 shows the MME-H results obtained by the greedy runner in this embodiment on LLaVA-1.5, including only the MME-H category.

[0100]

[0101] Table 4 summarizes 1,444 generated object labels from 494 images. The average branch probability fails to clearly distinguish between visually based labels and hallucinatory labels: hallucinatory labels have lower original and visually weakened support, and their auxiliary support is not significantly higher than the original support. However, linguistic prior support still predicts hallucinatory labels with better performance than random, with an AUROC of 0.601 and an AUPRC of 0.260, compared to the positive class proportion baseline of 0.202. Therefore, the branch signal, as a soft correction signal, is informative but too weak to be considered an explicit hallucination classifier. For the probability rows, the reference side and risk side represent visually based labels and hallucinatory labels, respectively. For AUPRC and AUROC, the reference side represents the positive class proportion or random baseline, and the risk side represents linguistic prior support.

[0102] Table 4 Summary of Mechanisms

[0103]

[0104] As shown in Table 5, in the ablation experiment, after removing the language prior counterfactual branch, CHAIRs increased from 37.6% to 53.4%; after removing the visual weakening counterfactual branch, CHAIRs increased to 45.0%; and after replacing the risk perception gating with a fixed correction strength, CHAIRs increased to 41.8%. These results indicate that both counterfactual branches and the dynamic gating strength contribute to the final technical effect, but do not suggest that any single counterfactual branch can function as a hallucination classifier independently.

[0105] Table 5 Ablation studies on CHAIR

[0106]

[0107] Table 6 Summary of Free Runner Migration under Greedy Decoding

[0108]

[0109] As shown in Table 6, in the migration example on Qwen2.5-VL-7B-Instruct, greedy decoding is maintained, and the original decoding of the same model and the method of the present invention are compared respectively. The F1 scores on POPE random, popular, and adversarial partitions improve from 75.97%, 75.75%, and 75.60% to 81.45%, 81.10%, and 80.43%, respectively; however, CHAIRs decreases from 32.0% to 33.6%, CHAIRi decreases from 8.7% to 10.5%, object recall decreases from 63.0% to 59.6%, and the MME-H total score decreases from 700.00 to 693.33. Therefore, this migration example is used to illustrate the migration phenomenon of the present invention on POPE-style object affirmative tasks and is not intended to claim a unified caption or MME-H improvement across models.

[0110] Table 7. Hallucination risk prediction based on the branch support signals of this invention.

[0111]

[0112] Table 8 Efficiency Results on CHAIR

[0113]

[0114] As shown in Tables 7 and 8, in the mechanism diagnosis embodiment, 1444 COCO object labels generated from 494 images were statistically analyzed, including 1152 factual labels and 292 hallucination labels. When language prior support is used as a risk signal, AUROC is 0.601 and AUPRC is 0.260, which is higher than the AUPRC baseline of 0.202 for hallucination labels (20.2%). The individual predictive ability of visual weakening support is weak, but removing the visual weakening counterfactual branch still increases CHAIRs from 37.6% to 45.0%. In the efficiency embodiment, the throughput of the original decoding is 34.67 tokens / s, the single image processing time is 3.38 seconds, and the peak video memory usage is 13.61 GB; the throughput of the method of this invention is 16.02 tokens / s, the single image processing time is 6.95 seconds, and the peak video memory usage is 14.09 GB.

[0115] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.

Claims

1. A risk perception dual-fact decoding method for mitigating visual large-scale hallucinations, characterized in that: Includes the following steps: Step S101: Input the image input, text prompt, and generated token sequence corresponding to the current decoding step into the original multimodal branch to obtain the original logits of the current decoding step; Step S102: Construct a language prior counterfactual branch and a visually weakened counterfactual branch; the language prior counterfactual branch does not accept image input and applies a text-side Boolean attention mask to the text token, and obtains language prior logits based on the text prompt, the generated token sequence, and the branch's independent key-value cache state; the visually weakened counterfactual branch retains image input and applies a visually weakened Boolean attention mask to the image token, and obtains visually weakened logits based on the image input, text prompt, the generated token sequence, and the branch's independent key-value cache state. The original multimodal branch, the linguistic prior counterfactual branch, and the visual weakened counterfactual branch maintain temporal alignment using a jointly generated token sequence in the same decoding step. The linguistic prior logits and the visual weakened logits are used for subsequent risk signal calculation and gating fusion, and are not used as hallucination judgment results alone. Step S103: Calculate the risk signal for the current decoding step based on the original logits, language prior logits, and visually weakened logits; and determine the gating correction strength based on the risk signal. Step S104: Based on the gating correction intensity, perform gating comparison and fusion on the original logits, language prior logits, and visually weakened logits to obtain the correction score; Step S105: Generate the token for the current decoding step based on the corrected score, and determine whether the stopping condition is met; If the condition is not met, proceed to the next decoding step; Then add the token of the current decoding step to the generated token sequence.

2. The risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations according to claim 1, characterized in that, Step S101 specifically involves inputting the image input, text prompts, and the generated token sequence into the original multimodal branch to obtain the original logits for the current decoding step. ; in, Indicates the original multimodal branch in the th... The unnormalized token scores output by each decoding step, i.e., the original logits; for a single sample, When the batch size is hour, , This represents the vocabulary used by the word segmenter in the basic visual language model. With vocabulary The candidate tokens in the text correspond one-to-one; the original multimodal branch, the language prior counterfactual branch, and the visual weakened counterfactual branch share the same word segmenter and vocabulary, and the dimensions and lexical indexes have the same meaning; This refers to the pixel tensor obtained by the image processor; the image processor is an external preprocessing module for the model. This represents a basic visual language model consisting of a visual encoder, a visual projection layer, and a decoder-only autoregressive language model. The internal visual encoder and visual projection layer convert the pixel tensor into a visual token sequence; the subsequent visual side mask is applied to the position corresponding to the visual token sequence without directly modifying the original pixel image. The token index sequence represents the tokens obtained by the word segmenter from text prompts or user instructions, rather than pre-generated text features; the token index sequence is converted into text representation by the word embedding layer of the basic visual language model; Indicates the first The token index sequence generated before each decoding step is not the token embedding vector; each token index is encoded by the same word embedding layer and appended to the end of the prompt sequence of each branch in the order of generation, as the input for autoregressive decoding; Indicates the original multimodal branch in the th... The key-value cache state used in each decoding step; the visual token, text prompt token, and generated token form the decoder input of the decoder-only autoregressive language model in the order specified by the model dialogue template.

3. The risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations according to claim 2, characterized in that, Step S102 specifically includes: calculating linguistic prior logits through the linguistic prior counterfactual branch. ; in, The language prior counterfactual branch uses the same text prompts and generated token sequences as the original multimodal branch, with no image input and no image token block. This represents a Boolean attention mask on the text side. The language prior counterfactual branch is represented in the 1st... Each decoding step uses an independent key-value cache state. In the first decoding step, the language prior counterfactual branch is constructed independently based on the text-side sequence without image input; in subsequent decoding steps, the language prior counterfactual branch uses its current latent state. Perform forward computation on the jointly generated token and update it to obtain the hidden state at the next time step. ; The output of the language prior counterfactual branch is represented by the language prior logits. Language a priori counterfactual branch in the 1st Each decoding step performs a text-side Boolean attention mask. No additional risk triggering conditions are set; the number of valid tokens on the text side is set to... Based on the attention scores obtained within the language prior counterfactual branches, in ascending order, the branch with the lowest attention score is selected. The set consists of the positions of the text tokens. ; In the first branch of language a priori counterfactual Each decoding step originates from a pre-defined attention layer within that branch. Get the current query token position Attention weights for each text token position, and for The average of the attention points is used to obtain the text token position. Corresponding attention score : ; in, The first branch of the language prior counterfactual Layer The first point of attention, the first The query location corresponding to the token to be generated in each decoding step. For the text token position Attention weights; No. The actual number of text tokens retained per decoding step for: ; in, Minimum number of text tokens to retain, a positive integer; To round down; This is represented as the increment in the number of text tokens. ; The growth rate of the number of text tokens. ; Represents the natural exponential function; A function to find the minimum value; a set The position within the text-side Boolean attention mask The center position is set to 1, and the remaining text positions are set to 0, meaning the position with the lowest attention score is retained. One text token is used for attention calculation, while the rest of the text tokens are ignored.

4. The risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations according to claim 3, characterized in that, Step S102 specifically includes: calculating visual weakening logits through the visual weakening counterfactual branch: ; in, This represents the visual weakening logits output by the visual weakening counterfactual branch; In the first decoding step, it is constructed independently based on the image-text input and the visual side mask; in the second... In each decoding step, the visually weakened counterfactual branch utilizes its own hidden state. Perform forward computation on the jointly generated token and update it to obtain the hidden state at the next time step. ; The key-value caches corresponding to visual tokens and text tokens are updated based on the forward computation results of the visual weakened counterfactual branch, and are not copied from the original branch; the original multimodal branch, the language prior counterfactual branch, and the visual weakened counterfactual branch maintain temporal alignment through the same decoding step and the jointly generated token sequence; the visual weakened logits are used for subsequent risk calculation and gating fusion, and are not used as the hallucination determination result alone; The visual weakening counterfactual branch performs visual token masking in each decoding step, without setting additional risk triggering conditions; let the set of image token locations be... The number of image tokens is The number to be retained is: ; in, Indicates the first The actual number of visual tokens retained per decoding step; This indicates rounding down, and Select the lowest attention score in ascending order. The set consists of image token locations. It generates a visual sidemask, while keeping the text token and other non-image locations visible: ; ; in, This indicates that it belongs to all image tokens, but the positions of those image tokens within the set are no longer retained; Visual token retention quantity According to the current decoding step Total number of image tokens and the Visual token retention ratio per decoding step The decision shall not exceed the current total number of image tokens; No. Visual token retention ratio per decoding step Based on the preset minimum retention ratio Proportional increment and growth rate Dynamically determined: 。 5. The risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations according to claim 4, characterized in that, Step S103 specifically includes: converting the unnormalized logits output from the original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch into a probability distribution: ; in, , and Let represent the lexical probability distributions of the original multimodal branch, the linguistic prior counterfactual branch, and the visual weakening counterfactual branch, respectively; softmax converts the logits of each candidate token in the vocabulary into probabilities that sum to 1, and the normalized entropy of the original multimodal branch is: ; in, Represents a vocabulary set, Indicates vocabulary size, This represents candidate tokens in the vocabulary. Represents the natural logarithm; when At that time, it was agreed ;use After normalization, The range of values ​​is ;through The normalized Jensen-Shannon divergence is defined as: ; Based on the original multimodal branch With two counterfactual branches and The probability distribution calculation of the branch difference term: ; in, The value range is [0,1]; the larger the value, the greater the difference between the two probability distributions; the original multimodal branch uncertainty is reduced. The branch differences are combined to form the risk signal for the current decoding step: ; in, Indicates the first A risk signal for each decoding step is used to adjust the strength of the logits correction operation in the current decoding step. It is only used for logits correction and does not interfere with the mask generation of language prior counterfactual branches and visually weakened counterfactual branches, the number of tokens retained, or the key-value cache update. Representing the uncertainty term and branch differences The weighting coefficients between them, and .

6. The risk perception dual-fact decoding method for mitigating visual large-scale hallucinations according to claim 5, characterized in that, When the probability of the largest candidate token in the original multimodal branch satisfies At that time, a confidence rollback is performed, using the original branch's logits as the correction score, i.e., letting The counterfactual fusion correction is not implemented; among them, This represents the confidence backoff threshold with a value range of [0,1]. The original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch still complete the forward calculation before the confidence backoff judgment. When the confidence backoff condition is not met, perform reasonable truncation on the original multimodal branch logits: ; in, and Both represent vocabulary sets. Candidate token index in This represents the original branch `logits` after reasonable truncation. This represents the maximum logits of the original branch across all candidate tokens. This represents the reasonable cutoff strength parameter, and Candidate tokens that do not meet the truncation condition have their corresponding logits set to 0. .

7. The risk perception dual-reverse fact decoding method for mitigating visual large-scale hallucinations according to claim 6, characterized in that, If the confidence backoff condition is not triggered, proceed to step S104; step S104 specifically includes: The original multimodal branch, the language prior counterfactual branch, and the visual weakening counterfactual branch each yield unnormalized logits. , and The following calculations are performed separately during the fusion phase: ; ; ; in, , and Let these represent the log probabilities of the truncated original branch, the linguistic prior counterfactual branch, and the visual weakening counterfactual branch, respectively. The linguistic prior correction term is constructed from the original branch and the linguistic prior counterfactual branch. ; The time weights that vary with the decoding step are: ; in, The non-negative time-weighted rate of change parameter represents the risk signal mapped to the gating correction strength via the Sigmoid function. ; in, Indicates the minimum correction strength. Indicates the basic correction strength, and ; This indicates a preset risk threshold. This indicates a temperature parameter greater than 0. This represents the sigmoid monotonic mapping function; temperature parameter. Control risk signals Mapped to gated correction strength via Sigmoid function The smoothness of the process is ultimately adjusted to the following score: ; Among them, the same gating correction strength Simultaneously affects the language prior modification term. Log probability of visual weakening branch ; This indicates a language prior modification term enhanced by risk gating. This indicates that support in the visually weakened branch is subtracted according to the same gating strength. Used to generate the token for the current decoding step.