Data matching method and device and multi-modal model processing method and device

By encoding and merging different modal data and using gated weights for adaptive information extraction, the problem that the traditional VLP model cannot effectively utilize modal interaction information is solved, and the data processing performance and matching accuracy are improved.

CN118861697AActive Publication Date: 2024-10-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Application Number
CN202311777194.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2024-10-29
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

When the traditional visual-language pre-training model (VLP) processes image and text data, it cannot effectively utilize the interactive information between different modalities, resulting in low data processing performance.

Method used

By encoding data of different modalities, modal representations are generated, and combined with gating weights for fusion, adaptive information extraction and reconstruction is achieved, and matching accuracy is improved.

Benefits of technology

The accuracy and performance of data processing are improved, especially when data is missing, the missing information is compensated for through multi-modal information reconstruction, and the matching accuracy is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118861697A_ABST
    Figure CN118861697A_ABST
Patent Text Reader

Abstract

The invention relates to a data matching method and device, computer equipment, a storage medium and a computer program product. The method comprises the steps that first data and second data are coded to obtain first modal representation and second modal representation, and the first data and the second data are data of different modals; obtaining a mixed modal representation by combining the first modal representation and the second modal representation, and determining a self-adaptive gating weight according to the mixed modal representation; according to the gating weight, fusing the first modal representation and the mixed modal representation to obtain a first fusion representation, and fusing the second modal representation and the mixed modal representation to obtain a second fusion representation; and determining the matching degree of the first data and the second data according to the first fusion representation and the second fusion representation. By adopting the method, the data processing performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data matching method, apparatus, computer equipment, storage medium and computer program product, as well as a multimodal model processing method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] With the development of computer technology, machine learning technology has emerged. By building machine learning models through machine learning technology and training machine learning models, machine learning models can be equipped with the ability to perform tasks. In the field of vision-language learning, in order to improve the practicality of the model, a general vision-language pre-training model, namely the VLP (Vision-Language Pre-training) model, can usually be pre-trained to perform image and text processing.

[0003] At present, traditional VLP models usually adopt a dual encoder structure, where the encoder on one side processes image data in a single mode, and the encoder on the other side processes text data in a single mode. In actual business scenarios, there may be a correlation between paired image data and text data, and this single-mode processing method cannot make good use of the interactive information between different modes, resulting in low data processing performance. Summary of the invention

[0004] Based on this, it is necessary to provide a data matching method, device, computer equipment, computer readable storage medium and computer program product for the above technical problems.

[0005] On the one hand, the present application provides a data matching method, comprising:

[0006] Encoding the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities;

[0007] combining the first modal representation and the second modal representation to obtain a hybrid modal representation, and determining an adaptive gating weight according to the hybrid modal representation;

[0008] According to the gating weights, the first modality representation and the mixed modality representation are fused to obtain a first fused representation, and the second modality representation and the mixed modality representation are fused to obtain a second fused representation;

[0009] A matching degree between the first data and the second data is determined according to the first fused representation and the second fused representation.

[0010] In some embodiments, fusing the first intermediate mixed representation into the second intermediate mixed representation to obtain the (i+1)th interactively fused second intermediate mixed representation includes:

[0011] Perform an attention operation on the second intermediate mixed representation output by the i-th interactive fusion and the first intermediate mixed representation, combine the attention operation result with the second intermediate mixed representation output by the i-th interactive fusion, and then perform a layer regularization operation to obtain a second intermediate processing feature;

[0012] The second intermediate processing feature is processed by a feedforward neural network, and a layer regularization operation is performed after combining the feedforward neural network processing result and the second intermediate processing feature to obtain a second intermediate mixed representation of the i+1th interactive fusion.

[0013] In some embodiments, according to the gating weight, fusing the first modality representation and the mixed modality representation to obtain a first fused representation includes:

[0014] Using the gating weight as a coefficient of the mixed modal representation, and using a difference between the value one and the gating weight as a coefficient of the first modal representation;

[0015] The mixed modal representation and the first modal representation are weighted according to the coefficients of the mixed modal representation and the coefficients of the first modal representation to obtain a first fused representation.

[0016] In some embodiments, according to the gating weight, fusing the second modality representation and the mixed modality representation to obtain a second fused representation includes:

[0017] Using the gating weight as a coefficient of the mixed modal representation, and using the difference between the value one and the gating weight as a coefficient of the second modal representation;

[0018] The mixed modal representation and the second modal representation are weighted according to the coefficients of the mixed modal representation and the coefficients of the second modal representation to obtain a first fused representation.

[0019] On the other hand, the present application also provides a data matching device, comprising:

[0020] An encoding module, used for encoding the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities;

[0021] a determination module, configured to combine the first modal representation and the second modal representation to obtain a hybrid modal representation, and determine an adaptive gating weight according to the hybrid modal representation;

[0022] a fusion module, configured to fuse the first modality representation and the mixed modality representation to obtain a first fused representation, and to fuse the second modality representation and the mixed modality representation to obtain a second fused representation, according to the gating weight;

[0023] A matching module is used to determine a matching degree between the first data and the second data according to the first fusion representation and the second fusion representation.

[0024] On the other hand, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0025] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above method when executed by a processor.

[0026] On the other hand, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.

[0027] The above-mentioned data matching method, device, computer equipment, storage medium and computer program product respectively encode the first data and the second data belonging to different modes to obtain the first modal representation and the second modal representation. Then, the first modal representation and the second modal representation are combined to obtain a mixed modal representation. According to the mixed modal representation, an adaptive gating weight can be obtained, and the gating weight is used to control the proportion of the first modal representation and the second modal representation when they are fused with the mixed modal representation, that is, information can be intelligently extracted from the single mode / mixed mode to obtain the first fusion representation and the second fusion representation. The first fusion representation and the second fusion representation obtained in this way can better highlight the relevant information of the first data and the second data, so it can be used to more accurately determine the matching degree between the first data and the second data, greatly improving the data processing effect. In particular, in the case where the first data and the second data are missing, by intelligently extracting information from the mixed mode, intelligently selecting the proportion of the extracted mixed modal information, and reconstructing the first fusion representation of the first data and the second fusion representation of the second data through multi-modal information, the missing information is compensated, the matching accuracy can be greatly improved, and the data processing performance is improved.

[0028] On the other hand, the present application provides a multimodal model processing method, the method comprising:

[0029] By using the initial model to be trained, encoding is performed based on the first sample data and the second sample data in the training sample pair, respectively, to obtain a first sample modality representation and a second sample modality representation; the first sample data and the second sample data are sample data of different modalities;

[0030] Obtaining a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through the initial model, and determining a prediction weight according to the mixed sample modality representation;

[0031] fusing the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and performing decoding based on the fused result to obtain a first prediction feature representation;

[0032] fusing the second sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and performing decoding based on the fused result to obtain a second prediction feature representation;

[0033] Determine a first loss based on the true feature representation of the first sample data and the first predicted feature representation, and the true feature representation of the second sample data and the second predicted feature representation;

[0034] Determining a second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weight;

[0035] A target loss function is constructed according to the first loss and the second loss, and the initial model to be trained is trained based on the target loss function, and a multimodal model is obtained after the training is completed.

[0036] In some embodiments, the step of obtaining a mixed sample modality representation by combining the initial model with the first sample modality representation and the second sample modality representation includes:

[0037] Performing multiple interactive fusions on the first sample modality representation and the second sample modality representation through the initial model to obtain a first mixed sample representation biased towards the first modality side and a second mixed sample representation biased towards the second modality side;

[0038] The first mixed sample representation and the second mixed sample representation are combined to obtain a mixed sample modality representation.

[0039] In some embodiments, the mixed sample modality representation includes a first mixed sample representation biased toward a first modality side and a second mixed sample representation biased toward a second modality side, and the prediction weight includes a first prediction weight determined according to the first mixed sample representation, and a second prediction weight determined according to the second mixed sample representation;

[0040] The determining of the second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weight, comprises:

[0041] Constructing a first vector based on the alignment labels of the first sample data and the second sample data;

[0042] Determine a target weight according to the average of the first prediction weight and the second prediction weight, and construct a third vector based on the target weight and the difference between the value one and the target weight;

[0043] A second loss is determined based on the first vector and the third vector.

[0044] On the other hand, the present application also provides a multimodal model processing device, comprising:

[0045] An encoding module, used to encode the first sample data and the second sample data in the training sample pair respectively through the initial model to be trained to obtain a first sample modal representation and a second sample modal representation; the first sample data and the second sample data are sample data of different modalities;

[0046] A determination module, configured to obtain a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through the initial model, and determine a prediction weight according to the mixed sample modality representation;

[0047] A fusion module, configured to fuse the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and perform decoding based on the fused result to obtain a first prediction feature representation;

[0048] The fusion module is further used to fuse the second sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and perform decoding based on the fused result to obtain a second prediction feature representation;

[0049] A construction module is used to determine a first loss based on the real feature representation of the first sample data and the first predicted feature representation, and the real feature representation of the second sample data and the second predicted feature representation; determine a second loss based on the alignment label of the first sample data and the second sample data, and the prediction weight; and construct a target loss function according to the first loss and the second loss;

[0050] The training module is used to train the initial model to be trained based on the target loss function, and obtain a multimodal model after the training is completed.

[0051] On the other hand, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0052] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above method when executed by a processor.

[0053] On the other hand, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.

[0054] The above-mentioned multimodal model processing method, device, computer equipment, storage medium and computer program product respectively encode the first sample data and the second sample data belonging to different modalities to obtain the first sample modal representation and the second sample modal representation. Then, the first sample modal representation and the second sample modal representation are combined to obtain a mixed sample modal representation, and a prediction weight can be obtained according to the mixed sample modal representation. The prediction weight is used to control the proportion of the first sample modal representation and the second sample modal representation when they are respectively fused with the mixed sample modal representation, that is, information can be intelligently extracted from the single modality / mixed modality for subsequent decoding. During training, on the one hand, the loss between the predicted feature representation and the true feature representation is taken into account, and on the other hand, the matching loss between sample data of different modalities (that is, the second loss) is taken into account. This allows the model to learn encoding and decoding capabilities that are closer to the true feature representation. It can also intelligently control the ratio of the referenced single-modal representation and mixed-modal representation during the encoding and decoding process, so that when the alignment quality of the training sample pairs is high, the mixed-modal information can be considered more during the decoding of the single modality; when the training sample pairs are not aligned, the single-modal information can be considered more during the decoding of the single modality. This can better handle the problem of modal content mismatch in the training data set and improve the processing performance of the multimodal model. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0056] FIG1 is a diagram of an application environment of a data matching method and / or a multimodal model processing method in one embodiment;

[0057] FIG2 is a schematic diagram of a flow chart of a multimodal model processing method in one embodiment;

[0058] FIG3 is a schematic diagram showing the principle of mask processing in one embodiment;

[0059] FIG4 is a schematic flow chart of a multimodal model processing method in another embodiment;

[0060] Figure 5 A schematic diagram of a flow chart of a data matching method in one embodiment;

[0061] FIG6 is a schematic flow chart of a data matching method in another embodiment;

[0062] Figure 7 is a structural block diagram of a multimodal model in one embodiment;

[0063] FIG8 is a structural block diagram of a data matching device in one embodiment;

[0064] FIG9 is a structural block diagram of a multimodal model processing device in one embodiment;

[0065] FIG. 10 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0067] The data matching method and / or multimodal model processing method provided in the embodiment of the present application can be applied in the application environment as shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal and the server can execute the data matching method and / or multimodal model processing method provided in the embodiment of the present application separately, or they can execute the data matching method and / or multimodal model processing method provided in the embodiment of the present application in collaboration. Take the case where a server independently executes the data matching method provided in the present application as an example: the server receives the first data and the second data sent by the terminal, and encodes the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities; the first modal representation and the second modal representation are combined to obtain a mixed modal representation, and an adaptive gating weight is determined according to the mixed modal representation; according to the gating weight, the first modal representation and the mixed modal representation are fused to obtain a first fused representation, and the second modal representation and the mixed modal representation are fused to obtain a second fused representation; according to the first fused representation and the second fused representation, the matching degree between the first data and the second data is determined. The server feeds back the matching degree to the terminal.

[0068] Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application is not limited here.

[0069] It should be noted that this application involves artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0070] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, pre-trained models are also called large models and basic models. After fine-tuning, they can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0071] This application involves machine learning, which is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithmic complexity theory and other disciplines. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching. The pre-trained model is the latest development in deep learning, which integrates the above technologies.

[0072] More specifically, the multimodal model mentioned in the embodiment of the present application can be a pre-trained model. Among them, the pre-training model (Pre-training model), also known as the cornerstone model or the large model, refers to a deep neural network (DNN) with a large number of parameters, which is trained on a large amount of unlabeled data, and the function approximation ability of the large-parameter DNN is used to enable PTM to extract common features from the data, and fine-tune (fine tune), parameter efficient fine-tuning (PEFT), prompt-tuning and other technologies, which are suitable for downstream tasks. Therefore, the pre-training model can achieve ideal results in a few-shot or zero-shot scenario. PTM can be divided into language models (ELMO, BERT, GPT), visual models (swin-transformer, ViT, V-MOE), speech models (VALL-E), multimodal models (ViBERT, CLIP, Flamingo, Gato), etc. according to the data modality processed, wherein the multimodal model refers to a model that establishes two or more data modality feature representations. Pre-trained models are an important tool for outputting artificial intelligence generated content (AIGC) and can also serve as a general interface for connecting multiple specific task models.

[0073] The solution provided in the embodiments of the present application involves artificial intelligence machine learning, large models and other technologies, which are specifically introduced in detail through the following embodiments.

[0074] Before introducing the data matching method and / or multimodal model processing method provided in this application, the relevant English abbreviations are explained first:

