A training method and device for alleviating hallucinations of multimodal large models
By introducing two-dimensional Manhattan distance and improving causal attention masks, optimizing the position modeling method of multimodal large models, the hallucination problem is solved, the multimodal feature alignment and information interaction capabilities of the model are improved, and the reliability and performance of the model are enhanced.
Patent Information
- Application Number
- CN202510718228.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-05-30
AI Technical Summary
In existing multimodal large models, hallucinations caused by position coding seriously affect the accuracy and reliability of the model, especially because rotating position coding (RoPE) causes uneven perception of image markers and insufficient alignment of multimodal feature under long-term attenuation.
By introducing two-dimensional Manhattan distance calculation and improving causal attention masks, redefining the positional relationship of image markers, using the freezing pre-training module and gradually fine-tuning the multi-layer perceptron strategy to optimize the model's multimodal information interaction capabilities.
The image information perception ability and multimodal feature alignment effect of multimodal large models are significantly improved, the incidence of hallucinations is reduced, and the reliability and performance of the model are improved.
Smart Images

Figure CN120258071B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multimodal large model training, and in particular to a training method and device for alleviating multimodal large model hallucinations. Background Art
[0002] In today's era of rapid advancements in artificial intelligence, large multimodal models (LVLMs) have garnered widespread attention and application as a powerful technical tool. They can integrate information from multiple modalities, such as vision and language, to enable more intelligent and comprehensive task processing. However, with the continued development and application of large multimodal models, hallucinations have become increasingly prominent, becoming a key bottleneck restricting their further development.
[0003] Hallucination refers to the phenomenon in which large multimodal models, when generating or processing information, produce erroneous output that is inconsistent, irrelevant, or illogical with the actual input information. This phenomenon severely impacts the accuracy and reliability of the model, reducing its credibility and usability in practical applications. In-depth research has revealed that insufficient alignment between multimodal features is a key factor contributing to hallucination. In existing large multimodal models, the rotational position encoding (RoPE) used for position modeling has limitations, and its long-term decay negatively impacts multimodal alignment.
[0004] Specifically, under long-term attenuation, the instruction marker exhibits an uneven perception of image markers located at different positions in the two-dimensional space. In a one-dimensional sequence, the markers in the lower right image region that are closer to the instruction marker are preferentially selected, while less attention is paid to image markers that are farther away. This perceptual bias leads to insufficient information interaction between the image and the instruction, and the multimodal feature alignment effect is not ideal, which in turn causes the hallucination phenomenon. Existing position encoding methods fail to fully consider the two-dimensional spatial structure of the image. They only flatten the image markers into a one-dimensional sequence for processing, losing the spatial locality information of the image and failing to effectively support the accurate alignment and interaction between multimodal features.
[0005] Therefore, how to improve the position modeling method of large multimodal models, enhance the model's perception of image information, and improve the accuracy and effect of multimodal feature alignment, thereby effectively alleviating the hallucination problem, has become an important technical problem that needs to be solved urgently in the current research field of large multimodal models.
[0006] In view of this, this application is filed. Summary of the Invention
[0007] The present invention provides a training method and device for alleviating the hallucination of a multimodal large model, which can at least partially improve the above-mentioned problem.
[0008] To achieve the above object, the present invention adopts the following technical solutions:
[0009] A training method for alleviating hallucinations in multimodal large models, comprising:
[0010] Acquire image data, and transfer the image data into a multimodal large model, encode the image data, and obtain multiple image tags;
[0011] Calculate the relative position distance between each image marker, and evolve the relative position distance from the one-dimensional level to the two-dimensional level to obtain the two-dimensional coordinate Manhattan distance;
[0012] Performing raster scanning processing on the image mark, assigning a position index, and reallocating a two-dimensional position coordinate to the image mark;
[0013] Performing equivalent conversion processing on the two-dimensional coordinate Manhattan distance, and replacing the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers;
[0014] Model the causal attention mask based on the new position index and the transformed two-dimensional coordinate Manhattan distance, and replace the default causal attention mask with the newly modeled causal attention mask;
[0015] Freeze the multimodal large model, and perform adjustment training preprocessing on the multimodal large model according to the replaced causal attention mask and preset pre-training data until the multimodal large model achieves a preset effect.
[0016] The present invention also provides a training device for alleviating the illusion of a multimodal large model, comprising:
[0017] An encoding unit, configured to acquire image data, transfer the image data into a multimodal large model, and perform encoding processing on the image data to obtain a plurality of image labels;
[0018] A distance calculation unit is used to calculate the relative position distance between each image marker and evolve the relative position distance from a one-dimensional level to a two-dimensional level to obtain a two-dimensional coordinate Manhattan distance;
[0019] a reallocation unit, configured to perform raster scanning processing on the image mark, allocate position indexes, and reallocate two-dimensional position coordinates to the image mark;
[0020] an equivalent conversion unit, configured to perform equivalent conversion processing on the two-dimensional coordinate Manhattan distance, and replace the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers;
[0021] A replacement unit is used to model the causal attention mask according to the new position index and the transformed two-dimensional coordinate Manhattan distance, and replace the default causal attention mask with the newly modeled causal attention mask;
[0022] A training unit is used to freeze the multimodal large model and adjust the training preprocessing of the multimodal large model according to the replaced causal attention mask and preset pre-training data until the multimodal large model achieves a preset effect.
[0023] In summary, the proposed training method for alleviating hallucinations in large multimodal models effectively addresses the hallucination phenomenon caused by positional encoding methods in existing large multimodal models through innovative position modeling and attention masking mechanisms. Specifically, based on the deployment of a large multimodal model, this method redefines the positional relationship of image labels and introduces a two-dimensional Manhattan distance calculation, replacing the traditional one-dimensional raster scan position index, thereby preserving the spatial locality of the image. By equivalently transforming the Manhattan relative position distance calculation formula and combining it with causal attention mask modeling, a Manhattan causal mask is formed, further optimizing the model's multimodal information interaction capabilities. During model training, the strategy of freezing the pre-trained visual encoder and large language model, fine-tuning only some parameters of the multilayer perceptron, and then training all model parameters, significantly improves the model's image information perception and multimodal feature alignment. This method achieves the best accuracy and lowest hallucination rate on classic hallucination evaluation metrics, providing a new technical path for building more reliable and efficient multimodal artificial intelligence systems, with significant application value and broad market prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 1 is a flow chart of a training method for alleviating the hallucination of a multimodal large model provided by the first embodiment of the present invention;
[0025] Figure 2 Schematic diagram of image marker position index allocation according to an embodiment of the present invention. (a) The number of image markers in the figure is 100 for demonstration purposes, and (b) shows the position index calculated based on the coordinates.
[0026] Figure 3 This is a visualization diagram of the image and text information flow under the default position modeling method of the multimodal large model provided by an embodiment of the present invention;
[0027] Figure 4 This is a diagram of visualizing the image and text information flow provided by an embodiment of the present invention;
[0028] Figure 5 2 is a schematic diagram of a causal attention mask under the default position modeling mode of a multimodal large model provided by an embodiment of the present invention;
[0029] Figure 6 is a schematic diagram of a causal attention mask provided by an embodiment of the present invention;
[0030] Figure 7 Schematic diagram of the results of the classic hallucination evaluation index provided by an embodiment of the present invention;
[0031] Figure 8 2 is a schematic diagram of a module of a training device for alleviating the illusion of a multimodal large model provided by a second embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0033] refer to Figure 1 、 Figure 2 As shown, the first embodiment of the present invention discloses a training method for alleviating the hallucination of a multimodal large model, which can be executed by a training device for alleviating the hallucination of a multimodal large model (hereinafter referred to as a training device), and in particular, by one or more processors in the training device to implement the following method:
[0034] S1, acquiring image data, and transferring the image data into a multimodal large model, encoding the image data to obtain multiple image tags;
[0035] Specifically, step S1 includes: encoding each image of the image data using a visual encoder of a multimodal large model;
[0036] The resolution of each image is reset to 24x24, and each image is segmented according to this size to obtain 576 image tags.
[0037] Preferably, the multimodal large model includes a visual encoder, a large language model and a multilayer perceptron for connecting the visual encoder and the large language model, wherein the visual encoder adopts CLIP ViT-L / 14, the large language model adopts Vicuna-7B, the multilayer perceptron includes a two-layer MLP, and the overall scale of the multimodal large model is 7B.
[0038] In this embodiment, image data is acquired and passed to a large multimodal model for processing. This large multimodal model consists of a visual encoder, a large language model, and a multilayer perceptron (MLP) connecting the two. The visual encoder uses CLIP ViT-L / 14, the large language model uses Vicuna-7B, and the MLP consists of a two-layer MLP. The overall model size is 7B. This architectural choice aims to fully leverage the power of the pre-trained model while achieving effective fusion of visual and language modalities through the MLP.
[0039] When processing image data, the resolution of each image is reset to 24x24. This ensures that the image can be evenly segmented into multiple image tokens during subsequent processing, providing the model with more detailed visual information. Based on the 24x24 resolution, each image is further segmented into 576 image tokens. These image tokens serve as input to the visual encoder for subsequent encoding.
[0040] By encoding image tags through a visual encoder, the visual features of the image are converted into a tag form that the model can understand and process. This process not only preserves the key information of the image but also provides a foundation for subsequent fusion with language modalities. Dividing the image into 576 tags and using a 24x24 resolution enables the model to capture local features in the image in greater detail, while also providing richer spatial information for subsequent position modeling.
[0041] This preprocessing and encoding of image data not only provides high-quality visual input for the model but also lays the foundation for subsequent position modeling and attention mechanism optimization. By segmenting the image into multiple markers and using an appropriate resolution, the spatial locality of the image is better preserved, enabling more effective multimodal information interaction and alignment in subsequent steps.
[0042] S2, calculate the relative position distance between each image marker, and evolve the relative position distance from the one-dimensional level to the two-dimensional level to obtain the two-dimensional coordinate Manhattan distance;
[0043] Specifically, step S2 includes: performing position encoding processing on the image mark using the rotation position encoding technology, and calculating the relative position distance of the image mark. The calculation formula is: ,in, is the Query tag at position index i, The key mark at position index j, express and The relative position distance between them is a one-dimensional distance. represents the position index of the image mark determined by raster scanning, represents the position index of the j-th image marker, Represents the position index of the i-th image marker;
[0044] Expanding the relative position distance from the one-dimensional level to the two-dimensional level, we get the two-dimensional coordinate Manhattan distance, which is: ,in, is the two-dimensional coordinate Manhattan distance, and are the two-dimensional horizontal and vertical coordinates of the Key mark at position j, and are the two-dimensional horizontal and vertical coordinates of the Query mark at position i.
[0045] In this embodiment, the rotational position encoding (RoPE) technology is used to position encode the image markers. This method is achieved by calculating the relative position distance between the image markers; this relative position distance is one-dimensional, and it determines the position index of the image marker by raster scanning. However, this one-dimensional position encoding method has obvious limitations, because it flattens the two-dimensional image markers into a one-dimensional sequence, loses the spatial locality characteristics of the two-dimensional image, and causes the model to have insufficient perception of the spatial relationship of the image markers. Specifically, the image markers are flattened into a one-dimensional sequence in a raster scan order (from top to bottom, from left to right), and then connected with the instruction markers to form an input sequence. Under long-term attenuation, the attention of image markers that are farther away from the instruction marker will gradually weaken. This leads to a fixed multimodal alignment pattern, where image markers at the end of the raster scan order receive more attention, while image markers farther away receive very sparse attention. As Figure 3 As shown in Figure 3, the visualization of the information flow from image to instruction further reveals this phenomenon.
[0046] To address this problem, this method proposes to extend the relative position distance from the one-dimensional level to the two-dimensional level, and introduces the concept of two-dimensional coordinate Manhattan distance to more accurately reflect the spatial relationship between image markers and retain the two-dimensional local characteristics of the image. This extension from one dimension to two dimensions has significant beneficial effects. First, the two-dimensional coordinate Manhattan distance can more realistically reflect the spatial distance between image markers, avoiding the perceptual bias caused by the raster scanning order in one-dimensional position encoding. For example, in one-dimensional position encoding, the attention of image markers will gradually weaken with increasing distance, resulting in less attention to image markers far away from the instruction marker. By introducing the two-dimensional Manhattan distance, the model can perceive image markers more evenly, regardless of their position in the image. This improvement significantly enhances the model's ability to perceive image information, thereby improving the accuracy of multimodal feature alignment.
[0047] Secondly, the introduction of the two-dimensional Manhattan distance also optimizes the model's causal attention mechanism. In traditional causal attention masks, the model's attention decay on image tags is unidirectional. However, with the two-dimensional Manhattan distance model, attention decay is extended to multiple directions, allowing the model to more comprehensively capture the interactive information between image and text. This improvement not only reduces the occurrence of hallucinations but also improves the model's overall performance on multimodal tasks.
[0048] S3, performing raster scanning processing on the image mark, assigning a position index, and reassigning a two-dimensional position coordinate to the image mark;
[0049] Specifically, step S3 includes: raster scanning the image mark and Assign position indices that increment by 1, where is the number of image tags;
[0050] Reassign the two-dimensional position coordinates to each of the image markers in the following manner: ;
[0051] The positions of the image markers at the four vertices of the image are set to the four starting coordinate origins (0, 0), and the marker points adjacent to the origin are set to the next marker point with an increment of 1, where the positive directions of the horizontal and vertical coordinate axes are consistent with the increment directions;
[0052] According to the four starting coordinate origins, the image token after the resolution is reset is divided into four mirrored parts, and the image tokens in each part are linearly increased in the positive direction of the two-dimensional coordinate axis of the origin.
[0053] In this embodiment, the image markers are subjected to raster scanning, and the image markers are scanned in a row-by-column order starting from the upper left corner, and a position index is assigned to each image marker. These position indexes are incremented by 1, thereby forming a one-dimensional position index sequence. Assuming that the total number of image markers is v, the position index assignment range is from 0 to v-1. Although this raster scanning method is simple and intuitive, it will cause the spatial locality information of the image markers to be lost in traditional multimodal large models because all image markers are flattened into a one-dimensional sequence, ignoring their actual positional relationship in the two-dimensional image.
[0054] To overcome this limitation, this method proposes an innovative two-dimensional position coordinate assignment method to reassign two-dimensional position coordinates to each image marker to better preserve the spatial locality characteristics of the image. First, the positions of the image markers located at the four vertices of the image are set to the four starting coordinate origins (0, 0). These four origins correspond to the upper left corner, upper right corner, lower left corner, and lower right corner of the image, respectively. Starting from these four origins, the marker points adjacent to the origin are set as the next marker point, and their coordinate values increase in sequence with an increment of 1. The positive direction of the horizontal coordinate axis and the vertical coordinate axis is consistent with the increment direction, ensuring that the coordinate assignment of the image marker is carried out along the two-dimensional spatial direction of the image.
[0055] Secondly, according to the four starting coordinate origins, the image token after the resolution is reset is divided into four mirrored parts. In each part, the two-dimensional coordinates of the image marker increase linearly along the positive direction of the two-dimensional coordinate axis of the origin. For example, in the upper left corner, the coordinates of the image marker start from (0, 0) and increase in the horizontal and vertical directions to form an ordered two-dimensional coordinate grid. This distribution method not only retains the spatial locality characteristics of the image, but also enables the model to handle the spatial relationship between image markers more naturally. Under the new position modeling mechanism, the information flow from image to instruction is as follows: Figure 4 shown.
[0056] Based on this two-dimensional position coordinate assignment method, this method achieves the following beneficial effects: 1. Preserving the spatial locality of the image: Traditional raster scanning methods flatten image markers into a one-dimensional sequence, losing the image's spatial locality. However, by assigning two-dimensional coordinates to image markers, this method preserves the image's two-dimensional structural information, enabling the model to better perceive the spatial relationships between image markers. 2. Enhancing multimodal feature alignment: In large multimodal models, alignment between image and text is critical. By introducing two-dimensional coordinates, the model can more accurately align image and text markers, thereby improving multimodal feature fusion and reducing the occurrence of hallucinations. 3. Optimizing the attention mechanism: The two-dimensional coordinate assignment method allows the model to more naturally consider the spatial position of image markers when calculating attention. Compared to traditional raster scanning methods, this assignment method can more effectively guide the model's attention, focusing on important areas in the image, thereby improving model performance. 4. Improving the model's generalization: By better preserving the image's spatial locality, the model can demonstrate stronger generalization when processing different image types. This improvement is not only applicable to specific datasets but also has potential applications in a wider range of scenarios.
[0057] S4, performing equivalent conversion processing on the two-dimensional coordinate Manhattan distance, and replacing the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers;
[0058] Specifically, step S4 includes: performing equivalent conversion processing on the two-dimensional coordinate Manhattan distance so that the two-dimensional coordinate Manhattan distance can be formally aligned with the relative position distance of the image mark, and the formula is: ,in, is the new position index calculated based on the two-dimensional position coordinates of the image marker at position m, is the horizontal coordinate of the image marker at position m, is the ordinate of the image marker at position m, for The new position index of for The new position index of
[0059] The position index of the raster scan is replaced by the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers, where the default self-attention calculation formula of the raster scan is: ,in, Query token at position index i q i The key token at position index j k j The self-attention between is the matrix transpose, is the activation function, is the feature dimension, is the rotation matrix, is the predefined sine function value.
[0060] In this embodiment, the two-dimensional Manhattan distance is converted to an equivalent form. The purpose of this process is to align the two-dimensional Manhattan distance with the relative position distance of the image labels in form, so as to better integrate it into the model's self-attention mechanism. To be compatible with the traditional self-attention mechanism, the two-dimensional Manhattan distance is converted to an equivalent one-dimensional index form. In this way, the two-dimensional Manhattan distance is converted to a one-dimensional position index, allowing it to seamlessly integrate with the traditional self-attention mechanism.
[0061] Next, the position index of the raster scan is replaced by the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image tags. In the traditional self-attention mechanism, the position index is assigned by raster scanning, and the position information of the token is embedded in the self-attention by adding a rotation matrix. Further, the position index is replaced by the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image tags. This replacement process not only retains the spatial locality characteristics of the image, but also enables the model to handle the spatial relationship between image tags more naturally. In this way, the two-dimensional coordinate Manhattan distance can be effectively integrated into the self-attention mechanism, thereby optimizing the multimodal information interaction capability of the model. Among them, the implementation plan of the specific transformation process is as follows Figure 2 As shown; Under the current default position modeling mechanism, the causal attention mask modeling effect is as follows Figure 5 shown.
[0062] Simply put, by incorporating the two-dimensional Manhattan distance into the self-attention mechanism, the model can more accurately perceive the spatial relationship between image tags, thereby improving the accuracy of multimodal feature alignment. Secondly, the model's attention allocation mechanism is optimized, allowing the model to more evenly focus on various areas in the image, avoiding the attention bias caused by the raster scanning order in traditional methods. Furthermore, by preserving the spatial locality of the image, the model can demonstrate stronger generalization and robustness when handling complex multimodal tasks.
[0063] S5, modeling the causal attention mask according to the new position index and the converted two-dimensional coordinate Manhattan distance, and replacing the default causal attention mask with the newly modeled causal attention mask;
[0064] Specifically, step S5 includes: modeling the relative positions of the image markers according to the converted two-dimensional coordinate Manhattan distance to obtain an adjusted position modeling mechanism, and obtaining a causal attention mask based on the mechanism;
[0065] Among them, the self-attention calculation formula is updated as: , the updated self-attention calculation formula is unified with the initial self-attention calculation formula in form;
[0066] Replace the default causal attention mask with the newly modeled causal attention mask.
[0067] In this embodiment, the relative positions of image markers are modeled based on the converted two-dimensional coordinate Manhattan distance. The core of this process is to integrate the spatial relationship between image markers into the model's attention mechanism in a more natural way. Specifically, the relative position relationship between image markers is redefined using the equivalent transformation result of the two-dimensional coordinate Manhattan distance. This new position modeling mechanism not only preserves the spatial locality characteristics of the image, but also enables the model to more accurately perceive the spatial distance between image markers.
[0068] Based on a new position modeling mechanism, a causal attention mask is further derived. In traditional large multimodal models, causal attention masks are typically modeled based on one-dimensional position indices, which ignores the two-dimensional spatial structure of image tags. This method, however, extends the modeling of causal attention masks to a two-dimensional level by introducing the two-dimensional Manhattan distance of coordinates. This extension not only optimizes the model's spatial perception of image tags but also enables the attention mechanism to more naturally handle the interaction between image and text.
[0069] To achieve this improvement, the self-attention calculation formula is updated. The updated self-attention calculation formula is consistent with the original self-attention calculation formula in form, but its internal logic has been expanded from one dimension to two dimensions, thereby better supporting the spatial relationship modeling of image tags.
[0070] Finally, replace the default causal attention mask with the newly modeled causal attention mask, e.g. Figure 6 This replacement process not only optimizes the model's attention allocation mechanism but also enables it to more evenly focus on various regions in the image, avoiding the attention bias caused by the raster scanning order in traditional methods. In this way, the model can demonstrate stronger generalization and robustness when handling complex multimodal tasks.
[0071] S6, freeze the multimodal large model, and adjust the training preprocessing of the multimodal large model according to the replaced causal attention mask and the preset pre-training data until the multimodal large model achieves the preset effect.
[0072] Specifically, step S6 includes: freezing the visual encoder and the large language model of the multimodal large model, adjusting the multimodal large model based on the replaced causal attention mask and the preset pre-training data, and updating only the parameters of the multilayer perceptron part thereof;
[0073] The multimodal large model is trained according to the updated parameters of the multilayer perceptron part until the multimodal large model achieves a preset effect.
[0074] In this embodiment, the visual encoder and large language model of the multimodal large model are frozen. Freezing means that the parameters of these pre-trained components remain unchanged during training. The visual encoder is responsible for encoding image data into feature representations that the model can process, while the large language model is responsible for processing text data. These two components are typically pre-trained on large-scale data and have strong feature extraction capabilities. By freezing their parameters, we can focus on optimizing other parts of the model during subsequent training, while avoiding the performance degradation caused by retraining.
[0075] Next, the large multimodal model is adjusted based on the replaced causal attention mask and the pre-set pre-training data. This adjustment process only updates the parameters of the multi-layer perceptron (MLP) portion of the model. The MLP serves as the link between the visual encoder and the large language model, fusing image and text features. By updating only the MLP parameters, the model can be more efficiently adjusted to better suit specific task requirements while reducing the computational burden during training.
[0076] During the adjustment process, a replaced causal attention mask is used to guide the interaction of multimodal information. This new causal attention mask, based on two-dimensional coordinate Manhattan distance modeling, can more accurately reflect the spatial relationship between image tags, thereby optimizing the model's fusion of image and text features. In this way, the model can more effectively process multimodal data and reduce the occurrence of hallucinations. Finally, based on the updated parameters of the multi-layer perceptron part, the multimodal large model is further trained until the model achieves the preset effect. This training process usually involves fine-tuning the model to ensure its performance on the specific task is optimal. By freezing the visual encoder and large language model and only updating the parameters of the multi-layer perceptron part, the model can be adjusted more efficiently while maintaining its strong feature extraction capabilities.
[0077] Compared with the existing technology, the training method for alleviating the hallucination of multimodal large models has the following advantages: (1) It points out the shortcomings of the position encoding method currently widely used in multimodal large models. The long-term decay of the rotation position encoding (RoPE) used for position modeling in multimodal large models will cause the instruction marker to show an uneven perception of image markers located at different positions in the two-dimensional space: in a one-dimensional sequence, more attention will be paid to the image marker closer to the instruction marker in the lower right image area. This perceptual bias will lead to insufficient information interaction between the image and the instruction and unsatisfactory multimodal feature alignment, thereby producing hallucinations. (2) Manhattan position assignment is proposed to replace the raster scan position index used by RoPE, which preserves the local spatial properties of the image: the causal attention of the image marker is extended from the unidirectional decay of ROPE to multidirectional decay. In addition, compared with raster scanning, the number of Manhattan position indexes is reduced from 576 to 23, thereby reducing the overall distance between the image and the instruction marker, which is more conducive to information interaction. (3) A position modeling method based on Manhattan distance, called Manhattan causal attention, is proposed, which extends the long-term decay to a two-dimensional, multi-directional spatial decay. For the two-dimensional continuity information contained in the image, the new attention calculation method retains the spatial local characteristics when establishing causal properties, improves the model's image information perception ability, and reduces hallucination phenomena. Figure 7 The results in
[15] show that the Manhattan Causal Attention (MCA-LLaVA) proposed in this method achieves the best or highly competitive results on different hallucination benchmarks compared with mainstream hallucination mitigation methods.
[0078] In summary, this training method for alleviating hallucinations in large multimodal models significantly improves the performance and reliability of these models by optimizing position modeling and attention mechanisms. The core of this method lies in redefining the positional relationships between image markers. By introducing the two-dimensional Manhattan distance and an improved causal attention mask, the model's perception and processing of image information is optimized. This improvement not only enhances the model's multimodal information interaction capabilities but also provides important technical support for building more reliable and efficient multimodal AI systems.
[0079] Specifically, the training method for mitigating hallucinations in large multimodal models first encodes image data into multiple image labels using a visual encoder and introduces a two-dimensional Manhattan distance to replace the traditional one-dimensional position encoding. This improvement preserves the spatial locality of the image, enabling the model to more accurately perceive the spatial relationships between image labels. By reallocating the two-dimensional position coordinates of the image labels and incorporating these coordinate values into the attention mechanism, the model can more naturally handle the interaction between image and text, thereby optimizing the effect of multimodal feature alignment. Furthermore, by freezing the pre-trained visual encoder and large language model, only fine-tuning the parameters of the multilayer perceptron (MLP), significantly improving training efficiency. This strategy not only saves computational resources but also avoids performance degradation caused by retraining. By introducing a new causal attention mask, the model can more evenly focus on various regions in the image, reducing attention bias caused by raster scanning order. This improvement significantly enhances the model's ability to perceive image information, effectively alleviating the hallucination problem.
[0080] See also Figure 8 A second embodiment of the present invention provides a training device for alleviating the hallucination of a multimodal large model, comprising:
[0081] The encoding unit 101 is used to obtain image data, and input the image data into the multimodal large model, and perform encoding processing on the image data to obtain multiple image labels;
[0082] A distance calculation unit 102 is used to calculate the relative position distance between each image marker, and evolve the relative position distance from a one-dimensional level to a two-dimensional level to obtain a two-dimensional coordinate Manhattan distance;
[0083] a reallocation unit 103 for performing raster scanning processing on the image mark, allocating position indexes, and reallocating two-dimensional position coordinates to the image mark;
[0084] An equivalent conversion unit 104 is configured to perform an equivalent conversion process on the two-dimensional coordinate Manhattan distance and replace the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers;
[0085] a replacement unit 105, configured to model a causal attention mask according to the new position index and the converted two-dimensional coordinate Manhattan distance, and replace the default causal attention mask with the newly modeled causal attention mask;
[0086] The training unit 106 is used to freeze the multimodal large model and adjust the training preprocessing of the multimodal large model according to the replaced causal attention mask and the preset pre-training data until the multimodal large model achieves the preset effect.
[0087] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A training method for alleviating hallucinations in multimodal large models, characterized in that: include: Acquire image data, and transfer the image data into a multimodal large model, encode the image data, and obtain multiple image tags; Calculate the relative position distance between each image marker, and evolve the relative position distance from the one-dimensional level to the two-dimensional level to obtain the two-dimensional coordinate Manhattan distance; Performing raster scanning processing on the image mark, assigning a position index, and reallocating a two-dimensional position coordinate to the image mark; Performing equivalent conversion processing on the two-dimensional coordinate Manhattan distance, and replacing the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers; Model the causal attention mask based on the new position index and the transformed two-dimensional coordinate Manhattan distance, and replace the default causal attention mask with the newly modeled causal attention mask; Freeze the multimodal large model, and perform adjustment training preprocessing on the multimodal large model according to the replaced causal attention mask and preset pre-training data until the multimodal large model achieves a preset effect.
2. The training method for alleviating the multimodal large model hallucination according to claim 1, characterized in that: The multimodal large model includes a visual encoder, a large language model, and a multilayer perceptron for connecting the visual encoder and the large language model. The visual encoder adopts CLIP ViT-L / 14, the large language model adopts Vicuna-7B, the multilayer perceptron includes a two-layer MLP, and the overall scale of the multimodal large model is 7B.
3. The training method for alleviating multimodal large model hallucination according to claim 1, characterized in that: The image data is encoded to obtain multiple image tags, specifically: A visual encoder of a multimodal large model is used to encode each image of the image data; The resolution of each image is reset to 24x24, and each image is segmented according to this size to obtain 576 image tags.
4. The training method for alleviating multimodal large model hallucination according to claim 1, characterized in that: Calculate the relative position distance between each image marker and evolve the relative position distance from the one-dimensional level to the two-dimensional level to obtain the two-dimensional coordinate Manhattan distance, specifically: The rotation position encoding technology is used to perform position encoding processing on the image markers and calculate the relative position distance of the image markers. The calculation formula is: ,in, is the Query tag at position index i, The key mark at position index j, express and The relative position distance between them is a one-dimensional distance. represents the position index of the image mark determined by raster scanning, represents the position index of the j-th image marker, Represents the position index of the i-th image marker; Expanding the relative position distance from the one-dimensional level to the two-dimensional level, we get the two-dimensional coordinate Manhattan distance, which is: ,in, is the two-dimensional coordinate Manhattan distance, and are the two-dimensional horizontal and vertical coordinates of the Key mark at position j, and are the two-dimensional horizontal and vertical coordinates of the Query mark at position i.
5. The training method for alleviating multimodal large model hallucination according to claim 1, characterized in that: Perform raster scanning on the image markers, assign position indexes, and reassign two-dimensional position coordinates to the image markers, specifically: The image mark is raster scanned and the Assign position indices that increment by 1, where is the number of image tags; Reassign the two-dimensional position coordinates to each of the image markers in the following manner: ; The positions of the image markers at the four vertices of the image are set to the four starting coordinate origins (0, 0), and the marker points adjacent to the origin are set to the next marker point with an increment of 1, where the positive directions of the horizontal and vertical coordinate axes are consistent with the increment directions; According to the four starting coordinate origins, the image token after the resolution is reset is divided into four mirrored parts, and the image tokens in each part are linearly increased in the positive direction of the two-dimensional coordinate axis of the origin.
6. The training method for alleviating multimodal large model hallucination according to claim 4, characterized in that: An equivalent conversion process is performed on the two-dimensional coordinate Manhattan distance, and the position index of the raster scan is replaced by the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers, specifically: The two-dimensional coordinate Manhattan distance is equivalently transformed so that the two-dimensional coordinate Manhattan distance can be formally aligned with the relative position distance of the image marker. The formula is: ,in, is the new position index calculated based on the two-dimensional position coordinates of the image marker at position m, is the horizontal coordinate of the image marker at position m, is the ordinate of the image marker at position m, for The new position index of for The new position index of The position index of the raster scan is replaced by the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers, where the default self-attention calculation formula of the raster scan is: ,in, Query token at position index i q i The key token at position index j k j The self-attention between is the matrix transpose, is the activation function, is the feature dimension, is the rotation matrix, is the predefined sine function value.
7. The training method for alleviating multimodal large model hallucination according to claim 6, characterized in that: According to the new position index and the converted two-dimensional coordinate Manhattan distance, the causal attention mask is modeled and the default causal attention mask is replaced with the newly modeled causal attention mask, specifically: The relative positions of the image markers are modeled according to the converted two-dimensional coordinate Manhattan distance to obtain an adjusted position modeling mechanism, based on which a causal attention mask is obtained; Among them, the self-attention calculation formula is updated as: , The updated self-attention calculation formula is unified with the initial self-attention calculation formula in form; Replace the default causal attention mask with the newly modeled causal attention mask.
8. The training method for alleviating multimodal large model hallucination according to claim 1, characterized in that: Freeze the multimodal large model, and perform adjustment training preprocessing on the multimodal large model according to the replaced causal attention mask and the preset pre-training data until the multimodal large model achieves the preset effect, specifically: Freeze the visual encoder and the large language model of the multimodal large model, adjust the multimodal large model based on the replaced causal attention mask and the preset pre-training data, and only update the parameters of the multi-layer perceptron part; The multimodal large model is trained according to the updated parameters of the multilayer perceptron part until the multimodal large model achieves a preset effect.
9. A training device for alleviating the illusion of a multimodal large model, characterized in that: include: An encoding unit, configured to acquire image data, transfer the image data into a multimodal large model, and perform encoding processing on the image data to obtain a plurality of image labels; A distance calculation unit is used to calculate the relative position distance between each image marker and evolve the relative position distance from a one-dimensional level to a two-dimensional level to obtain a two-dimensional coordinate Manhattan distance; a reallocation unit, configured to perform raster scanning processing on the image mark, allocate position indexes, and reallocate two-dimensional position coordinates to the image mark; an equivalent conversion unit, configured to perform equivalent conversion processing on the two-dimensional coordinate Manhattan distance, and replace the position index of the raster scan with the sum of the coordinate values of the two-dimensional position coordinates of the reallocated image markers; A replacement unit is used to model the causal attention mask according to the new position index and the transformed two-dimensional coordinate Manhattan distance, and replace the default causal attention mask with the newly modeled causal attention mask; A training unit is used to freeze the multimodal large model and adjust the training preprocessing of the multimodal large model according to the replaced causal attention mask and preset pre-training data until the multimodal large model achieves a preset effect.