Pre-trained model training, application method, device, electronic device and medium
By acquiring and fusing multi-dimensional features of image, image description information and text information in the image, and training pre-trained models, the problem of limited information in the BLIP model is solved, and the effect of unified visual language understanding and generation tasks is improved.
Patent Information
- Application Number
- CN202310318563.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2043-03-28
AI Technical Summary
The BLIP model has limited information in unified vision-language understanding and generation tasks, resulting in limited effects.
By obtaining a sample set containing images, image description information and text information in the image, input it to the pre-trained model to obtain image features, fusion features and description features, and train based on these features, the model's visual language understanding and generation ability is enhanced.
The effect of unified visual language understanding and generation tasks is improved, and the performance of pre-trained models is enhanced by considering multi-dimensional information of image, image description information and text information.
Smart Images

Figure CN116186545B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to image processing technology, and more particularly to the training, application methods, devices, electronic devices and media of pre-trained models. Background Art
[0002] Vision-Language Pre-training (VLP) aims to improve the performance of downstream vision and language tasks by pre-training the model on large-scale image-text pairs. Most existing pre-trained models can only perform well in understanding-based tasks or generation-based tasks. The Bootstrapping Language-Image Pre-training (BLIP) model is a new VLP framework that can be used to unify vision-language understanding and generation tasks, supporting a wider range of downstream tasks than existing methods.
[0003] However, the BLIP model considers limited information in the unified visual-language understanding and generation tasks, which limits the effectiveness of the BLIP model. Summary of the invention
[0004] The present disclosure provides a training and application method, device, electronic device and medium for a pre-trained model to improve the effect of unified visual language understanding and generation tasks.
[0005] In a first aspect, an embodiment of the present disclosure provides a training method for a pre-trained model, comprising:
[0006] Acquire a sample set for training, the sample set including an image, image description information corresponding to the image, and text information in the image;
[0007] Input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image;
[0008] The pre-trained model is trained based on the image features, the fusion features and the description features.
[0009] In a second aspect, the embodiments of the present disclosure further provide a method for using a pre-trained model, wherein the pre-trained model is obtained by training using the method described in the first aspect, and the method includes:
[0010] The sample to be processed is input into the pre-trained model to obtain a processing result of the sample to be processed, where the sample to be processed is a sample to be processed by the pre-trained model.
[0011] In a third aspect, the present disclosure also provides a training device for a pre-trained model, including:
[0012] An acquisition module, used to acquire a sample set for training, wherein the sample set includes an image, image description information corresponding to the image, and text information in the image;
[0013] An input module, used to input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image;
[0014] A training module is used to train the pre-trained model based on the image features, the fusion features and the description features.
[0015] In a fourth aspect, an embodiment of the present disclosure further provides a device for using a pre-trained model, wherein the pre-trained model is obtained by training using the method described in the first aspect, and the device comprises:
[0016] The input module is used to input the sample to be processed into the pre-trained model to obtain the processing result of the sample to be processed.
[0017] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, the electronic device comprising:
[0018] one or more processing devices;
[0019] a storage device for storing one or more programs,
[0020] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method as described in the first aspect and / or the second aspect.
[0021] In a sixth aspect, an embodiment of the present disclosure provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the method as described in the first aspect and / or the second aspect.
[0022] In the disclosed embodiment, a sample set for training is obtained, the sample set includes an image, image description information corresponding to the image, and text information in the image; the samples in the sample set are input into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information; the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image; the pre-trained model is trained based on the image features, the fusion features, and the description features. During training, multi-dimensional information of images, image description information, and text information is considered, solving the problem that the BLIP model has limited information considered in unified visual-language understanding and generation tasks, which limits the effect of the BLIP model, and improves the effect of unified visual language understanding and generation tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0024] Figure 1 It is a flowchart of a training method of a pre-training model provided in an embodiment of the present disclosure;
[0025] Figure 2 It is a flowchart of a training method of a pre-training model provided in an embodiment of the present disclosure;
[0026] Figure 3 It is a flowchart of a method for using a pre-training model provided in an embodiment of the present disclosure;
[0027] Figure 4 is a structural schematic diagram of a pre-training model provided in an embodiment of the present disclosure;
[0028] Figure 5 It is a structural schematic diagram of a training device for a pre-training model provided in an embodiment of the present disclosure;
[0029] Figure 6 It is a structural schematic diagram of a device for using a pre-training model provided in an embodiment of the present disclosure;
[0030] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0032] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0033] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0034] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0035] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0036] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0037] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0038] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0039] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0040] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0041] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0042] Figure 1 It is a flow chart of a training method for a pre-trained model provided in an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation where a pre-trained model is trained. The method can be executed by a training device for the pre-trained model, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0043] BLIP is a unified visual language pre-training framework that learns from noisy image-text pairs. The BLIP model can be considered as a unified model for understanding and generating multimodal information. BLIP has two functions, image annotation and question answering. The BLIP model can use its understanding ability (encoder) and its generation ability (decoder). The BLIP model can be applied to the task of image text retrieval or the task of image annotation. However, the information considered by the BLIP model is limited. In order to solve this technical problem, the present disclosure provides a training method for a pre-training model. The pre-training model of the present disclosure also has the ability to understand and generate visual language. As Figure 1 As shown, the method includes:
[0044] S110: Obtain a sample set for training.
[0045] The sample set includes an image, image description information corresponding to the image, and text information in the image.
[0046] The sample set can be considered as a set of multiple samples used to train the pre-trained model. Each sample can include an image, image description information corresponding to the image, and text information in the image.
[0047] Text information can be considered as information representing text in an image. Image description information can be considered as information used to describe an image, such as the title of an image. Image description information may not be included in the image.
[0048] The text information in the image can be extracted from the image. The specific extraction method is not limited, and can be extracted through optical character recognition (OCR) technology. OCR refers to the process of analyzing and recognizing an image to obtain text information in the image.
[0049] This step does not limit the means of acquisition, and may be to obtain a sample set input by the user.
[0050] S120: Input the samples in the sample set into a pre-training model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information.
[0051] The pre-trained model is a model with visual language understanding and generation capabilities. The content input to the pre-trained model includes images, image description information, and text information in the image. The pre-trained model is trained from multiple dimensions of images and text. The text dimension includes image description information and text information in the image, wherein the text information in the image fully considers the information in the image, making the pre-trained model more effective. For example, in a rich text scenario, the visual language pre-training of the pre-trained model can achieve better results.
[0052] Image features can be understood as features obtained after an image is processed by a pre-trained model. For example, image features are features obtained after an image is processed by an image encoding module in a pre-trained model.
[0053] The fused feature is a feature that fuses the image feature of the image and the feature of the text information corresponding to the image. When the pre-trained model processes the image and text information, it fuses the image feature corresponding to the image and the feature corresponding to the text information to obtain the fused feature. Then, comparative learning can be performed based on the fused feature and the description feature.
[0054] The description feature can be considered as the feature obtained after processing the image description information through the pre-trained model, such as the feature processed by the description encoding module in the pre-trained model. The image description information can be input into the text encoder, the image-based text encoder and the image-based text decoder in the description encoding module, respectively, wherein the text encoder, the image-based text encoder and the image-based text decoder can process the image description information respectively to obtain their respective description features.
[0055] S130: Training the pre-trained model based on the image features, the fusion features and the description features.
[0056] After obtaining the image features, fusion features and description features, comparative learning can be performed to train the pre-trained model. For example, a loss function for training the pre-trained model is obtained based on the image features, fusion features and description features, and the pre-trained model is trained based on the loss function until the training end condition is met. The training end condition is not limited and can be set based on actual conditions.
[0057] The loss function of the pre-trained model is not limited here and may include an image-text contrast loss function, an image-text matching loss function, and a language modeling loss function. Among them, the image-text contrast loss function and the image-text matching loss function can be determined by contrastive learning of fusion features and description features. The image-text matching loss function activates an image-based text encoder, the purpose of which may be to learn a multimodal representation of image text to capture fine-grained alignment between vision and language. The language modeling loss function activates an image-based text encoder, the purpose of which may be to generate image description information for a given image.
[0058] The technical solution of the disclosed embodiment is to obtain a sample set for training, the sample set includes an image, image description information corresponding to the image, and text information in the image; input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, the pre-trained model is a model with visual language understanding and generation capabilities, the fusion features are features that fuse the image features of the image and the text information corresponding to the image; based on the image features, the fusion features, and the description features, the pre-trained model is trained. During training, multi-dimensional information of images, image description information, and text information is considered, solving the problem that the BLIP model has limited information considered in unified visual-language understanding and generation tasks, which limits the effect of the BLIP model, and improves the effect of unified visual language understanding and generation tasks.
[0059] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0060] In one embodiment, the training of the pre-trained model based on the image features, the fusion features and the description features includes:
[0061] Determining the image-text contrast loss function of the pre-trained model based on the fusion feature and the description feature;
[0062] Based on the fusion feature, the image feature and the description feature, determining the image-text matching loss function and the language modeling loss function of the pre-trained model;
[0063] The pre-trained model is trained based on the image-text contrast loss function, the image-text matching loss function and the language modeling loss function.
[0064] The image-text contrast loss function can activate the unimodal encoder and align the feature spaces of the image encoder Image Encoder (ViT) and the text encoder by promoting similar representations of positive image-text pairs and negative image-text pairs. The technical means for determining the image-text contrast loss function by fusing features and description features are not limited here. The same means as that for determining the image-text contrast loss function by image features and description features in BLIP can be used, or adaptive adjustments can be made.
[0065] In this embodiment, the fusion features and the image features can be input into the image-based text encoder in the description encoding module of the pre-trained model. The description features obtained by processing the image description information by the image-based text encoder can be combined to obtain the corresponding image-text matching loss function. The specific determination means is not limited, and the same means as BLIP can be used to determine the image-text matching loss function based on image features and description features, or adaptive adjustments can be made.
[0066] In this embodiment, the fusion features and the image features can be input into the image-based text decoder in the description encoding module of the pre-trained model. The description features obtained by processing the image description information with the image-based text decoder can be combined to obtain the corresponding language modeling loss function. The specific determination means is not limited, and the same means as BLIP can be used to determine the language modeling loss function based on image features and description features, or adaptive adjustments can be made.
[0067] In one embodiment, determining the image-text matching loss function and the language modeling loss function of the pre-trained model based on the fusion feature, the image feature and the description feature includes:
[0068] fusing the fusion feature and the image feature;
[0069] Through the description coding module of the pre-trained model, based on the description features and the fused features input into the description coding module, an image-text matching loss function and a language modeling loss function are obtained.
[0070] When determining the image-text matching loss function of the pre-trained model, the image features and the fused features can be fused, and then the fused features are input into the cross-attention layer of the image-based text encoder of the description encoding module, and the image description information is input into the bidirectional self-attention layer to obtain the image-text matching loss function based on the fused features and the description features.
[0071] When determining the language modeling loss function of the pre-trained model, the image features and the fused features can be fused, and then the fused features are input into the cross-attention layer of the image-based text decoder of the description encoding module, and the image description information is input into the causal self-attention layer to obtain the image-text matching loss function based on the fused features and the description features obtained based on the image description information.
[0072] In one embodiment, the amount of text included in the image is greater than a set threshold. In this embodiment, the amount of text included in the image is greater than a set threshold, and the value of the set threshold is not limited. When the amount of text included in the image is greater than the set threshold, the image can be considered to be an image in a rich text scenario, that is, the image includes a lot of text. In this embodiment, the pre-trained model is trained using the training method provided by the present disclosure in a rich text scenario, so that the pre-trained model makes full use of the internal information of the image and improves the effect of the pre-trained model.
[0073] Figure 2 is a flow chart of a training method for a pre-training model provided in an embodiment of the present disclosure. Based on the above embodiment, this embodiment specifically implements the steps of obtaining the image features corresponding to the image, the fusion features corresponding to the text information, and the description features corresponding to the image description information, such as Figure 2 As shown, the method includes:
[0074] S210: Obtain a sample set for training.
[0075] S220: Input the images included in the samples in the sample set into the image encoding module in the pre-trained model to obtain image features of the images.
[0076] The image encoding module can be considered as a module that performs image encoding within the pre-trained model. Image features can be obtained by inputting the image into the image encoding module.
[0077] S230: Input the image features and the text information in the image into a text encoding module in the pre-trained model to obtain fusion features corresponding to the text information.
[0078] The text encoding module can be considered as a module for text encoding in the pre-trained model. Text information is input into the text encoding module to obtain text features. The text encoding module of the present disclosure also inputs image features so that image features and text features are fused to obtain fused features.
[0079] The image features can be input into the cross-attention layer of the text encoding module, and the text information can be input into the bidirectional self-attention layer of the text encoding module, and the fused features are output through the text encoding module.
[0080] S240: Input the image description information into a description encoding module to obtain description features corresponding to the image description information.
[0081] The description encoding module can be considered as a module for encoding image description information in the pre-trained model. After the image description information is input into the description encoding module, description features can be output. For example, the description features are output by the text encoder in the text encoding module.
[0082] In this step, the image description information can be input into the text encoder, image-based text encoder and image-based text decoder in the description encoding module respectively, and the description features of the corresponding image description information of the text encoder, image-based text encoder and image-based text decoder are obtained.
[0083] S250: training the pre-trained model based on the image features, the fusion features and the description features.
[0084] In the disclosed embodiment, an image is input into an image encoder to obtain image features, image features and text information are input into a text encoder to obtain fusion features of the fused image and text, and image description information is input into a description encoding module to obtain description features corresponding to the image description information. Thus, the pre-trained model is trained based on image features, fusion features, and description features, thereby improving the effect of the pre-trained model in rich text scenarios.
[0085] Figure 3 It is a flow chart of a method for using a pre-trained model provided in an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the case where a prediction model is used. The method can be executed by a device for using the pre-trained model, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0086] like Figure 3 As shown, the method includes:
[0087] S310: Input the sample to be processed into the pre-trained model to obtain a processing result of the sample to be processed, where the sample to be processed is a sample to be processed by the pre-trained model.
[0088] After the pre-training model is trained, the sample to be processed can be input into the pre-training model to obtain the processing result. The processing result can be determined based on the needs of the downstream model of the pre-training model, such as outputting image features, fusion features, description features, image-text comparison loss function, image-text matching loss function and language modeling loss function. The sample to be processed includes images, image description information and / or text information in the image. The sample to be processed is a sample in the application stage.
[0089] In one embodiment, the processing result includes one or more of the image features, descriptive features, fusion features, probability values represented by the image-text contrast loss function, probability values represented by the image-text matching loss function, and probability values represented by the language modeling loss function corresponding to the sample to be processed.
[0090] The specific content of the processing result may depend on the function of the pre-trained model, or the requirements of the model downstream of the pre-trained model, which is not limited here.
[0091] In one embodiment, taking tasks such as object recall and recommendation ranking as examples, the processing results may be one or more of image features, description features, and fusion features. Image features may be features obtained by processing images in samples to be processed, and description features may be features obtained by processing image description information in samples to be processed. Fusion features may be features obtained by extracting text information from image information and fusing image features.
[0092] After the pre-trained model of this embodiment obtains the sample to be processed, it outputs the processing result, which can be input into the subsequent downstream model for subsequent object recall and recommendation ranking.
[0093] Among them, object recall can be considered as recalling objects, such as retrieving corresponding images based on image description information to achieve image recall. More specifically, it can be based on the title of the item to retrieve the image corresponding to the item. When performing object recall, description features can be used.
[0094] The recommendation ranking can be considered as the ranking of the recommended objects, such as based on image features, description features and / or fusion features, to achieve the recommendation ranking of the downstream model. The downstream model can rank the recommended objects based on image features, description features and / or fusion features.
[0095] In one embodiment, taking the task of matching an image and image description information as an example, the input of the pre-trained model may be the image and image description information to be matched, the purpose of which is to determine whether the image and image description information are matched, also known as whether they are a pair. The output of the pre-trained model may be one or more of the image-text contrast loss function, the image-text matching loss function, and the language modeling loss function to determine the probability of matching. In this embodiment, the image-text contrast loss function, the image-text matching loss function, and the language modeling loss function may be embodied as probability values, which may characterize the degree of matching.
[0096] For example, there are many items in the item library, and one item and many titles are actually a pair, but they are not reflected as a pair in the item library. For example, different item owners can give different titles to the same item. Therefore, the pre-trained model can output an image-text comparison loss function, an image-text matching loss function, and a language modeling loss function to determine the probability value of the match between the image and title (i.e., image description information) corresponding to the item.
[0097] During use, the pre-trained model of the embodiment of the present disclosure can fully utilize images, image description information and text information in the image, thereby improving the application effect of the pre-trained model.
[0098] The present disclosure is described exemplarily below. The pre-training model provided by the present disclosure can be considered as a large-scale language image pre-training model combined with OCR. In a rich text scenario, the present disclosure can use OCR to process images of rich text scenarios, obtain text information of the images, and add the text information to the visual language pre-training framework to make up for the shortcomings of BLIP in rich text scenarios. This allows visual language pre-training to play a better role in rich text scenarios.
[0099] Figure 4 is a schematic diagram of the structure of a pre-training model provided in an embodiment of the present disclosure, see Figure 4 The pre-trained model includes an image encoding module 1, a text encoding module 2 and a description encoding module. The description encoding module includes a text encoder 3, an image-based text encoder 4 and an image-based text decoder 5.
[0100] The pre-trained model incorporates text information extracted from the image using OCR technology. Considering that the text information comes from the image, there is a relatively large domain gap between the image and the image title. If the text information is directly spliced with the image description information as text input, the domain gap will be aggravated. Therefore, the present disclosure uses the text encoding module 2 in the pre-trained model to fuse the text information and image features, and then conducts comparative learning with the description features to alleviate the domain gap between the image and the image description information, accelerate model convergence, and achieve better model effects. Among them, the output of the image encoding module 1 can be an image feature, the output of the text encoding module 2 can be a fusion feature, and after the description encoding module inputs the image description information, the description feature can be obtained, and after the text encoder 3 inputs the image description information, the description feature of the text encoder 3 can be output.
[0101] Figure 5 is a structural diagram of a training device for a pre-training model provided in an embodiment of the present disclosure, such as Figure 5 As shown, the device comprises:
[0102] An acquisition module 510 is used to acquire a sample set for training, wherein the sample set includes an image, image description information corresponding to the image, and text information in the image;
[0103] An input module 520 is used to input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image;
[0104] The training module 530 is used to train the pre-trained model based on the image features, the fusion features and the description features.
[0105] The technical solution provided by the embodiment of the present disclosure is to obtain a sample set for training, wherein the sample set includes an image, image description information corresponding to the image, and text information in the image; the samples in the sample set are input into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information; the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image; the pre-trained model is trained based on the image features, the fusion features, and the description features. During training, multi-dimensional information of images, image description information, and text information is considered, solving the problem that the BLIP model has limited information considered in unified visual-language understanding and generation tasks, which limits the effect of the BLIP model, and improves the effect of unified visual language understanding and generation tasks.
[0106] In one embodiment, the input module 520 is specifically configured to:
[0107] Inputting the images included in the samples in the sample set into the image encoding module in the pre-trained model to obtain image features of the images;
[0108] Inputting the image features and the text information in the image into the text encoding module in the pre-trained model to obtain fusion features corresponding to the text information;
[0109] The image description information is input into a description encoding module to obtain description features corresponding to the image description information.
[0110] In one embodiment, the training module 530 includes:
[0111] A first determining unit, configured to determine an image-text contrast loss function of the pre-trained model based on the fusion feature and the description feature;
[0112] A second determining unit is used to determine the image-text matching loss function and the language modeling loss function of the pre-trained model based on the fusion feature, the image feature and the description feature;
[0113] A training unit is used to train the pre-trained model based on the image-text contrast loss function, the image-text matching loss function and the language modeling loss function.
[0114] In one embodiment, the second determining unit is specifically configured to:
[0115] fusing the fusion feature and the image feature;
[0116] Through the description coding module of the pre-trained model, based on the description features and the fused features input into the description coding module, an image-text matching loss function and a language modeling loss function are obtained.
[0117] In one embodiment, the amount of text included in the image is greater than a set threshold.
[0118] The training device for the pre-trained model provided in the embodiments of the present disclosure can execute the training method for the pre-trained model provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method.
[0119] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0120] Figure 6 is a schematic diagram of a structure of a device for using a pre-training model provided in an embodiment of the present disclosure, such as Figure 6 As shown, the device comprises:
[0121] The input module 610 is used to input the sample to be processed into the pre-trained model to obtain the processing result of the sample to be processed. The pre-trained model is trained by the training method provided by the embodiment of the present disclosure.
[0122] The technical solution provided by the embodiments of the present disclosure can fully utilize images, image description information and text information in the images, thereby improving the application effect of the pre-trained model.
[0123] In one embodiment, the processing result includes one or more of the image features, descriptive features, fusion features, probability values represented by the image-text contrast loss function, probability values represented by the image-text matching loss function, and probability values represented by the language modeling loss function corresponding to the sample to be processed.
[0124] The device for using the pre-trained model provided in the embodiments of the present disclosure can execute the method for using the pre-trained model provided in any embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.
[0125] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0126] Figure 7Schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 7 , which shows an electronic device (eg, Figure 7 A schematic diagram of the structure of a terminal device or server) 500.
[0127] The electronic device 500 includes:
[0128] one or more processing devices;
[0129] a storage device for storing one or more programs,
[0130] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method provided by the embodiment of the present disclosure.
[0131] The terminal devices in the embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., as well as fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device 500 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0132] like Figure 7 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.
[0133] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0134] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0135] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0136] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0137] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method provided by the above embodiments is implemented.
[0138] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.
[0139] The computer storage medium may be a storage medium of computer executable instructions, which, when executed by a computer processor, are used to perform the methods provided by the present disclosure.
[0140] Computer readable storage media may be, for example, but not limited to: electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, device, or device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the foregoing.
[0141] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0142] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0143] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0144] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a sample set for training, the sample set including an image, image description information corresponding to the image, and text information in the image;
[0145] Input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image;
[0146] The pre-trained model is trained based on the image features, the fusion features and the description features.
[0147] Alternatively, the computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: inputs the sample to be processed into the pre-trained model to obtain the processing result of the sample to be processed, and the sample to be processed is the sample to be processed by the pre-trained model.
[0148] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0150] The modules or units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module or unit does not limit the unit itself in some cases. For example, an input module may also be described as a "sample input module".
[0151] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0152] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0154] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0155] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A training method for a pre-trained model, characterized in that: include: Acquire a sample set for training, the sample set including an image, image description information corresponding to the image, and text information in the image; Input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image; Training the pre-trained model based on the image features, the fusion features and the description features; The step of training the pre-trained model based on the image feature, the fusion feature and the description feature comprises: Determining the image-text contrast loss function of the pre-trained model based on the fusion feature and the description feature; Based on the fusion feature, the image feature and the description feature, determining the image-text matching loss function and the language modeling loss function of the pre-trained model; The pre-trained model is trained based on the image-text contrast loss function, the image-text matching loss function and the language modeling loss function.
2. The method according to claim 1, characterized in that Inputting the samples in the sample set into the pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, including: Inputting the images included in the samples in the sample set into the image encoding module in the pre-trained model to obtain image features of the images; Inputting the image features and the text information in the image into the text encoding module in the pre-trained model to obtain fusion features corresponding to the text information; The image description information is input into a description encoding module to obtain description features corresponding to the image description information.
3. The method according to claim 1, characterized in that The step of determining the image-text matching loss function and the language modeling loss function of the pre-trained model based on the fusion feature, the image feature and the description feature includes: fusing the fusion feature and the image feature; Through the description coding module of the pre-trained model, based on the description features and the fused features input into the description coding module, an image-text matching loss function and a language modeling loss function are obtained.
4. The method according to any one of claims 1 to 3, characterized in that: The amount of text included in the image is greater than a set threshold.
5. A method for using a pre-trained model, characterized in that: The pre-trained model is obtained by training using the method according to any one of claims 1 to 4, wherein the method comprises: The sample to be processed is input into the pre-trained model to obtain a processing result of the sample to be processed, where the sample to be processed is a sample to be processed by the pre-trained model.
6. The method according to claim 5, characterized in that The processing result includes one or more of the image features, description features, fusion features, probability values represented by the image-text comparison loss function, probability values represented by the image-text matching loss function, and probability values represented by the language modeling loss function corresponding to the sample to be processed.
7. A training device for a pre-trained model, characterized in that: include: An acquisition module, used to acquire a sample set for training, wherein the sample set includes an image, image description information corresponding to the image, and text information in the image; An input module, used to input the samples in the sample set into a pre-trained model to obtain image features corresponding to the image, fusion features corresponding to the text information, and description features corresponding to the image description information, wherein the pre-trained model is a model with visual language understanding and generation capabilities, and the fusion features are features that fuse the image features of the image and the text information corresponding to the image; A training module, used for training the pre-training model based on the image features, the fusion features and the description features; The training module comprises: A first determining unit, configured to determine an image-text contrast loss function of the pre-trained model based on the fusion feature and the description feature; A second determining unit is used to determine the image-text matching loss function and the language modeling loss function of the pre-trained model based on the fusion feature, the image feature and the description feature; A training unit is used to train the pre-trained model based on the image-text contrast loss function, the image-text matching loss function and the language modeling loss function.
8. A device for using a pre-trained model, characterized in that: The pre-trained model is obtained by training according to any one of the methods described in claims 1 to 4, and the device comprises: The input module is used to input the sample to be processed into the pre-trained model to obtain the processing result of the sample to be processed.
9. An electronic device, characterized in that: The electronic device comprises: one or more processing devices; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method according to any one of claims 1 to 6.
10. A storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to perform the method according to any one of claims 1 to 6.