[0075] VLP: Vision-Language Pre-training, vision-language pre-training.

[0076] GIAE: Gated Interactive Masked AutoEncoders, gated interactive masked autoencoders.

[0077] GIM: Gated Interactive Mechanism, gated interactive mechanism.

[0078] MAE: Masked AutoEncoders, masked autoencoder.

[0079] Image-text mismatching issue: Image-text mismatching issue.

[0080] Transfomer: A neural network architecture based on the attention mechanism, which can effectively encode temporal information in the encoder part and is widely used in natural language processing, computer vision, machine translation, speech recognition and other fields.

[0081] LightVLP: a lightweight Vision-Language Pre-training framework, a lightweight vision-language pre-training model framework, which is also the multimodal model proposed in this application.

[0082] In the field of vision-language learning, in order to improve the practicality of the model, a general vision-language pre-training model, namely the VLP (Vision-Language Pre-training) model, is usually pre-trained, and the image and text processing is performed through the VLP model. In addition, in the actual business processing process, in order to adapt to the diverse tasks downstream, retraining can be performed on the basis of the VLP model to obtain a task model suitable for specific business scenarios. Therefore, how to train a high-performance VLP model is a project with very practical value.

[0083] Traditional VLP methods often face the following challenges: (1) The training process is very time-consuming because the text and image inputs are often very long; (2) The embedded information of different modalities is not effectively fused; (3) In the real world, many training image-text alignment data contain a lot of noise and need further processing.

[0084] In view of this, the present application proposes a multimodal model processing method, which can solve the above technical problems, optimize the multimodal information fusion method on the basis of improving the efficiency of the VLP model, and obtain better results. In addition, the multimodal model of the present application can better handle the modal data mismatch problem in the training data set during the training process, such as the image-text mismatch problem, thereby improving the processing performance of the model.

[0085] The following is an introduction to the training method of the multimodal model involved in this application:

[0086] In an exemplary embodiment, as shown in FIG2 , a multimodal model processing method is provided, which is described by taking the method applied to a computer device (such as a terminal or a server in FIG1 ) as an example, and includes the following steps 202 to 214. Among them:

[0087] Step 202, encoding the first sample data and the second sample data in the training sample pair respectively through the initial model to be trained to obtain a first sample modal representation and a second sample modal representation; the first sample data and the second sample data are sample data of different modalities.

[0088] The initial model is a pre-built neural network model, which becomes a multimodal model after training. The initial model in this application may include two encoders and decoders with a symmetrical relationship, two decoders with a symmetrical relationship, and a cross transformer for processing interactive information.

[0089] The training sample pair is a pre-constructed data pair for model training. The training sample pair includes a first sample data and a second sample data. The first sample data is data of the first modality, and the second sample data is data of the second modality, and the first modality is different from the second modality. Among them, the modality is a way of carrying information in a perceptual channel, such as visual, auditory, olfactory or tactile channels. The modality in this application may be at least one of a visual modality, a text modality, or an audio modality. For example, the first sample data may be image data, and the second sample data may be text data; or, the first sample data may be image data, and the second sample data may be audio data, etc., which is not limited in the embodiments of this application.

[0090] It should be noted that, to facilitate understanding, the data used and generated in the model training phase, and to distinguish them from the data used and generated in the model application phase, are named with the word "sample", such as the first sample data, the second sample data, etc.

[0091] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, the first sample data may be referred to as the second sample data, and similarly, the first data may be referred to as the second data.

[0092] Encoding is the process of mapping plaintext information to latent space through calculation. The present application can encode based on the first sample data through the first encoder in the initial model to be trained to obtain the first sample modal representation; and encode based on the second sample data through the second encoder in the initial model to obtain the second sample modal representation.

[0093] In some embodiments, the computer device may directly encode the first sample data to obtain the first sample modal representation, and directly encode the second sample data to obtain the second sample modal representation. In other embodiments, the computer device may perform mask processing on the first sample data, and then encode the masked first sample data through the first encoder in the initial model to obtain the first sample modal representation. The computer device may perform mask processing on the second sample data, and then encode the masked second sample data through the second encoder in the initial model to obtain the second sample modal representation.

[0094] For the convenience of description, the data input into the first encoder may be referred to as the first input sequence, and the data input into the second encoder may be referred to as the second input sequence. That is, the first input sequence may be the first sample data or the masked first sample data; the second input sequence may be the second sample data or the masked second sample data.

[0095] In some embodiments, the initial model to be trained encodes the first input sequence multiple times to obtain a first sample modality representation. The initial model to be trained encodes the second input sequence multiple times to obtain a second sample modality representation.

[0096] In some embodiments, the first encoder and the second encoder have the same network structure, so the encoding process performed on the first input sequence is the same as the encoding process performed on the second input sequence. Of course, in other embodiments, the first encoder and the second encoder may have different network structures, and the encoding process performed on the first input sequence is different from the encoding process performed on the second input sequence. This embodiment of the application does not limit this.

[0097] Take the first encoder and the second encoder having the same network structure as an example for explanation: for any encoding, such as the l+1th encoding, the output of the lth encoding can be obtained first, and the multi-head self-attention layer operation can be performed according to the output of the lth encoding. The multi-head self-attention layer operation result and the output of the lth encoding are combined and then the layer regularization operation is performed to obtain the intermediate processing features in the encoding process; the intermediate processing features in the encoding process are processed by the forward neural network, and the forward neural network processing result and the intermediate processing features in the encoding process are combined and then the layer regularization operation is performed to obtain the output of the l+1th encoding; l+1 is used as the new l, and the output of the lth encoding is obtained and continued to be executed until the last encoding process is completed, and the output of the last encoding is used as the first sample modal representation or the second sample modal representation. Wherein, l is a natural number greater than or equal to 0. When l is 0, the output of the lth encoding obtained is the first input sequence or the second input sequence.

[0098] In some embodiments, the computer device may perform multiple encodings on each input data in the first input sequence (when the first input sequence includes multiple data blocks, each input data is each data block) to obtain outputs corresponding to each input data, and concatenate the outputs corresponding to each input data in the last encoding to obtain the first sample modal representation. Similarly, the computer device may perform multiple encodings on each input data in the second input sequence to obtain outputs corresponding to each input data, and concatenate the outputs corresponding to each input data in the last encoding to obtain the second sample modal representation.

[0099] Exemplarily, the computer device may express the output of the (l+1)th encoding corresponding to any input data by Formula 1:

[0100] ; (Formula 1)

[0101] in, Represents the output of the l-th encoding, which can also be considered as the hidden feature of the l-th layer; Representation layer regularization operation, It means that the multi-head self-attention layer operation is performed through the encoder layer l network. Indicates processing by the forward neural network of the encoder's lth layer (specifically, it can be a two-layer fully connected network); That is, it is the intermediate processing feature in the encoding process. The encoder can be the first encoder or the second encoder.

[0102] Further, the computer device may express the first sample modality representation by the following formula 2:

[0103] ;(Formula 2)

[0104] in, represents the first data block in the first input sequence, represents the second data block in the first input sequence, represents the Mth data block (that is, the last data block) in the first input sequence; represents the latent features corresponding to the first data block output by the last encoding layer of the first encoder, represents the latent features corresponding to the second data block output by the last encoding layer of the first encoder, Represents the hidden features corresponding to the Mth data block output by the last encoding layer of the first encoder.

[0105] Further, the computer device may express the second sample modality representation by the following formula 3:

[0106] ;(Formula 3)

[0107] in, represents the first data block in the second input sequence, represents the second data block in the second input sequence, represents the Nth data block in the second input sequence (that is, the last data block); represents the latent features corresponding to the first data block output by the last encoding layer of the second encoder, represents the latent features corresponding to the second data block output by the last encoding layer of the second encoder, Represents the latent features corresponding to the Nth data block output by the last encoding layer of the second encoder.

[0108] In some embodiments, the first encoder and / or the second encoder are composed of a recurrent neural network, a convolutional neural network, or a graph neural network. In practical applications, more or fewer network layers can be designed according to actual needs, and the embodiments of the present application are not limited to this. In some embodiments, the first encoder and / or the second encoder can be a Transformers structure.

[0109] Step 204: obtain a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through the initial model, and determine a prediction weight according to the mixed sample modality representation.

[0110] It should be noted that when the alignment quality of the first sample data and the second sample data in a training sample pair is high, more mixed modal information can be considered during unimodal decoding; when the first sample data and the second sample data have relatively large noise (such as image-text mismatch), more unimodal information can be considered during unimodal decoding. Based on this consideration, this application designs a gated interaction mechanism to control the ratio of reference unimodal representation and mixed modal representation during decoding, that is, dynamically adjust the reference ratio through gated weights.

[0111] Specifically, the initial model can fuse the first sample modal representation and the second sample modal representation through a cross transformer structure to obtain a mixed sample modal representation, and then perform a numerical transformation on the mixed modal sample representation to obtain a prediction weight.

[0112] In some embodiments, the computer device may directly perform addition or multiplication operations on the first sample modal representation and the second sample modal representation to obtain a mixed sample modal representation. In other embodiments, the computer device may also perform an attention operation on the first sample modal representation and the second sample modal representation to obtain a mixed sample modal representation. In other embodiments, the computer device may also use more complex operations, such as performing matrix addition or multiplication after attention mechanism processing, and then performing linear / nonlinear changes to obtain a mixed sample modal representation, etc. This application does not limit the specific fusion method.

[0113] Furthermore, after the initial model combines the first sample modality representation and the second sample modality representation to obtain a mixed sample modality representation, the mixed sample modality representation can be linearly changed and then activated to obtain a prediction weight, that is, the mixed sample modality is converted into a numerical value, which is also the prediction weight.

[0114] Step 206: The first sample modality representation and the mixed sample modality representation are fused according to the prediction weights through the initial model, and decoding is performed based on the fused result to obtain a first prediction feature representation.

[0115] Specifically, the initial model may perform weighted processing on the first sample modality representation and the mixed sample modality representation according to the prediction weight, and perform decoding based on the result obtained by the weighted processing to obtain the first prediction feature representation.

[0116] In some embodiments, the computer device may use the prediction weight as the weight of any one of the first sample modality representation and the mixed sample modality representation, and perform weighted sum processing on the first sample modality representation and the mixed sample modality representation.

[0117] In some embodiments, the computer device may use the predicted weight as the weight of any one of the first sample modality representation and the mixed sample modality representation, and use the difference between the value one and the predicted weight as the weight of the other representation, and perform weighted summation processing on the first sample modality representation and the mixed sample modality representation.

[0118] In some embodiments, the first sample modal representation and the mixed sample modal representation are fused according to the predicted weight, including: taking the predicted weight as the coefficient of the mixed sample modal representation, and taking the difference between the value one and the predicted weight as the coefficient of the first sample modal representation; and performing weighted processing on the mixed sample modal representation and the first sample modal representation according to the coefficient of the mixed sample modal representation and the coefficient of the first sample modal representation to obtain a first fused sample representation.

[0119] Specifically, the initial model may perform weighted summation of the mixed sample modal representation and the first sample modal representation according to the coefficients of the mixed sample modal representation and the coefficients of the first sample modal representation to obtain a first fused sample representation. Exemplarily, the computer device may calculate the first fused sample representation using the following formula 4:

[0120] ;(Formula 4)

[0121] Among them, p is the prediction weight, is the first sample mode representation, and S is the mixed sample mode representation.

[0122] In the above embodiment, by fusion of the mixed sample modality representation and the first sample modality through prediction weights, the ratio of the single modality representation and the mixed modality representation can be flexibly referenced according to the alignment quality of the two modal data, so that the fused representation can better express the information of the single modality data.

[0123] Furthermore, the initial model may be decoded based on the first fused sample representation to obtain a first prediction feature representation. The specific decoding method may be a traditional decoding method.

[0124] In some embodiments, the initial model encodes the masked data of the first sample data, and some data blocks are randomly discarded in the process of masking the first sample data. Therefore, when decoding, the mask embedding can be inserted into the first fused sample representation according to the position of the discarded data block in the first sample data, wherein the mask embedding can be a preset feature representation, such as a feature representation composed of preset values ​​(preset values ​​such as 0 or 1). Then, the first decoder in the initial model can decode the first fused sample representation after the mask embedding is inserted to obtain a first predicted feature representation. The first predicted feature representation represents the hidden features of the discarded data block.

[0125] Step 208: The second sample modality representation and the mixed sample modality representation are fused according to the prediction weights through the initial model, and decoding is performed based on the fused result to obtain a second prediction feature representation.

[0126] Specifically, the initial model may perform weighted processing on the second sample modality representation and the mixed sample modality representation according to the prediction weight, and perform decoding based on the result obtained by the weighted processing to obtain the second prediction feature representation.

[0127] In some embodiments, the computer device may use the prediction weight as the weight of any one of the second sample modality representation and the mixed sample modality representation, and perform weighted sum processing on the second sample modality representation and the mixed sample modality representation.

[0128] In some embodiments, the computer device may use the predicted weight as the weight of any one of the second sample modality representation and the mixed sample modality representation, use the difference between the value one and the predicted weight as the weight of the other representation, and perform weighted summation processing on the second sample modality representation and the mixed sample modality representation.

[0129] In some embodiments, the second sample modal representation and the mixed sample modal representation are fused according to the predicted weight, including: taking the predicted weight as the coefficient of the mixed sample modal representation, and taking the difference between the value one and the predicted weight as the coefficient of the second sample modal representation; and performing weighted processing on the mixed sample modal representation and the second sample modal representation according to the coefficient of the mixed sample modal representation and the coefficient of the second sample modal representation to obtain a second fused sample representation.

[0130] Specifically, the initial model may perform weighted summation of the mixed sample modal representation and the second sample modal representation according to the coefficients of the mixed sample modal representation and the coefficients of the second sample modal representation to obtain the second fused sample representation. Exemplarily, the computer device may calculate the second fused sample representation using the following formula 5:

