Model training method, information processing method, and related device

By using a master encoder and a negative feature encoder to calculate the correlation between positive and negative samples during image-text matching model training, the high hardware cost problem in existing technologies is solved, achieving efficient model training and cost reduction.

CN123160986APending Publication Date: 2026-11-24GUANGZHOU TENCENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510667749.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing technologies require extensive hardware support when training image-text matching models using multimodal learning, resulting in high training costs.

Method used

By acquiring the training dataset, the negative feature encoder, and the image-text matching model updated in the previous iteration, feature extraction is performed using the main encoder and the negative feature encoder respectively. The correlation between positive and negative samples is calculated, and the image-text matching model is updated until the preset termination condition is met, thereby reducing the dependence on the large-scale training dataset.

Benefits of technology

This effectively reduces the need for hardware support, lowers training costs, and improves the efficiency and effectiveness of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160986A_ABST
    Figure CN123160986A_ABST
Patent Text Reader

Abstract

This application discloses a model training method, an information processing method, and related equipment. The application acquires a training dataset, a negative feature encoder, and an image-text matching model updated in the previous iteration. Using the main encoder and the negative feature encoder, features are extracted from the image-text pairs to obtain a first feature representation and a second feature representation of the image-text pairs. Based on the first feature representation, image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair. Based on the first feature representation and the negative feature representation, image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. Based on the positive and negative sample relevance, the image-text matching model is updated until the iteration meets a preset termination condition, resulting in a trained image-text matching model. This application reduces the hardware support requirements during model training, thereby reducing training costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a model training method, an information processing method, and related equipment. Background Technology

[0002] In recent years, with the rapid development of deep learning technology, multimodal learning has gradually become a research hotspot in the field of artificial intelligence. Multimodal learning refers to the technology of simultaneously processing multiple types of data (such as text, images, and audio) and performing information interaction and knowledge representation between these data. Joint understanding of language and images is an important research direction in multimodal learning. For example, in existing technologies, multimodal learning is often used to train image-text matching models so that the trained model can simultaneously understand language and image data and achieve effective matching between images and text, thereby supporting functions such as image search, image-text search, text-text search, and text-image search.

[0003] However, training image-text matching models through multimodal learning typically requires building a large-scale training dataset containing a large number of image-text pairs. This necessitates powerful hardware support, such as high-performance GPU clusters, resulting in high training costs. Summary of the Invention

[0004] This application provides a model training method, an information processing method, and related equipment, which can effectively reduce the hardware support requirements during the training process of a text-image matching model, thereby reducing training costs.

[0005] This application provides a model training method, comprising: acquiring a training dataset, a negative feature encoder, and an image-text matching model updated in the previous iteration, wherein the training dataset includes at least one image-text pair, and the image-text matching model includes a master encoder; using the master encoder and the negative feature encoder to extract features from the image-text pair respectively, obtaining a first feature representation and a second feature representation of the image-text pair; calculating image-text relevance based on the first feature representation to obtain the positive sample relevance corresponding to the image-text pair; calculating image-text relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance corresponding to the image-text pair, wherein the negative feature representation is obtained from the second feature representation and historical feature representation, and the historical feature representation is the second feature representation extracted in a previous iteration; updating the image-text matching model based on the positive sample relevance and the negative sample relevance until the iteration meets a preset termination condition to obtain a trained image-text matching model, wherein the negative sample relevance includes the target negative sample relevance.

[0006] This application also provides an information processing method, comprising: determining information to be processed based on query information and at least one candidate information, wherein the information to be processed includes at least one information pair, the information pair including the query information and any one of the candidate information, wherein the query information and the candidate information are images or text; extracting features from the information pair using a trained image-text matching model to obtain a target feature representation of the information pair, wherein the trained image-text matching model is obtained using any model training method provided in this application; calculating information relevance based on the target feature representation to obtain the information relevance of the information in the information pair; and determining target information matching the query information from the at least one candidate information based on the information relevance.

[0007] This application embodiment also provides a model training apparatus, comprising: an acquisition unit, configured to acquire a training dataset, a negative feature encoder, and a text-image matching model updated in the previous iteration, wherein the training dataset includes at least one text-image pair, and the text-image matching model includes a master encoder; a training feature extraction unit, configured to use the master encoder and the negative feature encoder to extract features from the text-image pair respectively, to obtain a first feature representation and a second feature representation of the text-image pair; a positive sample determination unit, configured to calculate the text-image relevance based on the first feature representation, to obtain the positive sample relevance corresponding to the text-image pair; a negative sample determination unit, configured to calculate the text-image relevance based on the first feature representation and the negative feature representation, to obtain the target negative sample relevance corresponding to the text-image pair, wherein the negative feature representation is obtained from the second feature representation and historical feature representation, and the historical feature representation is the second feature representation extracted in a previous iteration; and an update unit, configured to update the text-image matching model based on the positive sample relevance and the negative sample relevance until the iteration meets a preset termination condition, to obtain a trained text-image matching model, wherein the negative sample relevance includes the target negative sample relevance.

[0008] In some embodiments, the main encoder includes a first image encoder and a first text encoder, the negative feature encoder includes a second image encoder and a second text encoder, and the training feature extraction unit includes a first feature extraction subunit and a second feature extraction subunit, comprising: the first feature extraction subunit, configured to use the first image encoder to extract features from the image in the image-text pair to obtain a first image feature representation of the image-text pair, and to use the first text encoder to extract features from the text in the image-text pair to obtain a first text feature representation of the image-text pair; the second feature extraction subunit, configured to use the second image encoder to extract features from the image in the image-text pair to obtain a second image feature representation of the image-text pair, and to use the second text encoder to extract features from the text in the image-text pair to obtain a second text feature representation of the image-text pair.

[0009] In some implementations, the positive sample determination unit is specifically used to: for any given image-text pair, calculate the correlation between the first image feature representation of the image-text pair and the first text feature representation of the image-text pair to obtain the positive sample correlation corresponding to the image-text pair.

[0010] In some embodiments, the positive sample determination unit includes a multiplication subunit and an element extraction subunit, including: the multiplication subunit, which is used to multiply an image feature representation sequence and a text feature representation sequence to obtain a relevance matrix, wherein the image feature representation sequence is a sequence composed of the first image feature representations of the at least one image-text pair, and the text feature representation sequence is a sequence composed of the first text feature representations of the at least one image-text pair, wherein the sequence order of the image feature representation sequence and the text feature representation sequence corresponds; the element extraction subunit, which is used to extract the diagonal element corresponding to the image-text pair from the relevance matrix for any image-text pair to obtain the positive sample relevance corresponding to the image-text pair.

[0011] In some embodiments, the negative sample relevance further includes additional negative sample relevance, and the model training device further includes an additional negative sample determination unit. The additional negative sample determination unit is used to: for any image-text pair, extract the off-diagonal elements corresponding to the corresponding additional negative sample pair from the relevance matrix to obtain the additional negative sample relevance corresponding to the image-text pair. The additional negative sample includes at least one of a first additional negative sample and a second additional negative sample. The first additional negative sample includes the first image feature representation of the image-text pair and the first feature representation of any target text. The second additional negative sample includes the first text feature representation of the image-text pair and the first feature representation of any target image. The any target text is text other than the text in the image-text pair in the training dataset, and the any target image is an image other than the image in the image-text pair in the training dataset.

[0012] In some embodiments, the negative sample determination unit includes a negative feature acquisition subunit, a feature determination subunit, and a relevance calculation subunit, comprising: the negative feature acquisition subunit, configured to acquire at least one negative feature representation, wherein the at least one negative feature representation includes at least one of negative image feature representation and negative text feature representation; the feature determination subunit, configured to determine at least one target negative sample corresponding to the image-text pair, wherein the at least one target negative sample includes at least one of a first target negative sample and a second target negative sample, wherein the first target negative sample includes the first image feature representation of the image-text pair and any acquired negative text feature representation, and the second target negative sample includes the first text feature representation of the image-text pair and any acquired negative image feature representation; the relevance calculation subunit, configured to perform relevance calculation on the first image feature representation and the negative text feature representation in the first target negative sample to obtain the relevance of the target negative sample corresponding to the image-text pair; or, to perform relevance calculation on the first text feature representation and the negative image feature representation in the second target negative sample to obtain the relevance of the target negative sample corresponding to the image-text pair.

[0013] In some embodiments, the model training device further includes a storage unit, which is used to: in any iteration round, store the second feature representation extracted in the current iteration round into a preset feature storage queue, wherein the queue length of the preset feature storage queue is a preset length;

[0014] The negative feature acquisition subunit is specifically used to: acquire the feature representation of the target quantity from the preset feature storage queue, and use the acquired feature representation of the target quantity as the negative feature representation, wherein the target quantity is related to the preset length, and the feature representation of the target quantity includes the second feature representation and the historical feature representation.

[0015] In some implementations, the update unit includes a loss determination subunit and a model update subunit, including: the loss determination subunit is used to determine the image-text matching loss based on the positive sample relevance and the negative sample relevance; the model update subunit is used to update the image-text matching model using the image-text matching loss until the iteration meets a preset termination condition to obtain the trained image-text matching model.

[0016] In some embodiments, the model training method further includes a momentum update unit, which is used to: obtain a first parameter, a second parameter, and a momentum coefficient, wherein the first parameter and the second parameter are model parameters of the main encoder and the negative feature encoder in the current iteration, respectively; use the momentum coefficient to perform a weighted summation of the first parameter and the second parameter to obtain the updated model parameters of the negative feature encoder, and use the updated model parameters as the model parameters of the negative feature encoder in the next iteration.

[0017] This application embodiment also provides an information processing apparatus, including: a to-be-processed determination unit, configured to determine to-be-processed information based on query information and at least one candidate information, wherein the to-be-processed information includes at least one information pair, the information pair including the query information and any one of the candidate information, and the query information and the candidate information being an image or text; an information feature extraction unit, configured to extract features from the information pair using a trained image-text matching model to obtain a target feature representation of the information pair, wherein the trained image-text matching model is obtained using any model training method provided in this application embodiment; a relevance determination unit, configured to calculate information relevance based on the target feature representation to obtain the information relevance of the information in the information pair; and a target determination unit, configured to determine target information matching the query information from the at least one candidate information based on the information relevance.

[0018] This application also provides an electronic device, including a processor and a memory, wherein the memory stores multiple instructions; the processor loads instructions from the memory to execute steps in any of the model training methods or information processing methods provided in this application.

[0019] This application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the model training methods or information processing methods provided in this application.

[0020] This application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps in any of the model training methods or information processing methods provided in this application.

