Multi-modal large language model visual attention guiding method

By selecting effective visual attention heads from multimodal large language models, constructing visual attention region mappings and generating binary masks, the illusion problem in visual question answering is solved, improving visual alignment capabilities and answer accuracy.

CN121544994APending Publication Date: 2026-02-17TONGJI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511736507.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Multimodal large language models suffer from the illusion problem in visual question answering tasks, generating content that is inconsistent with the image. In particular, visual information is suppressed by language priors during the generation process, resulting in insufficient visual alignment ability.

Method used

By selecting attention heads responsible for capturing effective visual information in a multimodal large language model, constructing a visual attention region mapping, calculating a relative attention map and fusing multi-layer attention information, generating a binary mask to force the model to focus on key visual information and eliminate irrelevant regions.

Benefits of technology

It significantly improves the accuracy and reliability of visual question answering tasks, reduces the probability of generating incorrect descriptions, adapts to different model structures and the diversity of input images, and has good versatility and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544994A_ABST
    Figure CN121544994A_ABST
Patent Text Reader

Abstract

The invention relates to a multi-mode large language model visual attention guiding method. The method comprises the following steps: screening attention heads responsible for capturing effective visual information in a multi-mode large language model; establishing a mapping relationship between the model output answer and the original image region corresponding to the effective attention head; calculating an attention ratio of the general problem to the specific problem, and screening a visual attention region strongly related to the model input problem to obtain a relative attention graph; performing comprehensive scoring on each middle layer according to the focusing degree and the certainty of the relative attention maps, and fusing the relative attention maps generated by a set number of middle layers with the highest scores; and constructing a binary mask based on the fused attention map to carry out binary segmentation on the model input image to obtain a processed image with a reserved high attention area, and inputting the processed image into the multi-modal large language model for reasoning. According to the method, the model can be guided to more accurately pay attention to the image region related to the problem, so that the visual alignment capability and the output accuracy are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of multi-modal large language models, in particular to a multi-modal large language model visual attention guiding method. BACKGROUND

[0002] Currently, multi-modal large language models (MLLMs) such as Kimi-VL, BLIP3-O, Qwen2.5-VL, DeepSeek-VL2 and Llava-Next have made significant progress in visual question answering, image description and visual reasoning tasks. These models usually take large language models as the backbone, introduce visual encoders, and conduct joint training on large-scale image-text data, thereby realizing strong image-text alignment and cross-modal reasoning capabilities.

[0003] Although the overall performance is excellent, MLLMs still have the problem of "hallucination", that is, generating content that is inconsistent with the image, such as describing non-existent objects, incorrect colors or quantity information, etc. This problem is particularly prominent in scenarios that require high-precision visual positioning. Studies suggest that the cause of hallucination may be that the visual token is located at the front of the input sequence, causing the information to be weakened during the generation process, or the strong language prior accumulated during the language model pre-training stage suppressing the visual information.

[0004] Notably, existing research has found that the model still has strong visual recognition ability at the intermediate layer. This indicates that hallucination is not due to the lack of visual understanding by the model, but rather the visual attention in the subsequent generation stage is overshadowed by the language-dominated reasoning process.

[0005] Currently, there are various methods attempting to explain the model attention mechanism, including saliency map-based visualization methods, correlation analysis between gradients and embeddings, and the use of internal attention mechanisms of the model. However, these methods still have limitations in distinguishing between effective semantic attention and noise attention, especially in identifying which visual attention is truly driven by the input question. SUMMARY

[0006] The technical problem to be solved by the present application is to provide a multi-modal large language model visual attention guiding method that can enhance the semantic-related visual attention of the intermediate layer during the answer generation process, guide the model to focus more accurately on the image regions related to the question, and thereby significantly improve the visual alignment capability and output accuracy.

[0007] The technical solution adopted by the present application to solve its technical problem is: providing a multi-modal large language model visual attention guiding method, comprising:

[0008] constructing a multi-modal large language model for image-text question answering to reason according to the input question and the input image;

[0009] screening an attention head responsible for capturing effective visual information in the multi-modal large language model to obtain an effective attention head;