[0131] ;(Formula 5)

[0132] Among them, p is the prediction weight, is the second sample modality representation, and S is the mixed sample modality representation.

[0133] In the above embodiment, by fusion of the mixed sample modality representation and the second sample modality through prediction weights, the ratio of the single modality representation and the mixed modality representation can be flexibly referenced according to the alignment quality of the two modality data, so that the fused representation can better express the information of the single modality data.

[0134] Furthermore, the initial model can be decoded based on the second fused sample representation to obtain a second prediction feature representation. The specific decoding method can be a traditional decoding method.

[0135] In some embodiments, the initial model encodes the masked data of the second sample data, and some data blocks are randomly discarded during the masking process of the second sample data. Therefore, when decoding, the mask embedding can be inserted into the second fused sample representation according to the position of the discarded data block in the second sample data, wherein the mask embedding can be a preset feature representation, such as a feature representation composed of preset values ​​(preset values ​​such as 0 or 1). Then, the second decoder in the initial model can decode the second fused sample representation after the mask embedding is inserted to obtain a second predicted feature representation. The second predicted feature representation represents the hidden features of the discarded data block.

[0136] Step 210: Determine a first loss based on the true feature representation and the first predicted feature representation of the first sample data, and the true feature representation and the second predicted feature representation of the second sample data.

[0137] Specifically, the computer device may extract the real feature representation of the first sample data, and then calculate the difference between the real feature representation of the first sample data and the first predicted feature representation, and use the difference as the first modal loss. The computer device may extract the real feature representation of the second sample data, and then calculate the difference between the real feature representation of the second sample data and the second predicted feature representation, and use the difference as the second modal loss. The first loss is determined based on the first modal loss and the second modal loss. The difference can be represented by a difference, a comparison value, or a quotient.

[0138] In some embodiments, the true characteristic representation of the first sample data involved in the loss calculation may specifically be the true characteristic representation of some data blocks discarded from the first sample data before encoding; the true characteristic representation of the second sample data involved in the loss calculation may specifically be the true characteristic representation of some data blocks discarded from the second sample data before encoding.

[0139] In other embodiments, the true feature representation of the first sample data involved in the loss calculation may also be the true feature representation of all data blocks in the first sample data; the true feature representation of the second sample data involved in the loss calculation may also be the true feature representation of all data blocks in the second sample data.

[0140] In some embodiments, the computer device may extract the true feature representation of the first sample data and the true feature representation of the second sample data through other trained codecs.

[0141] In some embodiments, when the first sample data is image data, the difference between the true feature representation of the first sample data and the first predicted feature representation can be measured by MSE (Mean Square Error) loss; when the second sample data is text data, the difference between the true feature representation of the second sample data and the second predicted feature representation can be measured by CE (Cross-Entropy) loss.

[0142] In some embodiments, the computer device may use the average of the differences between the true feature representations of multiple first sample data and the first predicted feature representation as the first modal loss; and use the average of the differences between the true feature representations of multiple second sample data and the second predicted feature representation as the second modal loss.

[0143] Exemplarily, the computer device may calculate the first modal loss by the following formula:

[0144] ;(Formula 6)

[0145] Among them, among them, represents the set consisting of the first sample data in the training sample set, is the number of first sample data in the set consisting of the first sample data, represents the average error function, Represents the first prediction feature representation of the mth first sample data, Represents the true feature representation of the mth first sample data.

[0146] Exemplarily, the computer device may calculate the second modal loss by the following formula:

[0147] ;(Formula 7)

[0148] in, represents the set consisting of the second sample data in the training sample set, is the number of second sample data in the set consisting of the second sample data, represents the cross entropy function, Represents the second prediction feature representation of the mth second sample data, Represents the true feature representation of the mth second sample data.

[0149] In some embodiments, the computer device may use the sum of the first modal loss and the second modal loss as the first loss, or use the average of the first modal loss and the second modal loss as the first loss, or use the product of the first modal loss and the second modal loss as the first loss, etc., which is not limited in the embodiments of the present application.

[0150] Step 212: Determine a second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weights.

[0151] The alignment tag is a tag indicating whether the first sample data and the second sample data are aligned. If the first sample data and the second sample data are aligned, it indicates that the contents of the first sample data and the second sample data are matched; if the first sample data and the second sample data are not aligned, it indicates that the contents of the first sample data and the second sample data are not matched. For example, if the first sample data is image data and the second sample data is text data, alignment indicates that the image and text are consistent, and misalignment indicates that the image and text are inconsistent.

[0152] It can be understood that when the first sample data and the second sample data are aligned data, it means that the contents of the first sample data and the second sample data are matched, so when decoding, more reference can be made to the mixed sample modal representation, that is, the proportion of the mixed sample modal representation is controlled to be larger.

[0153] In some embodiments, the computer device may set the alignment label to 1 or 0, where 1 indicates alignment and 0 indicates misalignment. Then, the second loss is determined based on the difference between the alignment label and the predicted weight, for example, the second weight may be determined based on the difference between the alignment label and the predicted weight.

[0154] In some embodiments, based on the alignment labels of the first sample data and the second sample data, and the prediction weights, determining the second loss includes: constructing a first vector based on the alignment labels of the first sample data and the second sample data; constructing a second vector according to the prediction weights and the difference between the numerical value one and the prediction weights; and determining the second loss based on the first vector and the second vector.

[0155] Specifically, the computer device may construct a first vector based on the alignment tags of the first sample data and the second sample data. Specifically, the value of the alignment tag and the difference between 1 and the value may be used as a two-dimensional vector, namely, the first vector. For example, when the alignment tag is 1, the constructed first vector is [0,1]; when the alignment tag is 0, the constructed first vector is [1,0].

[0156] The computer device may construct a second vector using the predicted weight and the difference between the value 1 and the predicted weight, such as [1-p, p], where p is the predicted weight.

[0157] Furthermore, the computer device may determine the second loss according to the cross entropy of the first vector and the second vector. Exemplarily, the computer device may determine the second loss by the following formula:

[0158] L ITM = f CE ( y itm ,[1-p,p]) ;(Formula 8)

[0159] in, represents the first vector, p is the prediction weight, represents the cross entropy function.

[0160] In the above embodiment, the second loss is determined based on the alignment labels of the first sample data and the second sample data, and the prediction weight, so that the prediction weight learned by the model through training is positively correlated with the alignment degree of the input data. That is, the higher the alignment quality of the input data, the greater the predicted weight, and the proportion of the mixed modal representation can be dynamically controlled to increase.

[0161] Step 214, constructing a target loss function according to the first loss and the second loss, and training the initial model to be trained based on the target loss function, and obtaining a multimodal model after the training is completed.

[0162] Specifically, the computer device may perform weighted summation processing on the first loss and the second loss to construct a target loss function, wherein the weighted coefficient may be 1 or other pre-set values, which is not limited in the embodiment of the present application.

[0163] Exemplarily, the computer device may construct the target loss function by the following formula:

[0164] ;(Formula 9)

[0165] in, represents the first modal loss in the first loss, represents the second modal loss in the first loss, Indicates the second loss.

[0166] Furthermore, the computer device can input multiple training sample pairs into the initial model in batches for processing, and adjust the model weights of the initial model through the target loss function to train the initial model. Stop when the training stop condition is reached to obtain a trained multimodal model. Among them, the training stop condition can specifically be reaching a preset number of iterations, reaching a preset training time, or the model performance reaches a preset performance, or the change in model prediction accuracy is less than a preset change, etc., which is not limited in the embodiments of the present application.

[0167] The above multimodal model processing method encodes the first sample data and the second sample data belonging to different modalities respectively to obtain the first sample modal representation and the second sample modal representation. Then, the first sample modal representation and the second sample modal representation are combined to obtain a mixed sample modal representation, and a prediction weight can be obtained according to the mixed sample modal representation. The prediction weight is used to control the proportion of the first sample modal representation and the second sample modal representation when they are fused with the mixed sample modal representation, that is, information can be intelligently extracted from the single modality / mixed modality for subsequent decoding. During training, on the one hand, the loss between the predicted feature representation and the true feature representation is taken into account, and on the other hand, the matching loss between sample data of different modalities (that is, the second loss) is taken into account. This allows the model to learn encoding and decoding capabilities that are closer to the true feature representation, and can also intelligently control the ratio of the referenced single modal representation and mixed modal representation during the encoding and decoding process, so that when the alignment quality of the training sample pairs is high, the mixed modal information can be considered more during the decoding of the single modality; when the training sample pairs are not aligned, the single modal information can be considered more during the decoding of the single modality. This can better handle the problem of modal content mismatch in the training data set and improve the processing performance of the multimodal model.

[0168] In some embodiments, before encoding the first sample data and the second sample data in the training sample pair, the method further includes: obtaining a training sample pair, the training sample pair including the first sample data and the second sample data; splitting the first sample data to obtain a plurality of first data blocks, splitting the second sample data to obtain a plurality of second data blocks, extracting some data blocks from the plurality of first data blocks to form a first input sequence, and extracting some data blocks from the plurality of second data blocks to form a second input sequence. Encoding the first sample data and the second sample data in the training sample pair to obtain a first sample modal representation and a second sample modal representation includes: encoding the first input sequence multiple times to obtain a first modal representation, and encoding the second input sequence multiple times to obtain a second modal representation.

[0169] Specifically, the computer device can perform model training on the initial model through the training sample pairs. During the training process, the first sample data and the second sample data in the training sample pairs can be directly processed, or the first sample data and the second sample data can be masked before being input into the initial model.

[0170] In some embodiments, the computer device may split the first sample data into multiple first data blocks, and split the second sample data into multiple second data blocks. Then, according to a certain ratio, some data blocks are extracted from the multiple first data blocks to form a first input sequence, and some data blocks are extracted from the multiple second data blocks to form a second input sequence. The first input sequence is input into one of the encoders of the initial model, and the second input sequence is input into another encoder of the initial model.

[0171] In some embodiments, for a plurality of first data blocks of the first sample data, the computer device may randomly mask a certain proportion of the first data blocks, and form the remaining first data blocks into a first input sequence. For a plurality of second data blocks of the second sample data, the computer device may randomly mask a certain proportion of the second data blocks, and form the remaining second data blocks into a second input sequence.

[0172] Exemplarily, the initial model uses two separate autoencoders to model different modal information. For one of the modalities, such as image data, the computer device can randomly mask a certain proportion (such as 50%) of patches, and then the remaining patches form an input sequence, which is input into the autoencoder corresponding to the image data to obtain an image representation.

[0173] In some embodiments, taking the first modality as an image modality and the second modality as a text modality as an example, LightVLP (i.e., the multimodal model of the present application) includes two autoencoders, which process image information and text information respectively. In order to improve the efficiency of the model, the present application introduces a masked autoencoder strategy, which removes the masked token (masked feature) from the sequences obtained by masking the sample data of the two modalities and then inputs them into their respective autoencoders.

[0174] For ease of understanding, please refer to Figure 3, which is a schematic diagram of a masking strategy in an embodiment. Taking the sample data (x1, x2, x3, x4, x5, x6) as an example, in the traditional masking strategy, referring to part A in Figure 3, some of the data blocks, such as x2, x4 and x5, are usually randomly masked to become mask features, such as by replacing them with 0 or 1. Then the sequence including the mask features is input as an input sequence to the encoder for processing. The masking strategy in the present application is to refer to part B in Figure 3, and randomly mask some of the data blocks, such as x2, x4 and x5, to become mask features, such as by replacing them with 0 or 1. Then the sequence after removing the mask features is input as an input sequence to the encoder for processing. Further, after the input sequence is encoded by the encoder, the corresponding modal representation (e1, e3, e6) is obtained, and then the mask feature is inserted into the modal representation for decoding. In the above embodiment, a mask encoding strategy is introduced in the process of processing data of different modalities. For each modality of data, part of the data blocks are extracted to form an input sequence. This can greatly reduce the amount of data in the encoding process of the model and improve the model processing efficiency, especially in the training stage, which can effectively improve the model training efficiency.

[0175] In some embodiments, a mixed sample modality representation is obtained by combining the first sample modality representation and the second sample modality representation through an initial model, including: performing multiple interactive fusions of the first sample modality representation and the second sample modality representation through the initial model to obtain a first mixed sample representation biased towards the first modality side and a second mixed sample representation biased towards the second modality side; combining the first mixed sample representation and the second mixed sample representation to obtain a mixed sample modality representation.

[0176] Specifically, in the process of fusing the first sample modal representation and the second sample modal representation, the initial model can perform multiple fusions through a multi-layer neural network to obtain a first mixed sample representation biased towards the first modal side and a second mixed sample representation biased towards the second modal side. Each time the interactive fusion is performed, the second intermediate mixed sample representation can be fused into the first intermediate mixed sample representation based on the attention mechanism to obtain the first intermediate mixed sample representation biased towards the first modal side. The first intermediate mixed sample representation is fused into the second intermediate mixed sample representation based on the attention mechanism to obtain the second intermediate mixed sample representation biased towards the second modal side. In this way, the first intermediate mixed sample representation output by the last layer of the neural network is the first mixed sample representation, and the second intermediate mixed sample representation output by the last layer of the neural network is the second mixed sample representation.

[0177] Furthermore, the initial model may fuse the first mixed sample representation and the second mixed sample representation to obtain a mixed sample modality representation, for example, by weighted summation, or by concat (connection), or by splicing, etc., which is not limited in the present embodiment of the application.

[0178] In the above embodiment, the first sample modal representation and the second sample modal representation are interactively fused multiple times through the initial model, so that a first mixed sample representation biased towards the first modal side and a second mixed sample representation biased towards the second modal side can be obtained, and the relationship information between the first sample data and the second sample data can be fully extracted, and then the first mixed sample representation and the second mixed sample representation are combined to obtain a mixed sample modal representation.