[0021] This application embodiment can obtain a training dataset, a negative feature encoder, and an image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes a master encoder. Using the master encoder and the negative feature encoder, features are extracted from the image-text pair to obtain a first feature representation and a second feature representation of the image-text pair. Based on the first feature representation, image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair. Based on the first feature representation and the negative feature representation, image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and historical feature representation, where the historical feature representation is the second feature representation extracted in previous iterations. Based on the positive sample relevance and the negative sample relevance, the image-text matching model is updated until the iteration meets a preset termination condition to obtain a trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0022] In this application, during the training process of the image-text matching model, a negative feature representation is constructed through a negative feature encoder. This allows for the construction of rich and diverse negative samples for the image-text pairs in the training data with only a small amount of training data, so as to obtain the corresponding negative sample relevance for model updates. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1a This is a schematic diagram of a scenario illustrating the model training method and information processing method provided in the embodiments of this application;

[0025] Figure 1bThis is a flowchart illustrating the model training method provided in the embodiments of this application;

[0026] Figure 1c This is a schematic diagram of the model training process provided in the embodiments of this application;

[0027] Figure 1d This is a schematic diagram of another model training process provided in an embodiment of this application;

[0028] Figure 2 This is a flowchart illustrating the information processing method provided in an embodiment of this application;

[0029] Figure 3 This is a flowchart illustrating a model training method provided in another embodiment of this application;

[0030] Figure 4 This is a schematic diagram of the structure of the model training device provided in the embodiments of this application;

[0031] Figure 5 This is a schematic diagram of the structure of the information processing device provided in the embodiments of this application;

[0032] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0033] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0034] This application provides a model training method, an information processing method, and related equipment.

[0035] Specifically, the model training device or information processing device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.

[0036] In some embodiments, the model training device or information processing device may also be integrated into multiple electronic devices. For example, the model training device or information processing device may be integrated into multiple servers, and the model training method or information processing method of this application may be implemented by multiple servers.

[0037] In some embodiments, the terminal can also be used as a server to implement some or all of the functions of a server.

[0038] For example, refer to Figure 1a Taking the joint execution of the model training method and information processing method by a terminal and a server as an example, the information processing system provided in this application includes a terminal and a server, etc.; the terminal and the server are connected through a network, such as through a wired or wireless network, etc., wherein the model training device or information processing device can be integrated into the terminal.

[0039] The terminal can be used to: send query information to the server for information processing, and receive target information returned by the server. The terminal can include mobile phones, vehicle-mounted terminals, aircraft, tablets, laptops, or personal computers (PCs), etc. A client can also be set on the terminal, which can be an application client or a browser client, etc.

[0040] The server can be used to: acquire a training dataset, a negative feature encoder, and an image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes a master encoder. Using the master encoder and the negative feature encoder, features are extracted from the image-text pairs to obtain a first feature representation and a second feature representation of the image-text pairs. Based on the first feature representation, image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair. Based on the first feature representation and the negative feature representation, image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and historical feature representation, where the historical feature representation is the second feature representation extracted in previous iterations. Based on the positive sample relevance and the negative sample relevance, the image-text matching model is updated until the iteration meets a preset termination condition to obtain the trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0041] The server can also be used to: determine information to be processed based on query information and at least one candidate information, wherein the information to be processed includes at least one information pair, the information pair including query information and any candidate information, and the query information and candidate information being images or text; extract features from the information pair through a trained image-text matching model to obtain the target feature representation of the information pair; calculate the information relevance based on the target feature representation to obtain the information relevance of the information in the information pair; and determine the target information that matches the query information from at least one candidate information based on the information relevance.

[0042] The server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.

[0043] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0044] The following sections provide detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. It is understood that the specific embodiments of this application involve user-related data such as images, text, feature representations, query information, and information to be processed. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0045] In this embodiment, a model training method is provided, such as Figure 1b As shown, the specific process of this model training method can be as follows:

[0046] 110. Obtain the training dataset, the negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the main encoder.

[0047] The training dataset refers to the set of samples used to train the image-text matching model. This dataset can include one or more image-text pairs, with each image-text pair constituting one sample. An image-text pair is a data pair consisting of a related image and text. The text in the image-text pair can be descriptive text for the image in the pair, such as text describing the image content, image category, or one or more other pieces of information.

[0048] The model training method provided in this application can be applied to various image-text matching scenarios, such as image-text search scenarios. In some implementations, the training dataset is a collection of data from a specific application scenario, so that the trained image-text matching model has better performance in that specific application scenario. Taking product search as an example, the image in any image-text pair can be a photo or product image of the product, and the text in the image-text pair can be one or more combinations of descriptive text such as the product name, title, and product description.

[0049] Image-text matching models are deep learning models that compare, match, and associate images and text. Their main task is to learn the relationships between images and text, ensuring the model can understand and capture the correlations and differences between them. The core objective of image-text matching models is to ensure that related images and text have relevant feature representations, while unrelated images and text should have significant distances or feature differences.

[0050] In this context, the master encoder refers to the encoder in the image-text matching model, also known as the standard encoder, which is used to generate feature representations of the input. Therefore, for any image-text pair, the feature representation generated by the master encoder in each iteration can be considered as a positive feature representation (i.e., a correct feature representation) of the image and text in that pair.

[0051] In this context, the negative feature encoder refers to an encoder used to generate negative feature representations. These negative feature representations are different from the positive feature representations (i.e., erroneous feature representations), and can be used to construct feature representations for negative samples. Therefore, the main function of the negative feature encoder is to construct corresponding negative samples by generating feature representations different from those of the main encoder (i.e., negative feature representations).

[0052] In this embodiment, the image-text matching model can be iteratively trained using a training dataset and a negative feature encoder. Each iteration retrieves the image-text matching model updated in the previous iteration, and the model parameters of this model are the same as those obtained in the previous iteration. Specifically, in the first iteration, the model parameters of the image-text matching model updated in the previous iteration are the initial model parameters.

[0053] 120. Using the main encoder and the negative feature encoder, extract features from the image-text pair to obtain the first feature representation and the second feature representation of the image-text pair.

[0054] Feature extraction refers to extracting feature representations from the input (i.e., text-image pairs) that can characterize its core information. This feature representation is the output of feature extraction, usually a vector or embedding, which contains key information about the data and can be used for subsequent tasks.

[0055] The first feature represents the feature representation extracted from the image-text pair by the main encoder (i.e., the positive feature representation), and the second feature represents the feature representation extracted from the image-text pair by the negative feature encoder (i.e., the negative feature representation).

[0056] For example, in each iteration of this application, feature extraction can be performed on each image-text pair in the training dataset. For instance, for any image-text pair, an encoder (master encoder or negative feature encoder) can be used to encode the input (i.e., each image-text pair) to map the image and text in the image-text pair to a feature space, thereby converting them into corresponding feature representations. These feature representations of the image and text can represent the content of the image and text. In this application embodiment, for any image-text pair, the first feature representation includes a first image feature representation of the image in the image-text pair and a first text feature representation of the text in the image-text pair, and the second feature representation includes a second image feature representation of the image in the image-text pair and a second text feature representation of the text in the image-text pair.

[0057] In some implementations, feature extraction can be performed separately on the image and text in the image-text pair to extract and represent data of different modalities in the image-text pair separately. This facilitates the construction of cross-modal samples based on the extracted image feature representations and text feature representations, and the calculation of intra-sample image-text correlation. Specifically, the main encoder includes a first image encoder and a first text encoder, and the negative feature encoder includes a second image encoder and a second text encoder. Using the main encoder and the negative feature encoder, feature extraction is performed on the image-text pair to obtain a first feature representation and a second feature representation of the image-text pair, including:

[0058] Using a first image encoder, feature extraction is performed on the image in the image-text pair to obtain a first image feature representation of the image-text pair; and using a first text encoder, feature extraction is performed on the text in the image-text pair to obtain a first text feature representation of the image-text pair.

[0059] Using a second image encoder, features are extracted from the image in the image-text pair to obtain a second image feature representation of the image-text pair. Similarly, using a second text encoder, features are extracted from the text in the image-text pair to obtain a second text feature representation of the image-text pair.

[0060] For example, for any image-text pair, the first image encoder and the second image encoder can extract features from the image using a model architecture such as a convolutional neural network (CNN) or Vision Transformer (ViT, multi-head attention) to obtain a first feature representation (i.e., the first image feature representation) and a second feature representation (i.e., the second image feature representation) of the image in the image-text pair. Similarly, the first text encoder and the second text encoder can extract features from the text using a convolutional neural network (CNN), or a model architecture such as Transformer, BERT, or other attention-based models to obtain a first feature representation (i.e., the first text feature representation) and a second feature representation (i.e., the second text feature representation) of the text in the image-text pair.

[0061] In some implementations, the first image encoder and the second image encoder can have the same network structure, and the first text encoder and the second text encoder can have the same network structure, so that encoders processing the same modal data have similar performance in the feature extraction process, and they will follow similar mechanisms when generating feature representations, so that the generated feature representations are comparable, which facilitates subsequent correlation comparison and calculation.

[0062] For example, the first image encoder and the second image encoder can be image encoders of the visual branch of a contrastive language-image pre-trained model (such as CLIP), such as the Vision Transformer; the first text encoder and the second text encoder can be text encoders of the natural language branch of a contrastive language-image pre-trained model (CLIP), such as the Bert-base model (a transducer represented by a bidirectional encoder). The image encoder and the text encoder form a dual-tower structure.

[0063] Specifically, the first and second image encoders use a Vision Transformer convolutional kernel with a basepatchsize of 16 to process the images in the text-image pair. Compared to a convolutional kernel with a patchsize of 32, patchsize=16 provides more fine-grained semantic information about the images. Then, a self-attention mechanism is used to focus on the importance of each image patch, achieving a global understanding of the image and converting it into a low-dimensional vector representation (Embedding, i.e., the first or second image feature representation). The first and second text encoders, on the other hand, use a 12-layer Bert-base model within the Transformer architecture to process the text and generate high-quality text vector representations (Embedding, i.e., the first or second text feature representation).

[0064] In some implementations, feature extraction can be performed sequentially on the image-text pair to obtain a first feature sequence. Specifically, a first image encoder is used to extract features from the image in the image-text pair to obtain a first image feature representation of the image-text pair, and a first text encoder is used to extract features from the text in the image-text pair to obtain a first text feature representation of the image-text pair, including:

[0065] Using a first image encoder, features are extracted sequentially from the images in at least one image-text pair to obtain an image feature representation sequence;

[0066] Using a first text encoder, features are extracted sequentially from the text in at least one image-text pair to obtain a text feature representation sequence.

[0067] Here, the image feature representation sequence refers to the sequence composed of the first feature representations of an image (i.e., the first image feature representation). The text feature representation sequence refers to the sequence composed of the first feature representations of text (i.e., the first text feature representation).