[0010] establishing a mapping relationship between the model output answer and the original image area corresponding to the effective attention head, and extracting a visual attention area;

[0011] calculating the attention ratio of general questions and specific questions, and then screening the visual attention area strongly related to the model input question to obtain a relative attention map;

[0012] According to the focusing degree and certainty of the relative attention map, each intermediate layer is comprehensively scored, and the relative attention maps generated by the top scoring intermediate layers are fused to obtain a fused attention map;

[0013] Constructing a binary mask based on the fused attention map, and performing binary segmentation on the model input image using the binary mask to obtain a processed image that retains a high attention area;

[0014] inputting the processed image into the multi-modal large language model for inference.

[0015] Further, the screening of the attention head responsible for capturing effective visual information in the multi-modal large language model comprises:

[0016] Calculate the visual relevance ratio of each attention head in the multi-modal large language model;

[0017] Screening the attention head with a visual relevance ratio greater than a preset threshold.

[0018] Further, the visual relevance ratio is the ratio of the sum of the weights of the semantic-related visual tokens assigned by the current attention head to the total sum of the weights of all visual tokens assigned by the current attention head.

[0019] Further, the establishment of the mapping relationship between the model output answer and the original image area corresponding to the effective attention head comprises:

[0020] For the model output answer, calculate the cross-attention weight of each answer token to the visual token and average it to obtain a first associated attention;

[0021] Calculate the attention between each visual token and the original image area and average it to obtain a second associated attention;

[0022] Combine the first associated attention and the second associated attention to establish the mapping relationship between the model output answer and the original image area corresponding to the effective attention head.

[0023] Furthermore, when calculating the attention ratio, a small constant is introduced to avoid division by zero.

[0024] Furthermore, the comprehensive scoring of each intermediate layer based on the focus and determinism of the relative attention map includes:

[0025] Calculate the peak value of the attention map;

[0026] Calculate the entropy value of the attention map;

[0027] A comprehensive score is calculated based on the peak value and the entropy value.

[0028] Furthermore, the comprehensive score is expressed as

[0029]

[0030] in, For the middle layer Overall score To set parameters, The peak value, The entropy value is given.

[0031] Furthermore, the fusion of the relative attention maps generated by the intermediate layers with the highest scores of a predetermined number includes:

[0032] Dynamically select a set number of the highest-scoring intermediate layers and use softmax normalization to calculate the fusion coefficient of each layer;

[0033] Based on the fusion coefficient, a weighted average is applied to the relative attention map generated from the selected intermediate layer.

[0034] Furthermore, the construction of the binary mask based on the fused attention graph includes:

[0035] Scan the fused attention map to identify local peak points;

[0036] Calculate the maximum and minimum attention values ​​in the fused attention graph, and use the midpoint between them as the dynamic threshold;

[0037] All local peak points with attention values ​​greater than the dynamic threshold are retained as the starting point of the core region. The bounding box is expanded outward from these starting points until the attention value at the edge of the bounding box is lower than the dynamic threshold.

[0038] Set the pixel value inside the bounding box to 1, and set the pixel value of other areas to 0 to obtain a binary mask.

[0039] Further, the multi-modal large language model comprises a visual encoder and a transformer-based language generation module, the visual token is generated by the visual encoder, and the answer token and the question token are generated by the language generation module.

[0040] Advantages

[0041] Compared with the prior art, the present application has the following advantages and positive effects:

[0042] The present application quantifies the attention of the attention head to the semantic related visual token, eliminates the attention head paying attention to the background and the information-free area, ensures that the subsequent visual attention analysis is based on the effective signal strongly related to the core semantics of the image, avoids the noise interference introduced by the irrelevant attention head, and improves the utilization efficiency of visual information from the source; the present application screens the attention head capturing the effective visual information through the visual correlation ratio, fully excavates the real visual attention of the intermediate layer of the model, avoids the visual information being suppressed by the language prior in the generation stage, directly establishes the mapping relationship of “answer token-visual token-original image area”, and significantly improves the contribution of the visual feature to the final answer; the present application obtains the relative attention map by calculating the attention ratio of the general question and the specific question, dynamically selects and sets the number of layers based on the focusing degree and the certainty score, fuses the visual attention information of multiple complementary layers, accurately locates the image area strongly related to the input question semantics, and effectively improves the capturing and understanding ability of the model to the fine-grained visual information; the present application constructs a binary mask based on the fused attention map, performs binary segmentation on the input image to retain the high-attention area and exclude the interference area, forcibly focuses the model on the key visual information from the physical level, completely cuts off the error association path caused by the irrelevant area, significantly reduces the probability of generating error description or irrelevant information, and greatly improves the accuracy and reliability of the visual question and answer task; the present application retains the optimal layer of a certain number based on the comprehensive score, and combines the dynamic threshold mechanism, which can automatically adapt to the diversity of different model structures (such as different numbers of layers and attention heads) and input images (such as different scenes and resolutions), effectively improving the stability and robustness of the scheme; the present application does not need to modify the structure of the existing multi-modal large language model (MLLM) or perform additional fine-tuning, can directly adapt to various MLLM frameworks (such as the architecture containing a visual encoder and a transformer language module), has good universality and expandability, and is convenient for deployment and popularization in actual scenes. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1 is a network overall architecture schematic diagram of an embodiment of the present application;

[0044] Figure 2This is a schematic diagram of image-centered attention head filtering according to an embodiment of the present invention;

[0045] Figure 3 This is a flowchart of a preferred embodiment 1 of the present invention. Detailed Implementation

[0046] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.

[0047] The embodiments of the present invention relate to a visual attention guidance method for multimodal large language models for text-to-image question answering. Specifically, it proposes a visual realignment method based on intermediate layer attention guidance to address the visual illusion problem commonly found in multimodal large language models (MLLM) in text-to-image question answering tasks.

[0048] The technical terms used in this embodiment are explained as follows:

[0049] MLLM (Multimodal Large Language Model): A large language model that can simultaneously process multiple modal inputs such as images and text and generate text responses;

[0050] Token: The basic unit when the model processes input. Text tokens are usually words or subwords, while image tokens are feature vectors generated after the image is segmented into fixed-size patches.

[0051] Attention: A mechanism in the model used to measure the strength of the association between different input tokens. The higher the attention value, the more important the corresponding token is to the current task.

[0052] This implementation method deeply mines the spatial semantic information of the model's internal attention mechanism to construct a precise mapping from text queries to key image regions. Finally, it enhances the model's ability to focus on core visual content through visual masks, thereby significantly improving the visual-text alignment accuracy and response accuracy of the question-answering system. As a pluggable improvement mechanism, it requires no additional training of the original model and can be directly adapted to various existing MLLM architectures, demonstrating strong engineering practicality.

[0053] like Figure 1As shown, the core of the entire technical solution lies in achieving precise guidance of visual attention through the collaborative work of three modules: first, extracting effective attention signals related to visual semantics from the middle layer of the model; second, enhancing the discriminativeness and robustness of the attention map through cross-layer fusion; and finally generating targeted masks to filter out interference areas and guide the model to focus on key visual information.

[0054] The intermediate layer attention extraction module is the foundation of the entire scheme. Its core objective is to filter out truly effective signals carrying visual semantic information from the complex attention network of MLLM. For example... Figure 2 As shown, it is necessary to identify a subset of attention heads in the model that are responsible for capturing meaningful visual information: by calculating each attention head The "visual relevance ratio" quantifies the proportion of attention given to context-relevant visual tokens (rather than background or non-information areas). It is defined as the ratio of the sum of weights assigned to relevant visual tokens by the attention head to the sum of weights assigned to all visual tokens. Based on this ratio, a set of "image center attention heads" exceeding a preset threshold p is selected, while attention heads interfered with by non-information areas such as the background are removed to ensure the validity of subsequent calculations.

[0055] After determining the effective attention heads, a further association mapping between the answer and the image region is constructed: on the one hand, the cross-attention weights of the model-generated answer token and the visual token in these attention heads are extracted and averaged to obtain "answer-tag attention"; on the other hand, the attention between the image token and the original image patch in the visual encoder is calculated and averaged to obtain "tag-image attention". Combining these two types of attention establishes a direct association between the answer token and the original image region. To eliminate the model's inherent preference for fixed regions (general highlighting unrelated to the current question), a "relative attention" mechanism is introduced: by calculating the ratio of attention for a specific question to attention for a general instruction (such as "describe the image") (introducing a small constant ε to avoid division by zero), non-semantically relevant highlighted regions are filtered out, ultimately obtaining a relative attention map strongly related to the current query.