[0179] In some embodiments, the first sample modal representation and the second sample modal representation are interactively fused multiple times through the initial model to obtain a first mixed sample representation biased towards the first modal side and a second mixed sample representation biased towards the second modal side, including: when performing the i+1th interactive fusion, obtaining the first intermediate mixed sample representation and the second intermediate mixed sample representation outputted by the i-th interactive fusion; fusing the second intermediate mixed sample representation into the first intermediate mixed sample representation to obtain the first intermediate mixed sample representation of the i+1th interactive fusion; fusing the first intermediate mixed sample representation into the second intermediate mixed sample representation to obtain the second intermediate mixed sample representation of the i+1th interactive fusion. ; Take i+1 as the new i, and return to the first intermediate mixed sample representation and the second intermediate mixed sample representation obtained by the i-th interactive fusion when performing the i+1-th interactive fusion, and continue to execute until the stopping condition is reached; take the first intermediate mixed sample representation output by the last interactive fusion as the first mixed sample representation, and take the second intermediate mixed sample representation output by the last interactive fusion as the second mixed sample representation; wherein, i is a natural number greater than or equal to 0. When i is 0, the first intermediate mixed representation output by the i-th interactive fusion obtained is the first sample modal representation, and the second intermediate mixed representation output by the i-th interactive fusion obtained is the second sample modal representation.

[0180] Specifically, for the first interactive fusion, the initial model can fuse the second sample modal representation into the first sample modal representation based on the attention mechanism to obtain a first intermediate mixed sample representation, and fuse the first sample modal representation into the second sample modal representation based on the attention mechanism to obtain a second intermediate mixed sample representation.

[0181] For the second interactive fusion, the initial model can fuse the second intermediate mixed sample representation obtained by the first interactive fusion into the first intermediate mixed sample representation based on the attention mechanism to obtain a new first intermediate mixed sample representation. Based on the attention mechanism, the first intermediate mixed sample representation obtained by the first interactive fusion is fused into the second intermediate mixed sample representation to obtain a new second intermediate mixed sample representation.

[0182] In this way, during each interactive fusion process, the interactive fusion of the current time is continuously performed according to the output of the previous interactive fusion until the last interactive fusion. The initial model can directly output the first intermediate mixed sample representation and the second intermediate mixed sample representation obtained by the last interactive fusion. The first intermediate mixed sample representation output this time is the first mixed sample representation, and the second intermediate mixed sample representation output this time is the second mixed sample representation.

[0183] In the above embodiment, after the first sample modality representation and the second sample modality representation are fused, the next interactive fusion is continuously performed based on the previous output through an iterative cycle, so that the information obtained from each fusion can be better utilized, making the information fusion more complete.

[0184] In some embodiments, the second intermediate mixed sample representation is fused into the first intermediate mixed sample representation to obtain the first intermediate mixed sample representation of the i+1th interactive fusion, including: performing an attention operation based on the first intermediate mixed sample representation and the second intermediate mixed sample representation output by the i-th interactive fusion, combining the attention operation result with the first intermediate mixed sample representation output by the i-th interactive fusion, and performing a layer regularization operation to obtain a first intermediate sample processing feature; performing a forward neural network processing on the first intermediate sample processing feature, combining the forward neural network processing result with the first intermediate sample processing feature, and performing a layer regularization operation to obtain the first intermediate mixed sample representation of the i+1th interactive fusion.

[0185] Specifically, when the attention operation result and the first intermediate mixed sample representation outputted by the i-th interactive fusion are combined and then a layer regularization operation is performed, the attention operation result and the first intermediate mixed sample representation outputted by the i-th interactive fusion are combined in a manner that can be addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application. When the feedforward neural network processing result and the first intermediate sample processing feature are combined and then a layer regularization operation is performed, the feedforward neural network processing result and the first intermediate sample processing feature are combined in a manner that can be addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application.

[0186] Exemplarily, the computer device may determine the first intermediate mixed sample representation of the (i+1)th interactive fusion by the following formula:

[0187] ;(Formula 10)

[0188] ;(Formula 11)

[0189] in, is the first intermediate mixed sample representation obtained by the i-th interactive fusion, is the second intermediate mixed sample representation obtained by the i-th interactive fusion, is the classic attention calculation formula, which is is the Q value, Attention processing for K and V values, is a normalization function. Representation layer regularization operation, It represents the processing by the i-th layer of the feedforward neural network (specifically, it can be a two-layer fully connected network) of the interactive transformation structure.

[0190] In the above embodiment, the interactive fusion processing method based on the attention mechanism can better fuse the second intermediate mixed representation into the first intermediate mixed representation. Moreover, through such a stacked fusion design, the problem of gradient explosion can be prevented during model training.

[0191] In some embodiments, the first intermediate mixed sample representation is fused into the second intermediate mixed sample representation to obtain the second intermediate mixed sample representation of the i+1th interactive fusion, including: performing an attention operation on the second intermediate mixed sample representation output by the i-th interactive fusion and the first intermediate mixed sample representation, combining the attention operation result with the second intermediate mixed sample representation output by the i-th interactive fusion and performing a layer regularization operation to obtain a second intermediate sample processing feature; performing a forward neural network processing on the second intermediate sample processing feature, combining the forward neural network processing result with the second intermediate sample processing feature and performing a layer regularization operation to obtain the second intermediate mixed sample representation of the i+1th interactive fusion.

[0192] Specifically, when the attention operation result and the second intermediate mixed sample representation output by the i-th interactive fusion are combined and then a layer regularization operation is performed, the attention operation result and the second intermediate mixed sample representation output by the i-th interactive fusion can be combined by addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application. When the feedforward neural network processing result and the second intermediate sample processing feature are combined and then a layer regularization operation is performed, the feedforward neural network processing result and the second intermediate sample processing feature can be combined by addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application.

[0193] Exemplarily, the computer device may determine the second intermediate mixed sample representation of the (i+1)th interactive fusion by the following formula:

[0194] ;(Formula 12)

[0195] ;(Formula 13)

[0196] in, is the first intermediate mixed sample representation obtained by the i-th interactive fusion, is the second intermediate mixed sample representation of the i-th interactive fusion, is the classic attention calculation formula, which is is the Q value, Attention processing for K and V values, is a normalization function. Representation layer regularization operation, It represents the processing by the i-th layer of the feedforward neural network (specifically, it can be a two-layer fully connected network) of the interactive transformation structure.

[0197] In the above embodiment, the interactive fusion processing method based on the attention mechanism can better fuse the first intermediate mixed representation into the second intermediate mixed representation. Moreover, through such a stacked fusion design, the problem of gradient explosion can be prevented during model training.

[0198] In some embodiments, referring to FIG4 , the multimodal model processing method includes the following steps:

[0199] Step 402, encoding the first sample data and the second sample data in the training sample pair respectively through the initial model to be trained to obtain the first sample modality representation and the second sample modality representation; the first sample data and the second sample data are sample data of different modalities.

[0200] Step 404 , combining the first sample modality representation and the second sample modality representation through the initial model to obtain a first mixed sample representation biased towards the first modality side and a second mixed sample representation biased towards the second modality side.

[0201] Specifically, the first sample modality representation and the second sample modality representation are interactively fused multiple times through the initial model to obtain a first mixed sample representation biased towards the first modality side and a second mixed sample representation biased towards the second modality side. For details on the method of performing multiple interactive fusions, please refer to the description of the aforementioned related embodiments.

[0202] Step 406: determine a first prediction weight according to the first mixed sample representation, and determine a second prediction weight according to the second mixed sample representation.

[0203] Specifically, the initial model may perform a linear transformation on the first mixed sample representation and then perform an activation process to obtain a first prediction weight; and perform a linear transformation on the second mixed sample representation and then perform an activation process to obtain a second prediction weight.

[0204] Step 408: The first sample modality representation and the first mixed sample representation are fused according to the first prediction weight through the initial model, and decoding is performed based on the fused result to obtain a first prediction feature representation.

[0205] Specifically, the initial model may use the first prediction weight as the coefficient of the first mixed sample representation, and the difference between the value one and the first prediction weight as the coefficient of the first sample modal representation; according to the coefficient of the first mixed sample representation and the coefficient of the first sample modal representation, the first mixed sample representation and the first sample modal representation are weightedly summed, and then decoded based on the result of the weighted summation to obtain the first prediction feature representation.

[0206] Step 410: fuse the second sample modality representation and the second mixed sample representation through the initial model according to the second prediction weight, and decode based on the fused result to obtain a second prediction feature representation.

[0207] Specifically, the initial model may use the second prediction weight as the coefficient of the second mixed sample representation, and use the difference between the value one and the second prediction weight as the coefficient of the second sample modal representation; according to the coefficient of the second mixed sample representation and the coefficient of the second sample modal representation, the second mixed sample representation and the second sample modal representation are weightedly summed, and then decoded based on the result of the weighted summation to obtain the second prediction feature representation.

[0208] Step 412: Determine a first loss based on the true feature representation and the first predicted feature representation of the first sample data, and the true feature representation and the second predicted feature representation of the second sample data.

[0209] Step 414: determine a second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weights.

[0210] Step 416, constructing a target loss function according to the first loss and the second loss, and training the initial model to be trained based on the target loss function, and obtaining a multimodal model after the training is completed.

[0211] In the above embodiment, for the first modality, the initial model will use the first sample modality as the main information, and at the same time integrate the information represented by the second sample modality to obtain the first mixed sample representation, and then determine the prediction weight of the first modality side according to the first mixed sample representation, that is, the first prediction weight. In this way, the proportion of the single modality information and the mixed modality information referenced when decoding the first modality side can be controlled according to the first prediction weight. For the second modality, the initial model will use the second sample modality as the main information, and at the same time integrate the information represented by the first sample modality to obtain the second mixed sample representation, and then determine the prediction weight of the first modality side according to the second mixed sample representation, that is, the second prediction weight. In this way, the proportion of the single modality information and the mixed modality information referenced when decoding the second modality side can be controlled according to the second prediction weight. In this way, different modality sides can be more flexible and adaptive when fusing mixed modality information.

[0212] In some embodiments, the mixed sample modality representation includes a first mixed sample representation biased toward the first modality side and a second mixed sample representation biased toward the second modality side, and the prediction weight includes a first prediction weight determined according to the first mixed sample representation and a second prediction weight determined according to the second mixed sample representation. Based on the alignment labels of the first sample data and the second sample data, and the prediction weights, the second loss is determined, including: constructing a first vector based on the alignment labels of the first sample data and the second sample data; determining a target weight based on the mean of the first prediction weight and the second prediction weight, constructing a third vector based on the target weight and the difference between the value one and the target weight; and determining the second loss based on the first vector and the third vector.

[0213] As mentioned above, for different modalities, the initial model will generate a prediction loss that is compatible with the modality. Then, during the model training process, the average of the first prediction loss and the second prediction loss can be used as the target loss, and the second loss can be determined based on the target loss and the alignment label.

[0214] Specifically, the computer device may construct a first vector based on the alignment tags of the first sample data and the second sample data. Specifically, the value of the alignment tag and the difference between 1 and the value may be used as a two-dimensional vector, namely, the first vector. For example, when the alignment tag is 1, the constructed first vector is [0,1]; when the alignment tag is 0, the constructed first vector is [1,0].

[0215] The computer device may construct a second vector using the target weight and the difference between the value 1 and the target weight, such as [1-p, p], where p is the target weight. Furthermore, the computer device may determine the second loss based on the cross entropy of the first vector and the second vector.

[0216] In the above embodiment, the second loss is determined based on the alignment labels of the first sample data and the second sample data, and the mean of the first prediction weight and the second prediction weight, so that the two prediction weights learned by the model through training are positively correlated with the alignment degree of the input data. That is, when the alignment quality of the input data is higher, the two predicted weights are larger, and the proportion of the mixed modal representation can be dynamically controlled to increase.

[0217] In some embodiments, the method further includes constructing a third loss, the step of constructing the third loss including: determining the correlation between the first sample data and the second sample data according to the first sample modality representation and the second sample modality representation; determining the third loss based on the alignment label of the first sample data and the second sample data, and the correlation between the first sample data and the second sample data. Constructing a target loss function according to the first loss and the second loss includes: constructing a target loss function according to the first loss, the second loss, and the third loss.

[0218] In some embodiments, in order to align representations of different modalities, the present application introduces contrastive loss, that is, the third loss. By adding the third loss to the target loss for learning, the model can compensate for the performance impact caused by the data misalignment of training sample pairs during the training process.

[0219] Specifically, the computer device may obtain a first sample modality representation output by the first encoder and a second sample modality representation output by the second encoder, and then input the first sample modality representation into a linear layer and a regularization layer to obtain a first conversion representation, and input the second sample modality representation into a linear layer and a regularization layer to obtain a second conversion representation.

[0220] Exemplarily, the computer device may calculate the first conversion representation by the following formula:

[0221] ;(Formula 14)

[0222] in, represents the regularization process, represents the linearization process, Represents the first sample modal representation.

[0223] Exemplarily, the computer device may calculate the second conversion representation by the following formula:

[0224] ;(Formula 15)

[0225] in, represents the regularization process, represents the linearization process, Represents the second sample modal representation.

[0226] Furthermore, the computer device may determine the correlation between the first sample data and the second sample data according to the first conversion representation and the second conversion representation. For example, the similarity between the first conversion representation and the second conversion representation may be calculated, and the similarity may be used as the correlation between the first sample data and the second sample data. The similarity may specifically be cosine similarity or distance similarity, etc., which is not limited in the embodiments of the present application.