[0068] For example, the training dataset includes at least one batch of samples, and each batch can include at least one image-text pair. In each iteration, one or more batches can be selected for that iteration. Figure 1c The model training process is illustrated, where any sample batch consists of an input sequence of n image-text pairs. After this input sequence is fed into the main encoder, the first image encoder can sequentially extract features from the n images in the input sequence to obtain an image feature representation sequence (e.g., a 768-dimensional image embedding). This sequence includes the first image feature representations of the n images, and the first image feature representations of the n images in this sequence are ordered in accordance with the order of the n image-text pairs in the input sequence. Simultaneously, the first text encoder can sequentially extract features from the n texts in the input sequence to obtain a text feature representation sequence (e.g., a 768-dimensional text embedding). This sequence includes the first text feature representations of the n texts, and the first text feature representations of the n texts in this sequence are ordered in accordance with the order of the n image-text pairs in the input sequence.

[0069] Correspondingly, such as Figure 1c The model training process shown can input the input sequence of the sample batch into the negative feature encoder, so that the second image encoder and the second text encoder can sequentially extract features from the n images and n texts in the input sequence to obtain the image feature representation sequence and the text feature representation sequence. The image feature representation sequence and the text feature representation sequence respectively include the second image feature representation of n images and the second text feature representation of n texts.

[0070] 130. Calculate the correlation between the image and text based on the first feature representation to obtain the positive sample correlation between the image and text pairs.

[0071] In this context, a positive sample refers to a pair consisting of a relevant image and text. That is, one image-text pair corresponds to one positive sample, and the image and text in the image-text pair together constitute a positive sample.

[0072] Image-text relevance calculation refers to the process of calculating the relevance between an image and text. Positive sample relevance refers to the relevance between an image and text in a positive sample.

[0073] For example, positive samples can be represented as feature representations, such as images and text in positive samples being represented as corresponding positive feature representations (i.e., first feature representations). Thus, a positive sample can be a feature composed of the first feature representations of related images and text (i.e., images and text belonging to the same image-text pair) in the current iteration. For instance, in each iteration, for any image-text pair, the corresponding positive sample is a pair consisting of the first image feature representation of the image in the image-text pair extracted by the main encoder in that iteration and the first text feature representation of the text in the image-text pair. Positive sample relevance refers to the correlation between the image feature representation and the text feature representation in the corresponding positive sample representation.

[0074] In some implementations, the similarity between the feature representations of images and text in a sample can be used to represent the relevance between the images and text in the sample, i.e., the sample relevance. For example, similarity calculation methods such as dot product similarity, inner product similarity (i.e., cosine similarity), and Euclidean distance can be used to calculate the image-text relevance. For instance, by calculating the similarity between the feature representations of images and text in positive or negative samples, the corresponding positive or negative sample relevance can be obtained.

[0075] In some implementations, the feature representations of the image and the feature representations of the text in the sample can be multiplied to obtain the sample relevance.

[0076] For example, in some implementations, for any image-text pair, the first feature representations of the image and text extracted by the main encoder in the current iteration can be used as positive samples of the image-text pair, and the positive sample relevance can be calculated. This ensures that the feature representations of different modalities in the positive samples are obtained synchronously in the same iteration, so that their feature representations are consistent, and thus their relevance can more accurately represent the positive sample relevance. Specifically, the first feature representation includes a first image feature representation and a first text feature representation. Based on the first feature representation, the image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair, including:

[0077] For any image-text pair, the correlation between the first image feature representation and the first text feature representation of the image-text pair is calculated to obtain the positive sample correlation of the image-text pair.

[0078] For example, in each iteration, for any image-text pair such as image i-text i, the positive sample is a pair of feature representations of image i and text i in the image-text pair, such as {image feature representation i, text feature representation i}. This image feature representation and text feature representation are the positive feature representations extracted by the main encoder in the current iteration. Therefore, the positive sample corresponding to any image-text pair is the pair of the first feature representation of the image (i.e., the first image feature representation) and the feature representation of the text (i.e., the first text feature representation) obtained by feature extraction of the image-text pair using the main encoder in the current iteration. For this image-text pair, the correlation can be calculated by multiplying the first feature representations of the image and text in the negative sample; the resulting correlation value is the correlation of the positive sample corresponding to this image-text pair.

[0079] In some implementations, the encoded image feature representation sequence can be multiplied by the text feature representation sequence to obtain the relevance of all relevant images and texts (i.e., positive sample relevance) and the relevance of irrelevant images and texts (i.e., negative sample relevance) with a single multiplication operation, thereby improving the efficiency of determining sample relevance. Specifically, for any image-text pair, the relevance of the first image feature representation and the first text feature representation of the image-text pair is calculated to obtain the positive sample relevance of the image-text pair, including:

[0080] Multiply the image feature representation sequence and the text feature representation sequence to obtain the relevance matrix. The image feature representation sequence is a sequence composed of the first image feature representations of at least one image-text pair, and the text feature representation sequence is a sequence composed of the first text feature representations of at least one image-text pair. The sequence order of the image feature representation sequence and the text feature representation sequence corresponds.

[0081] For any image-text pair, extract the diagonal elements corresponding to the image-text pair from the relevance matrix to obtain the positive sample relevance of the image-text pair.

[0082] The relevance matrix is ​​a matrix composed of the relevance scores of all images and texts in at least one image-text pair. These relevance scores include the relevance scores of related image texts (i.e., image texts within the same image-text pair, i.e., positive sample relevance) and the relevance scores of irrelevant image texts (i.e., image texts in different image-text pairs, i.e., negative sample relevance). Each element in the relevance matrix represents a single sample relevance score.

[0083] In this context, diagonal elements refer to elements located on the diagonal of the relevance matrix. Conversely, off-diagonal elements refer to elements not located on the diagonal of the relevance matrix; that is, all elements in the relevance matrix other than the diagonal elements are off-diagonal elements.

[0084] For example, during this iteration, after the input sequence of a sample batch is input into the main encoder, it can generate a 768-dimensional image embedding (i.e., an image feature representation sequence) and a 768-dimensional text embedding (i.e., a text feature representation sequence). Multiplying the image embedding and the text embedding yields a score matrix (i.e., a relevance matrix) for all image-text matching in the sample batch. The diagonal elements of the matrix represent the relevance of all image-text pairs belonging to the same image-text pair in the sample batch (i.e., related image-text pairs) (i.e., positive sample relevance), while the other off-diagonal elements represent the relevance of unrelated image-text pairs (i.e., additional negative sample relevance). Therefore, the diagonal elements corresponding to each image-text pair can be extracted from this relevance matrix, i.e., the relevance of the image-text pairs in the sample batch, i.e., the positive sample relevance.

[0085] In some implementations, before iterative training, image-text pairs in each batch of samples can be deduplicated to ensure that images or texts with the same content do not appear repeatedly in different image-text pairs within the same batch of samples. This avoids the appearance of correct features in additional negative samples, thereby improving the quality of the training set and preventing the model from learning incorrect samples.

[0086] For example, taking product search as an example, when constructing the training dataset, the image-text pairs within each batch can be deduplicated and cleaned to ensure that the same product is not sampled repeatedly in the same batch. Furthermore, a product often has multiple images and a name; therefore, the product images and names can be grouped into image-text pairs, i.e., one image corresponds to one text. Then, image-text pairs belonging to the same product are shuffled and placed into different batches, thus ensuring that image-text pairs corresponding to the same product do not appear in the same batch.

[0087] 140. Calculate the image-text relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance of the image-text pair. The negative feature representation is obtained from the second feature representation and the historical feature representation. The historical feature representation is the second feature representation extracted in the historical iteration rounds.

[0088] Among them, negative feature representation refers to the feature representation extracted by negative feature encoder.

[0089] In some implementations, the negative feature representation includes at least one of a second feature representation and a historical feature representation. That is, the negative feature representation may include the feature representation extracted by the negative feature encoder in the current iteration round and / or in the historical iteration rounds, and the feature representation extracted by the negative feature encoder in the historical iteration rounds is the historical feature representation. In this embodiment, the N-1 iteration rounds preceding the current iteration round can be used as the historical iteration rounds, where N is a positive integer greater than 1, and N can be set according to actual needs or application scenarios.

[0090] In this context, negative samples are pairs consisting of unrelated images and text. That is, the image in any image-text pair forms a negative sample with other text, or the text in any image-text pair forms a negative sample with other images. In this embodiment, negative samples can be constructed from textual features of the text and image features of the image; therefore, negative samples can be represented in the form of feature representations. Consequently, in this embodiment, negative samples can also be pairs consisting of unrelated image features and text features.

[0091] Negative sample relevance refers to the correlation between images and text in negative samples. In this embodiment, negative sample relevance can be the correlation between image feature representations and text feature representations in negative samples. In this embodiment, in each iteration, one image-text pair corresponds to only one positive sample, but one image-text pair can correspond to one or more negative samples; therefore, one image-text pair can correspond to one or more negative sample similarities.

[0092] Here, the target negative sample refers to the negative sample constructed from the first feature representation and the negative feature representation, which are extracted by the main encoder and the negative feature encoder, respectively. For example, for any image-text pair, the target negative sample corresponding to the image-text pair is the pair of the first feature representation of the image / text in the current iteration and any negative feature representation of any text / image.

[0093] Among them, the target negative sample correlation is the correlation of the target negative sample, that is, the correlation between the first feature representation and the negative feature representation in the target negative sample. This correlation can characterize the correlation between unrelated image features and text features.

[0094] For example, in each iteration, the image and text in the target negative sample can be represented by corresponding feature representations. These feature representations can be positive feature representations (i.e., positive feature representations extracted by the main encoder in the current iteration) or negative feature representations (negative feature representations extracted by the negative feature encoder in the current iteration or in previous iterations). Thus, the target negative sample is a pair consisting of unrelated image feature representations and text feature representations.

[0095] For example, in some implementations, for any image-text pair, the first feature representation of the image or text extracted by the main encoder in the current iteration round and the first feature of the text or image extracted by the negative feature encoder in the current iteration round and / or historical iteration rounds can be used to construct a negative sample of the image-text pair and calculate the negative sample relevance. This utilizes the positive and negative feature representations extracted by the main encoder and the negative feature encoder to construct new negative samples, thereby increasing the diversity and richness of negative samples. Specifically, the image-text relevance calculation based on the first feature representation and the negative feature representation yields the target negative sample relevance corresponding to the image-text pair, including:

[0096] Obtain at least one negative feature representation;

[0097] The correlation between the obtained negative feature representation and the first feature representation is calculated to obtain the correlation between the target negative sample and the image-text pair.

[0098] For example, the first feature representation includes a first image feature representation and a first text feature representation, and at least one negative feature representation includes at least one of a negative feature representation of an image and a negative feature representation of text. The correlation between the obtained negative feature representation and the first feature representation is calculated to obtain the correlation between the target negative sample and the image-text pair, including:

[0099] Determine at least one target negative sample corresponding to the image-text pair. The at least one target negative sample includes at least one of a first target negative sample and a second target negative sample. The first target negative sample includes a first image feature representation of the image-text pair and any acquired negative text feature representation. The second target negative sample includes a first text feature representation of the image-text pair and any acquired negative image feature representation.

[0100] The correlation between the first image feature representation and the negative text feature representation in the first target negative sample is calculated to obtain the correlation between the image and text pairs and the target negative samples.