[0056] The cross-layer attention fusion module aims to integrate complementary information from multiple layers of attention to improve the reliability of the attention map. Since different intermediate layers of attention heads have varying abilities to capture visual semantics—some layers may be better at locating local details, while others are better at capturing global semantics—this module uses a hybrid "entropy-peak" metric to score the relative attention map of each layer. "Peak" measures the intensity of attention focus, while "entropy" reflects the dispersion of attention distribution (lower entropy indicates stronger focus). The overall score is then calculated. This approach balances the focus and determinism of attention. Based on this score, a Top-K layer set is dynamically selected to form the effective layer set. Then, the fusion coefficients of each layer are calculated using softmax normalization. The relative attention maps of the selected layers are then weighted and averaged to generate a fused attention map. This fused map not only integrates semantic information from multiple layers but also suppresses noise interference through weight adjustment, thus more accurately reflecting the actual visual attention area of ​​the model for the current problem.

[0057] The attention-guided visual masking module is a key execution step in achieving visual realignment. It generates physical-level visual guidance signals through spatial region selection. First, salient regions are extracted from the fused attention map: local peak points (i.e., locations where surrounding pixel attention values ​​are all lower than the point) are identified by scanning the entire image with a sliding window. Simultaneously, the global maximum and minimum attention values ​​of the entire image are calculated, with the midpoint between the two used as a dynamic threshold τ. All peak points with attention values ​​exceeding τ are retained as the starting points of the core region. Bounding boxes are expanded outward from these starting points until the attention values ​​at the edges of the bounding boxes are lower than τ, forming multiple closed high-attention regions. These regions are then merged to generate a binary mask M—pixels inside the mask have a value of 1 (retained regions), and pixels outside the mask have a value of 0 (filtered regions).

[0058] After applying the mask to the original image, only the visual information of the high-attention areas is retained, and the image is then input into the MLLM for inference. By physically filtering out irrelevant areas, the model is forced to focus its limited computational resources on the core visual content relevant to the question. This effectively cuts off erroneous association paths caused by interfering areas, significantly reducing the probability of visual illusions and improving the accuracy and visual alignment of the answer. For example, in the question "What is the man doing?", the original image may contain multiple areas such as a kitchen (which could easily lead to a misjudgment of "cooking") and a desk (the actual scene of "writing"). After filtering the kitchen area with a mask, the model can more clearly identify the key actions in the desk scene, correcting the answer from the incorrect "cooking" to the correct "writing".

[0059] In this embodiment, the threshold parameter, the number of layers (Top-K), and the division-to-zero constant in relative attention can all be adjusted and optimized according to different tasks and model structures.

[0060] A preferred embodiment 1 of the present invention is based on a Modal Large Language Model (MLLM), which includes a visual encoder and a language generation module based on a Transformer architecture. It achieves the localization and guidance of semantically relevant regions of an image by extracting visual attention information from the multi-head self-attention mechanism in the intermediate layers of the model. Specifically, as follows... Figure 3 As shown, it includes the following steps:

[0061] First, the Visual Relevance Ratio of each attention head is calculated to measure its attention to semantically relevant visual tokens in the image. Then, "image center attention heads" are selected based on a set threshold, and heads that focus on the background or areas without information are removed to ensure that subsequent calculations are based on effective visual information.

[0062] Subsequently, the attention weight of the answer token to the visual token during the answer generation process is calculated, and combined with the information of the image patch in the visual encoder, a multi-layer attention mapping from the answer token to the image region is constructed;

[0063] Next, a relative attention mechanism is adopted, which uses the ratio of general descriptive cues to attention for specific questions to eliminate the inherent attention bias of the model and highlight the visual attention areas closely related to the question;