[0227] Next, the computer device can determine the third loss based on the alignment labels of the first sample data and the second sample data, and the difference between the correlation between the first sample data and the second sample data. Specifically, the cross entropy between the alignment labels and the correlation can be calculated, and the cross entropy is used as the third loss.

[0228] Further, the computer device may construct a target loss function according to the first loss, the second loss, and the third loss, for example, by summing the first loss, the second loss, and the third loss to construct the target loss function. Exemplarily, the computer device may construct the target loss function by the following formula:

[0229] ;(Formula 16)

[0230] in, represents the first modal loss in the first loss, represents the second modal loss in the first loss, represents the second loss, Indicates the third loss.

[0231] In the above embodiment, the contrast loss is introduced in the model training process, which can guide the model to learn the ability to distinguish whether the representations of different modalities are aligned.

[0232] In some embodiments, the correlation between the first sample data and the second sample data includes: the correlation between the first sample data and the second sample data, and the correlation between the second sample data and the first sample data. According to the first sample modal representation and the second sample modal representation, determining the correlation between the first sample data and the second sample data includes: determining a preset number of third sample data with the same modality as the first sample data, and a preset number of fourth sample data with the same modality as the second sample data; calculating the correlation between the first sample data and the second sample data according to the first sample modal representation, the second sample modal representation, and the sample modal representation of each fourth sample data; calculating the correlation between the second sample data and the first sample data according to the first sample modal representation, the second sample modal representation, and the sample modal representation of each third sample data.

[0233] When calculating the correlation between the first sample data and the second sample data, the correlation of the first sample data with respect to the second sample data and the correlation of the second sample data with respect to the first sample data may be calculated respectively.

[0234] Specifically, the computer device performs linear processing and regularization processing on the first sample modal representation to obtain a first conversion representation, performs linear processing and regularization processing on the second sample modal representation to obtain a second conversion representation, performs linear processing and regularization processing on the third sample modal representation to obtain a third conversion representation, and performs linear processing and regularization processing on the fourth sample modal representation to obtain a fourth conversion representation.

[0235] Furthermore, the computer device can calculate the correlation of the first sample data with respect to the second sample data based on the first conversion representation, the second conversion representation, and each fourth conversion representation; and calculate the correlation of the second sample data with respect to the first sample data based on the first conversion representation, the second conversion representation, and each third conversion representation.

[0236] In some embodiments, the correlation of the first sample data with respect to the second sample data is calculated based on the first sample modal representation, the second sample modal representation, and the sample modal representation of each fourth sample data, including: determining a first value based on the first sample modal representation and the second sample modal representation; determining multiple second values ​​based on the first sample modal representation and the sample modal representation of each fourth sample data; and using a comparison value of the first value and the sum of the multiple second values ​​as the correlation of the first sample data with respect to the second sample data.

[0237] Specifically, the computer device may determine the first value according to the product of the first conversion representation and the second conversion representation, such as directly using the product as the first value, or using the quotient of the product and the temperature coefficient as the exponent, and using the result of the power operation of the natural constant e as the base as the first value. Similarly, the computer device may determine the second value according to the product of the first conversion representation and each fourth conversion representation. Furthermore, the computer device uses the comparison value of the first value and the sum of the multiple second values ​​as the correlation of the first sample data with respect to the second sample data. Among them, the comparison value can specifically be a quotient value or a difference value that can reflect the difference.

[0238] Exemplarily, the computer device may calculate the correlation between the first sample data and the second sample data by the following formula:

[0239] ; (Formula 17)

[0240] in, represents the correlation between the first sample data and the second sample data; I represents the first conversion representation of the first sample data in the training sample pair this time, A second transformed representation representing the second sample data corresponding to the first sample data in the training sample pair; is the preset quantity, A fourth transformed representation representing the j-th fourth sample data; Represents the temperature coefficient.

[0241] In the above embodiment, when calculating the correlation of the first sample data with respect to the second sample data, the fourth sample data having different content from the second sample data but the same modality is utilized, and the degree of alignment of the sample data pair with respect to other data pairs composed of the first sample data can be calculated, so that the correlation of the first sample data with respect to the second sample data can be accurately obtained.

[0242] In some embodiments, the correlation of the second sample data with respect to the first sample data is calculated based on the first sample modal representation, the second sample modal representation, and the sample modal representations of each third sample data, including: determining a first value based on the first sample modal representation and the second sample modal representation; determining multiple third values ​​based on the second sample modal representation and the sample modal representations of each third sample data; and using a comparison value of the first value and the sum of the multiple third values ​​as the correlation of the second sample data with respect to the first sample data.

[0243] Specifically, the computer device may determine the first value according to the product of the first conversion representation and the second conversion representation, such as directly using the product as the first value, or using the quotient of the product and the temperature coefficient as the exponent, and using the result of the power operation of the natural constant e as the base as the first value. Similarly, the computer device may determine the third value according to the product of the second conversion representation and each third conversion representation. Furthermore, the computer device uses the comparison value of the first value and the sum of the plurality of third values ​​as the correlation of the second sample data with respect to the first sample data. Among them, the comparison value may specifically be a value such as a quotient or a difference value that can reflect the difference.

[0244] Exemplarily, the computer device may calculate the correlation between the first sample data and the second sample data by the following formula:

[0245] ; (Formula 18)

[0246] in, represents the correlation of the second sample data with respect to the first sample data; T represents the second transformation representation of the second sample data in the training sample pair this time, A first conversion representation of the first sample data corresponding to the second sample data in the training sample pair; is the preset quantity, A third transformed representation representing the j-th third sample data; Represents the temperature coefficient.

[0247] In the above embodiment, when calculating the correlation of the second sample data with respect to the first sample data, the third sample data having different content from the first sample data but the same modality is utilized, and the degree of alignment of the sample data pair with respect to other data pairs composed of the second sample data can be calculated, so that the correlation of the second sample data with respect to the first sample data can be accurately obtained.

[0248] Furthermore, the computer device can determine a loss based on the alignment labels of the first sample data and the second sample data and the difference between the correlation of the first sample data with respect to the second sample data, and determine another loss based on the alignment labels and the difference between the correlation of the second sample data with respect to the first sample data, and then average the two losses to obtain a third loss.

[0249] Exemplarily, the computer device may calculate the third loss by the following formula:

[0250] ; (Formula 19)

[0251] Among them, for a set of training sample pairs, and The same is the alignment label representing the first sample data and the second sample data in the training sample pair. represents the correlation between the first sample data and the second sample data, Indicates the correlation between the second sample data and the first sample data. is the cross entropy loss function.

[0252] In the above embodiment, by using the fourth sample data having different content from the second sample data but the same modality, the correlation of the first sample data with respect to the second sample data can be accurately calculated; by using the third sample data having different content from the first sample data but the same modality, the correlation of the second sample data with respect to the first sample data can be accurately obtained, thereby obtaining the correlation in two dimensions, which can more accurately measure the degree of alignment between the representations of the two modalities after being processed by the encoder in the multimodal model.

[0253] In some embodiments, the modality includes an image modality and a text modality, and the method also includes a text retrieval step, specifically including: obtaining a text retrieval task, extracting the image data specified in the text retrieval task, and forming a first data pair to be processed with each text data in the text library and the specified image data; processing the first data pair through a multimodal model to obtain two feature representations, and determining the matching degree of the first data pair based on the two feature representations; and determining the target text that matches the specified image data according to the matching degree of each first data pair.

[0254] The multimodal model obtained by training through the above-mentioned embodiment can be applied in the image-text retrieval scenario, for example, it can be used to retrieve text matching with an image. In practical applications, if a text retrieval task is obtained, the computer device can extract the image data specified in the text retrieval task, and then form multiple first data pairs with each text data in the text library and the specified image data. Thus, any first data pair is processed by the trained multimodal model, and two characteristic representations corresponding to the first data pair are output. Thus, the computer device can determine the matching degree of the first data pair based on the two characteristic representations, and according to the matching degree of each first data pair, the text data in the first data whose matching degree meets the push condition is used as the target text matching with the specified image data and pushed to the terminal for display, that is, the text retrieval result of the specified image data is obtained. Among them, the matching degree meeting the push condition can be specifically the highest matching degree, or the matching degree is greater than the preset threshold, or the top N with the highest matching degree, etc., and the embodiment of the present application does not limit this.

[0255] In some embodiments, the specific method of determining the matching degree of the first data pair can be any of the following methods: calculating the feature similarity of the two feature representations, and using the feature similarity as the matching degree; inputting the two feature representations into the classification layer, and outputting the classification result through the classification layer, and using the classification result as the matching degree. The feature similarity can be represented by cosine similarity, Euclidean distance, Manhattan distance, etc.

[0256] In the above embodiment, the matching calculation between image and text can be realized through the trained multimodal model, which can help improve the quality and efficiency of text retrieval.

[0257] In some embodiments, the modality includes images and text, and the method also includes an image retrieval step, specifically including: obtaining an image retrieval task, extracting text data specified in the image retrieval task, and forming a second data pair to be processed with each image data in the image library and the specified text data; processing the second data pair through a multimodal model to obtain two feature representations, and determining the matching degree of the second data pair based on the two feature representations; and determining a target image that matches the specified text data according to the matching degree of each second data pair.

[0258] The multimodal model obtained through training in the above embodiment can be applied in the image-text retrieval scenario, for example, it can be used to retrieve images that match the text. In practical applications, if an image retrieval task is obtained, the computer device can extract the text data specified in the image retrieval task, and then form multiple second data pairs with each image data in the image library and the specified text data. Thus, any second data pair is processed by the trained multimodal model, and two feature representations corresponding to the second data pair are output. Thus, the computer device can determine the matching degree of the second data pair based on the two feature representations, and according to the matching degree of each second data pair, the image data in the second data whose matching degree meets the push condition is used as the target image matching the specified text data and pushed to the terminal for display, that is, the image retrieval result of the specified text data is obtained. Among them, the matching degree that meets the push condition can be the highest matching degree, or the matching degree is greater than the preset threshold, or the top N with the highest matching degree, etc., and the embodiment of the present application does not limit this.

[0259] In some embodiments, the specific method of determining the matching degree of the second data pair can be any of the following methods: calculating the feature similarity of the two feature representations, and using the feature similarity as the matching degree; inputting the two feature representations into the classification layer, and outputting the classification result through the classification layer, and using the classification result as the matching degree. Among them, the feature similarity can be represented by cosine similarity, Euclidean distance, Manhattan distance, etc.

[0260] In the above embodiment, the matching calculation between image and text can be realized through the trained multimodal model, which can help improve the quality and efficiency of image retrieval.

[0261] In an exemplary embodiment, Figure 5 As shown, a data matching method is provided, which is described by taking the method applied to a computer device (such as a terminal or server in FIG1 ) as an example, and includes the following steps. Among them:

[0262] Step 502 , encode the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities.

[0263] The present application can encode based on the first data through a first encoder in a multimodal model to obtain a first modal representation; and encode based on the second data through a second encoder in the multimodal model to obtain a second modal representation.

[0264] In some embodiments, the computer device may directly encode the first data to obtain the first modal representation, and directly encode the second data to obtain the second modal representation. In other embodiments, the computer device may perform mask processing on the first data, and then encode the masked first data through the first encoder in the multimodal model to obtain the first modal representation. The computer device may perform mask processing on the second data, and then encode the masked second data through the second encoder in the multimodal model to obtain the second modal representation.

[0265] For the convenience of description, the data input into the first encoder may be referred to as the first input sequence, and the data input into the second encoder may be referred to as the second input sequence. That is, the first input sequence may be the first data or the masked first data; the second input sequence may be the second data or the masked second data.

[0266] In some embodiments, the multimodal model encodes the first input sequence multiple times to obtain a first modality representation. The multimodal model encodes the second input sequence multiple times to obtain a second modality representation.

[0267] In some embodiments, the first encoder and the second encoder have the same network structure, so the encoding process performed on the first input sequence is the same as the encoding process performed on the second input sequence. Of course, in other embodiments, the first encoder and the second encoder may have different network structures, and the encoding process performed on the first input sequence is different from the encoding process performed on the second input sequence. This embodiment of the application does not limit this.

[0268] Take the first encoder and the second encoder having the same network structure as an example for explanation: for any encoding, such as the l+1th encoding, the output of the lth encoding can be obtained first, and the multi-head self-attention layer operation can be performed according to the output of the lth encoding. The multi-head self-attention layer operation result and the output of the lth encoding are combined and then the layer regularization operation is performed to obtain the intermediate processing feature; the intermediate processing feature is processed by the forward neural network, and the forward neural network processing result and the intermediate processing feature are combined and then the layer regularization operation is performed to obtain the output of the l+1th encoding; l+1 is used as the new l, and the output of the lth encoding is obtained and continued to be executed until the last encoding process is completed, and the output of the last encoding is used as the first modal representation or the second modal representation. Wherein, l is a natural number greater than or equal to 0. When l is 0, the output of the lth encoding obtained is the first input sequence or the second input sequence.

[0269] In some embodiments, the computer device may encode each input data in the first input sequence multiple times to obtain outputs corresponding to each input data, and concatenate the outputs corresponding to each input data in the last encoding to obtain the first modal representation. Similarly, the computer device may encode each input data in the second input sequence multiple times to obtain outputs corresponding to each input data, and concatenate the outputs corresponding to each input data in the last encoding to obtain the second modal representation.

[0270] Exemplarily, the computer device may determine the output of the (l+1)th encoding by using formula (1) in step 202.

[0271] Step 504: Combine the first modality representation and the second modality representation to obtain a hybrid modality representation, and determine an adaptive gating weight according to the hybrid modality representation.

[0272] This application designs a gated interaction mechanism to control the ratio of reference single-modal representation and mixed-modal representation during decoding, that is, to dynamically adjust the reference ratio through gating weights.