[0101] Alternatively, the correlation between the first text feature representation and the negative image feature representation in the second target negative sample can be calculated to obtain the correlation between the text and image pairs and the target negative samples.

[0102] For example, for any image-text pair (e.g., image i - text i), the target negative sample can include a pairing of the first image feature representation of image i and the negative text feature representation of any text j in the image-text pair, such as the first target negative sample {first image feature representation i, negative text feature representation j}, and / or a pairing of the negative image feature representation of any image j and the first text feature representation of text i in the image-text pair, such as the second target negative sample {negative image feature representation k, first text feature representation i}, and so on. Here, image i and text j can be related images and text or unrelated images and text; that is, text j can be text i in the image-text pair or any other text. Similarly, image k and text j can be text from a related image or text from an unrelated image; that is, image k can be image i in the image-text pair or any other image. For each first target negative sample and / or second target negative sample of the image-text pair, the relevance can be calculated by multiplying the first feature representation and the negative feature representation in each negative sample; the resulting relevance value is the relevance of the target negative sample corresponding to the image-text pair.

[0103] It should be noted that in the embodiments of this application, the negative feature representation extracted by the negative feature encoder differs from the first feature representation extracted by the main encoder. Therefore, for any image-text pair (such as image i-text i), even the negative feature representation i (i.e., the second feature representation) of the same image i / text i will deviate from its first feature representation i. For example, for images and texts belonging to the same image-text pair, the correlation between the negative feature representation i of image i and the first text feature representation i of text i is lower than the correlation between the first image feature representation i of image i and the first text feature representation i of text i. Therefore, a target negative sample can be constructed using the negative feature representation (i.e., the second feature representation) of the image in the same image-text pair and the first text feature representation of the text, or the target negative sample can be constructed using the first feature representation of the image in the same image-text pair and the negative text feature representation (i.e., the second feature representation) of the image.

[0104] Furthermore, for different image-text pairs, such as image i and text j or image k and text i, the correlation between the corresponding negative feature representation (i.e., the second feature representation) and the first feature representation is lower than the correlation between the corresponding first feature representations. Therefore, the negative feature representation (i.e., the second feature representation) and the first feature representation of different image-text pairs, such as image i and text j or image k and text i, are used to construct target negative samples in order to build effective negative samples and increase the diversity and richness of negative samples.

[0105] Furthermore, in this embodiment, negative feature representations from previous iterations (i.e., historical feature representations) can be added to construct the target negative samples. Since the negative feature encoder extracts different negative feature representations in each iteration of training as iterative training is updated, historically extracted negative feature representations can be added to construct negative samples, thereby further increasing the diversity and richness of the negative samples.

[0106] Therefore, in this embodiment of the application, during the training process of the image-text matching model, negative feature representations are constructed by constructing negative feature encoders, enabling the construction of various negative samples for given training data. These negative samples can include at least a variety of the following eight types: negative samples constructed from the first feature representation of the image and the second feature representation of the text in the same image-text pair; negative samples constructed from the second feature representation of the image and the first feature representation of the text in the same image-text pair; negative samples constructed from the first feature representation of the image and the second feature representation of the text in different image-text pairs; negative samples constructed from the second feature representation of the image and the first feature representation of the text in different image-text pairs; negative samples constructed from the first feature representation of the image and the historical feature representation of the text in the same image-text pair; negative samples constructed from the historical feature representation of the image and the first feature representation of the text in the same image-text pair; negative samples constructed from the first feature representation of the image and the historical feature representation of the text in different image-text pairs; and negative samples constructed from the historical feature representation of the image and the first feature representation of the text in different image-text pairs. With this method, only a small amount of training data is needed to construct rich and diverse negative samples from the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model updates. This ensures the diversity and quality of negative samples even with a small amount of training data, thereby reducing the dependence on large-scale training datasets.

[0107] In multimodal learning, image-text matching training methods typically require pre-constructing a large-scale training dataset containing numerous image-text pairs to increase sample diversity. However, training on large-scale datasets usually demands powerful hardware support, leading to high training costs. In contrast, this embodiment constructs negative feature representations using a negative feature encoder, requiring only a small amount of training data to build rich and diverse negative samples during training. This allows for good training results even with limited training data and hardware resources, avoiding the hardware support required for large-scale dataset training. Therefore, this method effectively reduces the need for hardware support such as high-performance GPU clusters in multimodal learning, especially in the training of image-text matching models, thereby lowering training costs.

[0108] In some implementations, a fixed-size preset feature storage queue can be introduced to store the second feature representations. This ensures that the number of available negative feature representations is fixed during iterative training; that is, a fixed number of negative feature representations can be retrieved from the preset feature storage queue in each iteration. Therefore, the number of negative feature representations is independent of the number of samples used each time, decoupling the negative sample representations from the number of samples. This effectively prevents fluctuations in the number of negative samples during training, improving the consistency and stability of the training process and thus enhancing the model training effect.

[0109] Specifically, before obtaining at least one negative feature representation, the method further includes: in any iteration round, storing the second feature representation extracted in the current iteration round into a preset feature storage queue, wherein the queue length of the preset feature storage queue is a preset length;

[0110] Obtaining negative feature representations includes: obtaining feature representations of the target quantity from a preset feature storage queue, and using the obtained feature representations of the target quantity as negative feature representations. The target quantity is related to a preset length, and the feature representations of the target quantity include second feature representations and historical feature representations.

[0111] The preset feature storage queue refers to a queue used to store the second feature representation. The queue length of the preset feature storage queue is a preset fixed length to keep the queue size constant and avoid the infinite growth of the queue content. In some embodiments, when the negative feature encoder includes a second image encoder and a second text encoder, the preset feature storage queue includes an image feature storage queue and a text feature storage queue. The image feature storage queue is used to store the second feature representation of the image in the image-text pair, and the text feature storage queue is used to store the second feature representation of the text in the image-text pair.

[0112] For example, such as Figure 1d The model training process shown involves iterative training. In each iteration, the second feature representations of all images extracted in the current iteration are stored in an image feature storage queue, and the second feature representations of all text extracted in the current iteration are stored in a text feature storage queue. Thus, the preset feature storage queue can store the second feature representations extracted in the current iteration and the second feature representations extracted in previous iterations. For example, the preset feature storage queue can store the second feature representation extracted in the current iteration and the second feature representations extracted in the N-1 iterations prior to the current iteration (i.e., historical feature representations).

[0113] Therefore, in this embodiment of the application, in each iteration, a target number of second feature representations can be obtained from a preset feature storage queue. The target number can be set according to the application scenario or actual needs. The target number is less than or equal to the preset length of the queue to ensure that enough negative feature representations can be obtained each time.

[0114] In some implementations, the target number is the preset length of the queue. For example, if the queue length is K, all K second feature representations can be obtained from the preset feature storage queue as K negative feature representations. Therefore, in each iteration, the number (M) of additional negative samples constructed based on the negative sample representations depends on the queue length (K) of the preset feature storage queue. Verification has shown that setting the queue length of the preset feature storage queue to 30,000 or more yields the best model training results.

[0115] In some implementations, the preset feature storage queue adopts a first-in, first-out (FIFO) storage method, so that each time a new negative feature representation is added to the queue, the oldest negative feature representation in the queue is removed. This ensures that the negative feature representations in the queue are constantly updated, guaranteeing that the model can access newer negative samples. This avoids negative feature representations remaining in the queue for extended periods, which could lead to the model overlearning some outdated negative samples.

[0116] In some implementations, the number of historical iteration rounds and / or the length of the preset feature storage queue can be set according to the number of image-text pairs in the training dataset to ensure that a sufficient amount of negative sample features are obtained in each training process. For example, the number of historical iteration rounds and / or the preset feature storage queue can be set inversely proportional to the number of image-text pairs in the training dataset; that is, when the number of image-text pairs in the training dataset is small, more historical iteration rounds and / or a longer preset feature storage queue length can be set.

[0117] In some implementations, for any image-text pair, the first feature representation of the image or text extracted by the main encoder for that image-text pair in the current iteration can be combined with the first features of the text or image extracted by the main encoder for other text or images in the current iteration to construct a negative sample for that image-text pair and calculate the negative sample relevance. This utilizes the positive feature representation extracted in the current iteration to construct negative samples, thereby increasing the diversity and richness of negative samples. Specifically, the negative sample relevance also includes additional negative sample relevance. The model training method also includes:

[0118] For any image-text pair, based on the additional negative samples corresponding to the image-text pair, the relevance of the additional negative samples corresponding to the image-text pair is determined. The additional negative samples include at least one of a first additional negative sample and a second additional negative sample. The first additional negative sample includes a first image feature representation of the image-text pair and a first feature representation of any target text. The second additional negative sample includes a first text feature representation of the image-text pair and a first feature representation of any target image. Any target text is text other than the text in the image-text pair in the training dataset, and any target image is an image other than the image in the image-text pair in the training dataset.

[0119] Here, additional negative samples refer to negative samples constructed from the first feature representations of an image and unrelated text, which are extracted by the main encoder. Specifically, additional negative samples are negative samples composed of the first feature representations of unrelated images and text (i.e., images and text that do not belong to the same image-text pair) in the current iteration. For example, for any image-text pair, the additional negative sample corresponding to the image-text pair is the pairing of the first feature representation of the image / text in the current iteration with the first feature representation of any other text / image in the current iteration.

[0120] Among them, the additional negative sample correlation is the correlation of the additional negative samples, that is, the correlation between the first image feature representation and the first text feature in the additional negative samples. This correlation can characterize the correlation between unrelated images and text.

[0121] For example, for any image-text pair (e.g., image i - text i), additional negative samples can include a pairing of the first image feature representation of image i and the first text feature representation of any text m in the image-text pair, such as a first additional negative sample {first image feature representation i, first text feature representation m}, and / or a pairing of the first image feature representation of any image n and the first text feature representation of text i in the image-text pair, such as a second additional negative sample {first image feature representation n, first text feature representation i}, and so on. Here, image i and text m are unrelated image and text, that is, text m can be any text in the training dataset other than text i. Similarly, image n and text i are unrelated image and text, that is, image n can be any image in the training dataset other than image i. For each first additional negative sample and / or second additional negative sample of the image-text pair, the first feature representation of the image and the first feature representation of the text in each negative sample can be multiplied to calculate the correlation. The resulting correlation value is the correlation of the additional negative sample corresponding to the image-text pair.

[0122] In some implementations, off-diagonal elements can be directly extracted as additional negative sample relevance from the relevance matrix obtained by multiplying the encoded image feature representation sequence and the text feature representation sequence, thereby improving the efficiency of determining negative sample relevance. Specifically, for any image-text pair, based on the additional negative samples corresponding to the image-text pair, the additional negative sample relevance corresponding to the image-text pair is determined, including:

[0123] For any image-text pair, extract the off-diagonal elements corresponding to the additional negative sample pairs from the relevance matrix to obtain the additional negative sample relevance of the image-text pair.