[0064] Subsequently, for the relative attention maps generated in the intermediate layers, an entropy and peak value hybrid scoring mechanism was designed to evaluate the spatial focus and determinism of each layer's attention map. Based on the scores, the top-K best performing layers were retained to avoid the limitations of single-layer selection and to take into account multi-scale and multi-stage visual information. The relative attention maps of the selected layers were then subjected to softmax normalization and weighted fusion to obtain the fused attention map as prior information for accurately locating the visual attention region.

[0065] Subsequently, local peaks are automatically detected in the fused attention map as significant points of interest. A dynamic threshold is set to filter out significant peaks, and a region boundary is formed around the peak point. A binary visual mask is generated and applied to the input image to block non-critical regions, retaining only the visual regions that the model is interested in. This helps the model focus on key information for reasoning, thereby improving visual alignment and answer accuracy.

Claims

1. A visual attention guidance method for a multimodal large language model, characterized in that, include: Construct a multimodal large language model for text-image question answering, and perform inference based on the input question and input image; The effective attention heads are obtained by selecting the attention heads responsible for capturing effective visual information in the multimodal large language model. Establish a mapping relationship between the model's output answer and the original image region corresponding to the effective attention head, and extract the visual attention region; Calculate the attention ratio between the general problem and the specific problem, and then select the visual attention regions that are strongly related to the model input problem to obtain a relative attention map; Each intermediate layer is comprehensively scored based on the focus and determinism of the relative attention map, and the relative attention maps generated by the intermediate layers with the highest scores are fused to obtain a fused attention map. A binary mask based on the fused attention map is constructed, and the binary mask is used to perform binary segmentation on the model input image to obtain a processed image that retains the high attention region; The processed image is input into the multimodal large language model for inference.

2. The method according to claim 1, characterized in that, The process of selecting the attention heads responsible for capturing effective visual information in the multimodal large language model includes: Calculate the visual relevance ratio of each attention head in the multimodal large language model; Attention heads that have a visual relevance ratio greater than a preset threshold are selected.

3. The method according to claim 2, characterized in that, The visual relevance ratio is the ratio of the sum of weights assigned to semantically relevant visual tokens by the current attention head to the sum of weights assigned to all visual tokens.

4. The method according to claim 1, characterized in that, The mapping relationship between the model output answer and the original image region corresponding to the effective attention head includes: For the model's output answer, calculate the cross-attention weights of each answer token and the visual token, and average them to obtain the first associated attention; Calculate and average the attention between each visual token and the original image region to obtain the second associative attention; By combining the first and second associated attention, a mapping relationship is established between the model output answer and the original image region corresponding to the effective attention head.

5. The method according to claim 1, characterized in that, When calculating the attention ratio, a small constant is introduced to avoid division by zero.

6. The method according to claim 1, characterized in that, The comprehensive scoring of each intermediate layer based on the focus and determinism of the relative attention map includes: Calculate the peak value of the attention map; Calculate the entropy value of the attention map; A comprehensive score is calculated based on the peak value and the entropy value.

7. The method according to claim 6, characterized in that, The comprehensive score is expressed as in, For the middle layer Overall score To set parameters, The peak value, The entropy value is given.

8. The method according to claim 1, characterized in that, The step of fusing the relative attention maps generated by the intermediate layers with the highest scores of a set number includes: Dynamically select a set number of the highest-scoring intermediate layers and use softmax normalization to calculate the fusion coefficient of each layer; Based on the fusion coefficient, a weighted average is applied to the relative attention map generated from the selected intermediate layer.

9. The method according to claim 1, characterized in that, The construction of the binary mask based on the fused attention graph includes: Scan the fused attention map to identify local peak points; Calculate the maximum and minimum attention values ​​in the fused attention graph, and use the midpoint between them as the dynamic threshold; All local peak points with attention values ​​greater than the dynamic threshold are retained as the starting point of the core region. The bounding box is expanded outward from these starting points until the attention value at the edge of the bounding box is lower than the dynamic threshold. Set the pixel value inside the bounding box to 1, and set the pixel value of other areas to 0 to obtain a binary mask.

10. The method according to claim 1, characterized in that, The multimodal large language model includes a visual encoder and a transformer-based language generation module. The visual token is generated by the visual encoder, and the answer token and question token are generated by the language generation module.