[0273] Specifically, the multimodal model can fuse the first modal representation and the second modal representation through a cross transformer structure to obtain a mixed modal representation, and then perform a numerical conversion on the mixed modal representation to obtain the gating weights.

[0274] In some embodiments, the computer device may directly perform addition or multiplication operations on the first modal representation and the second modal representation to obtain a mixed modal representation. In other embodiments, the computer device may also perform attention operations on the first modal representation and the second modal representation to obtain a mixed modal representation. In other embodiments, the computer device may also use more complex operations, such as performing attention mechanism processing, and then performing matrix addition or multiplication, and then performing linear / nonlinear changes to obtain a mixed modal representation, etc. This application does not limit the specific fusion method.

[0275] Furthermore, after the computer device combines the first modal representation and the second modal representation to obtain a mixed modal representation, it can perform a linear change on the mixed modal representation and then perform an activation process to obtain an adaptive gating weight. That is, the mixed modality is converted into a numerical value, which is also the gating weight. In this way, the adaptive gating weight of the current time can be obtained according to the relationship between the first data and the second data of the current time.

[0276] Step 506: According to the gating weights, the first modality representation and the mixed modality representation are fused to obtain a first fused representation, and the second modality representation and the mixed modality representation are fused to obtain a second fused representation.

[0277] Specifically, the computer device may perform weighted processing on the first modal representation and the mixed modal representation according to the gating weight to obtain a first fused representation; and perform weighted processing on the second modal representation and the mixed modal representation according to the gating weight to obtain a second fused representation.

[0278] In some embodiments, the computer device may use the gating weight as the weight of any one of the first modal representation and the mixed modal representation, use the difference between the value one and the gating weight as the weight of the other representation, and perform weighted summation processing on the first modal representation and the mixed modal representation.

[0279] In some embodiments, the computer device may use the gating weight as the weight of any one of the second modal representation and the mixed modal representation, use the difference between the value one and the gating weight as the weight of the other representation, and perform weighted summation processing on the second modal representation and the mixed modal representation.

[0280] Step 508: Determine the matching degree between the first data and the second data according to the first fused representation and the second fused representation.

[0281] In some embodiments, the computer device may directly calculate the matching degree between the first fused representation and the second fused representation, and use the matching degree as the matching degree between the first data and the second data. That is, in the use scenario of the multimodal model, the first encoder, the second encoder and the interactive conversion structure may be directly used.

[0282] In other embodiments, determining the degree of match between the first data and the second data based on the first fused representation and the second fused representation includes: decoding according to the first fused representation to obtain a first feature representation of the first data; decoding according to the second fused representation to obtain a second feature representation of the second data; and determining the degree of match between the first data and the second data based on the first feature representation and the second feature representation.

[0283] For the specific decoding method, please refer to the decoding method in the processing of the multimodal model in the aforementioned embodiment. The specific method for determining the matching degree between the first data and the second data can be any of the following methods: calculating the feature similarity between the two representations (the first fusion representation and the second fusion representation, or the first feature representation and the second feature representation), and using the feature similarity as the matching degree; inputting the two representations (the first fusion representation and the second fusion representation, or the first feature representation and the second feature representation) into the classification layer, and outputting the classification result through the classification layer, and using the classification result as the matching degree. The feature similarity can be represented by cosine similarity, Euclidean distance, Manhattan distance, etc.

[0284] The above data matching method encodes the first data and the second data belonging to different modes respectively to obtain the first modal representation and the second modal representation. Then, the first modal representation and the second modal representation are combined to obtain a mixed modal representation. According to the mixed modal representation, an adaptive gating weight can be obtained, and the gating weight is used to control the proportion of the first modal representation and the second modal representation when they are fused with the mixed modal representation, that is, information can be intelligently extracted from the single mode / mixed mode to obtain the first fusion representation and the second fusion representation. The first fusion representation and the second fusion representation obtained in this way can better highlight the relevant information of the first data and the second data, so it can be used to more accurately determine the matching degree between the first data and the second data, greatly improving the data processing effect. In particular, when the first data and the second data are missing, by intelligently extracting information from the mixed mode, intelligently selecting the proportion of the extracted mixed modal information, and reconstructing the first fusion representation of the first data and the second fusion representation of the second data through multi-modal information, the missing information is compensated, the matching accuracy can be greatly improved, and the data processing performance is improved.

[0285] In some embodiments, a first modal representation and a second modal representation are combined to obtain a mixed modal representation, including: performing multiple interactive fusions based on the first modal representation and the second modal representation to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side; combining the first mixed representation and the second mixed representation to obtain a mixed modal representation.

[0286] Specifically, in the process of fusing the first modal representation and the second modal representation, the initial model can perform multiple fusions through a multi-layer neural network to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side. Each time the interactive fusion is performed, the second intermediate mixed representation can be fused into the first intermediate mixed representation based on the attention mechanism to obtain a first intermediate mixed representation biased towards the first modal side. The first intermediate mixed representation is fused into the second intermediate mixed representation based on the attention mechanism to obtain a second intermediate mixed representation biased towards the second modal side. In this way, the first intermediate mixed representation output by the last layer of the neural network is the first mixed representation, and the second intermediate mixed representation output by the last layer of the neural network is the second mixed representation.

[0287] Furthermore, the initial model may fuse the first mixed representation and the second mixed representation to obtain a mixed modality representation, for example, by weighted summation, or by contact, or by concatenation, etc., which is not limited in the present embodiment of the application.

[0288] In the above embodiment, the first modal representation and the second modal representation are interactively fused multiple times through the initial model, so that a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side can be obtained, and the relationship information between the first data and the second data can be fully extracted, and then the first mixed representation and the second mixed representation are combined to obtain a mixed modal representation.

[0289] In some embodiments, multiple interactive fusions are performed based on the first modal representation and the second modal representation to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side, including: when performing the i+1th interactive fusion, obtaining the first intermediate mixed representation and the second intermediate mixed representation outputted by the i-th interactive fusion; fusing the second intermediate mixed representation into the first intermediate mixed representation to obtain the first intermediate mixed representation of the i+1th interactive fusion; fusing the first intermediate mixed representation into the second intermediate mixed representation to obtain the second intermediate mixed representation of the i+1th interactive fusion; taking i+1 as the new i, and returning to the first intermediate mixed representation and the second intermediate mixed representation obtained by the i-th interactive fusion when performing the i+1th interactive fusion, and continuing to execute until the stop condition is reached; taking the first intermediate mixed representation outputted by the last interactive fusion as the first mixed representation, and taking the second intermediate mixed representation outputted by the last interactive fusion as the second mixed representation; wherein i is a natural number greater than or equal to 0, and when i is 0, the first intermediate mixed representation outputted by the i-th interactive fusion obtained is the first modal representation, and the second intermediate mixed representation outputted by the i-th interactive fusion obtained is the second modal representation.

[0290] Specifically, for the first interactive fusion, the initial model can fuse the second modal representation into the first modal representation based on the attention mechanism to obtain a first intermediate mixed representation, and fuse the first modal representation into the second modal representation based on the attention mechanism to obtain a second intermediate mixed representation.

[0291] For the second interactive fusion, the initial model can fuse the second intermediate mixed representation obtained by the first interactive fusion into the first intermediate mixed representation based on the attention mechanism to obtain a new first intermediate mixed representation. Based on the attention mechanism, the first intermediate mixed representation obtained by the first interactive fusion is fused into the second intermediate mixed representation to obtain a new second intermediate mixed representation.

[0292] In this way, during each interactive fusion process, the interactive fusion of the current time is continuously performed according to the output of the previous interactive fusion until the last interactive fusion. The initial model can directly output the first intermediate mixed representation and the second intermediate mixed representation obtained by the last interactive fusion. The first intermediate mixed representation output this time is the first mixed representation, and the second intermediate mixed representation output this time is the second mixed representation.

[0293] In the above embodiment, after the first modality representation and the second modality representation are fused, the next interactive fusion is continuously performed based on the previous output through an iterative cycle, so that the information obtained from each fusion can be better utilized, making the information fusion more complete.

[0294] In some embodiments, the second intermediate mixed representation is fused into the first intermediate mixed representation to obtain the first intermediate mixed representation of the i+1th interactive fusion, including: performing an attention operation based on the first intermediate mixed representation and the second intermediate mixed representation output by the i-th interactive fusion, combining the attention operation result with the first intermediate mixed representation output by the i-th interactive fusion, and performing a layer regularization operation to obtain a first intermediate processing feature; performing a forward neural network processing on the first intermediate processing feature, combining the forward neural network processing result with the first intermediate processing feature, and performing a layer regularization operation to obtain the first intermediate mixed representation of the i+1th interactive fusion.

[0295] Specifically, in the layer regularization operation performed after combining the attention operation result with the first intermediate mixed representation of the output of the i-th interactive fusion, the combination method of the attention operation result and the first intermediate mixed representation of the output of the i-th interactive fusion can be addition, multiplication, or splicing, etc., which is not limited in the embodiments of the present application. In the layer regularization operation performed after combining the forward neural network processing result with the first intermediate processing feature, the combination method of the forward neural network processing result and the first intermediate processing feature can be addition, multiplication, or splicing, etc., which is not limited in the embodiments of the present application.

[0296] Similar to the processing method in the model training process, the computer device can determine the first intermediate mixed representation of the (i+1)th interactive fusion through the above formulas 10 and 11.

[0297] In the above embodiment, the interactive fusion processing method based on the attention mechanism can better fuse the second intermediate mixed representation into the first intermediate mixed representation. Moreover, through such a stacked fusion design, the problem of gradient explosion can be prevented during model training.

[0298] In some embodiments, the first intermediate mixed representation is fused into the second intermediate mixed representation to obtain the second intermediate mixed representation of the i+1th interactive fusion, including: performing an attention operation based on the second intermediate mixed representation output by the i-th interactive fusion and the first intermediate mixed representation, combining the attention operation result with the second intermediate mixed representation output by the i-th interactive fusion and performing a layer regularization operation to obtain a second intermediate processing feature; performing a forward neural network processing on the second intermediate processing feature, combining the forward neural network processing result with the second intermediate processing feature and performing a layer regularization operation to obtain the second intermediate mixed representation of the i+1th interactive fusion.

[0299] Specifically, when the attention operation result and the second intermediate mixed representation of the output of the i-th interactive fusion are combined and then a layer regularization operation is performed, the attention operation result and the second intermediate mixed representation of the output of the i-th interactive fusion are combined in a manner that can be addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application. When the feedforward neural network processing result and the second intermediate processing feature are combined and then a layer regularization operation is performed, the feedforward neural network processing result and the second intermediate processing feature are combined in a manner that can be addition, multiplication, or splicing, etc., which is not limited in this embodiment of the present application.

[0300] Similar to the processing method in the model training process, the computer device can determine the second intermediate mixed representation of the (i+1)th interactive fusion through Formula 12 and Formula 13 in the aforementioned embodiment.

[0301] In the above embodiment, the interactive fusion processing method based on the attention mechanism can better fuse the first intermediate mixed representation into the second intermediate mixed representation. Moreover, through such a stacked fusion design, the problem of gradient explosion can be prevented during model training.

[0302] In some embodiments, the first modal representation and the mixed modal representation are fused according to the gating weight to obtain a first fused representation, including: taking the gating weight as the coefficient of the mixed modal representation, and taking the difference between the value one and the gating weight as the coefficient of the first modal representation; and performing weighted processing on the mixed modal representation and the first modal representation according to the coefficient of the mixed modal representation and the coefficient of the first modal representation to obtain the first fused representation.

[0303] Specifically, the initial model may perform weighted summation of the mixed modal representation and the first modal representation according to the coefficients of the mixed modal representation and the coefficients of the first modal representation to obtain the first fused representation.

[0304] In the above embodiment, by fusing the mixed modal representation and the first modality through gated weights, the ratio of the single modal representation and the mixed modal representation can be flexibly referenced according to the alignment quality of the two modal data, so that the fused representation can better express the information of the single modal data.

[0305] In some embodiments, the second modal representation and the mixed modal representation are fused according to the gating weight to obtain the second fused representation, including: taking the gating weight as the coefficient of the mixed modal representation, and taking the difference between the value one and the gating weight as the coefficient of the second modal representation; and performing weighted processing on the mixed modal representation and the second modal representation according to the coefficient of the mixed modal representation and the coefficient of the second modal representation to obtain the first fused representation.

[0306] Specifically, the initial model may perform weighted summation of the mixed modal representation and the second modal representation according to the coefficients of the mixed modal representation and the coefficients of the second modal representation to obtain the second fused representation.

[0307] In the above embodiment, by fusing the mixed modal representation and the second modality through gated weights, the ratio of the single modal representation and the mixed modal representation can be flexibly referenced according to the alignment quality of the two modal data, so that the fused representation can better express the information of the single modal data.

[0308] In some embodiments, referring to FIG6 , the data matching method includes the following steps:

[0309] Step 602, encode the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities.

[0310] Step 604 , combining the first modality representation and the second modality representation to obtain a first mixed representation biased toward the first modality and a second mixed representation biased toward the second modality.

[0311] Step 606: determine an adaptive first gating weight according to the first mixed modality representation, and determine an adaptive second gating weight according to the second mixed modality representation.

[0312] Specifically, the multimodal model may perform a linear transformation on the first mixed modal representation and then perform an activation process to obtain a first gating weight; and perform a linear transformation on the second mixed modal representation and then perform an activation process to obtain a second gating weight.

[0313] Step 608: According to the first gating weight, the first modal representation and the first mixed representation are fused to obtain a first fused representation; according to the second gating weight, the second modal representation and the second mixed representation are fused to obtain a second fused representation.

[0314] Specifically, the multimodal model may use the first gating weight as the coefficient of the first mixed representation, and the difference between the value one and the first gating weight as the coefficient of the first modal representation; according to the coefficients of the first mixed representation and the coefficients of the first modal representation, the first mixed representation and the first modal representation are weightedly summed, and then decoded based on the result of the weighted summation to obtain the first predicted feature representation.

