Large visual language model illusion mitigation method and device
Through cross-modal dynamic sampling and adaptive attention enhancement methods, the hallucination problem in large-scale visual language models is solved, the coordinated optimization of visual and text information is achieved, and the accuracy and reliability of the generated results are improved. It is suitable for fields such as medical image analysis and autonomous driving.
Patent Information
- Application Number
- CN202511172128.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2045-08-21
AI Technical Summary
Existing large-scale visual language models are prone to hallucinations when generating text descriptions and cannot effectively balance the synergy between visual and textual information. This causes the model to be distracted by noisy areas, affecting the accuracy and credibility of the generated results, especially in high-risk fields such as medical image analysis and autonomous driving.
By obtaining the visual tokens of the original image and the text tokens of the text prompt, a cross-modal dynamic sampling strategy is used to calculate the attention score matrix, screen out the key visual tokens most relevant to the text prompt, and perform adaptive attention enhancement. Combined with the contrast decoding strategy to suppress the influence of language priors, the final target text output is obtained.
It significantly reduces hallucinations, improves the accuracy and reliability of generated results, maintains the ability to capture key visual information, does not require additional training, is applicable to existing large-scale visual language models, and reduces computational costs.
Smart Images

Figure CN120781883A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence and multimodal large models, and particularly relates to a method and device for alleviating hallucinations in large vision-language models (LVLMs). Background Art
[0002] In recent years, large-scale vision-language models have demonstrated remarkable capabilities in tasks such as visual question answering and image caption generation. By combining visual encoders with large language models (LLMs), these models are able to convert image content into natural language descriptions. However, a long-standing challenge is the problem of "hallucination," where the text descriptions generated by the model contain objects, attributes, or relationships that are absent or incorrect in the input image. This phenomenon severely impacts the credibility of the model, especially in high-stakes fields such as medical image analysis and autonomous driving, where factual accuracy is crucial.
[0003] Existing technologies mainly use the following two methods to alleviate the hallucination problem: unimodal enhancement methods and contrastive decoding (CD) methods. Among them, unimodal enhancement methods force the model to pay more attention to image features by enhancing the visual attention weight (PAI). However, such methods may over-rely on visual information and ignore the guiding role of textual cues, causing the model to be distracted by visual areas irrelevant to the problem. Contrastive decoding methods include using visual contrastive decoding (VCD) or instruction contrastive decoding (DCD) to adjust 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 input and the perturbation input, allowing the model to focus more on visual content rather than language priors; the lack of effective screening of key visual information within the modality can easily lead to attention being diverted by visual noise unrelated to the input cues.
[0004] In summary, existing technologies still have several limitations. First, generalization is poor; many methods rely on additional training or specific datasets, making them difficult to adapt to different tasks or model architectures. Second, computational efficiency is low; some methods require complex computations (such as integrating external expert models), increasing inference costs. Most importantly, existing methods fail to balance the synergy between visual and textual information, which can cause the model to overfocus on noisy areas or ignore key visual features.
[0005] Based on this, there is an urgent need for a method that can dynamically combine visual and textual information without the need for additional training 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 above-mentioned shortcomings of the prior art and provide a large-scale visual language model hallucination reduction method based on bimodal collaborative attention enhancement to address the hallucination problem in LVLMs.
[0007] The invention also discloses a device loaded with a large-scale visual language model hallucination reduction method.
[0008] The detailed technical solutions of the present invention are as follows: A large-scale visual language model hallucination reduction method, the method comprising: S1, obtaining a complete visual token of the original image and a text token of the text prompt, and concatenating the complete visual token and the text token and inputting them into the decoder of the large language model; S2. In the decoder of the large language model, the attention score matrix of the text token and all visual tokens is calculated based on the cross-modal dynamic sampling strategy to sample the most relevant text token prompts. Key visual tokens; S3, obtain the classification token of the original image, and based on the classification token and the attention score of each visual token in the complete visual token, select the top one with the highest score. The visual token is used as a significant visual token; S4, performing adaptive attention enhancement on the salient visual tokens and the key visual tokens; S5. By contrasting the decoding strategy, the influence of the logits distribution of the plain text input is subtracted from the logits distribution of the visual information enhancement to suppress the hallucination caused by the language prior and obtain the final target text output.
[0009] According to a preferred embodiment of the present invention, in S1, obtaining the complete visual token of the original image is specifically as follows: The original image is input into the visual encoder, and the complete visual token of the original image is obtained by CLS-driven sampling within the visual modality. ,in is the length of a complete visual token; it is calculated as follows: (1); In formula (1), represents the visual encoder; Represents the original input image.
[0010] According to a preferred embodiment of the present invention, in S1, obtaining the text token of the text prompt is specifically: Process the text prompt using a tokenizer and embedding module to produce input text tokens ,in is the length of the text token; it is calculated as follows: (2); In formula (2), Represents the word segmenter and embedding module; Represents a text prompt for input.
[0011] According to the preferred embodiment of the present invention, in said S2, the attention score matrix of the text token and all visual tokens is calculated based on the cross-modal dynamic sampling strategy to sample the most relevant text token prompts. Key visual tokens include: S21. Calculate the attention score matrix of text tokens and visual tokens through the attention mechanism : ( 3); 4); In formulas (3) and (4): The decoder of a large language model Layer, that is, early layer; Indicates the i The query weight of the layer; Indicates the i The key weight of the layer; Indicates the i The hidden layer vector of the text token of the layer; Indicates the i The hidden layer vector of the visual token of the layer; Represents the feature dimension of a large language model; Represents the matrix transpose operation; attention score matrix ,in, represents the number of heads in the multi-head attention mechanism, represents the number of visual tokens, Indicates the number of text tokens; S22. Calculate the importance score of the visual token: , (5); In formula (5): represents the first The importance scores of all visual tokens in the layer; specifically, the attention score matrix of H The attention head performs reduce-max operation, and then calculates the Accumulated to The average of the scores, j Indicates the index of the text prompt token; S23. Select the one with the highest importance score Visual tokens are sampled as key visual tokens, including: The decoder of a large language model Importance scores of all visual tokens in a layer Sort in descending order, and you get ,in, represents the first Layer Importance scores of visual tokens; Select key visual tokens whose cumulative importance exceeds a predefined importance threshold, the number of key visual tokens The calculation formula is as follows: (6); In formula (6): Indicates a predefined importance threshold; represents the number of key visual tokens among all visual tokens, where is a positive integer and ; Indicates the minimum value that makes the entire sum expression greater than the threshold , and assign it to ; An index representing the importance score of a visual token; According to importance score Sorting, sorting the top ranking Visual tokens are sampled as key visual tokens and ensure that the selected visual token is directly related to the text token hint.
[0012] According to a preferred embodiment of the present invention, in S3, the calculation formula of the attention score is as follows:
[0013] In formula (7): A query representing a classification token; A key representing a visual token; Represents the feature dimension of the visual encoder; attention score The higher the value, the more important the global information contained in the token; of .
[0014] According to a preferred embodiment of the present invention, in S4, adaptive attention enhancement is performed on the salient visual tokens and the key visual tokens: (8); In formula (8): represents the visual token attention score; represents the basic enhancement factor; represents the scaling factor introduced to prevent over-enhancement; express function; n Indicates the latest generated text token, Represents a visual token; represents the intersection of salient visual tokens and key visual tokens, i.e. ,in, As a significant visual token, is the key visual token; Represents one of the salient visual tokens or key visual tokens, i.e. ; Indicates other visual tokens that are not selected as salient visual tokens and key visual tokens.
[0015] Preferably, 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 by 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; Among them, the final target text output is: (9); In formula (9): Represents the parameters of a large language model; represents the degree of penalty used to control the initial prediction distribution, thereby reducing the prediction probability based only on text input; where, Represents the output distribution of the large language model when no image input is provided; Represents the output distribution of the latest text token of the final target text, where Indicates the first i text tokens, Indicates the index of the latest text token to be predicted. Represents the first i generated text tokens.
[0016] In another aspect of the present invention, a device for implementing a large-scale visual language model hallucination reduction method is provided, the device comprising: A token acquisition module is used to obtain the complete visual token of the original image and the text token of the text prompt, and concatenate the complete visual token and the text token and input them into the decoder of the large language model; The first token sampling module is used to calculate the attention score matrix of text tokens and all visual tokens based on the cross-modal dynamic sampling strategy in the decoder of the large language model to sample the most relevant text token prompts. Key visual tokens; The second token sampling module is used to obtain the classification tokens of the original image and screen the top score based on the attention scores of the classification tokens and the visual tokens in the complete visual tokens. The visual token is used as a significant visual token; an attention enhancement module, configured to adaptively enhance attention on the salient visual tokens and the 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 enhanced by visual information through a contrastive decoding strategy to suppress the hallucinations caused by language priors and obtain the final target text output.
[0017] In another aspect of the present invention, an electronic device is provided, comprising: at least one processor; and A memory stores instructions, which, when executed by the at least one processor, enable the at least one processor to perform the large visual language model hallucination reduction method as described above.
[0018] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions. When the instructions are executed, the machine performs the large-scale visual language model hallucination reduction method as described above.
[0019] Compared with the prior art, the present invention has the following beneficial effects: (1) This paper proposes a classification token-driven sampling mechanism within the visual modality. By comparing the attentional relevance between classification tokens and visual tokens, the visual tokens with the highest information content are selected, thus enhancing the model's perception of key visual areas. (2) This paper 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, avoiding the interference of irrelevant visual noise; (3) The present invention proposes an adaptive attention enhancement strategy, which dynamically adjusts the attention weights of key visual tokens selected by dual modality in the early and middle layers of the large language model decoder, and combines contrastive decoding to suppress language prior bias, thereby achieving balanced optimization of visual and language modalities. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 Flowchart of the large-scale visual language model hallucination reduction method of the present invention.
[0021] Figure 2 Schematic diagram of the network model structure of the large-scale visual language model hallucination reduction method of the present invention.
[0022] Figure 3 The method of the present invention is applied to the LLaVA-1.5-7B benchmark model and at different enhancement factors The ablation experiment results are shown below.
[0023] Figure 4 The method of the present invention is applied to the LLaVA-1.5-7B benchmark model and at different scaling factors The ablation experiment results are shown below.
[0024] Figure 5 This is a diagram of the ablation experiment results when the method of the present invention is applied to the LLaVA-1.5-7B benchmark model and at different intervention end layers EndLayer. DETAILED DESCRIPTION
[0025] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0026] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.
[0027] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0028] In the absence of conflict, the embodiments of the present invention and the features thereof may be combined with each other.
[0029] Existing methods for addressing hallucinations focus solely on mitigating unilateral hallucinations, while neglecting joint optimization within and across modalities. This results in insufficient perception of essential visual information during decoding, or attention being diverted by visual noise unrelated to the input cues. The present invention aims to provide a dual-modal collaborative attention enhancement method that can mitigate hallucinations in large visual-language models. This method effectively mitigates hallucinations by jointly leveraging intra-modal visual cues and cross-modal interactions to identify key information and suppressing noise through adaptive attention enhancement.
[0030] This method first inputs the original image into the visual encoder and obtains salient visual tokens through CLS-driven sampling within the visual modality; simultaneously, the text prompt is processed by the word segmenter and embedding module to generate text tokens, which are concatenated with the text tokens and input into the decoder of the large language model; the attention score matrix of the text tokens and all visual tokens is calculated based on the cross-modal dynamic sampling strategy, and the visual tokens most relevant to the text token prompt are sampled; then, in the multimodal fusion stage, the key visual tokens selected by the two sampling methods are adaptively enhanced in 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 hallucinations caused by the language prior and obtaining the final target text output.
[0031] This method does not require additional training and effectively improves the accuracy and reliability of the generation results of large-scale visual language models by synergistically utilizing the attention mechanism within and across visual modalities.
[0032] The method and device for alleviating hallucinations of a large-scale visual language model of the present invention will be further described below with reference to specific embodiments.
[0033] Example 1 Ginseng Figure 1 This embodiment provides a method for alleviating hallucinations in a large-scale visual language model, the method comprising: S1. Obtain a complete visual token of the original image and a text token of the text prompt, and concatenate the complete visual token and the text token and input them into the decoder of the large language model.
[0034] The complete visual token of the original image is obtained. In this embodiment, the original image can be input into the visual encoder, and the complete visual token of the original image can be obtained by CLS driving sampling in the visual modality, which is expressed as ,in is the length of a complete visual token, i.e., the visual token The number of; the calculation formula is as follows: (1); In formula (1), represents the visual encoder; Represents the original input image.
[0035] The text tokens of the text prompt are obtained. In this embodiment, the text prompt can be processed by the word segmenter and the embedding module to generate text tokens, which are represented as ,in is the length of the text token, i.e. The number of. That is, the text prompt is processed by the word segmenter and the embedding module to obtain the text token , the calculation formula is as follows: (2); In formula (2), Represents the word segmenter and embedding module; Represents a text prompt for input.
[0036] Complete visual token based on the original image obtained above and text tokens for text hints , concatenate them and input them together into the decoder of the large language model LLMs.
[0037] S2. In the decoder of the large language model, the attention score matrix of the text token and all visual tokens is calculated based on the cross-modal dynamic sampling strategy to sample the most relevant text token prompts. A key visual token.
[0038] Because the LLM needs to focus not only on salient visual regions but also on the visual regions most relevant to the cues based on the textual cues, the textual information from the LLM model also plays a valuable role in guiding the selection of visual tokens. Therefore, this embodiment utilizes the textual embeddings of the early layers of the LLM decoder to guide the dynamic sampling of visual tokens.
[0039] This step specifically includes: S21. Calculate the attention score matrix of text tokens and visual tokens through the attention mechanism.
[0040] Specifically, for a complete visual token that is input to the decoder of a large language model With text tokens , in the decoder of a large language model The layer (i.e., the early layer) uses the multi-head attention mechanism to calculate the attention score matrix of visual tokens and text tokens, treating the text tokens as queries, and using Indicates; visual tokens are treated as keys, using Indicates; Attention score matrix of layer visual tokens and textual tokens The calculation formula is as follows: ( 3); 4); In formulas (3) and (4): Indicates the i The query weight of the layer; Indicates the i The key weight of the layer; Indicates the iThe hidden layer vector of the text token of the layer; Indicates the i The hidden layer vector of the visual token of the layer; Represents the feature dimension of the large language model; Represents a matrix transpose operation.
[0041] The attention score matrix is calculated based on the above formula ,in, represents the number of heads in the multi-head attention mechanism, represents the number of visual tokens, Indicates the number of text tokens.
[0042] S22. Calculate the importance score of the visual token.
[0043] For full visual tokens For each visual token in , we take its maximum attention score over all text tokens, and then take the average of these maximum attention scores over all text tokens to obtain the importance score. , the specific calculation formula is as follows: , (5); In formula (5): represents the first The importance scores of all visual tokens in the layer; specifically, the attention score matrix of H The attention head performs reduce-max operation, and then calculates the Accumulated to The average of the scores, Indicates the index of the text hint token.
[0044] S23. Select the one with the highest importance score visual tokens are sampled as key visual tokens.
[0045] To identify important visual tokens, we first train the decoder of a large language model Importance scores of all visual tokens in a layer Sort in descending order, and you get ,in, represents the first Layer The importance scores of visual tokens are counted; and then the key visual tokens whose cumulative importance exceeds the predefined importance threshold are selected. The number of key visual tokens The specific calculation formula is as follows: (6); In formula (6): Indicates a predefined importance threshold; represents the number of key visual tokens among all visual tokens, where is a positive integer and ; Indicates the minimum value that makes the entire sum expression greater than the threshold , and assign it to ; An index representing the importance score of a visual token.
[0046] Finally, sort by importance and visual tokens are sampled as key visual tokens and expressed as ; also ensure that the selected visual token is directly related to the textual token hint.
[0047] S3, obtain the classification token of the original image, and based on the classification token and the attention score of each visual token in the complete visual token, select the top one with the highest score. The visual token serves as a significant visual token.
[0048] 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 capture significant visual information, attention scores are calculated for classification tokens and visual tokens in the penultimate layer of the visual encoder. These scores provide an effective metric for evaluating the importance of visual tokens in the visual encoder.
[0049] Specifically, based on the attention scores of classification tokens and visual tokens, the top (e.g. 25%) visual tokens are considered as significant visual tokens and are represented as , ensuring that the large language model focuses on the information-rich visual area. The calculation formula of the attention score is as follows:
[0050] In formula (7): A query representing a classification token; A key representing a visual token; Represents the feature dimension of the visual encoder; attention score The higher the value, the more important the global information contained in the token; of .
[0051] S4. Adaptively enhance attention on the salient visual tokens and key visual tokens.
[0052] 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 distribution 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 fixed enhancement is used for the tokens selected by only a single sample, and the unselected tokens remain unchanged.
[0053] Based on the research investigation of the LVLM model, it is found that visual information mainly propagates from the early to the middle layers of the large language model, while answer generation mainly occurs in the later stages. Therefore, it can be determined that the early and middle layers are the key stages of cross-modal fusion. This step uniformly enhances the attention of the sampled salient visual tokens and key visual tokens in these layers during the forward pass of the multi-head self-attention mechanism.
[0054] The visual tokens selected by the two sampling strategies mentioned above not only have rich visual content but are also highly relevant to the textual prompts, which can be expressed as ;in, The salient visual tokens selected by the sampling strategy in step S3, The key visual tokens selected by the sampling strategy in step S2; adaptive attention enhancement is applied to encourage Greater information contribution.
[0055] For visual tokens selected by only one of the two sampling strategies (i.e., salient visual tokens or key visual tokens), a fixed level of attention enhancement is adopted, denoted as ; while the visual tokens that are not selected by any sampling strategy remain unchanged and are expressed as .
[0056] Based on the above, the specific calculation formula for adaptive attention enhancement is as follows: (8); In formula (8): represents the visual token attention score; represents the basic enhancement factor; represents the scaling factor introduced to prevent over-enhancement; express function; n Indicates the latest generated text token, Represents a visual token.
[0057] S5. By contrasting 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 to suppress the hallucination caused by the language prior and obtain the final target text output.
[0058] 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 predicted distribution and obtain the final language output. The visually enhanced logits distribution is the logits layer output of the LLM model with visual image input and augmented with key visual tokens; the text-only logits distribution is the logits layer output of the LLM model after removing the image input.
[0059] The specific output text prediction calculation formula is as follows: (9); In formula (9): Represents the parameters of a large language model; represents the degree of penalty used to control the initial prediction distribution, thereby reducing the prediction probability based only on text input; where, Represents the output distribution of the large language model when no image input is provided; Represents the output distribution of the latest text token of the final target text, where Indicates the first text tokens, i Indicates the position of the text token currently to be predicted. Represents the first i generated text tokens.
[0060] Specifically, in this embodiment, multiple experiments were conducted on two 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 perception ability of the model.
[0061] For experimental comparison, the following are some basic settings for the experiment: For the experimental benchmark model, three popular multimodal large language models: 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 a comprehensive comparison, three commonly used decoding methods and two mainstream hallucination mitigation methods were benchmarked, including Greedy decoding method, Beam search method ( =5), Nucleus Sample, Visual Contrastive Decoding (VCD), and PAI. VCD reduces the statistical prior 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 illustration method follows a similar paradigm but places greater emphasis on strengthening the model's perception of important visual tokens.
[0062] For this part of the experimental implementation details, the base enhancement factor is set to = 0.6, and the final intervention layer is set to = 18. For the two benchmark models LLaVA1.5-7B and LLaVA-1.5-13B, the adaptive scaling factor = 0.2, while for the Shikra benchmark model, a larger adaptive scaling factor is adopted following the experience of predecessors = 0.4. This is consistent with previous studies. = 3 layers start to apply inference time decoding intervention, the final penalty degree weight Set to 1.1. In the key visual token selection stage, use the default settings, Its value is 0.25%, the threshold VCD is implemented using kernel sampling and greedy decoding as the baseline for the PAI method and the proposed method.
[0063] Specifically, the experimental results on the CHAIR benchmark are: CHAIR evaluates hallucinations in LVLMs models by prompting the model to generate descriptions of input images, and then comparing these descriptions with the actual objects in the image. 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 hallucinated object. CHAIR includes two evaluation dimensions: instance-level and sentence-level, denoted as and .
[0064] 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 hallucination 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 randomly sampled instances for evaluation. The experimental results of this method are shown in Table 1: Table 1. Experimental results of evaluating the model using the CHAIR metric
[0065] As can be seen in Table 1, the proposed method, denoted as DuCAR, shows significant improvement across different models and settings. The proposed method outperforms other decoding strategies in reducing hallucinations. Compared to the strongest baseline PAI, when applied to the LLaVA-1.5-7B model, the proposed method DuCAR The evaluation index decreased by 34.0% (from 27.0% to 17.8%), The evaluation metric was reduced by 42.3% (from 7.8% to 4.5%), demonstrating 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 mitigate hallucinations while still producing accurate and comprehensive image descriptions.
[0066] Specifically, the experimental results on the POPE benchmark are: POPE is a widely used object hallucination benchmark with the question format of "Is 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 that are highly correlated with the actual objects in the image are selected to introduce challenging distractors. The inventive method experiments on 500 images from the MS-COCO dataset, each image is paired with six questions corresponding to each POPE segmentation. The performance of the model in target recognition is evaluated using accuracy and F1 score. The experimental results of the inventive method are shown in Table 2: Table 2. Experimental results of evaluating the performance of the model on object recognition using accuracy and F1 score
[0067] As can be seen from Table 2, the method of the present invention, DuCAR, shows significant improvements under different models and settings. Specifically, the method of the present invention, DuCAR, consistently outperforms existing methods, including PAI and VCD, on the LLaVA-1.5-7B and LLaVA-1.5-13B models. The DuCAR method is able to identify and enhance visual areas that are rich in semantics and highly relevant to a given problem, significantly reducing hallucinations. Compared with the visual contrast decoding method VCD, DuCAR has significant improvements in both accuracy and F1 score. In addition, in most cases, DuCAR improves precision and recall, demonstrating its robustness in generating accurate and complete descriptions.
[0068] Finally, in this example, extensive ablation studies were performed to better understand the roles of different components in the inventive method. All ablation experiments were based on the representative LVLM baseline LLaVA-1.5-7B, with the hyperparameter gamma fixed to 1.1 based on previous research.
[0069] To evaluate our method, this section primarily uses the CHAIR metric. However, since CHAIR only evaluates hallucinations, we also incorporate the F1 score to balance hallucination mitigation and generation accuracy. This allows for a fairer comparison under the CHAIR metric when F1 scores are similar.
[0070] The contributions of the core components of the proposed DuCAR method are 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) are tested. The experimental results are shown in Table 3. Table 3. Ablation experiment results using only DuCAR-v or DuCAR-c
[0071] As can be seen from Table 3, the CHAIR index is reduced when both are used alone, proving the necessity of dual-modal collaboration; secondly, by comparing the difference between fixed attention enhancement (DuCAR-fa) and adaptive enhancement, it is found that the adaptive strategy is more effective in The indicators are further reduced, and the F1 score only drops by 2.1%, indicating that dynamic adjustment can balance hallucination suppression and description richness.
[0072] Furthermore, as shown in the experimental results Table 4, Figure 3 、 4 As shown, by adjusting the key hyperparameters, the sampling ratio is confirmed =25%, importance threshold =0.85, enhancement factor =0.6, scaling factor =0.2 to achieve the best effect. The experimental results in Table 4 are as follows: Table 4. Ablation experimental results of the method of the present invention .
[0073] Finally, as the experimental results Figure 5 As shown in Figure 2, experiments on intervening layers show that only the middle 3-18 layers need to be covered to achieve over 90% performance. Ablation experiments further fully verify the effectiveness of our proposed method, DuCAR, and its parameter robustness.
[0074] In summary, the large-scale visual language model hallucination reduction method based on dual-modal collaborative attention enhancement disclosed in the present invention has the following beneficial effects compared with the existing technology: (1) Significantly reduce hallucinations: By collaboratively screening and enhancing key visual tokens through bimodal approaches, the hallucination rate is significantly reduced in the POPE and CHAIR benchmarks, and the generated results are more consistent with the actual image content; (2) No additional training required: As an inference stage intervention method, it can be directly applied to existing LVLM models (such as LLaVA-1.5 and Shikra), with strong compatibility and low computational overhead; (3) Maintaining generation quality: While suppressing hallucinations, the ability to capture visual details is retained through an adaptive enhancement strategy. The F1 score is better than the comparison methods (such as PAI and VCD), ensuring the accuracy and richness of the output description.
[0075] Example 2 This embodiment provides a device for implementing a method for reducing hallucinations in a large visual language model, the device comprising: A token acquisition module is used to obtain the complete visual token of the original image and the text token of the text prompt, and concatenate the complete visual token and the text token and input them into the decoder of the large language model; The first token sampling module is used to calculate the attention score matrix of text tokens and all visual tokens based on the cross-modal dynamic sampling strategy in the decoder of the large language model to sample the most relevant text token prompts. Key visual tokens; The second token sampling module is used to obtain the classification tokens of the original image and screen the top score based on the attention scores of the classification tokens and the visual tokens in the complete visual tokens. The visual token is used as a significant visual token; an attention enhancement module, configured to adaptively enhance attention on the salient visual tokens and the 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 enhanced by visual information through a contrastive decoding strategy to suppress the hallucinations caused by language priors and obtain the final target text output.
[0076] Example 3 This embodiment further provides an electronic device, including: at least one processor; and A memory stores instructions, which, when executed by the at least one processor, enable the at least one processor to perform the large visual language model hallucination reduction method as described above.
[0077] In this embodiment, electronic devices may include, but are not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.
[0078] Example 4 This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to perform the large-scale visual language model hallucination reduction method as described above.
[0079] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0080] In this case, the program code read from the machine-readable medium can itself implement the functions of any of the above-described embodiments. Therefore, the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification. Examples of machine-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, 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.
[0081] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A large-scale visual language model hallucination reduction method, characterized in that: The method comprises: S1, obtaining a complete visual token of the original image and a text token of the text prompt, and concatenating the complete visual token and the text token and inputting them into the decoder of the large language model; S2. In the decoder of the large language model, the attention score matrix of the text token and all visual tokens is calculated based on the cross-modal dynamic sampling strategy to sample the most relevant text token prompts. Key visual tokens; S3, obtain the classification token of the original image, and based on the classification token and the attention score of each visual token in the complete visual token, select the top one with the highest score. The visual token is used as a significant visual token; S4, performing adaptive attention enhancement on the salient visual tokens and the key visual tokens; S5. By contrasting 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 to suppress the hallucination caused by the language prior and obtain the final target text output.
2. The large-scale visual language model hallucination reduction method according to claim 1, characterized in that In S1, the complete visual token of the original image is obtained, specifically: The original image is input into the visual encoder, and the complete visual token of the original image is obtained by CLS-driven sampling within the visual modality. ,in is the length of a complete visual token; it is calculated as follows: (1); In formula (1), represents the visual encoder; Represents the original input image.
3. The large-scale visual language model hallucination reduction method according to claim 2, characterized in that: In S1, the text token of the text prompt is obtained, specifically: Process the text prompt using a tokenizer and embedding module to produce input text tokens ,in is the length of the text token; it is calculated as follows: (2); In formula (2), Represents the word segmenter and embedding module; Represents a text prompt for input.
4. The large-scale visual language model hallucination reduction method according to claim 1, characterized in that In S2, the attention score matrix of text tokens and all visual tokens is calculated based on the cross-modal dynamic sampling strategy to sample the most relevant text token prompts. Key visual tokens include: S21. Calculate the attention score matrix of text tokens and visual tokens through the attention mechanism : ( 3); 4); In formulas (3) and (4): The decoder of a large language model Layer, that is, early layer; Indicates the i The query weight of the layer; Indicates the i The key weight of the layer; Indicates the i The hidden layer vector of the text token of the layer; Indicates the i The hidden layer vector of the visual token of the layer; Represents the feature dimension of a large language model; Represents the matrix transpose operation; attention score matrix ,in, represents the number of heads in the multi-head attention mechanism, represents the number of visual tokens, Indicates the number of text tokens; S22. Calculate the importance score of the visual token: , (5); In formula (5): represents the first The importance scores of all visual tokens in the layer, that is, first the attention score matrix of H The attention head performs the reduce-max operation, and then calculates the Accumulated to The average of the scores, j Indicates the index of the text prompt token; S23. Select the one with the highest importance score Visual tokens are sampled as key visual tokens, including: The decoder of a large language model Importance scores of all visual tokens in a layer Sort in descending order, and you get ,in, represents the first Layer Importance scores of visual tokens; Select key visual tokens whose cumulative importance exceeds a predefined importance threshold, the number of key visual tokens The calculation formula is as follows: (6); In formula (6): Indicates a predefined importance threshold; represents the number of key visual tokens among all visual tokens, where is a positive integer and ; Indicates the minimum value that makes the entire sum expression greater than the threshold , and assign it to ; An index representing the importance score of a visual token; According to importance score Sorting, sorting the top ranking Visual tokens are sampled as key visual tokens and ensure that the selected visual token is directly related to the text token hint.
5. The large-scale visual language model hallucination reduction method according to claim 4, characterized in that: In S3, the calculation formula of the attention score is as follows: In formula (7): A query representing a classification token; A key representing a visual token; Represents the feature dimension of the visual encoder; attention score The higher the value, the more important the global information contained in the token; of .
6. The large-scale visual language model hallucination reduction method according to claim 5, characterized in that: In S4, adaptive attention enhancement is performed on the salient visual tokens and the key visual tokens: (8); In formula (8): represents the visual token attention score; represents the basic enhancement factor; represents the scaling factor introduced to prevent over-enhancement; express function; n Indicates the latest generated text token, Represents a visual token; represents the intersection of salient visual tokens and key visual tokens, i.e. ,in, As a significant visual token, is the key visual token; Represents one of the salient visual tokens or key visual tokens, i.e. ; Indicates other visual tokens that are not selected as salient visual tokens and key visual tokens.
7. The large-scale visual language model hallucination reduction method 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 by 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; Among them, the final target text output is: (9); In formula (9): Represents the parameters of a large language model; represents the degree of penalty used to control the initial prediction distribution to reduce the prediction probability based only on text input; Represents the output distribution of the large language model when no image input is provided; Represents the output distribution of the latest text token of the final target text, where Indicates the first i text tokens, Indicates the index of the latest text token to be predicted. Represents the first i generated text tokens.
8. A device for implementing a large-scale visual language model hallucination reduction method, characterized in that: The device comprises: A token acquisition module is used to obtain the complete visual token of the original image and the text token of the text prompt, and concatenate the complete visual token and the text token and input them into the decoder of the large language model; The first token sampling module is used to calculate the attention score matrix of text tokens and all visual tokens based on the cross-modal dynamic sampling strategy in the decoder of the large language model to sample the most relevant text token prompts. Key visual tokens; The second token sampling module is used to obtain the classification tokens of the original image and screen the top score based on the attention scores of the classification tokens and the visual tokens in the complete visual tokens. The visual token is used as a significant visual token; an attention enhancement module, configured to adaptively enhance attention on the salient visual tokens and the 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 enhanced by visual information through a contrastive decoding strategy to suppress the hallucinations caused by language priors and obtain the final target text output.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to perform the large visual language model hallucination reduction method according to any one of claims 1 to 7.
10. A machine-readable storage medium, characterized in that The machine-readable storage medium stores executable instructions, which, when executed, cause the machine to perform the large-scale visual language model hallucination reduction method according to any one of claims 1 to 7.
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
Visual token compression method and device and storage medium
CN120451291A
Method and computer system for inference using a vision-language model based on cached information associated with input prompt
KR102798633B1
Knowledge-constrained tree search decoding with token-level hallucination detection
US20250117583A1
Cited By
Illusion mitigation method and device for multi-modal large language model
CN121661442A
A visual positioning backtracking method for relieving multimodal large language model hallucination
CN122435247A