[0124] For example, after multiplying the image feature representation sequence and the text feature representation sequence to obtain the relevance matrix, off-diagonal elements can be extracted from this relevance matrix as additional negative sample relevance for the image-text pair. This means extracting the relevance of unrelated images and texts in the sample batch, i.e., the additional negative sample relevance. It should be noted that when extracting off-diagonal elements, for any image-text pair, the off-diagonal elements in the row and column containing the positive sample relevance (i.e., the diagonal elements) of that image-text pair can be extracted from the relevance matrix as the additional negative sample relevance for that image-text pair.

[0125] 150. Based on the positive and negative sample relevance, update the image-text matching model until the iteration meets the preset termination condition to obtain the trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0126] The preset termination condition refers to the condition used to terminate the iterative training process. This preset termination condition can be set according to actual needs or application scenarios. For example, the preset termination condition may include, but is not limited to, reaching the maximum number of training rounds, loss (such as text-image matching loss) convergence, reaching the specified validation set accuracy, reaching the maximum training time, etc.

[0127] For example, during the training of an image-text matching model, multiple iterations are performed. In each iteration, the model parameters are adjusted based on the current model performance (i.e., the relevance between positive and negative samples) until the model reaches a preset termination condition. For instance, in each iteration, the model parameters can be adjusted based on the positive and negative sample relevance determined in the current iteration, and it is determined whether the preset termination condition is met. If not, the next iteration of training begins, repeating steps 110 to 150. If the condition is met, training terminates, and the image-text matching model with adjusted parameters becomes the trained image-text matching model. This trained model can be used to extract features from input images or text to obtain feature representations of the image or text. Based on these feature representations, the relevance between images, between images and text, or between texts can be calculated pairwise. This allows for image-text search, image-text search, text-text search, and text-image search functions, applicable to image-text retrieval systems, image-text recommendation systems, and other image-text query scenarios.

[0128] In some implementations, the image-text matching loss can be calculated from the positive and negative sample relevance to measure and optimize the overall positive and negative sample relevance, thereby adjusting the model and improving its training performance. Specifically, based on the positive and negative sample relevance, the image-text matching model is updated until a preset termination condition is met, resulting in a trained image-text matching model, including:

[0129] The image-text matching loss is determined based on the positive and negative sample correlation.

[0130] The image-text matching model is updated using the image-text matching loss until the preset termination condition is met, resulting in the trained image-text matching model.

[0131] Image-text matching loss refers to the loss used to measure the correlation between an image and text. In this embodiment, image-text matching loss determines whether an image and text match by calculating the correlation between them.

[0132] For example, such as Figure 1c The model training process shown involves obtaining the positive and negative sample relevance scores, and then using loss functions such as the contrastive loss function to calculate the image-text matching loss. The goal of this loss is to maximize the relevance between relevant images and text (i.e., positive sample relevance) while minimizing the relevance between irrelevant images and text (i.e., negative sample relevance), thereby improving the accuracy of image-text matching.

[0133] For example, in some implementations, the cross-entropy loss function is used to calculate the image-text matching loss based on the relevance of positive and negative samples.

[0134] In some implementations, the model parameter update mechanisms for the main encoder and the negative feature encoder are different. For example, ... Figure 1d The model training process shown illustrates that the main encoder updates its parameters using gradient updates during iterative training. The negative feature encoder can be a momentum encoder, which updates its parameters using a momentum update strategy during iterative training. Here, momentum update refers to updating the encoder's parameters using momentum. Therefore, the model parameters of the negative feature encoder obtained in each iteration are the same as the encoder's model parameters obtained from the momentum update in the previous iteration.

[0135] It should be noted that in this embodiment, the momentum encoder updates the encoder using momentum, which is a relatively slow update speed. Therefore, it can also be called a slow encoder. The momentum update strategy allows the parameters of the momentum encoder to be updated more smoothly, ensuring that the generated negative feature representation is relatively stable and that the negative feature representation does not change drastically due to excessively rapid updates during each training session. This ensures the quality of the corresponding negative samples and improves the training effect. In contrast, the main encoder updates faster and can therefore be called a fast encoder.

[0136] In this embodiment, the image-text matching model (i.e., the main encoder) is updated using gradient updates, and the negative feature encoder is updated using momentum updates. The reason for using the features from the first N iterations as negative samples is that if the relevance obtained from multiplication differs too much, the model training effect will deteriorate. Therefore, momentum updates are used to update the negative feature encoder to ensure that the outputs of the main encoder and the negative feature encoder do not differ too much, thus avoiding the model's inability to effectively distinguish between positive and negative samples due to excessive bias in positive and negative sample analysis.

[0137] Furthermore, when the first image encoder and the second image encoder have the same network structure, and the first text encoder and the second text encoder have the same network structure, using different update mechanisms to update the main encoder and the negative feature encoder can make the feature representations extracted by the main encoder and the negative feature encoder different, thereby making the difference between positive and negative samples more obvious, so that the model can better distinguish between positive and negative samples and improve the image-text matching ability.

[0138] In some implementations, the model parameters of the negative feature encoder can be updated based on the momentum of the model parameters of the main encoder. Through this momentum update method, the parameters of the negative feature encoder gradually approach the parameters of the main encoder in each iteration, further avoiding the model's inability to effectively distinguish between positive and negative samples due to excessive bias. Furthermore, due to the presence of momentum, the update is relatively smooth, avoiding overly drastic changes in model parameters. Specifically, the model training method also includes:

[0139] Obtain the first parameter, the second parameter, and the momentum coefficient. The first parameter and the second parameter are the model parameters of the main encoder and the negative feature encoder in the current iteration, respectively.

[0140] Using the momentum coefficient, the first and second parameters are weighted and summed to obtain the updated model parameters of the negative feature encoder, and the updated model parameters are used as the model parameters of the negative feature encoder in the next iteration.

[0141] The next iteration round refers to the iteration round following the current iteration round.

[0142] For example, the momentum of the negative feature encoder can be updated as follows:

[0143]

[0144] Where, θ q The current model parameters of the main encoder, θ k These are the current model parameters for the negative feature encoder. These are the updated model parameters from the negative feature encoder. m is the momentum coefficient, which can be set according to the application scenario or actual needs. For example, m is usually close to 1, such as 0.99.

[0145] The model training scheme provided in this application can be applied to various model training scenarios. For example, taking the training of an image-text matching model as an example, the following steps are taken: A training dataset, a negative feature encoder, and the image-text matching model updated in the previous iteration are obtained. The training dataset includes at least one image-text pair, and the image-text matching model includes a master encoder. Using the master encoder and the negative feature encoder, features are extracted from the image-text pair to obtain a first feature representation and a second feature representation. Based on the first feature representation, image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair. Based on the first feature representation and the negative feature representation, image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and historical feature representation, where the historical feature representation is the second feature representation extracted in previous iterations. Based on the positive sample relevance and the negative sample relevance, the image-text matching model is updated until the iteration meets a preset termination condition, resulting in a trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0146] As can be seen from the above, in the training process of the image-text matching model, negative feature representations are constructed by a negative feature encoder. In this way, only a small amount of training data is needed to construct rich and diverse negative samples for the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model updates. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs.

[0147] In this embodiment, an information processing method is also provided, such as... Figure 2 As shown, the specific process of this information processing method can be as follows:

[0148] 210. Based on query information and at least one candidate information, determine the information to be processed. The information to be processed includes at least one information pair, where each information pair includes query information and any candidate information, and the query information and candidate information are images or text.

[0149] The information to be processed refers to the information processed by the image-text matching model during the inference (inference) phase after training. In this embodiment, the information to be processed includes one or more information pairs, which are pairs of two pieces of information, such as image pairs, text pairs, or image-text pairs.

[0150] The query information is used to determine relevant (i.e., matching) information from the at least one candidate information. Candidate information refers to information used to filter information related to the query information. In this embodiment, the query information and candidate information can come from user input and / or be automatically obtained / generated.

[0151] For example, the query information can be paired with each candidate information. If there are n candidate information, they can be paired with the query information to form n information pairs.

[0152] 220. After training the image-text matching model, feature extraction is performed on the information pairs to obtain the target feature representation of the information pairs.

[0153] For example, in this embodiment, the trained image-text matching model is obtained through any of the model training methods provided in this embodiment. For each information pair, the trained image-text matching model can use the encoder of the corresponding modality in the main encoder to extract features from the two pieces of information (such as an image or text) in the information pair respectively, so as to obtain the target feature representations of the two pieces of information. It should be noted that the specific implementation and principle of the feature extraction process of the trained image-text matching model in this embodiment are the same as the feature extraction process in the model training method. For details, please refer to the implementation method in the foregoing embodiments, which will not be repeated in this embodiment.

[0154] 230. Calculate the information relevance based on the target feature representation to obtain the information relevance of the information in the information pair.

[0155] In this context, target feature representation refers to the feature representation extracted by the main encoder from the query information and candidate information in the information pair. For example, the target feature representation of any information pair may include the target feature representation of the query information in the information pair and the target feature representation of the candidate information in the information pair.

[0156] Among them, information relevance calculation refers to the process of calculating the relevance of information in information pairs.

[0157] For example, for each information pair, the relevance between the two pieces of information (i.e., the relevance of the information pair) can be calculated based on the target feature representations of the two pieces of information in the pair, such as the relevance between images, or between images and text, or between texts. Image-text search functions such as image-to-image search, image-to-text search, text-to-text search, and text-to-image search can be implemented based on the calculated relevance, and applied to image-text search scenarios such as image-text retrieval systems and image-text recommendation systems.

[0158] In some implementations, in the embodiments of this application, after training, the image-text matching model can calculate the cosine similarity of the target feature representations of the two pieces of information in each information pair during the inference (inference) stage, and obtain the information relevance of the information pair.

[0159] 240. Based on information relevance, determine the target information that matches the query information from at least one candidate information.

[0160] Among them, target information refers to one or more candidate information that best match the query information, determined based on information relevance.

[0161] For example, the candidate information can be sorted according to its relevance, and the top n candidate information in the sorting can be used as the target information, where n is a positive integer greater than or equal to 1.

[0162] For example, in an image-text query scenario, the information to be processed can be obtained from a query and multiple candidate information. The query can be paired with any candidate information, and both the query and candidate information can be images or text. Therefore, a trained image-text matching model can be used to calculate the relevance between the query and each candidate information, and the one or more candidate information with the highest relevance can be used as the query result.

[0163] For example, taking a text-to-image search scenario, the embodiments of this application can be used in a search system. A user can input a query text into the search system. The search system can obtain multiple candidate images (e.g., n candidate images) from the system database, and treat the user-input query text and each candidate image as a text-image pair to be processed, resulting in n text-image pairs to be processed. Each text-image pair includes the query text and a candidate image. The first text encoder and the first image encoder in the trained text-image matching model are used to extract features from the query text and candidate images in the text-image pairs, respectively, to obtain the target feature representation of the query text and the target feature representation of the candidate images. For each text-image pair to be processed, based on the corresponding target feature representation, the relevance between the query text and the candidate images in the text-image pair is calculated, and one or more candidate images with the highest relevance are used as the search results.