[0315] The multimodal model can use the second gating weight as the coefficient of the second mixed representation, and the difference between the value one and the second gating weight as the coefficient of the second modal representation; according to the coefficient of the second mixed representation and the coefficient of the second modal representation, the second mixed representation and the second modal representation are weightedly summed, and then decoded based on the result of the weighted summation to obtain a second predicted feature representation.

[0316] Step 610: Determine the matching degree between the first data and the second data according to the first fused representation and the second fused representation.

[0317] In the above embodiment, for the first modality, the multimodal model will use the first modality as the main information, and at the same time integrate the information represented by the second modality to obtain a first mixed representation, and then determine the gating weight of the first modality side according to the first mixed representation, that is, the first gating weight. In this way, the proportion of the single modality information and the mixed modality information referenced when decoding the first modality side can be controlled according to the first gating weight. For the second modality, the initial model will use the second modality as the main information, and at the same time integrate the information represented by the first modality to obtain a second mixed representation, and then determine the gating weight of the first modality side according to the second mixed representation, that is, the second gating weight. In this way, the proportion of the single modality information and the mixed modality information referenced when decoding the second modality side can be controlled according to the second gating weight. In this way, different modal sides can be more flexible and adaptive when fusing mixed modality information.

[0318] In some embodiments, it is characterized in that the first data includes image data and the second data includes text data, and the method also includes: determining the text retrieval result of the specified image data based on the matching degree between the specified image data and multiple different text data respectively; and / or determining the image retrieval result of the specified text data based on the matching degree between the specified text data and multiple different image data respectively.

[0319] Specifically, the specific method of determining text retrieval results based on the matching degree may be to use text data whose matching degree meets the push condition as the text retrieval result. The specific method of determining image retrieval results based on the matching degree may be to use image data whose matching degree meets the push condition as the image retrieval result.

[0320] Among them, the matching degree satisfying the push condition may specifically be the highest matching degree, or the matching degree being greater than a preset threshold, or the top N with the highest matching degree, etc., and the embodiment of the present application does not limit this.

[0321] In the above embodiment, the matching calculation of image and text can be realized through the trained multimodal model, which can help improve the quality and efficiency of image and text retrieval.

[0322] In a specific embodiment, the first mode is an image mode and the second mode is a text mode. Figure 7 , Figure 7 4 is a structural block diagram of a multimodal model in one embodiment.

[0323] Take the model training stage as an example: Figure 7As shown, LightVLP uses two separate encoders to model different modal information. For one of the modalities, such as image input, the model randomly masks a certain proportion (such as 50%) of patches. Then, the remaining patches form a sequence and are input into the image transformer to obtain an image representation (in the training phase, corresponding to the first sample modal representation in the aforementioned embodiment). Correspondingly, for text input, the model randomly masks a certain proportion of characters. Then, the remaining characters form a sequence and are input into the text transformer to obtain a text representation (in the training phase, corresponding to the second sample modal representation in the aforementioned embodiment).

[0324] The image representation and text representation are input into Cross Transformers, which are processed by Cross Transformers to output a mixed modality sample representation. The gating weight p is then determined by the mixed modality representation. The image representation and the mixed modality sample representation are fused by the gating weight p to obtain a first fused sample representation, and the text representation and the mixed modality sample representation are fused by the gating weight p to obtain a second fused sample representation.

[0325] Further, based on the first fused sample representation and the mask feature on the image side, decoding is performed to obtain a representation of the masked block, and based on the second fused sample representation and the mask feature on the text side, decoding is performed to obtain a representation of the masked character. This application introduces two traditional image / text unsupervised training tasks, namely the image reconstruction task and the text reconstruction task, and constructs the first modality loss and the second modality loss. An image-text matching task is also introduced to construct the second loss. A contrastive learning task is also introduced to construct the third loss. The model is trained through joint task learning.

[0326] For the trained multimodal model, in some application scenarios, the trained multimodal model can be used as a visual-language pre-training model, that is, a large model. For specific downstream tasks, the multimodal model can be fine-tuned based on the requirements of the downstream tasks to obtain a task model suitable for specific downstream tasks. Downstream tasks include generating text from images, generating images from text, generating image titles, and so on.

[0327] In some application scenarios, the multimodal model can be used to recover the original data. For example, the input data is the first data and the second data of two modalities, the first data is an image with missing data, and the second data is a text with missing data. Then, the multimodal model can output the missing image and the missing text.

[0328] In some embodiments, the present application also conducts an effect test on the multimodal model obtained by the above training. Please refer to Table 1. From the results presented in Table 1, it can be seen that the model of the present application has a good improvement in efficiency and effect compared with the baseline model.

[0329] Table 1 Experimental results of different models on operation speed and recall rate

[0330]

[0331] Among them, TR refers to the text retrieval task and IR refers to the image retrieval task.

[0332] In addition, an ablation experiment was conducted to verify the effectiveness of the gated interaction strategy (gate part) in the multimodal model in this application. Please refer to the following Table 2 for the experimental data:

[0333] Table 2 Ablation experiment results

[0334]

[0335] It can be clearly seen from Table 2 above that the model of the present application with the gated interaction strategy has a significant improvement in recall rate.

[0336] Finally, we conducted detailed tests on different mask ratios, and the conclusions are shown in Table 3:

[0337] Table 3 Test results of different mask ratios

[0338]

[0339] It can be clearly seen from the above test results that the multimodal model provided in this application has advantages in flexibility and efficiency compared with the traditional VLP model, and the dual encoding structure is more suitable for image-text retrieval tasks.

[0340] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0341] Based on the same inventive concept, the embodiment of the present application also provides a data matching device for implementing the data matching method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more data matching device embodiments provided below can refer to the limitations on the data matching method above, and will not be repeated here.

[0342] In an exemplary embodiment, as shown in FIG8 , a data matching device 800 is provided, comprising: an encoding module 801, a determination module 802, a fusion module 803 and a matching module 804, wherein:

[0343] The encoding module is used to encode the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities.

[0344] A determination module is used to combine the first modality representation and the second modality representation to obtain a hybrid modality representation, and determine an adaptive gating weight according to the hybrid modality representation.

[0345] The fusion module is used to fuse the first modality representation and the mixed modality representation according to the gating weight to obtain a first fused representation, and to fuse the second modality representation and the mixed modality representation to obtain a second fused representation.

[0346] The matching module is used to determine the matching degree between the first data and the second data according to the first fused representation and the second fused representation.

[0347] In some embodiments, the determination module is also used to perform multiple interactive fusions based on the first modal representation and the second modal representation to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side; and combine the first mixed representation and the second mixed representation to obtain a mixed modal representation.

[0348] In some embodiments, the determination module is also used to obtain the first intermediate mixed representation and the second intermediate mixed representation of the i-th interactive fusion output when performing the i+1-th interactive fusion; fuse the second intermediate mixed representation into the first intermediate mixed representation to obtain the first intermediate mixed representation of the i+1-th interactive fusion; fuse the first intermediate mixed representation into the second intermediate mixed representation to obtain the second intermediate mixed representation of the i+1-th interactive fusion; use i+1 as the new i, and return to the first intermediate mixed representation and the second intermediate mixed representation obtained by the i-th interactive fusion when performing the i+1-th interactive fusion, and continue to execute until the stop condition is reached; use the first intermediate mixed representation output of the last interactive fusion as the first mixed representation, and use the second intermediate mixed representation output of the last interactive fusion as the second mixed representation; wherein, i is a natural number greater than or equal to 0, when i is 0, the first intermediate mixed representation obtained by the i-th interactive fusion output is the first modal representation, and the second intermediate mixed representation obtained by the i-th interactive fusion output is the second modal representation.

[0349] In some embodiments, the determination module is also used to perform an attention operation based on the first intermediate mixed representation and the second intermediate mixed representation output by the i-th interactive fusion, and perform a layer regularization operation after combining the attention operation result with the first intermediate mixed representation output by the i-th interactive fusion to obtain a first intermediate processing feature; perform a forward neural network processing on the first intermediate processing feature, and perform a layer regularization operation after combining the forward neural network processing result with the first intermediate processing feature to obtain the first intermediate mixed representation of the i+1-th interactive fusion.

[0350] In some embodiments, the determination module is also used to perform an attention operation based on the second intermediate mixed representation output by the i-th interactive fusion and the first intermediate mixed representation, and perform a layer regularization operation after combining the attention operation result with the second intermediate mixed representation output by the i-th interactive fusion to obtain a second intermediate processing feature; perform a forward neural network processing on the second intermediate processing feature, and perform a layer regularization operation after combining the forward neural network processing result with the second intermediate processing feature to obtain a second intermediate mixed representation of the i+1-th interactive fusion.

[0351] In some embodiments, the determination module is further used to perform linear transformation on the mixed modal representation and then perform activation processing to obtain adaptive gating weights.

[0352] In some embodiments, the fusion module is also used to use the gating weight as the coefficient of the mixed modal representation, and the difference between the value one and the gating weight as the coefficient of the first modal representation; according to the coefficient of the mixed modal representation and the coefficient of the first modal representation, the mixed modal representation and the first modal representation are weighted to obtain a first fused representation.

[0353] In some embodiments, the fusion module is also used to use the gating weight as the coefficient of the mixed modal representation, and the difference between the value one and the gating weight as the coefficient of the second modal representation; according to the coefficient of the mixed modal representation and the coefficient of the second modal representation, the mixed modal representation and the second modal representation are weighted to obtain a first fused representation.

[0354] In some embodiments, the mixed modal representation includes a first mixed representation biased toward the first modality and a second mixed representation biased toward the second modality, and the gating weights include a first gating weight determined according to the first mixed modality representation and a second gating weight determined according to the second mixed modality representation; the fusion module is further used to fuse the first modality representation and the first mixed representation according to the first gating weight to obtain a first fused representation; and to fuse the second modality representation and the second mixed representation according to the second gating weight to obtain a second fused representation.

[0355] In some embodiments, the matching module is further used to decode according to the first fused representation to obtain a first feature representation of the first data; decode according to the second fused representation to obtain a second feature representation of the second data; and determine the degree of matching between the first data and the second data based on the first feature representation and the second feature representation.

[0356] In some embodiments, the first data includes image data, the second data includes text data, and the device also includes a retrieval module for determining a text retrieval result of the specified image data based on the matching degree between the specified image data and a plurality of different text data; and / or determining an image retrieval result of the specified text data based on the matching degree between the specified text data and a plurality of different image data.

[0357] Based on the same inventive concept, the embodiment of the present application also provides a multimodal model processing device for implementing the multimodal model processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more multimodal model processing device embodiments provided below can refer to the limitations on the multimodal model processing method above, and will not be repeated here.

[0358] In an exemplary embodiment, as shown in FIG9 , a multimodal model processing device 900 is provided, including an encoding module 901, a determination module 902, a fusion module 903, a construction module 904 and a training module 905, wherein:

[0359] The encoding module is used to encode the first sample data and the second sample data in the training sample pair through the initial model to be trained, so as to obtain the first sample modal representation and the second sample modal representation; the first sample data and the second sample data are sample data of different modalities.

[0360] The determination module is used to obtain a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through an initial model, and determine a prediction weight according to the mixed sample modality representation.

[0361] The fusion module is used to fuse the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and decode based on the fused result to obtain the first prediction feature representation.

[0362] The fusion module is also used to fuse the second sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and decode based on the fused result to obtain the second prediction feature representation.

[0363] A construction module is used to determine a first loss based on a true feature representation and a first predicted feature representation of the first sample data, and a true feature representation and a second predicted feature representation of the second sample data; determine a second loss based on an alignment label of the first sample data and the second sample data, and a predicted weight; and construct a target loss function based on the first loss and the second loss.

[0364] The training module is used to train the initial model to be trained based on the target loss function, and obtain the multimodal model after the training is completed.

[0365] In some embodiments, the device further includes a mask module, which is used to obtain a training sample pair, the training sample pair includes a first sample data and a second sample data; split the first sample data to obtain a plurality of first data blocks, split the second sample data to obtain a plurality of second data blocks, extract some data blocks from the plurality of first data blocks to form a first input sequence, and extract some data blocks from the plurality of second data blocks to form a second input sequence. The encoding module is specifically used to perform multiple encodings on the first input sequence to obtain a first modal representation, and perform multiple encodings on the second input sequence to obtain a second modal representation.

[0366] In some embodiments, the determination module is also used to perform multiple interactive fusions of the first sample modal representation and the second sample modal representation through the initial model to obtain a first mixed sample representation biased towards the first modal side and a second mixed sample representation biased towards the second modal side; and combine the first mixed sample representation and the second mixed sample representation to obtain a mixed sample modal representation.

[0367] In some embodiments, the construction module is also used to construct a first vector based on the alignment labels of the first sample data and the second sample data; construct a second vector based on the predicted weight and the difference between the numerical value one and the predicted weight; and determine the second loss based on the first vector and the second vector.

[0368] In some embodiments, the mixed sample modality representation includes a first mixed sample representation biased toward the first modality side and a second mixed sample representation biased toward the second modality side, and the prediction weight includes a first prediction weight determined according to the first mixed sample representation and a second prediction weight determined according to the second mixed sample representation. The fusion module is further used to fuse the first sample modality representation and the first mixed sample representation through the initial model according to the first prediction weight; and fuse the second sample modality representation and the second mixed sample representation through the initial model according to the second prediction weight.

[0369] In some embodiments, the mixed sample modality representation includes a first mixed sample representation biased towards the first modality side and a second mixed sample representation biased towards the second modality side, and the prediction weight includes a first prediction weight determined according to the first mixed sample representation and a second prediction weight determined according to the second mixed sample representation; the construction module is also used to construct a first vector based on the alignment labels of the first sample data and the second sample data; determine the target weight according to the mean of the first prediction weight and the second prediction weight, and construct a third vector based on the target weight and the difference between the numerical value one and the target weight; determine the second loss based on the first vector and the third vector.

