Large visual language model hallucination mitigation method and apparatus
By employing cross-modal dynamic sampling and adaptive attention enhancement, the illusion problem in large visual language models is solved, achieving improved accuracy and efficiency in high-risk domains, and is applicable to applications such as medical image analysis and autonomous driving.
Patent Information
- Application Number
- CN202511172128.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-08-21
AI Technical Summary
Existing large-scale visual language models are prone to hallucinations when generating text descriptions, especially in high-risk fields such as medical image analysis and autonomous driving. Existing methods cannot effectively balance the synergistic effect of visual and textual information, resulting in poor generalization ability, low computational efficiency and susceptibility to noise interference.
The attention score matrix of text tokens and visual tokens is calculated by a cross-modal dynamic sampling strategy. Key visual tokens are selected and adaptive attention enhancement is performed. Combined with a contrastive decoding strategy, language prior bias is suppressed, and the attention weights of visual and language modalities are dynamically adjusted.
It significantly reduces hallucinations, improves the accuracy and reliability of generated results, requires no additional training, is compatible with existing models, and maintains the accuracy and richness of generated descriptions.
Smart Images

Figure CN120781883B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of artificial intelligence and multimodal large models, specifically relating to a method and apparatus for alleviating hallucinations of large vision-language models (LVLMs). Background Technology
[0002] In recent years, large-scale visual language models (LLMs) have demonstrated significant capabilities in tasks such as visual question answering and image description generation. These models, by combining visual encoders and large-scale language models (LLMs), can transform image content into natural language descriptions. However, a long-standing challenge is the "illusion" problem, where the model-generated text descriptions contain objects, attributes, or relationships that are not present or are incorrect in the input image. This illusion phenomenon severely impacts the reliability of the model, especially in high-risk fields such as medical image analysis and autonomous driving, where factual accuracy is crucial.
[0003] Existing technologies primarily mitigate the hallucination problem through two main approaches: unimodal augmentation and contrastive decoding (CD). Unimodal augmentation methods enhance visual attention weights (PAI), forcing the model to focus more on image features. However, these methods may over-rely on visual information, neglecting the guidance of textual cues, leading to the model being distracted by visual regions irrelevant to the problem. Contrastive decoding methods include using visual contrastive decoding (VCD) or instruction contrastive decoding (DCD), adjusting the generation probability by comparing the output of the original input with the perturbation input. These methods work by amplifying the difference between the original and perturbation inputs, enabling the model to focus more on visual content rather than linguistic priors; however, they lack effective filtering of key visual information within the modality, easily leading to attention being diverted to visual noise unrelated to the input cues.
[0004] In summary, existing technologies still have some limitations. First, they have poor generalization ability; many methods rely on additional training or specific datasets, making it difficult to adapt to different tasks or model architectures. Second, they are computationally inefficient; some methods require complex computations (such as ensembles of external expert models), increasing inference costs. Most importantly, existing methods cannot balance the synergistic effect of visual and textual information, which may lead to models overemphasizing noisy regions or ignoring key visual features.
[0005] Therefore, there is an urgent need for a method that can dynamically combine visual and textual information without additional training, in order to accurately identify key visual tokens and suppress irrelevant interference, thereby effectively reducing hallucinations. Summary of the Invention
[0006] The present invention aims to overcome at least one of the defects of the prior art and provide a method for hallucination mitigation of large visual language models based on bimodal collaborative attention enhancement to address the hallucination problem in LVLMs.
[0007] The present invention also discloses an apparatus loaded with a large visual language model illusion relief method.
[0008] The detailed technical solution of this invention is as follows:
[0009] A method for alleviating hallucinations using a large visual language model, the method comprising:
[0010] S1. Obtain the complete visual token of the original image and the text token of the text prompt, and connect the complete visual token and the text token together to input the decoder of the large language model;
[0011] S2. In the decoder of the large language model, the attention score matrix of text tokens and all visual tokens is calculated based on a cross-modal dynamic sampling strategy, to sample the tokens most relevant to the text token cues. A key visual token;
[0012] S3. Obtain the classification tokens of the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, filter out the top visual tokens with the highest scores. Visual tokens are used as prominent visual tokens;
[0013] S4. Perform adaptive attention enhancement on the salient visual tokens and key visual tokens;
[0014] S5. By using a contrastive decoding strategy, the influence of the logits distribution of the plain text input is subtracted from the logits distribution of the visually enhanced information to suppress the illusion caused by language priors and obtain the final target text output.
[0015] According to a preferred embodiment of the present invention, in step S1, obtaining the complete visual token of the original image specifically involves:
[0016] The original image is input into the visual encoder, and the complete visual token of the original image is obtained through CLS-driven sampling within the visual modality. ,in It is the length of the complete visual token; the calculation formula is as follows:
[0017] (1);
[0018] In equation (1), Indicates a visual encoder; This represents the original input image.
[0019] According to a preferred embodiment of the present invention, in step S1, obtaining the text token for the text prompt specifically involves:
[0020] Text prompts are processed using a tokenizer and an embedding module to generate input text tokens. ,in It is the length of the text token; the calculation formula is as follows:
[0021] (2);
[0022] In equation (2), This indicates the word segmenter and the embedding module; This indicates the text prompt for the input.
[0023] According to a preferred embodiment of the present invention, in step S2, an attention score matrix of the text token and all visual tokens is calculated based on a cross-modal dynamic sampling strategy, in order to sample the tokens most relevant to the text token cue. The key visual tokens include:
[0024] S21. Calculate the attention score matrix of text tokens and visual tokens using an attention mechanism. :
[0025] ( 3);
[0026] 4);
[0027] In equations (3)-(4): For the first large language model decoder Layer, i.e., the early layer; Indicates the first i Query weight of the layer; Indicates the first i Layer key weights; Indicates the first i The hidden layer vector of the text token in the layer; Indicates the first i The hidden layer vector of the visual token of the layer; Represents the feature dimensions of a large language model; This represents the matrix transpose operation; attention score matrix. ,in, This indicates the number of heads in a multi-head attention mechanism. Indicates the number of visual tokens. Indicates the number of text tokens;
[0028] S22. Calculate the importance score of the visual token:
[0029] , (5);
[0030] In equation (5): The first character representing the large language model decoder Importance scores of all visual tokens in the layer; specifically, first, the attention score matrix... of H The attention head performs a reduce-max operation, and then calculates the th attention head. Accumulated to the th The average of the scores, j This indicates the index of the text prompt token;
[0031] S23. Select the one with the highest importance score. Several visual tokens are sampled as key visual tokens, specifically including:
[0032] The first for large language model decoders Importance scores of all visual tokens in the layer Sort in descending order to get ,in, The first character representing the large language model decoder The first in the layer The importance score of each visual token;
[0033] Select key visual tokens whose cumulative importance exceeds a predefined importance threshold. The number of key visual tokens... The calculation formula is as follows:
[0034] (6);
[0035] In formula (6): Indicates a predefined importance threshold; This represents the number of key visual tokens among all visual tokens, where are positive integers and ; This represents the minimum value that makes the entire summation expression greater than the threshold. and give it ; An index representing the visual token importance score;
[0036] Based on importance score Sort, for those ranked higher Each visual token is sampled as a key visual token. And ensure that the selected visual token is directly related to the text token cue.
[0037] According to a preferred embodiment of the present invention, in step S3, the calculation formula for the attention score is as follows:
[0038]
[0039] In equation (7): This indicates a query for category tokens; The key representing the visual token; Represents the feature dimensions of the visual encoder; attention score A higher score indicates that the global information contained in the token is more important; among them, the highest filtering score is the top... of .
[0040] According to a preferred embodiment of the present invention, in step S4, adaptive attention enhancement is performed on the salient visual tokens and key visual tokens:
[0041] (8);
[0042] In equation (8): Indicates the visual token attention score; Indicates the basic enhancement factor; This represents a scaling factor introduced to prevent over-enhancement; express function; n This represents the latest generated text token. Indicates a visual token; This represents the intersection of salient visual tokens and key visual tokens, i.e. ,in, For prominent visual tokens, For key visual tokens; This refers to one of the prominent visual tokens or key visual tokens, namely ; Other visual tokens that were not selected as prominent visual tokens and key visual tokens.
[0043] According to a preferred embodiment of the present invention, in step S5, the logits distribution of the visual information enhancement is the logits layer output of the LLM model with visual image input and enhanced with key visual tokens; the logits distribution of the plain text input is the logits layer output of the LLM model after removing the image input.
[0044] The final target text output is:
[0045] (9);
[0046] In equation (9): Represents the parameters of a large language model; This represents the degree of penalty used to control the initial prediction distribution, thereby reducing the prediction probability based solely on text input; where, This represents the output distribution of a large language model when no image input is provided; The output distribution of the latest text tokens represents the final target text, where, Indicates the number to be predicted i A text token, This represents the index of the latest text token to be predicted. This represents the first i generated text tokens.
[0047] In another aspect of the invention, an apparatus is provided for implementing a method for alleviating hallucinations in a large visual language model, the apparatus comprising:
[0048] The token acquisition module is used to acquire the complete visual token of the original image and the text token of the text prompt, and to connect the complete visual token and the text token together and input them into the decoder of the large language model.
[0049] The first token sampling module is used in the decoder of the large language model to calculate the attention score matrix of text tokens and all visual tokens based on a cross-modal dynamic sampling strategy, in order to sample the tokens most relevant to the text token cues. A key visual token;
[0050] The second token sampling module is used to acquire classification tokens from the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, to filter the top visual tokens with the highest scores. Visual tokens are used as prominent visual tokens;
[0051] An attention enhancement module is used to adaptively enhance the attention of the salient visual tokens and key visual tokens;
[0052] The target output module is used to subtract the influence of the logits distribution of the plain text input from the logits distribution of the visually enhanced information by using a contrastive decoding strategy, in order to suppress the illusion caused by language priors and obtain the final target text output.
[0053] In another aspect of the invention, an electronic device is also provided, comprising:
[0054] At least one processor; and
[0055] A memory that stores instructions that, when executed by the at least one processor, cause the at least one processor to perform the large visual language model illusion mitigation method as described above.
[0056] In another aspect of the invention, a machine-readable storage medium is also provided, which stores executable instructions that, when executed, cause the machine to perform the large visual-language model illusion mitigation method as described above.
[0057] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0058] (1) This invention proposes a classification token-driven sampling mechanism within the visual modality. By using the attentional correlation between classification tokens and visual tokens, the visual token with the highest information content is selected, thereby enhancing the model's ability to perceive key visual regions.
[0059] (2) This invention proposes a cross-modal dynamic sampling method, which dynamically selects visual tokens that are highly relevant to the question based on the similarity between text prompts and visual tokens, thereby avoiding interference from irrelevant visual noise;
[0060] (3) This invention proposes an adaptive attention enhancement strategy, which dynamically adjusts the attention weights of key visual tokens selected by dual modalities in the early and intermediate layers of the large language model decoder, while combining contrastive decoding to suppress language prior bias, thereby achieving balanced optimization of visual and language modalities. Attached Figure Description
[0061] Figure 1 This is a flowchart of the large-scale visual language model hallucination mitigation method described in this invention.
[0062] Figure 2 This is a schematic diagram of the network model structure of the large-scale visual language model hallucination mitigation method described in this invention.
[0063] Figure 3 When the method of this invention is applied to the LLaVA-1.5-7B baseline model and with different enhancement factors... The following is a diagram showing the results of the ablation experiment.
[0064] Figure 4 When the method of this invention is applied to the LLaVA-1.5-7B benchmark model and at different scaling factors... The following is a diagram showing the results of the ablation experiment.
[0065] Figure 5 The figure shows the ablation experimental results when the method of the present invention is applied to the LLaVA-1.5-7B baseline model and under different intervention end layers. Detailed Implementation
[0066] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0067] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0068] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0069] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0070] Existing methods for handling hallucination problems focus only on mitigating unilateral hallucinations, neglecting joint optimization within and between modalities. This leads to insufficient perception of basic visual information during decoding, or attention being diverted to visual noise unrelated to input cues. This invention aims to provide a bimodal collaborative attention enhancement method to mitigate hallucination problems in large visual-language models. By jointly utilizing intramodal visual cues and cross-modal interactions to find key information, and by suppressing noise through adaptive attention enhancement, it effectively mitigates hallucinations.
[0071] This method first inputs the original image into a visual encoder, and obtains salient visual tokens through CLS-driven sampling within the visual modality. Simultaneously, text cues are processed by a word segmenter and an embedding module to generate text tokens. The visual tokens and text tokens are concatenated and then input into the decoder of a large language model. Based on a cross-modal dynamic sampling strategy, the attention score matrix of text tokens and all visual tokens is calculated, and the visual tokens most relevant to the text token cues are sampled. Then, in the multimodal fusion stage, the key visual tokens selected by the two sampling methods are adaptively enhanced with attention. Finally, by comparing the decoding strategy, the influence of the logits distribution of the pure text input is subtracted from the logits distribution of the visual information enhancement, further suppressing the illusion caused by language priors, and obtaining the final target text output.
[0072] This method requires no additional training and effectively improves the accuracy and reliability of large-scale visual language model generation results by synergistically utilizing attention mechanisms within and across visual modalities.
[0073] The following detailed description of the large-scale visual language model hallucination mitigation method and apparatus of the present invention, with reference to specific embodiments, provides further insight.
[0074] Example 1
[0075] Reference Figure 1 , this embodiment provides a method for reducing hallucinations in large visual language models, and the method includes:
[0076] S1. Obtain the complete visual tokens of the original image, and obtain the text tokens of the text prompt, and connect the complete visual tokens and text tokens and jointly input them into the decoder of the large language model.
[0077] For the obtaining of the complete visual tokens of the original image, in this embodiment, the original image can be input into the visual encoder, and the complete visual tokens of the original image can be obtained through CLS-driven sampling within the visual modality, and it is represented as , where is the length of the complete visual tokens, that is, the number of visual tokens ; the calculation formula is as follows:
[0078] (1);
[0079] In formula (1), represents the visual encoder; represents the input original image.
[0080] For the obtaining of the text tokens of the text prompt, in this embodiment, the text prompt can be processed by a tokenizer and an embedding module to generate text tokens, and it is represented as , where is the length of the text tokens, that is, the number of text tokens . That is, the text prompt is processed by the tokenizer and the embedding module to obtain the text tokens , and the calculation formula is as follows:
[0081] (2);
[0082] In formula (2), [[ID=Because large visual language models need to focus not only on salient visual regions but also on the visual regions most relevant to the textual cues, textual information from the LLM model plays a valuable role in guiding the selection of visual tokens. Therefore, this embodiment utilizes text embeddings from early layers of the large language model decoder to guide the dynamic sampling of visual tokens.
[0086] This step specifically includes:
[0087] S21. Calculate the attention score matrix of text tokens and visual tokens using an attention mechanism.
[0088] Specifically, for a complete visual token input into a large language model decoder With text tokens In the large language model decoder The layer (i.e., the early layer) uses a multi-head attention mechanism to calculate the attention score matrix for visual tokens and text tokens, treating the text tokens as queries. This indicates that visual tokens are treated as keys, and are used... Indicate; then the first Attention score matrix of visual tokens and text tokens The calculation formula is as follows:
[0089] ( 3);
[0090] 4);
[0091] In equations (3)-(4): Indicates the first i Query weight of the layer; Indicates the first i Layer key weights; Indicates the first i The hidden layer vector of the text token in the layer; Indicates the first i The hidden layer vector of the visual token of the layer; The feature dimensions representing a large language model; This represents the matrix transpose operation.
[0092] The attention score matrix is calculated based on the above formula. ,in, This indicates the number of heads in a multi-head attention mechanism. Indicates the number of visual tokens. Indicates the number of text tokens.
[0093] S22, Calculate the importance score of the visual token.
[0094] For complete visual tokens For each visual token, take its maximum attention score across all text tokens, then average these maximum attention scores across all text tokens to obtain an importance score. The specific calculation formula is as follows:
[0095] , (5);
[0096] In equation (5): The first character representing the large language model decoder Importance scores of all visual tokens in the layer; specifically, first, the attention score matrix... of H The attention head performs a reduce-max operation, and then calculates the th attention head. Accumulated to the th The average of the scores, This indicates the index of the text prompt token.
[0097] S23. Select the one with the highest importance score. Each visual token is sampled and used as a key visual token.
[0098] To identify important visual tokens, the first step is to analyze the large language model decoder. Importance scores of all visual tokens in the layer Sort in descending order to get ,in, The first character representing the large language model decoder The first in the layer The importance score of each visual token; then select key visual tokens whose cumulative importance exceeds a predefined importance threshold. The number of key visual tokens. The specific calculation formula is as follows:
[0099] (6);
[0100] In formula (6): Indicates a predefined importance threshold; This represents the number of key visual tokens among all visual tokens, where are positive integers and ; This represents the minimum value that makes the entire summation expression greater than the threshold. and give it ; An index representing the visual token importance score.
[0101] Finally, based on their importance, the top-ranked items were... Each visual token is sampled as a key visual token and represented as... At the same time, ensure that the selected visual token is directly related to the text token cue.
[0102] S3. Obtain the classification tokens of the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, filter out the top visual tokens with the highest scores. The visual token is a prominent visual token.
[0103] In this embodiment, considering that large language models typically utilize features from the penultimate layer of the visual encoder, and that classification tokens aggregate global image information, the stronger the correlation between visual tokens and classification tokens, the more significant the information they carry. Therefore, to obtain significant visual information, attention scores for classification tokens and visual tokens in the penultimate layer of the visual encoder are calculated. These scores provide an effective measure for evaluating the importance of visual tokens in the visual encoder.
[0104] Specifically, based on the attention scores of classification tokens and visual tokens, the top tokens with the highest attention scores are sampled. (For example, 25%) of visual tokens are used as salient visual tokens, and are represented as This ensures that the large language model focuses on information-rich visual regions. The formula for calculating the attention score is as follows:
[0105]
[0106] In equation (7): This indicates a query for category tokens; The key representing the visual token; Represents the feature dimensions of the visual encoder; attention score A higher score indicates that the global information contained in the token is more important; among them, the highest filtering score is the top... of .
[0107] S4. Perform adaptive attention enhancement on the salient visual tokens and key visual tokens.
[0108] In the multimodal fusion stage, adaptive attention enhancement is performed on the sampled salient visual tokens and key visual tokens. That is, in the attention weight allocation of the early layers of the large language model, a dynamic enhancement factor is applied to the intersection of these salient visual tokens and key visual tokens, while a fixed enhancement is applied to the tokens that are selected by a single sample, and the tokens that are not selected remain unchanged.
[0109] Research on the LVLM model revealed that visual information primarily propagates from the early to the middle layers of the large language model, while answer generation mainly occurs in the later stages. Therefore, the early and middle layers can be identified as key stages in cross-modal fusion, where attention to the sampled salient and key visual tokens is uniformly enhanced during the forward propagation of the multi-head self-attention mechanism.
[0110] The visual tokens selected by both sampling strategies mentioned above not only possess rich visual content but are also highly relevant to the text prompts, and are represented as follows: ;in, The salient visual token selected for the sampling strategy in step S3, The key visual tokens selected for the sampling strategy in step S2; adaptive attention enhancement is applied to encourage... Greater information contribution.
[0111] For a visual token selected using only one of the two sampling strategies (i.e., a salient visual token or a key visual token), a fixed level of attention enhancement is applied, denoted as... Visual tokens that were not selected through any sampling strategy remain unchanged, represented as .
[0112] Based on the above, the specific calculation formula for adaptive attention enhancement is as follows:
[0113] (8);
[0114] In equation (8): Indicates the visual token attention score; Indicates the basic enhancement factor; This represents a scaling factor introduced to prevent over-enhancement; express function; n This represents the latest generated text token. Represents a visual token.
[0115] S5. By using a contrastive decoding strategy, the influence of the logits distribution of the plain text input is subtracted from the logits distribution of the visually enhanced information to suppress the illusion caused by language priors and obtain the final target text output.
[0116] In this step, to further suppress language priors, a contrastive decoding strategy is employed to mitigate language bias in vision-centric tasks. The output distribution (when no image is provided as input) is used as a reference to penalize the initial prediction distribution, resulting in the final language output. Specifically, the logits distribution for visual information augmentation is the logits layer output of the LLM model with visual image input and augmented using key visual tokens; the logits distribution for plain text input is the logits layer output of the LLM model after removing the image input.
[0117] The specific formula for calculating the output text prediction is as follows:
[0118] (9);
[0119] In equation (9): Represents the parameters of a large language model; This represents the degree of penalty used to control the initial prediction distribution, thereby reducing the prediction probability based solely on text input; where, This represents the output distribution of a large language model when no image input is provided; The output distribution of the latest text tokens represents the final target text, where, Indicates the number to be predicted A text token, i This indicates the position of the text token to be predicted. This represents the first i generated text tokens.
[0120] Specifically, in this embodiment, multiple experiments were conducted on the widely used test benchmarks CHAIR and POPE to verify the effectiveness of the method of the present invention in reducing hallucinations and maintaining the overall perceptual ability of the model.
[0121] To conduct experimental comparisons, the following are some basic experimental setup instructions:
[0122] For the experimental benchmark models, three popular multimodal large language models (LVLMs)—LLaVA-1.5-7B, LLaVA-1.5-13B, and Shikra-7B—were selected to evaluate the effectiveness of the proposed method. This method aims to propose a training-free LVLM decoding strategy. For comprehensive comparison, benchmark tests were performed against three commonly used decoding methods and two mainstream hallucination mitigation methods: the greedy decoding method Greedy and the beam search method Beam. =5), kernel sampling method Nucleus Sample, visual contrast decoding method VCD, and image attention method PAI. VCD reduces statistical priors by subtracting the output logit of the distorted visual input from the original output logit. PAI further enhances the model's attention to the input image by increasing the overall attention value of image tokens. This illustrated approach follows a similar paradigm but places greater emphasis on strengthening the model's perception of important visual tokens.
[0123] For the details of this experimental implementation, the basic enhancement factor is set to = 0.6, the final intervention layer is set to =18. For the two baseline models, LLaVA1.5-7B and LLaVA-1.5-13B, the adaptive scaling factor... = 0.2, while for the Shikra baseline model, following previous experience, a larger adaptive scaling factor was adopted. = 0.4. Consistent with previous studies, from = Starting from layer 3, inference time decoding intervention is applied, and the final penalty level weights are adjusted. Set to 1.1. Use the default settings during the key visual token selection phase. Its value is 0.25%, the threshold. The value is 0.85. VCD uses kernel sampling, and greedy decoding serves as the baseline for the PAI method and the method of this invention.
[0124] Specifically, the experimental results on the CHAIR benchmark are as follows:
[0125] CHAIR evaluates hallucinations in LVLMs by prompting the model to generate descriptions of the input images, then comparing these descriptions to actual objects in the images. For each image, a set of ground truth object labels is constructed, and any object mentioned in the generated description but not in this label set is considered a hallucination object. CHAIR includes two evaluation dimensions: instance-level and sentence-level, denoted as follows: and .
[0126] For different LVLM models, the CHAIR metric was evaluated on the MS-COCO validation set. Image descriptions were generated using the prompt "Please describe this image in detail," and then evaluated using the CHAIR metric. To evaluate hallucinations in long sequence generation, the same experimental setup as the PAI method was followed, with the maximum number of new tokens set to 512, and 500 instances were randomly sampled for evaluation. The experimental results of this invention are shown in Table 1.
[0127] Table 1. Experimental results of evaluating the model using the CHAIR index.
[0128]
[0129] As shown in Table 1, the method of this invention, denoted as DuCAR, exhibits significant improvements under different models and settings. This method outperforms other decoding strategies in reducing hallucinations. Compared to the strongest baseline PAI, when applied to the LLaVA-1.5-7B model, the DuCAR method of this invention... The evaluation index decreased by 34.0% (from 27.0% to 17.8%). The evaluation metric decreased by 42.3% (from 7.8% to 4.5%), indicating its effectiveness in suppressing hallucinations in long sequence generation tasks. Furthermore, as shown in Table 3, DuCAR also maintained a reasonable F1 score, demonstrating that the proposed method can significantly alleviate hallucinations while still producing accurate and comprehensive image descriptions.
[0130] Specifically, the experimental results on the POPE benchmark are as follows:
[0131] POPE is a widely used object illusion benchmark with the question format "Is there xxx in the image?". The dataset is divided into three subsets: random, popular, and adversarial. In the random subset, objects are randomly selected from the entire dataset. In the popular subset, objects are selected from the most frequently occurring categories. In the adversarial subset, objects highly correlated with the actual objects in the image are selected to introduce challenging distractors. The proposed method was tested on 500 images from the MS-COCO dataset, with each image paired with six questions corresponding to each POPE segment. The model's performance on object recognition was evaluated using accuracy and F1 score. The experimental results of the proposed method are shown in Table 2.
[0132] Table 2. Experimental results evaluating the model's performance in target recognition using accuracy and F1 score.
[0133]
[0134] As shown in Table 2, the DuCAR method of this invention exhibits significant improvements across different models and settings. Specifically, the DuCAR method consistently outperforms existing methods, including PAI and VCD, on the LLaVA-1.5-7B and LLaVA-1.5-13B models. The DuCAR method can identify and enhance visual regions with rich semantics and high relevance to the given problem, significantly mitigating hallucinations. Compared to the visual contrast decoding method VCD, DuCAR shows significant improvements in both accuracy and F1 score. Furthermore, in most cases, DuCAR improves precision and recall, demonstrating its robustness in generating accurate and complete descriptions.
[0135] Finally, in this embodiment, extensive ablation studies were conducted to better understand the roles of the different components in the method of the invention. All ablation experiments were based on the representative LVLM baseline LLaVA-1.5-7B, with the hyperparameter gamma fixed at 1.1 according to previous research.
[0136] To evaluate the method of this invention, this section primarily employs the CHAIR metric. However, since CHAIR only assesses hallucination problems, an additional F1 score is added to balance hallucination mitigation and generation accuracy. This allows for a fairer comparison under the CHAIR metric when F1 scores are similar.
[0137] The contributions of each core component of the DuCAR method in this invention were verified through systematic ablation experiments: First, the effects of using only intra-visual CLS-driven sampling (DuCAR-v) or cross-modal dynamic sampling (DuCAR-c) were tested respectively, and the experimental results are shown in Table 3:
[0138] Table 3. Ablation experimental results using only DuCAR-v or DuCAR-c
[0139]
[0140] Table 3 shows that both methods reduce the CHAIR index when used alone, demonstrating the necessity of bimodal synergy. Secondly, comparing the differences between fixed attention enhancement (DuCAR-fa) and adaptive enhancement reveals that the adaptive strategy... The indicators further decreased, and the F1 score only dropped by 2.1%, indicating that dynamic adjustment can balance hallucination suppression and descriptive richness.
[0141] Furthermore, as shown in Table 4 of the experimental results, Figure 3 , 4 As shown, by adjusting key hyperparameters, the sampling ratio was confirmed. =25%, Importance Threshold =0.85, Enhancement Factor =0.6, scaling factor The optimal effect was achieved when the coefficient of performance was 0.2. The experimental results are shown in Table 4 below:
[0142] Table 4. Ablation test results of the method of the present invention
[0143] .
[0144] Finally, as the experimental results show... Figure 5 As shown in the figure, the intervention layer experiment demonstrates that covering only the middle 3-18 layers is sufficient to achieve over 90% performance. The ablation experiment results further comprehensively validate the effectiveness of the DuCAR method of this invention and its parameter robustness.
[0145] In summary, the hallucination mitigation method for large visual-language models based on bimodal collaborative attention enhancement disclosed in this invention has the following advantages compared to existing technologies:
[0146] (1) Significantly reduce hallucinations: By using bimodal collaborative screening and enhancing key visual tokens, the hallucination rate is significantly reduced in the POPE and CHAIR benchmark tests, and the generated results are more consistent with the actual image content;
[0147] (2) No additional training required: As an intervention method in the inference stage, it can be directly applied to existing LVLM models (such as LLaVA-1.5, Shikra), with strong compatibility and low computational cost;
[0148] (3) Maintaining generation quality: While suppressing illusions, the ability to capture visual details is preserved through adaptive enhancement strategies, and the F1 score is better than that of the comparison methods (such as PAI and VCD), ensuring the accuracy and richness of the output description.
[0149] Example 2
[0150] This embodiment provides an apparatus for implementing a method to alleviate hallucinations in large-scale visual language models, the apparatus comprising:
[0151] The token acquisition module is used to acquire the complete visual token of the original image and the text token of the text prompt, and to connect the complete visual token and the text token together and input them into the decoder of the large language model.
[0152] The first token sampling module is used in the decoder of the large language model to calculate the attention score matrix of text tokens and all visual tokens based on a cross-modal dynamic sampling strategy, in order to sample the tokens most relevant to the text token cues. A key visual token;
[0153] The second token sampling module is used to acquire classification tokens from the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, to filter the top visual tokens with the highest scores. Visual tokens are used as prominent visual tokens;
[0154] An attention enhancement module is used to adaptively enhance the attention of the salient visual tokens and key visual tokens;
[0155] The target output module is used to subtract the influence of the logits distribution of the plain text input from the logits distribution of the visually enhanced information by using a contrastive decoding strategy, in order to suppress the illusion caused by language priors and obtain the final target text output.
[0156] Example 3
[0157] This embodiment also provides an electronic device, including:
[0158] At least one processor; and
[0159] A memory that stores instructions that, when executed by the at least one processor, cause the at least one processor to perform the large visual language model illusion mitigation method as described above.
[0160] In this embodiment, the electronic device may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile computing device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable computing device, consumer electronic device, etc.
[0161] Example 4
[0162] This embodiment also provides a machine-readable storage medium storing executable instructions that, when executed, cause the machine to perform the large visual-language model illusion mitigation method as described above.
[0163] Specifically, a system or apparatus equipped with a readable storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer or processor of the system or apparatus can read and execute the instructions stored in the readable storage medium.
[0164] In this case, the program code itself, which can be read from the readable medium, can implement the functionality of any of the embodiments described above. Therefore, the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of this specification. Embodiments of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROMs, CD-Rs, CD-RWs, DVD-ROMs, DVD-RAMs, DVD-RWs), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code can be downloaded from a server computer or the cloud via a communication network.
[0165] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. A method for alleviating hallucinations in a large visual language model, characterized in that, The method includes: S1. Obtain the complete visual token of the original image and the text token of the text prompt, and connect the complete visual token and the text token together to input the decoder of the large language model; S2. In the decoder of the large language model, the attention score matrix of text tokens and all visual tokens is calculated based on a cross-modal dynamic sampling strategy, to sample the tokens most relevant to the text token cues. A key visual token; Specifically, S2 includes: S21. Calculate the attention score matrix of text tokens and visual tokens using an attention mechanism. : (3); (4); In equations (3)-(4): the text token is treated as a query, and... This indicates that visual tokens are treated as keys, and are used... express; For the first large language model decoder layer; Indicates the first i Query weight of the layer; Indicates the first i Layer key weights; Indicates the first i The hidden layer vector of the text token in the layer; Indicates the first i The hidden layer vector of the visual token of the layer; Represents the feature dimensions of a large language model; This represents the matrix transpose operation; attention score matrix. ,in, This indicates the number of heads in a multi-head attention mechanism. Indicates the number of visual tokens. Indicates the number of text tokens; S22. Calculate the importance score of the visual token: , (5); In equation (5): The first character representing the large language model decoder The importance scores of all visual tokens in the layer, i.e., the attention score matrix. of H The attention head performs a reduce-max operation, and then calculates the th attention head. Accumulated to the th The average of the scores, j This indicates the index of the text prompt token; S23. Select the one with the highest importance score. Several visual tokens are sampled as key visual tokens, specifically including: The first for large language model decoders Importance scores of all visual tokens in the layer Sort in descending order to get ,in, The first character representing the large language model decoder The first in the layer The importance score of each visual token; Select key visual tokens whose cumulative importance exceeds a predefined importance threshold. The number of key visual tokens... The calculation is as follows: (6); In formula (6): Indicates a predefined importance threshold; This represents the number of key visual tokens among all visual tokens, where are positive integers and ; This represents the minimum value that makes the entire summation expression greater than the threshold. and give it ; An index representing the visual token importance score; Based on importance score Sort, for those ranked higher Each visual token is sampled as a key visual token. And the selected key visual token Directly related to text token prompts; S3. Obtain the classification tokens of the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, filter out the top visual tokens with the highest scores. Visual tokens are used as prominent visual tokens; The attention score is calculated as follows: In equation (7): This indicates a query for category tokens; The key representing the visual token; Represents the feature dimension of the visual encoder; S4. Perform adaptive attention enhancement on the salient visual tokens and key visual tokens: (8); In equation (8): Indicates the visual token attention score; Indicates the basic enhancement factor; This represents a scaling factor introduced to prevent over-enhancement; express function; n This represents the latest generated text token. Indicates a visual token; This represents the intersection of salient visual tokens and key visual tokens, i.e. ,in, For prominent visual tokens, For key visual tokens; This refers to one of the prominent visual tokens or key visual tokens, namely ; Other visual tokens that were not selected as prominent visual tokens and key visual tokens; S5. By using a contrastive decoding strategy, the influence of the logits distribution of the plain text input is subtracted from the logits distribution of the visually enhanced information to suppress the illusion caused by language priors and obtain the final target text output.
2. The method for alleviating hallucinations using a large visual language model according to claim 1, characterized in that, In step S1, obtaining the complete visual token of the original image specifically involves: The original image is input into the visual encoder, and the complete visual token of the original image is obtained through CLS-driven sampling within the visual modality. ,in It is the length of the complete visual token; the calculation formula is as follows: (1); In equation (1), Indicates a visual encoder; This represents the original input image.
3. The method for alleviating hallucinations using a large visual language model according to claim 2, characterized in that, In step S1, obtaining the text token for the text prompt specifically involves: Text prompts are processed using a tokenizer and an embedding module to generate input text tokens. ,in It is the length of the text token; the calculation formula is as follows: (2); In equation (2), This indicates the word segmenter and the embedding module; This indicates the text prompt for the input.
4. The method for alleviating hallucinations using a large visual language model according to claim 3, characterized in that, In S5, the logits distribution of the visual information enhancement is the logits layer output of the LLM model with visual image input and enhanced with key visual tokens; the logits distribution of the plain text input is the logits layer output of the LLM model after removing the image input. The final target text output is: (9); In equation (9): Represents the parameters of a large language model; This indicates the degree of penalty used to control the initial prediction distribution, in order to reduce the prediction probability based solely on text input; This represents the output distribution of a large language model when no image input is provided; The output distribution of the latest text tokens represents the final target text, where, Indicates the number to be predicted i A text token, This represents the index of the latest text token to be predicted. This represents the first i generated text tokens.
5. An apparatus for implementing the large visual-language model hallucination mitigation method as described in any one of claims 1 to 4, characterized in that, The device includes: The token acquisition module is used to acquire the complete visual token of the original image and the text token of the text prompt, and to connect the complete visual token and the text token together and input them into the decoder of the large language model. The first token sampling module is used in the decoder of the large language model to calculate the attention score matrix of text tokens and all visual tokens based on a cross-modal dynamic sampling strategy, in order to sample the tokens most relevant to the text token cues. A key visual token; The second token sampling module is used to acquire classification tokens from the original image, and based on the attention scores of each visual token in the classification tokens and the complete visual tokens, to filter the top visual tokens with the highest scores. Visual tokens are used as prominent visual tokens; An attention enhancement module is used to adaptively enhance the attention of the salient visual tokens and key visual tokens; The target output module is used to subtract the influence of the logits distribution of the plain text input from the logits distribution of the visually enhanced information by using a contrastive decoding strategy, in order to suppress the illusion caused by language priors and obtain the final target text output.
6. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the large visual-language model illusion mitigation method as described in any one of claims 1 to 4.
7. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores executable instructions that, when executed, cause the machine to perform the large visual-language model hallucination mitigation method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Attention contrast decoding method for visual language large model illusion alleviation
CN120339791A
Visual language model illusion suppression method based on adaptive dynamic attention intervention
CN120430402A