A multi-modal missing data classification method based on retrieval augmentation and prompt learning
By employing offline cross-modal retrieval and prompting learning, the problem of insufficient information in multimodal models under modality missing conditions is solved, achieving high-precision and low-overhead multimodal data classification. The missing state is explicitly perceived and attention weights are reasonably adjusted, improving classification performance and robustness.
Patent Information
- Application Number
- CN202611683586.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-29
- Publication Date
- 2026-11-24
AI Technical Summary
Existing multimodal models struggle to fully utilize complementary information between different modalities when modalities are missing, leading to performance degradation. Furthermore, existing methods suffer from problems such as accumulated generation errors, high computational overhead, complex training processes, or lack of proactive information compensation.
We employ a retrieval-enhanced and cue-learning-based approach. We compensate for missing modal information through offline cross-modal retrieval, explicitly encode missing states using a learnable cue matrix, and achieve high-precision classification under modal missing conditions by lightweight adaptation of the Transformer encoder using low-rank incremental parameters.
It effectively compensates for missing information, explicitly informs the model of missing states, reduces training parameter overhead, and improves classification performance and robustness under conditions of missing modalities.
Smart Images

Figure CN123158347A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of multimodal data processing and artificial intelligence technology, specifically to a multimodal missing data classification method based on retrieval enhancement and cue learning, particularly to multimodal classification in cases of missing image or text modalities. Background Technology
[0002] Multimodal classification aims to analyze samples from multiple dimensions by fusing information from different sources such as images, text, and audio, thereby constructing a more comprehensive and robust semantic representation and decision-making mechanism than single-modal classification. In the interdisciplinary field of natural language processing and computer vision, multimodal learning is widely used in tasks such as sentiment analysis, content moderation, medical diagnosis, and joint text-image reasoning.
[0003] Existing multimodal models are typically built on the ideal assumption that all modal data is complete and available during the training and inference phases. However, this assumption is often difficult to meet in real-world scenarios and complex engineering deployments. In practical applications, modality loss is widespread. On the one hand, sensor malfunctions, image occlusion, network packet loss, and compression distortion can lead to data acquisition and transmission failures, resulting in the loss of some modal data. On the other hand, privacy restrictions or information asymmetry can also make certain modalities unavailable, such as e-commerce displays containing only product images or social media comments containing only text without accompanying images. Modality loss alters the input distribution of models trained or pre-trained based on full-modal data, making it difficult for the model to fully utilize the complementary information between different modalities, leading to a significant performance degradation and even incorrect decisions. To alleviate the modality loss problem, researchers have proposed various solutions.
[0004] Chinese patent CN118916842A discloses a dynamic fusion method for missing multimodal data based on knowledge distillation. This method constructs multiple unimodal teacher models based on a classification network, trains the classification network separately using data from each individual modality, and builds a multimodal dynamic fusion network based on a threshold network and a series of expert networks. The teacher models are used to distill and train the student models. The actual acquired multimodal data is then input into the multimodal dynamic fusion network to obtain the category prediction results. This scheme improves the classification accuracy for missing modalities to a certain extent through knowledge distillation and dynamic fusion networks. However, existing technologies still have the following shortcomings: (1) Generative completion methods (such as using GAN or diffusion models to generate missing modalities) can visually recover data, but the generated content has the risk of error accumulation and semantic inconsistency, which may introduce noise interference in classification tasks; (2) Knowledge distillation methods require additional training of teacher networks, which has high computational overhead and complex training process, making it difficult to deploy in actual systems; (3) Some methods only handle missing positions through attention masking mechanisms, but do not actively compensate for information. Under high missing rate, the semantic information available to the model is seriously insufficient, and the effect is limited; (4) Most existing methods do not explicitly distinguish between real modalities and completed modalities within the model, which may cause the model to misjudge the completed information as the original real information and over-rely on it, thereby amplifying the impact of completion error.
[0005] Therefore, there is an urgent need for a multimodal classification method that can effectively compensate for missing information, clearly inform the model of missing states, and has low training parameter overhead. Summary of the Invention
[0006] The purpose of this application is to provide a multimodal missing data classification method based on retrieval enhancement and cue learning, overcoming the shortcomings of existing technologies. This method achieves high-precision, low-training-cost multimodal data classification under conditions of missing modalities through the synergy of offline cross-modal retrieval to compensate for missing modal information, explicit encoding of missing states using a learnable cue matrix, and lightweight adaptation of the Transformer encoder using low-rank incremental parameters. The technical solution to achieve the purpose of this application is as follows: A multimodal missing data classification method based on retrieval enhancement and cue learning includes the following steps: S1. Obtain multimodal sample data, which includes image modality and text modality, and label each sample with a missing type marker, which is used to indicate no missing, text missing, or image missing. S2. Using a dual encoder model, extract the image features and text features of each sample respectively, normalize the image features and text features respectively to obtain image normalized embedding vectors and text normalized embedding vectors, and store the image normalized embedding vectors and text normalized embedding vectors into a vector database to establish a feature index for cross-modal retrieval. S3. Based on the vector database, pre-generate cross-modal retrieval maps for each sample. The cross-modal retrieval maps include a first map for retrieving text from an image and a second map for retrieving an image from text. Store the cross-modal retrieval maps as offline mapping files. S4. During the data loading stage, candidate modal data is obtained from the offline mapping file according to the missing type label of the current sample, and the candidate modal data is backfilled into the missing modal position of the current sample to obtain the completed multimodal input, which includes both image modal data and text modal data. S5. Initialize a learnable cue matrix for each missing type. Select at least one injection layer among the multiple intermediate layers of the Transformer encoder. In the selected injection layer, concatenate the cue matrix corresponding to the missing type along the sequence dimension to the beginning of the input sequence of that layer. After the self-attention calculation of that layer, remove the cue token position so that the length of the input sequence of the subsequent layer is restored to the original length. The cue matrix is used to characterize the missing type of the current sample so that the Transformer encoder can know the missing state of the sample. S6. Freeze the original weights in the QKV projection layer of each self-attention mechanism of the Transformer encoder, and superimpose a low-rank increment matrix. The low-rank increment matrix is decomposed into the product of two trainable low-rank matrices, wherein the first low-rank matrix is initialized with a random Gaussian distribution, and the second low-rank matrix is initialized as a zero matrix. Only the first low-rank matrix, the second low-rank matrix, the cue matrix, and the classification head parameters are trained, while keeping the Transformer backbone parameters frozen, so that the Transformer encoder can adapt to modality-deficient scenarios. S7. The completed multimodal input obtained in S4 is injected into the prompt matrix in S5 and superimposed with the low-rank increment matrix in S6 by the Transformer encoder. After processing by the Transformer encoder, the classification head outputs the classification prediction result of the sample. The classification prediction result includes the category label of the sample or the probability distribution of each category.
[0007] Furthermore, the dual encoder model described in S2 is a contrastive language-image pre-trained model, which includes an image encoder and a text encoder. The image encoder divides the input image into multiple image blocks, which are then processed by a Transformer after linear mapping and position embedding. The hidden state of the last layer category label is then normalized and linearly projected to obtain the image embedding. The text encoder performs word segmentation on the text, which is then processed by a Transformer. The hidden state of the last layer end label position is then normalized and linearly projected to obtain the text embedding. The image embedding and the text embedding are respectively mapped to a shared space by linear projection and then L2 normalized to obtain the image normalized embedding vector and the text normalized embedding vector.
[0008] Furthermore, the vector database mentioned in S2 is a Milvus vector database. The image normalized embedding vector is stored in the image vector set of the Milvus vector database, and the text normalized embedding vector is stored in the text vector set of the Milvus vector database. IVF_FLAT indexes are established on the image vector set and the text vector set respectively, and the distance metric is cosine similarity.
[0009] Furthermore, the pre-generated cross-modal retrieval mapping described in S3 specifically includes: for each sample, when retrieving text from an image, retrieving N+1 candidates, removing the original paired texts with the same ID as the query sample, and taking the top N as the candidate text ID list; when retrieving images from text, generating a candidate image ID list in a symmetrical manner; and storing the candidate text ID list and the candidate image ID list as an offline mapping file.
[0010] Furthermore, the method for backfilling the candidate modality data in S4 is as follows: if the missing type of the current sample is marked as text missing, then the image ID of the current sample is used as the query, the corresponding candidate text ID is loaded from the first mapping, and one of the candidate texts or the first candidate text with the highest similarity is randomly selected to backfill the missing text position; if the missing type of the current sample is marked as image missing, then the text ID of the current sample is used as the query, the corresponding candidate image ID is loaded from the second mapping, and one of the candidate images or the first candidate image with the highest similarity is randomly selected to backfill the missing image position.
[0011] Furthermore, the dimension of the cue matrix described in S5 is... ,in To indicate the sequence length, The hidden layer dimension; the selected injection layers are the 4th, 7th and 10th layers of the Transformer encoder.
[0012] Furthermore, the cue matrix is of three types, corresponding to three missing types: no missing data, text missing data, and image missing data; each missing type corresponds to a learnable cue matrix. , , All dimensions .
[0013] Furthermore, in S5, during the output phase of each injection layer, the previous layer is discarded. The prompt token position is used to segment the feature vectors of the original text and image parts, so that the length of the input sequence of the subsequent layers is restored to the original length; the Transformer encoder is a visual-language Transformer model, which uses linear projection of image patches and text word embedding to form input tokens, and sends the image modality and text modality into a shared Transformer for interaction.
[0014] Furthermore, the low-rank increment matrix update method described in S6 is as follows: for any QKV projection layer, the original weights are... The low-rank increment is represented as ,in express d OK d The set of columns of real matrices. Describes the second low-rank matrix. , Denotes the first low-rank matrix. , d Indicates the hidden layer dimension. r Indicates rank. r much smaller d Forward computation is Where x represents the input of the QKV projection layer, and h represents the output of the QKV projection layer. The scaling factor is used; during training, only B and A are updated, while maintaining... fixed.
[0015] Furthermore, the classification head described in S7 is a linear mapping layer, used to map the global features output by the Transformer encoder to the number of categories dimension; the cross-entropy loss function is used for single-label classification tasks, and the binary cross-entropy loss function is used for multi-label classification tasks.
[0016] Compared with the prior art, this application has the following beneficial effects: (1) By pre-generating Top-N candidate mappings offline and backfilling them directly during the data loading stage, the high latency of online retrieval is avoided, the completion results are stable and reproducible, and the lack of missing modal information is alleviated.
[0017] (2) By encoding the missing types into a learnable cue matrix and injecting it into the Transformer in layers, the model can explicitly perceive the state of missing modalities, reasonably adjust the attention weights, and reduce the over-reliance on backfill noise.
[0018] (3) By introducing LoRA low-rank incremental parameters only in the self-attention QKV projection layer and freezing the backbone, the number of training parameters is very small, reducing computation and storage costs. The incremental weights can be saved independently, making it easy to switch missing scenarios.
[0019] (4) By combining retrieval compensation, prompt perception and LoRA adaptation, the problems of "what is missing", "telling the model what is missing" and "how to adjust the fusion rules" are solved respectively, and the classification performance and robustness under modality loss are systematically improved. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A flowchart illustrating the overall architecture of the multimodal missing data classification method based on retrieval enhancement and prompting learning provided in this application embodiment; Figure 2 This is a schematic diagram of the CLIP model provided in the embodiments of this application; Figure 3 This is a schematic diagram of the ViLT model provided in an embodiment of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] like Figure 1The diagram shows the overall architecture of the method in this application. Input samples are first classified into three categories based on their missing type: no missing data, text missing data, and image missing data. Missing modalities are filled in by retrieving candidate data from offline mapping files, resulting in a complete bimodal input. Then, the corresponding cue matrix is selected according to the missing type and injected into the encoder. The encoder backbone is frozen, and only the low-rank incremental parameters, cue matrix, and classification head participate in training. The encoder output is processed by a pooling layer and the classification head to obtain the classification result. Module parameters marked "frozen" in the diagram do not participate in training, while module parameters marked "trainable" do. The implementation method of this application will be described in detail below with reference to the accompanying drawings.
[0024] Step S1: Obtain the original multimodal samples and label the missing types.
[0025] Obtain the original sample ,in Indicates the first Image modalities of a sample Represents text modality, Indicates the corresponding label, The total number of samples.
[0026] In one specific implementation, the MM-IMDb multimodal sentiment classification dataset is used as an example. This dataset contains movie poster images and corresponding text descriptions, labeled with sentiment categories. Assume the training set has 20,000 samples, the validation set has 5,000, the test set has 5,000, and the number of categories is 23. The text modality is processed using the Deberta tokenizer, and the image modality images are uniformly scaled to 224×224 pixels.
[0027] Specifically, three missing data configurations were artificially constructed: text missing (image only), image missing (text only), and mixed missing (randomly missing one modality). The missing data rates were set to 10%, 30%, and 50%, respectively. The missing data type label for each sample was recorded. , where 0 indicates no missing text, 1 indicates missing text, and 2 indicates missing image.
[0028] like Figure 2 The diagram shown illustrates the structure of a Contrastive Language–Image Pre-training (CLIP) model, which is a prior art technique. Images and text are each encoded by their respective encoders to extract features, which are then mapped to a shared space and normalized. Subsequently, the similarity of all image-text pairs within a batch is calculated and a matrix is formed. The diagonal of the matrix (the thick box in the diagram) represents the true pairings, and the bidirectional contrastive loss is calculated accordingly. This application only uses the dual encoders of this model to extract retrieval features.
[0029] Step S2: Construct a cross-modal retrieval library.
[0030] Image encoder. Specifically, the input image is scaled, cropped, and normalized according to the image processing method of the pre-trained model; for a 224×224 pixel input, it is divided into 49 non-overlapping 32×32 pixel image blocks. The first... j Each image patch is expanded into a row vector. And through a linear mapping matrix Obtain visual tags and add learnable category tags. and position embedding Then, layer normalization is performed to obtain the initial sequence of the visual encoder:
[0031] in, This represents the initial input sequence of the image encoder. Representation layer normalization, Represents learnable image category tags, For the first j The row vectors of each image patch expanded into. The number of image patches, The linear mapping matrix of the image patch. Image location embedding matrix. Linear mapping matrix. Map the pixel vector of each image patch to 768 dimensions; location embedding It has the same shape as the sequence containing category labels. The visual backbone consists of 12 Transformer layers, each containing 12 self-attention and feedforward networks, taking the hidden state corresponding to the category label in the last layer. After layer normalization and linear projection Get image embedding :
[0032] in, The hidden state vector for labeling the location of the image category in the last layer. The linear projection matrix for image embedding. This is the image embedding vector.
[0033] Text encoder. Further, the text is first lowercase and segmented into byte-level BPE sub-words. Start markers [SOS] and end markers [EOS] are added to the beginning and end of the text, and truncation or padding is performed according to the model context length. The text marker embeddings and positional embeddings are added together to obtain the text Transformer input:
[0034] in, This represents the initial input sequence for the text encoder. to The embedding vector for each sub-word tag. and Let these represent the embedding vectors of the start and end tags, respectively. The number of effective text subwords, An embedding matrix is used for text positions. The text Transformer contains 12 layers with a hidden dimension of 512, 8 attention heads, and a causal attention mask. The hidden state at position [EOS] in the last layer is taken. After layer normalization and linear projection Get text embedding :
[0035] in, This is the hidden state vector at the end marker position of the last layer. For the linear projection matrix of the text embedding, This is a text embedding vector.
[0036] Shared space and normalization. Specifically, linear projection. and The global features of the image and text are mapped to a 512-dimensional shared space, and L2 normalization is performed on both embeddings to obtain unit-length vectors. and :
[0037] in, Represents the L2 norm. Represents the image normalized embedding vector. This represents the text normalization embedding vector. For normalized vectors, the inner product equals the cosine similarity. When retrieving text from an image, this is used... With each of the text libraries Similarity is calculated and ranked; symmetric operations are used when retrieving images from text. The method in this application uses its dual encoder to complete the retrieval, and the final classification is completed by subsequent ViLT and classification head.
[0038] Furthermore, comparing the pre-training process, the original CLIP was trained using approximately 400 million internet image-text pairing samples. Let a batch contain... A picture and text pair After the above encoding and normalization, we obtain and Calculate the scaled cosine similarity between all images and text in this batch, forming... × matrix:
[0039] in, For learnable temperature, i and j For batch sample index, and The first i The image and the first j Cosine similarity of the texts; To correspond to real-world pairings, The scaled similarity value is... This corresponds to negative samples within the batch. Cross-entropy is calculated along both the image-to-text and text-to-image directions:
[0040]
[0041]
[0042] in, This represents the contrast loss in the image-to-text direction. This represents the contrast loss in the text-to-image direction. Indicates batch size, Indicates the total comparative loss. The function is exponential. During pre-training, backpropagation using bidirectional contrastive loss is used to jointly update the image encoder, text encoder, linear projection layer, and temperature parameters, thereby improving the matching probability of true pairings relative to other combinations within the batch. The above process is used to illustrate how the pre-training weights are obtained; in this implementation, the pre-training parameters are directly loaded, the CLIP weights are fixed, and the following feature extraction, vector loading, and offline candidate mapping steps are performed.
[0043] Specifically, the image encoder uses a pre-trained CLIP model (ViT-B / 32 architecture). and text encoder Features were extracted from all training set images and text, with a feature dimension of 512. L2 normalization was performed on each feature vector to obtain a normalized embedding vector.
[0044] in, Represents the L2 norm. Indicates the first i Normalized embedding vectors of each image, Indicates the first i Normalized embedding vectors of each text. Indicates the image encoder for the first... i Feature vectors extracted from each image This indicates that the text encoder is for the first...i Feature vectors extracted from each text. All image vectors. The image vector collection "image_vectors" in the Milvus vector database contains all text vectors. Store the data in the "text_vectors" text vector collection. Create IVF_FLAT indices on both collections and set the number of clusters. The number of probe clusters, nprobe=16, is used, and the distance metric is cosine similarity.
[0045] Step S3: Pre-generate offline cross-modal retrieval mapping.
[0046] Furthermore, setting N=5, two types of cross-modal mappings are pre-generated for each sample: Image-based text retrieval mapping ,in For image The semantically closest Index of a text sample; Retrieving image mappings from text ,in For text The semantically closest Index of image samples.
[0047] Preferably, to avoid the search results containing the original pairings of the sample itself, a strategy of retrieving one more pair before filtering is adopted: Search After removing entries with the same query ID from the candidate list, the first few entries are truncated. One valid candidate. Ultimately, [the following will be determined]. and It is fixed into two offline JSON mapping files.
[0048] Step S4: Missing modalities are filled in completely.
[0049] During the data loading phase of training and inference, based on the missing type of each sample... Perform backfill operation: If (Text missing), using the image of the current sample For querying, from the mapping file The system loads five candidate text IDs, randomly selects one of them or the first candidate text with the highest similarity, and fills it into the missing text position to obtain the completed text. .like (Image missing), with text from the current sample For querying, from the mapping file Load the corresponding 5 candidate image IDs, randomly select one of the candidate images or select the first candidate image with the highest similarity, and fill it into the position of the missing image to obtain the completed image. .like (No missing parts), keeping the original image and text unchanged.
[0050] After completion, each sample is standardized to a bimodal input format containing both images and text, with the real modality and the retrieval backfill modality together forming a complete input.
[0051] Step S5 prompts for matrix layered injection.
[0052] like Figure 3 The diagram shown is a schematic of the Vision-and-Language Transformer (ViLT) model, which belongs to the prior art. Text tags and image patch tags are concatenated into a joint sequence after embedding layers and positional embedding, and then fed into a twelve-layer encoder. This application makes two modifications to this structure: first, four cue tags are concatenated at the beginning of the input sequences in layers 4, 7, and 10, and removed during the output of these layers; second, low-rank incremental branches are connected in parallel to the projection layers of the self-attention layers in each layer. The encoder backbone is frozen, and only the cue tags, low-rank parameters, and the classification head participate in training. Figure 3 Hollow boxes represent category markers, grid boxes represent text markers, and dotted boxes represent image block markers.
[0053] Text input. Specifically, the text is converted into sub-word tokens using the bert-base-uncased tokenizer corresponding to the ViLT pre-trained model, and then processed through a word embedding matrix. Mapped to a 768-dimensional space. Learnable text category labels are set before the sequence. and overlay text position embedding :
[0054] in, The input sequence representing the text modality. Represents learnable text category tags. Indicates the first One-hot representation of a text tag Represents the text word embedding matrix, For the number of text tags, An embedding matrix is used for text location. The image input is divided into 32×32 pixel blocks, the first... Each image block is flattened into via linear mapping matrix Mapped to 768-dimensional visual labels, with image category labels added. and image location embedding :
[0055] in, The input sequence represents the image modality. The number of image patches depends on the input resolution. Label the image categories that can be learned. For the first j Image patch flattening vector, The linear mapping matrix of the image patch Image location embedding matrix. Embed text modality type. Image modality type embedding The broadcasts are added to the corresponding markers, and then concatenated along the sequence dimension to obtain the joint input sequence of text and image concatenation. :
[0056] in, Embedded for text modal types, Embedding for image modality types, and respectively with , The embedding vectors of each marker are added element by element. The input sequence is a combined text and image sequence, which serves as the input sequence for the 0th layer (i.e., the input layer) of the Transformer encoder. Its length is the sum of the number of text tags and the number of image patches.
[0057] Image-text joint encoding. Furthermore, ViLT-B / 32 contains D=12 Transformer layers, each with a hidden dimension H=768, 12 attention heads, and a feedforward network with an intermediate dimension of 3072. Pre-layer normalization is employed, and multi-head self-attention processes both image and text tags simultaneously. d The layer is calculated as follows:
[0058]
[0059] in, Indicates the first d The output of the self-attention sublayer, Indicates the first d The final output of the layer, Indicates the first d -1 layer output, , Presentation layer normalization, MSA For multi-head self-attention, MLP As a feedforward network, residual summation preserves feature propagation. The feature vector from the first text category marker (i.e., the first position of the text sequence, denoted as [CLS]) in the final sequence is taken and used to form a global graph-text representation through linear pooling and hyperbolic tangent activation. p :
[0060] in, For the final layer output sequence The feature vector at position 0 (i.e., the position of the first text category label) has a superscript D indicating the final layer of the encoder and a subscript 0 indicating the first position in the sequence. Let p be the pooling mapping parameter matrix, and p be the global image-text representation vector. This global representation can be connected to the image-text matching header, or downstream to the classification header of the method in this application.
[0061] Pre-training initialization and data. Specifically, the original ViLT uses the ViT-B / 32 model weights of the Visual Transformer (ViT) to initialize the image patch linear projection layer and the Transformer backbone; these weights are first pre-trained on ImageNet-21K (a large-scale expanded version of the ImageNet dataset, containing approximately 21,800 categories and 14 million images, used for large-scale image classification pre-training), and then fine-tuned for classification on ImageNet-1K (a standard 1000-class subset of the ImageNet dataset, containing approximately 1.28 million training images). Text word embeddings, text category labels, and text location embeddings are learned from scratch during image-text pre-training. Using the BERT tokenizer does not imply loading the BERT text encoder.
[0062] Furthermore, ViLT's image-text pre-training uses MSCOCO (Microsoft Common Objects in Context), Visual Genome, Google Conceptual Captions, and SBU Captions. The original paper (Kim W, Son B, Kim I. ViLT: Vision-and-Language Transformer Without Convolution or Region Supervision[C] / / International Conference on Machine Learning. PMLR, 2021: 5583-5594.) lists the number of images from each source as approximately 113,000, 108,000, 3,010,000, and 867,000, respectively. Since one image can correspond to multiple descriptions, the number of images is not equal to the number of image-text pairs. Pre-training simultaneously calculates the loss for image-text matching and masked language modeling, and incorporates word-image patch alignment as an auxiliary constraint.
[0063] Image-Text Matching (ITM) is a task that involves replacing a matched image with another image with a probability of 0.5 to construct matching labels. To represent the global graphical representation p The data is fed into a linear classification head to obtain the model's predicted true matching probability. For those containing For a batch of samples, the matching loss is... for:
[0064] in, For the first i Image-text matching labels for each sample (1 indicates a match, 0 indicates no match). This represents the matching probability predicted by the model.
[0065] This paper presents a masked language modeling (MLM) task. It employs a whole-word masking strategy, selecting words with a probability of 0.15 and grouping consecutive subwords belonging to the selected word into a single mask. Based on image information and the surrounding text context, it predicts the original label for the selected position. The output at the corresponding position is processed through a two-layer MLP to generate vocabulary probabilities. The masked language modeling loss is then calculated. Represented as:
[0066] in, For the model in the firstm The probability of predicting the original label at each location. The set of mask locations participating in the prediction. For the size of the set, The original label is for the corresponding position. This loss prompts the model to combine the image and text context to recover the semantics of the selected word.
[0067] Word Patch Alignment (WPA). This involves aligning the effective text features in the final layer. and image patch feature set As two sets of characteristic distributions, their approximate Wasserstein alignment distance is calculated using optimal transmission:
[0068] in, OT represents word-plot alignment loss. This represents the optimal transmission alignment distance. The original ViLT uses the IPOT algorithm for approximation and adds the WPA auxiliary term to the ITM loss with a weight of 0.1. Summarizing the losses from each batch of tasks, the original pre-training objective can be written as:
[0069] in, This represents the total loss during ViLT pre-training. For image-text matching loss, For masked language modeling loss, is the word block alignment loss, and 0.1 is the weight coefficient of the word block alignment auxiliary term. The original pre-training used the AdamW optimizer with a learning rate of 10. 4 The weight decays to 10. 2 The first 10% of training steps are used for warm-up, followed by linear decay. The ViLT paper trains on 64 V100 images with a batch size of 4096 for 100K or 200K steps. Images maintain aspect ratio, with the shorter side scaled to 384 pixels and the longer side limited to 640 pixels. Pre-training samples a maximum of 200 visual image patches; these are the pre-training settings for the original model.
[0070] Regarding the training integration with the method of this application, this embodiment loads the ViLT weights that have already completed image-text pre-training; the input is the image-text obtained in step S4, where missing positions have been filled by candidate modalities. Subsequently, the missing type cue matrix is initialized, cuees are injected into the selected Transformer layer, and a low-rank adaptation (LoRA) branch is superimposed on the self-attention QKV projection layer. In the downstream stage, the original ViLT backbone and embedding parameters are frozen, and only the cue matrix, the LoRA low-rank matrix, and the classification head are updated, using the classification loss from step S7 to learn the target task; the aforementioned ITM, MLM, and WPA are used to explain the source of the pre-trained weights and do not enter the downstream classification loss of the method of this application.
[0071] Furthermore, the ViLT model is adopted as the basic multimodal Transformer, and its hidden layer dimension is... There are 12 layers in total, and the length of the prompt sequence is set. Initialize learnable cue matrices for each of the three missing types. .
[0072] Preferably, layers 4, 7, and 10 of the Transformer encoder are selected as the cue injection layers, denoted as the index set. For any sample, let its missing type be . In the injection layer Before the forward computation, the corresponding missing type of this layer is... m Hint matrix Concatenate along the sequence dimension to the original input sequence of this layer At the very beginning, we obtain the expanded input sequence. :
[0073] The length of the expanded sequence is the original sequence length plus 4. The expanded sequence is fed into the Transformer block of this layer for self-attention calculation. In the output stage of each injection layer, the first 4 cue token positions are removed, and the feature vectors of the original text and image parts are separated to ensure that the input sequence length of subsequent layers is restored to the original length.
[0074] Step S6: LoRA lightweight adaptation.
[0075] Freeze all backbone parameters of the ViLT model. Stack LoRA low-rank incremental parameters onto each QKV projection layer of the self-attention mechanism (weight matrix dimension 768×768). Set the rank. Scaling factor For any QKV projection layer, the original projection weights are denoted as... The low-rank increment matrix is decomposed into the product of two trainable low-rank matrices. Specifically, two trainable low-rank matrices are defined. and A is initialized with a random Gaussian distribution, and B is initialized as a zero matrix, so that the incremental branch does not change the model output in the initial stage of training.
[0076] Forward computation with LoRA is represented as:
[0077] in, This represents the output of the QKV projection layer. This represents the original weight matrix of the QKV projection layer. This represents the input to the QKV projection layer. Only for low-rank matrices. and Three-layer prompt matrix The downstream classification head parameters are then updated using gradients. The classification head is a linear mapping layer used to extract features from the output sequence corresponding to the original modality region. Specifically, the feature vector at the position of the first text category marker (i.e., the first position of the text sequence, denoted as [CLS]) in the output sequence is taken, pooled to obtain a fixed-dimensional global image-text representation vector, and then the classification head maps this global image-text representation vector to the number of categories dimension, mapping the global features output by ViLT to the number of categories dimension; the AdamW optimizer is used, with a learning rate set to... The batch size is set to 32, and the total number of training rounds is 10 epochs.
[0078] Step S7: Classification prediction and loss calculation.
[0079] For single-label classification tasks (such as MM-IMDb), use the cross loss function. :
[0080] in, C For the number of categories, One-hot encoding of the real label. This represents the probability distribution predicted by the model.
[0081] For multi-label classification tasks (such as UPMC Food-101), use the binary crossover loss function. :
[0082] The trainable parameters (low-rank matrix, cue matrix, and classification head) are updated using the backpropagation algorithm, while the backbone ViLT parameters remain frozen. After training, forward inference is performed on the completed samples on the test set to obtain the final classification accuracy.
[0083] In one specific implementation, taking the UPMCFood101 multi-label classification dataset as an example, this dataset contains images of food categories and corresponding text descriptions. Except for the use of binary cross-entropy loss as the loss function, the model architecture, retrieval library construction method, hint injection strategy, and LoRA adaptation parameters are consistent with the aforementioned MM-IMDb implementation.
[0084] Furthermore, this application pre-generates mapping files offline, directly reading local files to obtain candidate modalities during the data loading phase, eliminating the need for online vector database queries. Therefore, the additional time overhead during training and inference phases is limited to file I / O operations, resulting in overall computational efficiency roughly equivalent to that of a complete modal model.
[0085] To verify the roles and synergistic effects of the three modules—search completion, missing information suggestion, and low-rank adaptation—ablation experiments were conducted on the MM-IMDb and UPMC Food-101 datasets. A mixed missing information setting was used, retaining 65% of the image and 65% of the text modalities (70% missing information rate). Except for the removed modules, all other ablation configurations remained consistent: the base model was ViLT-B / 32, the suggestion sequence length was 4, the suggestion injection layers were layers 4, 7, and 10, the rank of the low-rank matrix was 8, the scaling factor was 16, the optimizer was AdamW, and the learning rate was 1×10⁻⁶. -4 The batch size was 32, and the training epochs were 10. The evaluation metrics were the accuracy of MM-IMDb Macro-F1 and UPMC Food-101.
[0086] The ablation experiment results are shown in Table 1. Under mixed missing conditions, when using only search completion, the Macro-F1 of MM-IMDb increased from 0.3519 to 0.3759, and the Accuracy of UPMC Food-101 increased from 0.6876 to 0.7563; when using only the missing hint matrix, they increased to 0.4175 and 0.7886 respectively; when using only LoRA, they increased to 0.4158 and 0.7752 respectively; when all three were used together, they reached 0.4805 and 0.8365 respectively, representing improvements of 12.9 and 14.9 percentage points relative to the baseline, respectively. These improvements were higher than the gains of any single module, indicating that the three modules had significant synergistic gains.
[0087] Table 1. Ablation experiment results (mixed deletions, 65% of images and 65% of text are retained).
[0088] In this application, the retrieval module addresses the "what's missing" problem by providing semantic substitution information for the missing locations through an external knowledge base; the prompting module addresses the "telling the model what's missing" problem by explicitly encoding the missing state, enabling the model to distinguish between the true modality and the backfilled modality during the fusion process; and the LoRA module addresses the "how to adjust the fusion rules" problem by introducing low-rank incremental parameters into the attention projection layer, allowing the model to adapt to interaction changes in missing scenarios with minimal parameter overhead. These three modules work together to systematically alleviate the problems of insufficient information, state confusion, and interaction mismatch caused by modality missingness.
[0089] Optionally, the core method of this application is not only applicable to image-text bimodal scenarios, but also to combinations of multiple modalities such as audio, video, and sensor signals. It can be directly applied simply by expanding the type of the cross-modal retrieval library (e.g., an audio vector library) and the category of missing information (e.g., missing audio). Such simple variations and extensions based on the principles of this application all fall within the protection scope of this application.
[0090] Optionally, this application can design the above-mentioned multimodal missing data classification method as a computer program, store it in the memory of smart devices such as mobile phones, computers, and servers, and use a processor to acquire multimodal data and run the computer program to implement the above-mentioned classification method.
[0091] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0092] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A multimodal missing data classification method based on retrieval enhancement and cue learning, characterized in that, Includes the following steps: S1. Obtain multimodal sample data, which includes image modality and text modality, and label each sample with a missing type marker, which is used to indicate no missing, text missing, or image missing. S2. Using a dual encoder model, extract the image features and text features of each sample respectively, normalize the image features and text features respectively to obtain image normalized embedding vectors and text normalized embedding vectors, and store the image normalized embedding vectors and text normalized embedding vectors into a vector database to establish a feature index for cross-modal retrieval. S3. Based on the vector database, pre-generate cross-modal retrieval maps for each sample. The cross-modal retrieval maps include a first map for retrieving text from an image and a second map for retrieving an image from text. Store the cross-modal retrieval maps as offline mapping files. S4. During the data loading stage, candidate modal data is obtained from the offline mapping file according to the missing type label of the current sample, and the candidate modal data is backfilled into the missing modal position of the current sample to obtain the completed multimodal input, which includes both image modal data and text modal data. S5. Initialize a learnable cue matrix for each missing type. Select at least one injection layer among the multiple intermediate layers of the Transformer encoder. In the selected injection layer, concatenate the cue matrix corresponding to the missing type along the sequence dimension to the beginning of the input sequence of that layer. After the self-attention calculation of that layer, remove the cue token position so that the length of the input sequence of the subsequent layer is restored to the original length. The cue matrix is used to characterize the missing type of the current sample so that the Transformer encoder can know the missing state of the sample. S6. Freeze the original weights in the QKV projection layer of each self-attention mechanism of the Transformer encoder, and superimpose a low-rank increment matrix. The low-rank increment matrix is decomposed into the product of two trainable low-rank matrices, wherein the first low-rank matrix is initialized with a random Gaussian distribution, and the second low-rank matrix is initialized as a zero matrix. Only the first low-rank matrix, the second low-rank matrix, the cue matrix, and the classification head parameters are trained, while keeping the Transformer backbone parameters frozen, so that the Transformer encoder can adapt to modality-deficient scenarios. S7. The completed multimodal input obtained in S4 is injected into the prompt matrix in S5 and superimposed with the low-rank increment matrix in S6 by the Transformer encoder. After processing by the Transformer encoder, the classification head outputs the classification prediction result of the sample. The classification prediction result includes the category label of the sample or the probability distribution of each category.
2. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The dual encoder model described in S2 is a contrastive language-image pre-trained model. The contrastive language-image pre-trained model includes an image encoder and a text encoder. The image encoder divides the input image into multiple image blocks, which are then processed by a Transformer after linear mapping and position embedding. The image embedding is obtained by taking the hidden state of the last layer of class labels, and then performing layer normalization and linear projection. The text encoder performs word segmentation on the text, and after processing by the Transformer, the hidden state at the end marker position of the last layer is obtained by layer normalization and linear projection to obtain the text embedding. The image embedding and the text embedding are respectively mapped to a shared space via linear projection and then L2 normalized to obtain the image normalized embedding vector and the text normalized embedding vector.
3. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The vector database mentioned in S2 is the Milvus vector database. The image normalized embedding vector is stored in the image vector set of the Milvus vector database, and the text normalized embedding vector is stored in the text vector set of the Milvus vector database. IVF_FLAT indexes are established on the image vector set and the text vector set respectively, and the distance metric is cosine similarity.
4. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The pre-generated cross-modal retrieval map described in S3 specifically includes: For each sample, when retrieving text from an image, N+1 candidates are retrieved. After removing the original paired texts with the same ID as the query sample, the top N texts are taken as the candidate text ID list. When retrieving images from text, a candidate image ID list is generated in a symmetrical manner. The candidate text ID list and the candidate image ID list are stored as offline mapping files.
5. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The method for backfilling the candidate modal data described in S4 is as follows: If the missing type of the current sample is marked as text missing, then the image ID of the current sample is used as the query, the corresponding candidate text ID is loaded from the first mapping, and one of the candidate texts is randomly selected or the first candidate text with the highest similarity is selected to fill the missing text position. If the missing type of the current sample is marked as image missing, then the text ID of the current sample is used as the query, the corresponding candidate image ID is loaded from the second mapping, and one of the candidate images is randomly selected or the first candidate image with the highest similarity is selected to fill the missing image position.
6. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The dimension of the hint matrix described in S5 is ,in To indicate the sequence length, The hidden layer dimension; the selected injection layers are the 4th, 7th and 10th layers of the Transformer encoder.
7. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 6, characterized in that, The cue matrix is of three types, corresponding to three types of missing data: no missing data, text missing data, and image missing data; each missing data type corresponds to a learnable cue matrix. , , All dimensions .
8. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 6, characterized in that, In S5, during the output phase of each injection layer, the previous... The feature vectors of the original text and image parts are segmented from the prompt token position, so that the length of the input sequence of the subsequent layers can be restored to the original length; The Transformer encoder is a visual-language Transformer model. The visual-language Transformer model uses linear projection of image patches and text word embedding to form input tags, and sends the image modality and text modality into a shared Transformer for interaction.
9. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The update method for the low-rank increment matrix described in S6 is as follows: For any of the QKV projection layers, the original weights are: The low-rank increment is represented as ,in express d OK d The set of columns of real matrices. Describes the second low-rank matrix. , Denotes the first low-rank matrix. , d Indicates the hidden layer dimension. r Indicates rank. r much smaller d ; Forward computation is Where x represents the input of the QKV projection layer, and h represents the output of the QKV projection layer. The scaling factor is used; during training, only B and A are updated, while maintaining... fixed.
10. The multimodal missing data classification method based on retrieval enhancement and cue learning according to claim 1, characterized in that, The classification head described in S7 is a linear mapping layer, used to map the global features output by the Transformer encoder to the number of categories dimension; the cross-entropy loss function is used for single-label classification tasks, and the binary cross-entropy loss function is used for multi-label classification tasks.
Citation Information
Patent Citations
Knowledge distillation-based missing multi-modal data dynamic fusion method, system and device
CN118916842A