[0370] In some embodiments, the construction module is further used to determine the correlation between the first sample data and the second sample data based on the first sample modal representation and the second sample modal representation; determine the third loss based on the alignment labels of the first sample data and the second sample data, and the correlation between the first sample data and the second sample data; and construct a target loss function based on the first loss, the second loss, and the third loss.

[0371] In some embodiments, the correlation between the first sample data and the second sample data includes: the correlation of the first sample data relative to the second sample data, and the correlation of the second sample data relative to the first sample data; the construction module is also used to determine a preset number of third sample data with the same modality as the first sample data, and a preset number of fourth sample data with the same modality as the second sample data; calculate the correlation of the first sample data with respect to the second sample data based on the first sample modal representation, the second sample modal representation, and the sample modal representation of each fourth sample data; calculate the correlation of the second sample data with respect to the first sample data based on the first sample modal representation, the second sample modal representation, and the sample modal representation of each third sample data.

[0372] In some embodiments, the construction module is also used to determine a first value based on the first sample modal representation and the second sample modal representation; determine multiple second values ​​based on the first sample modal representation and the sample modal representation of each fourth sample data; and use the comparison value of the first value and the sum of the multiple second values ​​as the correlation of the second sample data with respect to the first sample data.

[0373] In some embodiments, the device also includes a retrieval module, which is used to obtain a text retrieval task, extract the image data specified in the text retrieval task, and form a first data pair to be processed by respectively combining each text data in the text library with the specified image data; processing the first data pair through a multimodal model to obtain two feature representations, and determining the matching degree of the first data pair based on the two feature representations; and determining the target text that matches the specified image data according to the matching degree of each first data pair.

[0374] In some embodiments, the device also includes a retrieval module for obtaining an image retrieval task, extracting text data specified in the image retrieval task, and forming a second data pair to be processed by respectively combining each image data in the image library with the specified text data; processing the second data pair through a multimodal model to obtain two feature representations, and determining the matching degree of the second data pair based on the two feature representations; and determining a target image that matches the specified text data based on the matching degree of each second data pair.

[0375] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0376] In an exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be shown in FIG10. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store graphic data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data matching method and / or a multimodal model processing method is implemented.

[0377] Those skilled in the art will understand that the structure shown in FIG. 10 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0378] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0379] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0380] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0381] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0382] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0383] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0384] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A data matching method, characterized in that: The method comprises: Encoding the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities; combining the first modal representation and the second modal representation to obtain a hybrid modal representation, and determining an adaptive gating weight according to the hybrid modal representation; According to the gating weights, the first modality representation and the mixed modality representation are fused to obtain a first fused representation, and the second modality representation and the mixed modality representation are fused to obtain a second fused representation; A matching degree between the first data and the second data is determined according to the first fused representation and the second fused representation.

2. The method according to claim 1, characterized in that The combining the first modal representation and the second modal representation to obtain a mixed modal representation includes: Performing multiple interactive fusions based on the first modal representation and the second modal representation to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side; The first mixed representation and the second mixed representation are combined to obtain a mixed modal representation.

3. The method according to claim 2, characterized in that The performing multiple interactive fusions based on the first modal representation and the second modal representation to obtain a first mixed representation biased towards the first modal side and a second mixed representation biased towards the second modal side includes: When performing the (i+1)th interactive fusion, obtaining a first intermediate mixed representation and a second intermediate mixed representation outputted by the (i)th interactive fusion; fusing the second intermediate mixed representation into the first intermediate mixed representation to obtain an (i+1)th interactively fused first intermediate mixed representation; Fusing the first intermediate mixed representation into the second intermediate mixed representation to obtain an (i+1)th interactively fused second intermediate mixed representation; i+1 is used as the new i, and the first intermediate mixed representation and the second intermediate mixed representation obtained by the i-th interactive fusion are returned when the i+1-th interactive fusion is performed, and the execution continues until the stopping condition is reached; The first intermediate mixed representation output from the last interactive fusion is used as the first mixed representation, and the second intermediate mixed representation output from the last interactive fusion is used as the second mixed representation; Among them, i is a natural number greater than or equal to 0. When i is 0, the first intermediate mixed representation obtained from the i-th interactive fusion output is the first modal representation, and the second intermediate mixed representation obtained from the i-th interactive fusion output is the second modal representation.

4. The method according to claim 3, characterized in that The step of fusing the second intermediate mixed representation into the first intermediate mixed representation to obtain the (i+1)th interactively fused first intermediate mixed representation includes: Perform an attention operation on the first intermediate mixed representation and the second intermediate mixed representation output by the i-th interactive fusion, combine the attention operation result with the first intermediate mixed representation output by the i-th interactive fusion, and then perform a layer regularization operation to obtain a first intermediate processing feature; The first intermediate processing feature is processed by a feedforward neural network, and a layer regularization operation is performed after combining the feedforward neural network processing result and the first intermediate processing feature to obtain a first intermediate mixed representation of the i+1th interactive fusion.

5. The method according to claim 1, characterized in that Determining an adaptive gating weight according to the mixed modality representation includes: The mixed modality representation is linearly transformed and then activated to obtain adaptive gating weights.

6. The method according to claim 1, characterized in that The mixed modality representation includes a first mixed representation biased toward a first modality side and a second mixed representation biased toward a second modality side, and the gating weight includes a first gating weight determined according to the first mixed modality representation and a second gating weight determined according to the second mixed modality representation; The fusing the first modality representation and the mixed modality representation to obtain a first fused representation according to the gating weight, and fusing the second modality representation and the mixed modality representation to obtain a second fused representation, comprises: According to the first gating weight, fusing the first modal representation and the first mixed representation to obtain a first fused representation; According to the second gating weight, the second modal representation and the second mixed representation are fused to obtain a second fused representation.

7. The method according to claim 1, characterized in that The determining, according to the first fused representation and the second fused representation, a degree of matching between the first data and the second data includes: Decoding according to the first fused representation to obtain a first feature representation of the first data; Decoding according to the second fused representation to obtain a second feature representation of the second data; Based on the first feature representation and the second feature representation, a matching degree between the first data and the second data is determined.

8. The method according to any one of claims 1 to 7, characterized in that The first data includes image data, the second data includes text data, and the method further includes: Determining a text search result of the specified image data based on the matching degree between the specified image data and a plurality of different text data; and / or, Based on the matching degrees between the designated text data and a plurality of different image data, an image retrieval result of the designated text data is determined.

9. A multimodal model processing method, characterized in that: The method comprises: By using the initial model to be trained, encoding is performed based on the first sample data and the second sample data in the training sample pair, respectively, to obtain a first sample modality representation and a second sample modality representation; the first sample data and the second sample data are sample data of different modalities; Obtaining a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through the initial model, and determining a prediction weight according to the mixed sample modality representation; fusing the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and performing decoding based on the fused result to obtain a first prediction feature representation; fusing the second sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and performing decoding based on the fused result to obtain a second prediction feature representation; Determine a first loss based on the true feature representation of the first sample data and the first predicted feature representation, and the true feature representation of the second sample data and the second predicted feature representation; Determining a second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weight; A target loss function is constructed according to the first loss and the second loss, and the initial model to be trained is trained based on the target loss function, and a multimodal model is obtained after the training is completed.

10. The method according to claim 9, characterized in that Before encoding the first sample data and the second sample data in the training sample pair, the method further includes: Acquire a training sample pair, wherein the training sample pair includes first sample data and second sample data; The first sample data is split into a plurality of first data blocks, and the second sample data is split into a plurality of second data blocks, Extracting some data blocks from the plurality of first data blocks to form a first input sequence, and extracting some data blocks from the plurality of second data blocks to form a second input sequence; The first sample data and the second sample data in the training sample pair are respectively encoded to obtain a first sample modality representation and a second sample modality representation, including: The first input sequence is encoded multiple times to obtain a first modal representation, and the second input sequence is encoded multiple times to obtain a second modal representation.

11. The method according to claim 9, characterized in that The determining of the second loss based on the alignment labels of the first sample data and the second sample data, and the prediction weight, comprises: Constructing a first vector based on the alignment labels of the first sample data and the second sample data; constructing a second vector according to the prediction weight and the difference between the value one and the prediction weight; A second loss is determined based on the first vector and the second vector.

12. The method according to claim 9, characterized in that The mixed sample modality representation includes a first mixed sample representation biased toward the first modality side and a second mixed sample representation biased toward the second modality side, and the prediction weight includes a first prediction weight determined according to the first mixed sample representation and a second prediction weight determined according to the second mixed sample representation; The fusing the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model includes: fusing the first sample modality representation and the first mixed sample representation through the initial model according to the first prediction weight; The fusing the second sample modality representation and the mixed sample modality representation by the initial model according to the prediction weight includes: The second sample modality representation and the second mixed sample representation are fused through the initial model according to the second prediction weight.

13. The method according to claim 9, characterized in that The method further comprises: Determining a correlation between the first sample data and the second sample data according to the first sample modality representation and the second sample modality representation; determining a third loss based on the alignment labels of the first sample data and the second sample data, and the correlation between the first sample data and the second sample data; The constructing a target loss function according to the first loss and the second loss includes: An objective loss function is constructed according to the first loss, the second loss, and the third loss.

14. The method according to claim 13, characterized in that The correlation between the first sample data and the second sample data includes: the correlation of the first sample data with respect to the second sample data, and the correlation of the second sample data with respect to the first sample data; Determining the correlation between the first sample data and the second sample data according to the first sample modality representation and the second sample modality representation includes: Determine a preset number of third sample data having the same modality as the first sample data, and a preset number of fourth sample data having the same modality as the second sample data; Calculating the correlation of the first sample data with respect to the second sample data according to the first sample modality representation, the second sample modality representation, and the sample modality representation of each fourth sample data; The correlation of the second sample data with respect to the first sample data is calculated based on the first sample modality representation, the second sample modality representation, and the sample modality representation of each third sample data.

15. The method according to claim 14, characterized in that The calculating the correlation between the first sample data and the second sample data according to the first sample modality representation, the second sample modality representation, and the sample modality representation of each fourth sample data comprises: determining a first value based on the first sample modality representation and the second sample modality representation; Determining a plurality of second values ​​according to the first sample modal representation and the sample modal representation of each fourth sample data; A comparison value between the first value and the sum of the plurality of second values ​​is used as a correlation degree between the first sample data and the second sample data.

16. The method according to any one of claims 9 to 15, characterized in that The modality includes an image modality and a text modality, and the method further includes: Acquire a text retrieval task, extract the image data specified in the text retrieval task, and form a first data pair to be processed with each text data in the text library and the specified image data; Processing the first data pair by using the multimodal model to obtain two feature representations, and determining a matching degree of the first data pair based on the two feature representations; According to the matching degree of each first data pair, a target text matching the specified image data is determined.

17. The method according to any one of claims 9 to 15, characterized in that The modality includes an image and text, and the method further includes: Acquire an image retrieval task, extract text data specified in the image retrieval task, and form a second data pair to be processed with each image data in the image library and the specified text data; Processing the second data pair by using the multimodal model to obtain two feature representations, and determining a matching degree of the second data pair based on the two feature representations; According to the matching degree of each second data pair, a target image matching the specified text data is determined.

18. A data matching device, characterized in that: The device comprises: An encoding module, used for encoding the first data and the second data respectively to obtain a first modal representation and a second modal representation, wherein the first data and the second data are data of different modalities; a determination module, configured to combine the first modal representation and the second modal representation to obtain a hybrid modal representation, and determine an adaptive gating weight according to the hybrid modal representation; a fusion module, configured to fuse the first modality representation and the mixed modality representation to obtain a first fused representation, and to fuse the second modality representation and the mixed modality representation to obtain a second fused representation, according to the gating weight; A matching module is used to determine a matching degree between the first data and the second data according to the first fusion representation and the second fusion representation.

19. A multimodal model processing device, characterized in that: The device comprises: An encoding module, used to encode the first sample data and the second sample data in the training sample pair respectively through the initial model to be trained to obtain a first sample modal representation and a second sample modal representation; the first sample data and the second sample data are sample data of different modalities; A determination module, configured to obtain a mixed sample modality representation by combining the first sample modality representation and the second sample modality representation through the initial model, and determine a prediction weight according to the mixed sample modality representation; A fusion module, configured to fuse the first sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and perform decoding based on the fused result to obtain a first prediction feature representation; The fusion module is further used to fuse the second sample modality representation and the mixed sample modality representation according to the prediction weight through the initial model, and perform decoding based on the fused result to obtain a second prediction feature representation; A construction module is used to determine a first loss based on the real feature representation of the first sample data and the first predicted feature representation, and the real feature representation of the second sample data and the second predicted feature representation; determine a second loss based on the alignment label of the first sample data and the second sample data, and the prediction weight; and construct a target loss function according to the first loss and the second loss; The training module is used to train the initial model to be trained based on the target loss function, and obtain a multimodal model after the training is completed.

20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 17 are implemented.

Citation Information

Patent Citations

  • Cross-modal information retrieval method and device

    CN113032614A

  • Collaborative gating cycle fusion LSTM image annotation method

    CN113627424A

  • Multi-modal prediction method and device, equipment and storage medium

    CN115186062A

  • Aspect-level multi-modal sentiment analysis method based on collaborative attention fusion

    CN115293170A

  • Aspect-level fine-grained sentiment analysis method based on modal features

    CN116522955A

Cited By

  • Data replication method and device based on DMA, equipment and storage medium

    CN120821680A

  • Multi-modal fusion-based living perception method and system

    WO2026091847A1