[0164] The information processing scheme provided in this application can be applied to various information processing scenarios. For example, taking information search as an example, a training dataset, a negative feature encoder, and an image-text matching model updated in the previous iteration are obtained. The training dataset includes at least one image-text pair, and the image-text matching model includes a master encoder. Using the master encoder and the negative feature encoder, features are extracted from the image-text pair to obtain a first feature representation and a second feature representation of the image-text pair. Based on the first feature representation, the image-text relevance is calculated to obtain the positive sample relevance corresponding to the image-text pair. Based on the first feature representation and the negative feature representation, the image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and the historical feature representation, and the historical feature representation is the second feature representation extracted in the previous iteration. Based on the positive sample relevance and the negative sample relevance, the image-text matching model is updated until the iteration meets the preset termination condition to obtain the trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0165] As can be seen from the above, in the training process of the image-text matching model, negative feature representations are constructed by a negative feature encoder. In this way, only a small amount of training data is needed to construct rich and diverse negative samples for the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model updates. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs.

[0166] The method described in the above embodiments will be further described in detail below.

[0167] In this embodiment, the method of this application embodiment will be described in detail using a product search scenario as an example.

[0168] like Figure 3 As shown, the specific process of a model training method is as follows:

[0169] 310. Obtain the training dataset, the negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the main encoder.

[0170] For example, the training dataset is a collection of samples consisting of product data. Product images and descriptive text (such as names or titles) of multiple traded products can be collected from the database of a product trading platform (such as a video / image-based trading platform). Each product image and descriptive text is treated as a single image-text pair to construct the training dataset. The training dataset includes at least one batch of samples, and each batch can include at least one image-text pair. The image-text matching model is then iteratively trained using the training dataset and a negative feature encoder. Each iteration retrieves the updated image-text matching model from the previous iteration, whose model parameters are those updated in the previous iteration. This image-text matching model includes a master encoder, which comprises a first image encoder using a VitBase32 encoder and a first text encoder using a 12-layer Bert-base encoder.

[0171] In this case, image-text matching models (such as the clip model) match images and text one-to-one within a batch of data during training. Images and texts that do not belong to the same image-text pair within the same batch are treated as negative samples. Since this platform contains a large number of duplicate products, directly treating the product image and description text of the same traded product as a single image-text pair would result in the presence of correct image-text pairs among the negative samples.

[0172] 320. Using the main encoder and the negative feature encoder, extract features from the image-text pair to obtain the first feature representation and the second feature representation of the image-text pair.

[0173] For example, in this embodiment, for cross-modal image-text pairs, two image encoders with different update mechanisms are introduced as a first image encoder (Faster encoder) and a second image encoder (Slow encoder), and two text encoders with different update mechanisms are introduced as a first text encoder (Faster encoder) and a second text encoder (Slow encoder). The Faster encoder uses a gradient update method, and the Slow encoder uses a momentum update method. In each iteration, one or more batches can be data augmented and then input into the main encoder and the negative feature encoder for feature extraction.

[0174] After each batch is input into the main encoder, the first image encoder can sequentially extract features from the n images in the input sequence to obtain the first image feature representation sequence of that batch (such as a 768-dimensional image embedding). Simultaneously, the first text encoder can sequentially extract features from the n texts in the input sequence to obtain the first text feature representation sequence of that batch (such as a 768-dimensional text embedding).

[0175] After each batch is input into the negative feature encoder, the second image encoder can sequentially extract features from the n images in the input sequence to obtain the second image feature representation sequence of that batch (such as a 768-dimensional image embedding). Simultaneously, the second text encoder can sequentially extract features from the n texts in the input sequence to obtain the second text feature representation sequence of that batch (such as a 768-dimensional text embedding).

[0176] 330. Calculate the correlation between the image and text based on the first feature representation to obtain the positive sample correlation between the image and text pairs.

[0177] 340. Based on the first feature representation, determine the correlation of the additional negative samples corresponding to the image-text pair.

[0178] For example, in each iteration, the extracted first image feature representation sequence (such as a 768-dimensional image embedding) and the first text feature representation sequence (such as a 768-dimensional text embedding) can be multiplied to obtain the score matrix (i.e., the relevance matrix) of all image-text matching in the sample batch. The diagonal of the matrix represents the relevance of image-text pairs (i.e., related image-text pairs) (i.e., positive sample relevance), while the other elements off the diagonal represent the relevance of unrelated image-text pairs (i.e., additional negative sample relevance).

[0179] In practical applications, the images and text in each batch can be used to generate embeddings using the first image encoder and the first text encoder, respectively, and stored in the database. This way, the image and text embeddings generated during training can be used to calculate scores in the same space. This allows for image-to-image and image-to-text searches, and text-to-text and text-to-image searches.

[0180] 350. Calculate the image-text relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance of the image-text pair.

[0181] The negative feature representation is obtained from the second feature representation and the historical feature representation, where the historical feature representation is the second feature representation extracted in previous iterations. For example, in this embodiment, a negative sample queue (i.e., a preset feature storage queue) can be introduced to decouple the batch size and the number of negative samples, thus ensuring that a small batch size (e.g., 1024) can still have a large number of negative samples (over 30,000). This queue is used to cache the second feature representation (embedding) extracted in the first N iterations. The length of this queue is fixed.

[0182] Since each sample batch in this embodiment includes data from two modalities, the preset feature storage queue can include an image feature storage queue and a text feature storage queue. In each iteration, the second image feature representation from the second image feature representation sequence can be stored in the image feature storage queue, and the second text feature representation from the second text feature representation sequence can be stored in the text feature storage queue. Simultaneously, the preset feature storage queue adopts a first-in, first-out (FIFO) storage method to ensure that the queue always stores the second feature representations extracted from the most recent N iterations.

[0183] Therefore, for any image in an image-text pair, the first image feature representation of that image can be multiplied by the negative feature representation obtained from the text feature storage queue to obtain the target negative sample relevance of that image-text pair. Similarly, for any text in an image-text pair, the first text feature representation of that text can be multiplied by the negative feature representation obtained from the image feature storage queue to obtain the target negative sample relevance of that image-text pair.

[0184] Specifically, for any batch of samples, the image can be processed by a first image encoder (Fast Encoder) to obtain 768-dimensional features. These 768-dimensional features are then multiplied by the text embeddings of the first N iterations cached in the text feature storage queue to obtain the target negative sample relevance. Here, the text embeddings of the first N iterations can be regarded as the negative feature representation obtained after processing by a second text encoder (Slow Encoder). Similarly, text processed by the first text encoder (Fast Encoder) also yields 768-dimensional features. These 768-dimensional features are then multiplied by the image embeddings of the first N iterations cached in the image feature storage queue to obtain the target negative sample relevance. Here, the image embeddings of the first N iterations can be regarded as the negative feature representation obtained after processing by a second text encoder (Slow Encoder).

[0185] 360. Based on the positive and negative sample relevance, update the image-text matching model until the iteration meets the preset termination condition, and obtain the trained image-text matching model.

[0186] For example, the cross-entropy loss function can be used to calculate the loss score (i.e., image-text matching loss) for positive and negative sample relevance (including target negative sample relevance and additional negative sample relevance). The model parameters of the image-text matching model are then adjusted based on this loss to maximize the relevance between relevant images and text (i.e., positive sample relevance) and minimize the relevance between irrelevant images and text (i.e., negative sample relevance) until a pre-defined termination condition is met, at which point training terminates, resulting in the trained image-text matching model.

[0187] It should be noted that, in the context of commodity transactions, whether the products recommended by the trading platform can truly meet the actual needs of users is the key to whether customers will make a purchase. This requires the model to achieve good performance in the commodity domain. This model is the foundation of various e-commerce applications, which can effectively improve the performance of downstream tasks and can be directly applied to business.

[0188] In response, the image-text matching model (such as the clip model) in this application embodiment is a pre-trained model, which exhibits good performance in various application scenarios such as image classification, image search, and content generation. The training data used in the pre-training stage of this model contains a large number of image-text pairs. These images and texts come from various sources on the Internet, such as web pages, social media, and news, covering many different themes, styles, and languages, thus the model lacks domain focus. To address this, this application embodiment utilizes product data to construct the training dataset, enabling the trained image-text matching model to achieve good performance in product search scenarios.

[0189] Verification revealed that, in downstream application scenarios of the trained image-text matching model obtained in this application embodiment, taking product text-image retrieval as an example, on the Video Account Store dataset, compared with the image-text matching model before training, the trained image-text matching model showed a significant improvement in search performance in this scenario. For example, when searching for related product images through text, the accuracy of recalling the top 100 products increased by 5%; when searching for product images to recall the top 100 matching product names, the accuracy increased by 6%.

[0190] As can be seen from the above, in the embodiments of this application, for any batch of samples, images and texts belonging to the same image-text pair are taken as positive samples, images and texts not belonging to the same image-text pair are taken as negative samples, and the feature representations of the image / text and the cached first N text / images are taken as negative samples. In this way, the positive and negative feature representations extracted by the main encoder and the negative feature encoder are used to construct negative samples from multiple aspects to increase the diversity and richness of negative samples.

[0191] Furthermore, the training process of existing image-text matching models (such as the clip model) requires a large amount of computing resources, such as up to 256 GPUs to maintain a batch size of over 30,000 for two weeks, resulting in enormous training costs. In contrast, this application's embodiment introduces a negative feature encoder and a pre-defined feature storage queue to decouple the batch size from the number of negative samples, ensuring that even with a small batch size, a large number of negative samples can be used. This allows the training process to be completed with lower hardware requirements.

[0192] Experimental verification revealed that, compared to related technologies that use 256 GPUs to train a model, this embodiment of the application only used 16 GPUs to complete the model training.

[0193] To better implement the above methods, this application also provides a model training device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer; the server can be a single server or a server cluster composed of multiple servers.

[0194] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the model training device specifically integrated into the server as an example.

[0195] For example, such as Figure 4 As shown, the model training device may include an acquisition unit 410, a training feature extraction unit 420, a positive sample determination unit 430, a negative sample determination unit 440, and an update unit 450, as follows:

[0196] (a) Acquisition Unit 410

[0197] This is used to obtain the training dataset, the negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the master encoder.

[0198] (II) Training Feature Extraction Unit 420

[0199] This is used to extract features from image-text pairs using a main encoder and a negative feature encoder, respectively, to obtain the first feature representation and the second feature representation of the image-text pair.

[0200] In some embodiments, the main encoder includes a first image encoder and a first text encoder, the negative feature encoder includes a second image encoder and a second text encoder, and the training feature extraction unit includes a first feature extraction subunit and a second feature extraction subunit, comprising: a first feature extraction subunit, configured to use the first image encoder to extract features from the image in the image-text pair to obtain a first image feature representation of the image-text pair, and to use the first text encoder to extract features from the text in the image-text pair to obtain a first text feature representation of the image-text pair; and a second feature extraction subunit, configured to use the second image encoder to extract features from the image in the image-text pair to obtain a second image feature representation of the image-text pair, and to use the second text encoder to extract features from the text in the image-text pair to obtain a second text feature representation of the image-text pair.

[0201] (III) Positive Sample Determination Unit 430

[0202] It is used to calculate the correlation between images and text based on the first feature representation, and to obtain the positive sample correlation between the images and text pairs.

[0203] In some implementations, the positive sample determination unit is specifically used to: for any image-text pair, calculate the correlation between the first image feature representation and the first text feature representation of the image-text pair to obtain the positive sample correlation corresponding to the image-text pair.

[0204] In some implementations, the positive sample determination unit includes a multiplication subunit and an element extraction subunit, including: a multiplication subunit for multiplying an image feature representation sequence and a text feature representation sequence to obtain a relevance matrix, wherein the image feature representation sequence is a sequence composed of first image feature representations of at least one image-text pair, and the text feature representation sequence is a sequence composed of first text feature representations of at least one image-text pair, and the sequence order of the image feature representation sequence and the text feature representation sequence corresponds; and an element extraction subunit for extracting the diagonal elements corresponding to the image-text pair from the relevance matrix for any image-text pair to obtain the positive sample relevance corresponding to the image-text pair.

[0205] In some implementations, the negative sample relevance also includes additional negative sample relevance, and the model training device further includes an additional negative sample determination unit. The additional negative sample determination unit is used to: for any image-text pair, extract the off-diagonal elements corresponding to the corresponding additional negative sample pair from the relevance matrix to obtain the additional negative sample relevance corresponding to the image-text pair. The additional negative sample includes at least one of a first additional negative sample and a second additional negative sample. The first additional negative sample includes a first image feature representation of the image-text pair and a first feature representation of any target text. The second additional negative sample includes a first text feature representation of the image-text pair and a first feature representation of any target image. Any target text is text other than the text in the image-text pair in the training dataset, and any target image is an image other than the image in the image-text pair in the training dataset.

[0206] (iv) Negative Sample Determination Unit 440

[0207] This is used to calculate the relevance of images and text based on the first feature representation and the negative feature representation, to obtain the relevance of the target negative samples corresponding to the image and text pairs. The negative feature representation is obtained from the second feature representation and the historical feature representation, and the historical feature representation is the second feature representation extracted in the historical iteration rounds.

[0208] In some embodiments, the negative sample determination unit includes a negative feature acquisition subunit and a relevance calculation subunit, comprising: a negative feature acquisition subunit, configured to acquire at least one negative feature representation, the at least one negative feature representation including at least one of negative image feature representation and negative text feature representation; a feature determination subunit, configured to determine at least one target negative sample corresponding to an image-text pair, the at least one target negative sample including at least one of a first target negative sample and a second target negative sample, the first target negative sample including a first image feature representation of the image-text pair and any acquired negative text feature representation, the second target negative sample including a first text feature representation of the image-text pair and any acquired negative image feature representation; and a relevance calculation subunit, configured to perform relevance calculation on the first image feature representation and negative text feature representation in the first target negative sample to obtain the relevance of the target negative sample corresponding to the image-text pair; or, to perform relevance calculation on the first text feature representation and negative image feature representation in the second target negative sample to obtain the relevance of the target negative sample corresponding to the image-text pair.

[0209] In some embodiments, the model training apparatus further includes a storage unit, which is used to: store the second feature representation extracted in the current iteration into a preset feature storage queue in any iteration, wherein the queue length of the preset feature storage queue is a preset length;

[0210] The negative feature acquisition subunit is specifically used to: acquire the feature representation of the target quantity from the preset feature storage queue, and use the acquired feature representation of the target quantity as the negative feature representation. The target quantity is related to the preset length, and the feature representation of the target quantity includes the second feature representation and the historical feature representation.

[0211] (V) Update Unit 450

[0212] This is used to update the image-text matching model based on positive and negative sample relevance until the iteration meets the preset termination condition, resulting in the trained image-text matching model. Negative sample relevance includes the target negative sample relevance.

[0213] In some implementations, the update unit includes a loss determination subunit and a model update subunit, including: a loss determination subunit, used to determine the image-text matching loss based on positive sample relevance and negative sample relevance; and a model update subunit, used to update the image-text matching model using the image-text matching loss until the iteration meets a preset termination condition to obtain the trained image-text matching model.

[0214] In some implementations, the model training method further includes a momentum update unit, which is used to: obtain a first parameter, a second parameter, and a momentum coefficient, wherein the first parameter and the second parameter are the model parameters of the main encoder and the negative feature encoder in the current iteration, respectively; use the momentum coefficient to perform a weighted summation of the first parameter and the second parameter to obtain the updated model parameters of the negative feature encoder, and use the updated model parameters as the model parameters of the negative feature encoder in the next iteration.

[0215] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0216] As can be seen from the above, the model training device in this embodiment includes an acquisition unit, a training feature extraction unit, a positive sample determination unit, a negative sample determination unit, and an update unit. The system comprises the following components: an acquisition unit, which acquires a training dataset, a negative feature encoder, and a text-image matching model updated in the previous iteration; the training dataset includes at least one text-image pair, and the text-image matching model includes a master encoder; a training feature extraction unit, which uses the master encoder and the negative feature encoder to extract features from the text-image pair, respectively, to obtain a first feature representation and a second feature representation of the text-image pair; a positive sample determination unit, which calculates the text-image relevance based on the first feature representation to obtain the positive sample relevance of the text-image pair; a negative sample determination unit, which calculates the text-image relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance of the text-image pair, where the negative feature representation is obtained from the second feature representation and historical feature representation, and the historical feature representation is the second feature representation extracted in previous iterations; and an update unit, which updates the text-image matching model based on the positive sample relevance and the negative sample relevance until the iteration meets a preset termination condition to obtain the trained text-image matching model, where the negative sample relevance includes the target negative sample relevance.

[0217] Therefore, in this embodiment of the application, during the training process of the image-text matching model, a negative feature representation is constructed by a negative feature encoder. In this way, only a small amount of training data is needed to construct rich and diverse negative samples for the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model update. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs.

[0218] To better implement the above methods, this application also provides an information processing device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0219] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the information processing device specifically integrated into the server as an example.

[0220] For example, such as Figure 5 As shown, the information processing device may include a task determination unit 510, an information feature extraction unit 520, a relevance determination unit 530, and a target determination unit 540, as follows:

[0221] (I) Unit 510 to be processed

[0222] This is used to determine information to be processed based on query information and at least one candidate information. The information to be processed includes at least one information pair, where each information pair includes query information and any candidate information, and the query information and candidate information are images or text.

[0223] (II) Information Feature Extraction Unit 520

[0224] This is used to extract features from information pairs through a trained image-text matching model to obtain the target feature representation of the information pairs. The trained image-text matching model is obtained through any of the model training methods provided in the embodiments of this application.

[0225] (III) Relevance Determination Unit 530

[0226] It is used to calculate the information relevance based on the target feature representation, and to obtain the information relevance of information in information pairs.

[0227] (IV) Target Determination Unit 540

[0228] It is used to determine the target information that matches the query information from at least one candidate information based on the relevance of the information.

[0229] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0230] As can be seen from the above, the information processing device of this embodiment includes a task determination unit, an information feature extraction unit, a relevance determination unit, and a target determination unit. The task determination unit is used to determine task information based on query information and at least one candidate information. The task information includes at least one information pair, where each information pair includes query information and any candidate information, and the query information and candidate information are images or text. The information feature extraction unit is used to extract features from the information pair using a trained image-text matching model to obtain a target feature representation of the information pair. The trained image-text matching model is obtained using any of the model training methods provided in this application embodiment. The relevance determination unit is used to calculate information relevance based on the target feature representation to obtain the information relevance of the information in the information pair. The target determination unit is used to determine target information matching the query information from at least one candidate information based on the information relevance.

[0231] Therefore, in this embodiment of the application, during the training process of the image-text matching model, a negative feature representation is constructed by a negative feature encoder. In this way, only a small amount of training data is needed to construct rich and diverse negative samples for the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model update. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs.

[0232] This application also provides an electronic device, which can be a terminal, a server, or other similar device. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers, etc.

[0233] In some embodiments, the model training device or information processing device may also be integrated into multiple electronic devices. For example, the model training device or information processing device may be integrated into multiple servers, and the model training method or information processing method of this application may be implemented by multiple servers.

[0234] In this embodiment, a server will be used as an example for detailed description. For example, ... Figure 6 As shown, it illustrates a schematic diagram of the server structure involved in an embodiment of this application. Specifically:

[0235] The server may include components such as a processor 610 with one or more processing cores, a memory 620 with one or more computer-readable storage media, a power supply 630, an input module 640, and a communication module 650. Those skilled in the art will understand that... Figure 6The server structure shown does not constitute a limitation on the server and may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. Wherein:

[0236] The processor 610 is the control center of the server, connecting various parts of the server via various interfaces and lines. It performs various server functions and processes data by running or executing software programs and / or modules stored in the memory 620, and by accessing data stored in the memory 620. In some embodiments, the processor 610 may include one or more processing cores; in some embodiments, the processor 610 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 610.

[0237] The memory 620 can be used to store software programs and modules. The processor 610 executes various functional applications and data processing by running the software programs and modules stored in the memory 620. The memory 620 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 620 may also include a memory controller to provide the processor 610 with access to the memory 620.

[0238] The server also includes a power supply 630 that supplies power to the various components. In some embodiments, the power supply 630 can be logically connected to the processor 610 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 630 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0239] The server may also include an input module 640, which can be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0240] The server may also include a communication module 650. In some embodiments, the communication module 650 may include a wireless module, through which the server can perform short-range wireless transmission, thereby providing users with wireless broadband internet access. For example, the communication module 650 can be used to help users send and receive emails, browse web pages, and access streaming media.

[0241] Although not shown, the server may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 610 in the server loads the executable files corresponding to the processes of one or more applications into the memory 620 according to the following instructions, and the processor 610 runs the applications stored in the memory 620 to realize various functions, as follows:

[0242] Obtain the training dataset, negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the master encoder. Using the master encoder and negative feature encoder, extract features from the image-text pairs to obtain the first feature representation and the second feature representation of the image-text pair. Calculate the image-text relevance based on the first feature representation to obtain the positive sample relevance corresponding to the image-text pair. Calculate the target negative sample relevance corresponding to the image-text pair based on the first feature representation and the negative feature representation. The negative feature representation is obtained from the second feature representation and historical feature representations, where the historical feature representation is the second feature representation extracted in previous iterations. Update the image-text matching model based on the positive and negative sample relevances until the iteration meets a preset termination condition to obtain the trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0243] Alternatively, based on query information and at least one candidate information, determine the information to be processed, the information to be processed including at least one information pair, the information pair including query information and any candidate information, the query information and candidate information being images or text; through a trained image-text matching model, perform feature extraction on the information pair to obtain the target feature representation of the information pair, the trained image-text matching model being obtained through any model training method provided in the embodiments of this application; calculate the information relevance based on the target feature representation to obtain the information relevance of the information in the information pair; based on the information relevance, determine the target information matching the query information from at least one candidate information.

[0244] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0245] As can be seen from the above, in the training process of the image-text matching model, negative feature representations are constructed by a negative feature encoder. In this way, only a small amount of training data is needed to construct rich and diverse negative samples for the image-text pairs in the training data, so as to obtain the corresponding negative sample relevance for model updates. This reduces the dependence on large-scale training datasets, effectively reduces the demand for hardware support, and thus reduces training costs.

[0246] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0247] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the model training methods or information processing methods provided in embodiments of this application. For example, the instructions can execute the following steps:

[0248] Obtain the training dataset, negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the master encoder. Using the master encoder and negative feature encoder, extract features from the image-text pairs to obtain the first feature representation and the second feature representation of the image-text pair. Calculate the image-text relevance based on the first feature representation to obtain the positive sample relevance corresponding to the image-text pair. Calculate the target negative sample relevance corresponding to the image-text pair based on the first feature representation and the negative feature representation. The negative feature representation is obtained from the second feature representation and historical feature representations, where the historical feature representation is the second feature representation extracted in previous iterations. Update the image-text matching model based on the positive and negative sample relevances until the iteration meets a preset termination condition to obtain the trained image-text matching model. The negative sample relevance includes the target negative sample relevance.

[0249] Alternatively, based on query information and at least one candidate information, determine the information to be processed, the information to be processed including at least one information pair, the information pair including query information and any candidate information, the query information and candidate information being images or text; through a trained image-text matching model, perform feature extraction on the information pair to obtain the target feature representation of the information pair, the trained image-text matching model being obtained through any model training method provided in the embodiments of this application; calculate the information relevance based on the target feature representation to obtain the information relevance of the information in the information pair; based on the information relevance, determine the target information matching the query information from at least one candidate information.

[0250] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0251] According to one aspect of this application, a computer program product or computer program is provided, including a computer program or instructions that, when executed by a processor, implement the steps of the methods provided in the various optional implementations of the above embodiments. The computer program / instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer program / instructions from the computer-readable storage medium and executes the computer program / instructions, causing the electronic device to perform the methods provided in the various optional implementations of the above embodiments.

[0252] Since the instructions stored in the storage medium can execute the steps of any model training method or information processing method provided in the embodiments of this application, the beneficial effects that any model training method or information processing method provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0253] The above provides a detailed description of a model training method, information processing method, and related equipment provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A model training method, characterized in that, include: Obtain a training dataset, a negative feature encoder, and a text-image matching model updated in the previous iteration. The training dataset includes at least one text-image pair, and the text-image matching model includes a master encoder. Using the main encoder and the negative feature encoder, feature extraction is performed on the image-text pair to obtain the first feature representation and the second feature representation of the image-text pair; Based on the first feature representation, the image-text relevance is calculated to obtain the positive sample relevance of the image-text pair; Based on the first feature representation and the negative feature representation, the image-text relevance is calculated to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and the historical feature representation. The historical feature representation is the second feature representation extracted in the historical iteration rounds. Based on the positive sample relevance and negative sample relevance, the image-text matching model is updated until the iteration meets the preset termination condition, and the trained image-text matching model is obtained. The negative sample relevance includes the target negative sample relevance.

2. The model training method as described in claim 1, characterized in that, The first feature representation includes a first image feature representation and a first text feature representation. The step of calculating the image-text relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance corresponding to the image-text pair includes: Obtain at least one of the negative feature representations, wherein the at least one negative feature representation includes at least one of negative image feature representation and negative text feature representation; Determine at least one target negative sample corresponding to the image-text pair, wherein the at least one target negative sample includes at least one of a first target negative sample and a second target negative sample, wherein the first target negative sample includes the first image feature representation of the image-text pair and any of the acquired negative text feature representations, and the second target negative sample includes the first text feature representation of the image-text pair and any of the acquired negative image feature representations; The correlation between the first image feature representation and the negative text feature representation in the first target negative sample is calculated to obtain the correlation between the image and text pairs and the target negative sample. Alternatively, the correlation between the first text feature representation and the negative image feature representation in the second target negative sample can be calculated to obtain the correlation between the text and image pairs and the target negative sample.

3. The model training method as described in claim 2, characterized in that, Before obtaining at least one of the negative feature representations, the method further includes: In any iteration round, the second feature representation extracted in the current iteration round is stored in a preset feature storage queue, the queue length of which is a preset length; The process of obtaining the negative feature representation includes: The feature representation of the target quantity is obtained from the preset feature storage queue, and the obtained feature representation of the target quantity is used as the negative feature representation. The target quantity is related to the preset length, and the feature representation of the target quantity includes the second feature representation and the historical feature representation.

4. The model training method as described in claim 1, characterized in that, The first feature representation includes a first image feature representation and a first text feature representation. The step of calculating the image-text relevance based on the first feature representation to obtain the positive sample relevance of the image-text pair includes: For any of the image-text pairs, the correlation between the first image feature representation and the first text feature representation of the image-text pair is calculated to obtain the positive sample correlation corresponding to the image-text pair.

5. The model training method as described in claim 4, characterized in that, For any given image-text pair, the relevance calculation of the first image feature representation and the first text feature representation of the image-text pair to obtain the positive sample relevance of the image-text pair includes: The image feature representation sequence and the text feature representation sequence are multiplied to obtain a relevance matrix. The image feature representation sequence is a sequence composed of the first image feature representations of the at least one image-text pair, and the text feature representation sequence is a sequence composed of the first text feature representations of the at least one image-text pair. The sequence order of the image feature representation sequence and the text feature representation sequence corresponds. For any given image-text pair, extract the diagonal elements corresponding to the image-text pair from the relevance matrix to obtain the positive sample relevance corresponding to the image-text pair.

6. The model training method as described in claim 5, characterized in that, The negative sample correlation also includes an additional negative sample correlation, and the method further includes: For any of the image-text pairs, the off-diagonal elements corresponding to the corresponding additional negative sample pairs are extracted from the relevance matrix to obtain the relevance of the additional negative samples corresponding to the image-text pairs. The additional negative samples include at least one of a first additional negative sample and a second additional negative sample. The first additional negative sample includes the first image feature representation of the image-text pair and the first feature representation of any target text. The second additional negative sample includes the first text feature representation of the image-text pair and the first feature representation of any target image. The any target text is any text in the training dataset other than the text in the image-text pair, and the any target image is any image in the training dataset other than the image in the image-text pair.

7. The model training method as described in claim 1, characterized in that, The method further includes: Obtain the first parameter, the second parameter, and the momentum coefficient, where the first parameter and the second parameter are the model parameters of the main encoder and the negative feature encoder in the current iteration, respectively. Using the momentum coefficient, the first parameter and the second parameter are weighted and summed to obtain the updated model parameters of the negative feature encoder, and the updated model parameters are used as the model parameters of the negative feature encoder in the next iteration.

8. The model training method as described in claim 1, characterized in that, The main encoder includes a first image encoder and a first text encoder, and the negative feature encoder includes a second image encoder and a second text encoder. The step of using the main encoder and the negative feature encoder to extract features from the image-text pair, respectively, to obtain a first feature representation and a second feature representation of the image-text pair, includes: Using the first image encoder, feature extraction is performed on the image in the image-text pair to obtain a first image feature representation of the image-text pair; and using the first text encoder, feature extraction is performed on the text in the image-text pair to obtain a first text feature representation of the image-text pair. Using the second image encoder, feature extraction is performed on the image in the image-text pair to obtain a second image feature representation of the image-text pair; and using the second text encoder, feature extraction is performed on the text in the image-text pair to obtain a second text feature representation of the image-text pair.

9. The model training method according to any one of claims 1 to 8, characterized in that, The step of updating the image-text matching model based on the positive and negative sample relevance, until the iteration meets a preset termination condition, to obtain the trained image-text matching model, includes: Based on the positive sample relevance and the negative sample relevance, the image-text matching loss is determined; The image-text matching model is updated using the image-text matching loss until the preset termination condition is met, thus obtaining the trained image-text matching model.

10. An information processing method, characterized in that, include: Based on query information and at least one candidate information, information to be processed is determined. The information to be processed includes at least one information pair, and the information pair includes the query information and any of the candidate information. The query information and the candidate information are images or text. By training the image-text matching model, feature extraction is performed on the information pair to obtain the target feature representation of the information pair. The trained image-text matching model is obtained by the method described in any one of claims 1 to 9. Information relevance is calculated based on the target feature representation to obtain the information relevance of the information in the information pair. Based on the relevance of the information, target information that matches the query information is determined from the at least one candidate information.

11. A model training device, characterized in that, include: The acquisition unit is used to acquire the training dataset, the negative feature encoder, and the image-text matching model updated in the previous iteration. The training dataset includes at least one image-text pair, and the image-text matching model includes the main encoder. The training feature extraction unit is used to extract features from the image-text pair using the main encoder and the negative feature encoder, respectively, to obtain a first feature representation of the image-text pair and a second feature representation of the image-text pair; A positive sample determination unit is used to calculate the image-text relevance based on the first feature representation to obtain the positive sample relevance of the image-text pair. The negative sample determination unit is used to calculate the image-text relevance based on the first feature representation and the negative feature representation to obtain the target negative sample relevance corresponding to the image-text pair. The negative feature representation is obtained from the second feature representation and the historical feature representation. The historical feature representation is the second feature representation extracted in the historical iteration rounds. An update unit is used to update the image-text matching model based on the positive sample relevance and the negative sample relevance until the iteration meets a preset termination condition to obtain the trained image-text matching model, wherein the negative sample relevance includes the target negative sample relevance.

12. An information processing device, characterized in that, include: A pending-processing determination unit is configured to determine pending-processing information based on query information and at least one candidate information, wherein the pending-processing information includes at least one information pair, the information pair including the query information and any of the candidate information, and the query information and the candidate information being an image or text. The information feature extraction unit is used to extract features from the information pair through a trained image-text matching model to obtain the target feature representation of the information pair. The trained image-text matching model is obtained by the method described in any one of claims 1 to 9. A relevance determination unit is used to calculate information relevance based on the target feature representation to obtain the information relevance of the information in the information pair. A target determination unit is used to determine target information that matches the query information from the at least one candidate information based on the information relevance.

13. An electronic device, characterized in that, It includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform steps in the model training method or information processing method as described in any one of claims 1 to 10.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to execute the steps of the model training method or information processing method according to any one of claims 1 to 10.

15. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the steps of the model training method or information processing method according to any one of claims 1 to 10.