Service providing method, device, and storage medium
By using contrast loss and mask loss in the deep learning model to train the feature extraction model, and using the characteristics of the original and mask samples, the problem of insufficient feature extraction capabilities of the model is solved, and efficient and accurate processing of multi-modal data is achieved. sexual enhancement.
Patent Information
- Application Number
- PCT/CN2024/074059
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-21
- Filing Date
- 2024-01-25
- Publication Date
- 2024-08-29
Smart Images

Figure CN2024074059_29082024_PF_FP_ABST
Abstract
Description
Service providing method, device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 21, 2023, with application number 202310182949.7 and invention name “Service Providing Method, Device and Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence technology, and in particular to a service providing method, device, and storage medium. Background Art
[0003] With the continuous development of artificial intelligence technology, deep learning has been applied to a wide range of scenarios, enabling downstream functions such as classification, image semantic recognition, text semantic recognition, and image segmentation. These downstream functions can also be provided to users as a service. The basic process for implementing these downstream functions using deep learning is to first perform feature extraction on the input data to extract features at different levels. These extracted features are then used to implement the various functions mentioned above. Feature extraction and feature processing can be accomplished using different deep learning models.
[0004] It can be seen that the feature extraction ability of the model can directly affect the accuracy of downstream functions. Therefore, how to improve the feature extraction ability of the model to ensure the accuracy of downstream functions has become an urgent problem to be solved.
[0005] Summary of the Invention
[0006] In view of this, embodiments of the present application provide a service providing method, device, and storage medium to improve data processing efficiency and ensure the accuracy of downstream functions.
[0007] In a first aspect, an embodiment of the present application provides a service providing method, comprising: obtaining data to be processed of at least one modality; inputting the data to be processed of the at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed; determining a processing result of the data to be processed based on the local features and the global features; wherein the feature extraction model is trained using contrast loss and mask loss calculated based on features of training samples, and the training samples include original samples and mask samples obtained by masking the original samples.
[0008] In a second aspect, an embodiment of the present application provides a service providing method, which is applied to a cloud server, comprising: in response to an input operation triggered by a user on a service platform, obtaining data to be processed of at least one modality, wherein the service platform is deployed in the cloud server; inputting the data to be processed of at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed; determining a processing result of the data to be processed based on the local features and the global features; and displaying the processing result on the service platform; wherein the feature extraction model is trained using contrast loss and mask loss calculated based on the features of training samples, and the training samples include original samples and mask samples obtained by masking the original samples, and the training samples are the same modality as the data to be processed.
[0009] In a third aspect, an embodiment of the present application provides a service providing method, which obtains a search keyword input by a user, wherein the search keyword includes at least one of a voice modality, a text modality, and an image modality; inputs the search keyword into a feature extraction model so that the feature extraction model outputs local features and global features of the search keyword; determines an image corresponding to the search keyword based on the local features and the global features; and displays the image to the user; wherein the feature extraction model for image retrieval is trained using contrast loss and mask loss calculated based on the features of a training sample, and the training sample includes an original sample and a mask sample obtained by masking the original sample, and the training sample has the same modality as the search keyword.
[0010] In a fourth aspect, an embodiment of the present application provides a service providing method, comprising: in response to user input, obtaining an original sample and a mask sample obtained by masking the original sample; inputting the original sample into a feature extraction model, so that the feature extraction model outputs a first local feature and a first global feature of the original sample; inputting the mask sample into the feature extraction model, so that the feature extraction model outputs a second local feature and a second global feature of the mask sample; determining the contrast loss of the feature extraction model based on the first global feature and the second global feature; using the first local feature as supervision information of the second local feature to determine the mask loss of the feature extraction model; training the feature extraction model based on the mask loss and the contrast loss; and outputting the feature extraction model.
[0011] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement any of the service provision methods described in aspects 1 to 4 above. The electronic device may also include a communication interface for communicating with other devices or communication systems.
[0012] In the sixth aspect, an embodiment of the present application provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the service provision method described in any one of the first to fourth aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in this application and should not be construed as limiting the scope of this application.
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following is a brief introduction to the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0015] FIG1 shows a flow chart of a service providing method provided in an embodiment of the present application.
[0016] FIG2 shows a schematic structural diagram of a feature extraction model provided in an embodiment of the present application.
[0017] FIG3 shows a flow chart of a model training method provided in an embodiment of the present application.
[0018] FIG4 shows a flowchart of another model training method provided in an embodiment of the present application.
[0019] FIG5 shows a schematic diagram of a model training method provided in an embodiment of the present application.
[0020] FIG6 shows a flowchart of another service providing method provided in an embodiment of the present application.
[0021] FIG7 shows a flowchart of another service providing method provided in an embodiment of the present application.
[0022] FIG8 shows a schematic diagram of a human-computer interaction process corresponding to the embodiment shown in FIG7 .
[0023] FIG9 shows a flowchart of another service providing method provided in an embodiment of the present application.
[0024] FIG10 shows a flow chart of a feature extraction method provided in an embodiment of the present application.
[0025] FIG11 shows a schematic diagram of feature extraction performed by a feature extraction model provided in an embodiment of the present application.
[0026] FIG12 shows a schematic diagram of feature extraction performed by another feature extraction model provided in an embodiment of the present application.
[0027] Figure 13 shows a schematic diagram of a model training method and a service provision method provided by an embodiment of the present application using a single modality sample.
[0028] Figure 14 shows a schematic diagram of a model training method and a service provision method using multimodal samples using an embodiment of the present application.
[0029] FIG15 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0030] FIG16 shows a schematic structural diagram of another electronic device provided in an embodiment of the present application.
[0031] FIG17 shows a schematic structural diagram of another electronic device provided in an embodiment of the present application.
[0032] FIG18 shows a schematic structural diagram of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0034] The terms used in the examples of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a," "the," and "the" used in the examples of this application and the appended claims are also intended to include plural forms, and unless the context clearly indicates otherwise, "a plurality" generally includes at least two, but does not exclude the inclusion of at least one.
[0035] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0036] As used herein, the words “if” and “if” may be interpreted as “at the time of” or “when” or “in response to determining” or “in response to identifying,” depending on the context. Similarly, the phrases “if it is determined” or “if (stated condition or event) is identified” may be interpreted as “when it is determined” or “in response to determining” or “when identifying (stated condition or event)” or “in response to identifying (stated condition or event),” depending on the context.
[0037] It should also be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or system. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the product or system comprising the element.
[0038] Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other unless they conflict with each other. Furthermore, the sequence of steps in the following method embodiments is provided for illustrative purposes only and is not intended to be a strict limitation.
[0039] Figure 1 is a flowchart of a service provision method provided in an embodiment of the present application. The service provision method provided in an embodiment of the present application can be executed by a processing device with data processing capabilities, such as a server, and the feature extraction model can be deployed in the processing device. As shown in Figure 1, the method may include the following steps S101-S103.
[0040] S101: Obtain data to be processed of at least one modality.
[0041] The processing device can obtain data to be processed in at least one modality. For example, the modality of the data can be at least one of text, image, and audio. The modality of the data to be processed is related to the downstream function, that is, the service required by the user.
[0042] For services such as image classification, image-based text search, image retrieval, and semantic recognition, the corresponding data to be processed is usually single-modal. Taking the image-based text search service as an example, the data to be processed may include image modalities.
[0043] For services commonly found on web pages, such as image verification and voice verification, the corresponding data to be processed is typically multimodal. Taking the image verification service as an example, this service involves selecting images displayed on a page based on the selection requirements presented on the page to complete user verification. A selection requirement might be, for example, "Select the animal in the image below." Therefore, to determine whether the user's selected image is correct, it is necessary to use features extracted by the feature extraction model to understand the semantics of the selection requirement and the semantics of the candidate images. In this case, the data to be processed may include the selection requirement in text or voice modality, multiple candidate images, and the image selected by the user.
[0044] S102: Inputting data to be processed of at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed.
[0045] S103, determining a processing result of the data to be processed based on the local features and the global features, wherein the feature extraction model is trained using contrast loss and mask loss calculated based on the features of the training samples, and the training samples include original samples and masked samples obtained by masking the original samples.
[0046] In one embodiment, a processing device may input data to be processed from at least one modality into a feature extraction model, which then extracts local and global features of the data. Global features describe the overall information of the data to be processed, while local features describe the details of the data to be processed. For example, global features of an image include color, texture, and shape features, while local features reflect information about edges, corners, lines, curves, and other regions within the image.
[0047] The feature extraction model can be trained using contrastive loss and mask loss. These two losses can be calculated based on the local and global features of the training samples. The training samples can include original samples and masked samples obtained by masking the original samples. The specific training process of the feature extraction model can be found in the description of the relevant embodiments below and will not be repeated here.
[0048] Finally, the processing device can use the local features and global features output by the model to process the data to be processed to obtain the processing results.
[0049] For feature-based data processing, take image retrieval services as an example. The data to be processed may include user-entered search keywords in text mode. The processing device can determine the semantics of the search keywords based on the features extracted by the model and search the image library for images with the same semantics. The retrieved images can be fed back to the user as search results, which are also the processing results of the data to be processed.
[0050] Taking the image verification service as an example, the data to be processed may include a text or voice selection request on a page, multiple candidate images, and the image selected by the user based on the selection request. Based on the features extracted by the model, the processing device can determine the semantics of the selection request, the semantics of the candidate images, and the semantics of the selected image. The processing device can then determine whether the user's selected image meets the selection request based on the semantics, ultimately determining whether the user has been successfully verified. The verification result is also the processing result of the data to be processed.
[0051] In this embodiment, data to be processed from at least one modality is input into a feature extraction model, which then outputs local and global features of the data to be processed. Ultimately, the data to be processed is processed based on the features at different levels output by the model to obtain a processing result. The feature extraction model is trained using contrastive loss and mask loss.
[0052] In the above process, processing the unprocessed data of at least one modality to obtain a processing result can be considered a processing service provided to the data. The key to implementing this processing service is to utilize the feature extraction model to obtain the global and local features of the unprocessed data. Contrastive loss and mask loss are used simultaneously when training the feature extraction model. Training with mask loss improves the model's ability to extract detailed information from samples, while training with contrastive loss improves the model's ability to extract overall information from samples. This enables the feature extraction model to have a higher feature extraction capability, ultimately ensuring the accuracy of data processing across different modalities.
[0053] The above embodiment does not limit the specific model structure of the feature extraction model. For example, Figure 2 is a structural diagram of a feature extraction model provided in an embodiment of the present application. The model may include an input layer, a first extraction layer, and a second extraction layer. The second extraction layer may include a self-attention module, and each layer in the model may be specifically expressed as a deep learning network. Based on the above model structure, the process of feature extraction of the data to be processed by the model may be: the data segments obtained by dividing the data to be processed are input into the input layer, and the first extraction layer in the feature extraction model may perform feature extraction on multiple data segments to obtain intermediate features of the data to be processed. Then, the intermediate features can be further input into the second extraction layer, so that the second extraction layer can extract features from the intermediate features of the data to be processed with the help of the self-attention module, so as to finally obtain the local features and global features of the data to be processed.
[0054] Based on the description in the above embodiments, it can be known that the feature extraction capability of the feature extraction model will directly affect the quality of service, that is, the accuracy of downstream functions. In order to improve the feature extraction capability of the feature extraction model, Figure 3 is a flow chart of a model training method provided in an embodiment of the present application. The model training method provided in an embodiment of the present application can be executed by a training device with data processing capabilities. For example, the training device can be a server, etc., and the feature extraction model to be trained is deployed in the training device. The training device can be the same device as the processing device in the above embodiments. As shown in Figure 3, the method may include the following steps S201-step S205.
[0055] S201 , inputting an original sample into a feature extraction model, so that the feature extraction model outputs a first local feature and a first global feature of the original sample.
[0056] S202 : Input the mask sample into a feature extraction model, so that the feature extraction model outputs a second local feature and a second global feature of the mask sample.
[0057] Before training the feature extraction model, you can first obtain the original samples and perform masking on them to obtain masked samples. The original samples are unprocessed, semantically complete samples, while the masked samples are semantically incomplete samples obtained by masking the original samples.
[0058] In one embodiment, the original sample may be data of at least one modality, such as speech, text, or image. In one embodiment, the original sample may also have different representations. The original sample may be a semantically complete piece of data, such as a whole image, a semantically complete text, or speech. The original sample may also include multiple data segments that can form a complete semantic meaning, such as multiple image blocks in a whole image, or multiple words in a text or speech.
[0059] When the original sample is complete data, for obtaining the mask sample, in one embodiment, the original sample can be taken as a whole, and a preset proportion of the samples in the whole can be masked to obtain the mask sample.
[0060] When the original samples are data segments, in one embodiment, the training device may first collect and segment historical data to obtain the original samples and masked samples. The resulting multiple data segments constitute the original samples. A predetermined proportion of the multiple data segments is then masked to form masked samples from the masked segments and the remaining segments.
[0061] In some embodiments, the training device can input the original sample and the masked sample in any of the above-mentioned forms into the feature extraction model to be trained, so that the model can extract the first local feature and the first global feature of the original sample, and also extract the second local feature and the second global feature of the masked sample. In one embodiment, the global feature or the local feature of any sample can include multiple features. For example, when any original sample includes multiple data segments, any global feature of the sample can include information from multiple data segments, and any local feature of the sample can include information from one data segment.
[0062] S203: Determine a contrast loss of a feature extraction model according to the first global feature and the second global feature.
[0063] S204: Using the first local feature as supervisory information for the second local feature, and determining the mask loss of the feature extraction model.
[0064] Then, the training device can determine the contrast loss of the model based on the two global features output by the feature extraction model. At the same time, since the original sample is not masked, the first local feature contains the masked information in the second local feature, so the training device can also use the first local feature as the supervisory information of the second local feature to determine another loss of the model, which can also be called mask loss. Among them, since the original sample and the masked sample have the same semantics, the smaller the contrast loss, the closer the first global feature and the second global feature extracted by the feature extraction model are; the smaller the mask loss, the closer the second local feature is to the first local feature. That is, the size of the contrast loss and the mask loss can reflect the feature extraction ability of the feature extraction model. In one embodiment, the mask loss can be specifically implemented using a related model used to generate data vectors (Data to Vector, abbreviated as Data2Vec).
[0065] S205: Train the feature extraction model based on the mask loss and the contrast loss.
[0066] Finally, the training device can train the model based on the mask loss and contrast loss obtained above, that is, adjust the model parameters.
[0067] In this embodiment, the training device can input the original sample and its corresponding mask sample into the feature extraction model, so that the feature extraction model can respectively propose the global features and local features of the original sample and the mask sample. The training device then uses the global features of the original sample and the mask sample to determine the contrast loss of the feature extraction model, and uses the local features of the original sample and the mask sample to determine the mask loss of the feature extraction model. Finally, the two losses are used to adjust the parameters of the feature extraction model, that is, to achieve the training of the feature extraction model. In the above training process, the use of mask loss training can improve the model's ability to extract detailed information in the sample, and the use of contrast loss training can improve the model's ability to extract overall information in the sample. Therefore, the feature extraction model can have a higher feature extraction ability. In addition, the use of contrast loss can also improve the feature collapse problem caused by using mask loss alone.
[0068] Regarding the above embodiment, it should also be noted that after the feature extraction model is trained according to the method provided in the above embodiment, the features extracted by this model can realize the various downstream functions mentioned in the background technology. And because the original samples used in training the feature extraction model can be of different modalities, the trained feature extraction model also supports the input of multiple modal data. At this time, the various downstream functions mentioned in the background technology can be specifically image classification and segmentation, which can realize semantic recognition of images, speech or text, and can also realize image-based text search, image retrieval, etc. It can be seen that the feature extraction model supports input data with rich modalities, which greatly enriches the applicable scenarios of the feature extraction model and improves the generalization ability of the model.
[0069] In addition, the beneficial effects that can be achieved by the above-mentioned model training method can also be understood from the following perspectives.
[0070] In practice, depending on the different downstream functions implemented by the features extracted by the feature extraction model, the feature extraction model can be pre-trained using conventional training methods. Afterwards, in one case, the features extracted by the pre-trained model can be directly used to implement certain downstream functions, such as classification of different modal data such as images, voice or text, image-based text search, image retrieval and other functions, that is, there is no need to further use samples corresponding to downstream functions to perform transfer learning on the feature extraction model. In another case, it is also possible to use samples corresponding to other downstream functions to perform transfer learning on the pre-trained model, and finally use the features extracted by the feature extraction model that has completed transfer learning to implement other downstream functions. Other downstream functions can be, for example, semantic segmentation and semantic recognition of different modal data.
[0071] In the above embodiment, the training device uses contrast loss to train the model, which actually uses the contrast learning mechanism to train the model, so that the feature extraction model obtained by training has a strong feature extraction capability, and the feature extraction model has zero-sample retrieval capability. Then, when the features extracted by the model are applied to certain downstream functions that do not require transfer learning, even if transfer learning is not performed, the feature extraction model can use its own strong feature extraction capability to ensure the effects of these downstream functions. At the same time, the training device also uses mask loss to train the model, which actually uses the mask mechanism to train the model, so that the trained feature extraction model also has a strong transfer learning capability. Then, when the features extracted by the feature extraction model are applied to other downstream functions that require transfer learning, the effects of these downstream functions can also be guaranteed.
[0072] As mentioned in the above embodiments, local features are required to determine the mask loss of the feature extraction model during model training. Regarding the specific calculation process of the mask loss, when the original sample is specifically represented by a semantically complete entire segment of data, in one embodiment, the training device can calculate the mask loss based on the entire sample. For example, the first local feature of the original sample can be directly used as supervisory information for the second local feature of the masked sample to determine the mask loss of the feature extraction model.
[0073] When the original sample is specifically represented by multiple data segments, in one embodiment, the training device can calculate the mask loss in units of data segments. For example, the first local feature of the first data segment in the original sample can be used as the supervision information of the second local feature of the second data segment in the mask sample to determine the mask loss of the feature extraction model. The first data segment is any data segment in the original sample, and the position of the first data segment in the original sample is the same as the position of the second data segment in the mask sample. According to the above method, the mask loss corresponding to each data segment in the original sample can be calculated, and the training device can use the mask loss corresponding to each of the multiple data segments to realize model training.
[0074] In practice, the original samples input to the feature extraction model may include a single modality, such as a separate image, voice, text, and so on. After the feature extraction model is trained using the original samples of a single modality, the features extracted by this model can be used to implement the various downstream functions mentioned above, such as classification and semantic recognition. In practice, the original samples input to the feature extraction model may also include multiple modalities, such as text and images at the same time, or voice, text, and images at the same time. After the feature extraction model is trained using the original samples of multiple modalities, the features extracted by this model can be used to implement other richer downstream functions, such as image verification and voice verification commonly seen on web pages.
[0075] When the original sample contains multiple modalities, the model training method provided in the embodiment shown in Figure 3 can be further refined. Figure 4 is a flow chart of another model training method provided in an embodiment of the present application. As shown in Figure 4, the method may include the following steps S301-S305.
[0076] S301: Input an original sample into a feature extraction model, so that the feature extraction model outputs a first local feature and a first global feature of the original sample.
[0077] S302: Input the mask sample into a feature extraction model, so that the feature extraction model outputs a second local feature and a second global feature of the mask sample.
[0078] Since any original sample used in the training model can contain multiple modalities, and the multimodal samples in the same original sample have the same semantics, an original sample can be considered as a sample group containing multimodal samples with the same semantics.
[0079] Taking image and text modalities as an example, an image sample in an original sample may show two boys playing Frisbee on the grass, and the corresponding text sample may be "Two boys playing Frisbee on the grass." For example, the text can correspond to different languages. In this case, after the original sample is input into the feature extraction model, the model can output the first local features and first global features of samples of different modalities in the original sample. Similarly, after the masked sample is input into the feature extraction model, the model can output the second local features and second global features of samples of different modalities in the masked sample.
[0080] Among them, the method of obtaining the original samples and mask samples and the feature extraction process of different samples can refer to the specific description of the relevant steps in the embodiment shown in Figure 3 above, and will not be repeated here.
[0081] S303 : Determine a contrast loss of a feature extraction model according to a first global feature of a sample of any modality in the original sample and a second global feature of a sample of any modality in the masked sample.
[0082] For any of the multiple modalities, the training device can calculate the contrastive loss of this feature model based on the first global feature of the samples of the modality and the second global feature of the samples of the modality. It is easy to understand that each sample of different modalities contained in the original sample has a corresponding contrastive loss. The magnitude of this contrastive loss can reflect the similarity between the first global feature and the second global feature.
[0083] S304: Using the first local feature of the sample of any modality in the original sample as supervision information of the second global feature of the sample of any modality in the mask sample, and determining the mask loss of the feature extraction model.
[0084] At the same time, since the original sample contains complete semantics, the training device can also use the first local feature of the sample of any modality in the original sample extracted in step S301 as the supervision information of the second local feature of the sample of any modality in the mask sample extracted in step S302, thereby determining the mask loss of the feature extraction model.
[0085] Regarding the determination of mask loss, in one embodiment, when any modal sample in the original sample has a whole segment of data that is semantically complete, the training device can directly use the first local feature of any modal sample as the supervision information of the second local feature of the mask sample corresponding to the modal sample to determine the mask loss of the feature extraction model. In one embodiment, when any modal sample is specifically manifested as multiple data segments, the training device can calculate the mask loss in units of data segments. The specific determination process can be found in the description in the above-mentioned related embodiments and will not be repeated here.
[0086] Similar to step S303, each of the samples of different modalities included in the original sample also has a corresponding mask loss. The size of the mask loss can also reflect whether the first local feature and the second local feature are similar.
[0087] S305: Train the feature extraction model based on the mask loss and the contrast loss.
[0088] Finally, the training device can train the feature extraction model based on the mask loss and contrast loss of samples from each modality.
[0089] In this embodiment, when the original samples and mask samples contain multiple modal samples, the feature extraction model can extract the local features and global features of the multiple modal samples respectively, and the training device can further calculate the contrast loss and mask loss corresponding to the different modal samples, and perform model training based on these losses. The use of contrast loss and mask loss can respectively improve the model's ability to extract overall information and detail information, thereby enabling the feature extraction model to have a higher feature extraction capability. And compared to samples of a single modality, the feature extraction model trained according to the method provided in this embodiment has a wider range of applicable scenarios. In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can be found in the description in the above embodiments, and will not be repeated here.
[0090] On the basis of the embodiment shown in FIG4 , in order to further improve the training effect of the model, in one embodiment, the training device may further first fuse the second global features of each of the multiple modal samples in the mask sample to obtain a fused global feature. Then, the fused global features are respectively combined with the first global features of each of the multiple modal samples in the original sample to determine the contrast loss of the feature extraction model. For the sake of clarity and indirectness in the subsequent description, the contrast loss in step S303 can be referred to as the first type of contrast loss, and the contrast loss obtained by fusing the global features can be referred to as the second type of contrast loss. Among them, each modality sample contained in the original sample has a corresponding second type of contrast loss.
[0091] In this embodiment, the global features of various modal samples in the mask sample are fused to obtain a fused global feature, which can contain information of multiple modal samples at the same time. The second type of contrast loss is calculated using this information-rich fused global feature and the global features of various modal samples in the original sample. Using this second type of contrast loss for model training can enable the feature extraction model to better learn the information contained in the different modal samples in the original sample, that is, to achieve the alignment of single modal samples, and can also improve the generalization ability of the model. In addition, the content not described in detail in this embodiment and the technical effects that can be achieved can be found in the description of the above embodiment, and will not be repeated here.
[0092] Based on the above description, in order to further improve the training effect of the model, in one embodiment, the training device can also determine the contrast loss of the feature extraction model based on the first global features of the different modal samples in the original sample. This contrast loss can also be called the third type of contrast loss, and use this third contrast loss to train the model.
[0093] In this embodiment, for samples with the same semantics but different modalities, this third type of contrastive loss training enables the feature extraction model to learn the inherent correlation between these samples, that is, to achieve alignment between samples of different modalities and improve the model's generalization ability. In addition, the details not described in detail in this embodiment and the technical effects that can be achieved can be found in the description of the above embodiments and will not be repeated here.
[0094] In summary, the use of contrastive loss can improve the feature collapse problem caused by using mask loss alone. Furthermore, when the original samples specifically include samples with the same semantics but different modalities, the use of the first type of contrastive loss can improve the model's ability to extract overall information; the use of the second type of contrastive loss can achieve alignment of single-modal samples, which can improve the model's generalization ability; and the use of the third type of contrastive loss can achieve alignment between samples of different modalities, which can also improve the model's generalization ability.
[0095] It can be seen that the use of different contrastive losses can improve the training effect of the feature extraction model from different perspectives. Assuming that the original samples include samples of image modality and samples of text modality, the process of using different losses for feature extraction model can be understood in conjunction with Figure 5.
[0096] The service providing methods mentioned in the above embodiments may be executed by a processing device, and the processing device may be specifically a server. For example, the server may be a cloud server, in which case different services may be provided externally with the help of the cloud server.
[0097] Figure 6 is a flow chart of a service provision method provided in an embodiment of the present application. The method may be executed by a cloud server, which may also include a service platform. Users can interact with the service platform to access the services provided by the platform, thereby obtaining data processing results. As shown in Figure 6, the method may include the following steps S401 to S404.
[0098] S401, in response to an input operation triggered by a user on a service platform, obtaining data to be processed in at least one modality, where the service platform is deployed in a cloud server.
[0099] S402: Inputting data to be processed of at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed, wherein the feature extraction model is trained using contrast loss and mask loss calculated based on features of training samples, the training samples including original samples and masked samples obtained by masking the original samples, and the training samples have the same modality as the data to be processed.
[0100] S403: Determine a processing result of the data to be processed according to the local features and the global features.
[0101] S404, displaying the processing results on the service platform.
[0102] The service platform can provide a user interface where users can enter data to be processed in at least one modality corresponding to the service in a data input area. The cloud server can extract features from the data to be processed using a feature extraction model and determine processing results based on the extracted features. This processing result can be displayed to the user as a service result. The service platform can provide at least one service, and the service platform's homepage provides a data input area and can also display processing results.
[0103] In addition, the specific implementation method of each step in this embodiment and the technical effects that can be achieved can be found in the description of the above embodiments and will not be repeated here.
[0104] The above embodiments mention various services. Regarding image retrieval services, FIG7 is a flow chart of a service provision method provided in an embodiment of the present application. The method may be performed by a processing device, which may be a cloud server or a traditional server. As shown in FIG7 , the method may include the following steps S501 through S504.
[0105] S501: Acquire a search keyword input by a user, where the search keyword includes at least one modality such as voice modality, text modality, and image modality.
[0106] S502: Input the search keyword into the feature extraction model so that the feature extraction model outputs the local features and global features of the search keyword. The feature extraction model for image retrieval is trained using contrast loss and mask loss calculated based on the features of training samples. The training samples include original samples and mask samples obtained by masking the original samples. The training samples have the same modality as the search keyword.
[0107] S503: Determine the image corresponding to the search keyword based on the local features and the global features.
[0108] S504: Display the image to the user.
[0109] When a user wants to perform an image search, he or she can input a search keyword into the processing device. The search keyword can be at least one modality. When the search keyword is a text modality or a voice modality, the image retrieval service is a single-modal image retrieval service, that is, a text-to-image search service; when the search keyword includes both the image modality and the text modality, or both the image modality and the voice modality, the image retrieval service is a multi-modal image retrieval service. After the processing device obtains the search keyword input by the user, it can use the global features and local features extracted by the feature extraction model to realize image retrieval, and the search results can be fed back to the user.
[0110] In one embodiment, the user's input of search keywords and the display of search results can be achieved through the service platform deployed in the processing device, that is, the user can interact with the service platform to input search keywords, and finally the search results are displayed to the user on the service platform.
[0111] In one embodiment, the interactive interface provided by the service platform may be as shown in FIG8 . A user may select an image search service from among the various services displayed on the service platform homepage and enter a search keyword in the corresponding data input area. Finally, the service platform displays the image search results on the search results page.
[0112] In this embodiment, users can implement image retrieval by interacting with the service platform. Because the feature extraction model can accurately extract the features of the search keywords, the accuracy of the image retrieval can be guaranteed. In addition, the specific implementation methods of each step of this embodiment and the technical effects achieved can be found in the description of the above embodiment and will not be repeated here.
[0113] In the embodiments shown in Figures 1 and 6 to 8, with the help of the powerful feature extraction capabilities of the feature extraction model, various downstream functions can be provided to users as services. In addition to the various services mentioned above, the training process of the feature extraction model, that is, the model training method shown in Figures 3 to 5, can also be provided as a model training service to users with training needs. Figure 9 is a flow chart of a service provision method provided in an embodiment of the present application. The executor of the method can be a service platform. For example, this service platform can be deployed in the servers mentioned in the above embodiments. As shown in Figure 9, the method may include the following steps S601-step S607.
[0114] S601 : In response to a user input, an original sample and a masked sample obtained by performing masking processing on the original sample are obtained.
[0115] For users who need model training, they can pre-collect raw samples and mask them to obtain masked samples. Afterwards, the user can trigger an input operation on the service platform to input the raw and masked samples into the service platform.
[0116] S602: Input the original sample into a feature extraction model, so that the feature extraction model outputs a first local feature and a first global feature of the original sample.
[0117] S603 , inputting the mask sample into a feature extraction model so that the feature extraction model outputs a second local feature and a second global feature of the mask sample, where the mask sample is a result of masking the original sample.
[0118] S604: Determine a contrast loss of a feature extraction model based on the first global feature and the second global feature.
[0119] S605: Use the first local feature as supervisory information for the second local feature to determine the mask loss of the feature extraction model.
[0120] S606: Train the feature extraction model based on the mask loss and the contrast loss.
[0121] The specific implementation process of the above steps S602 to S606 can refer to the specific description of the relevant steps in the embodiment shown in Figure 3, and will not be repeated here.
[0122] S607: Output the feature extraction model.
[0123] Finally, the service platform may output the feature extraction model to the user, for example, the parameters of the output feature extraction model.
[0124] In this embodiment, after obtaining the original sample and its corresponding masked sample, the service platform can input them into the feature extraction model to be trained, so that the feature extraction model can respectively extract global features and local features of the original sample and masked sample. The service platform then uses the global features of the original sample and masked sample to determine the contrast loss of the feature extraction model, and uses the local features of the original sample and masked sample to determine the mask loss of the feature extraction model. Ultimately, these two losses are used to adjust the parameters of the feature extraction model, thereby achieving training of the feature extraction model.
[0125] During the training process described above, using mask loss can improve the model's ability to extract detailed information from samples, while using contrast loss can improve the model's ability to extract overall information from samples. This results in a feature extraction model with higher feature extraction capabilities. Furthermore, using contrast loss can also improve the feature collapse problem caused by using mask loss alone.
[0126] It should be noted that, as mentioned in any of the embodiments in Figures 3 to 5, the original sample input by the user can include samples of at least one modality. In this case, the service platform can also use samples of multiple modalities to train the feature extraction model in the manner provided in the above-mentioned related embodiments. While ensuring the effectiveness of model training, the feature extraction model also supports input of different modalities. In addition, the content not described in detail in this embodiment and the technical effects that can be achieved can be found in the description of the above-mentioned related embodiments and will not be repeated here.
[0127] Following the structure of the feature extraction model provided in FIG2 , FIG10 is a flow chart of a feature extraction method provided in an embodiment of the present application. During the model training process, the feature extraction model can extract features from the training samples according to the following process. As shown in FIG10 , the method may include the following steps S701 to S704.
[0128] S701: The first extraction layer in the feature extraction model performs feature extraction on the original sample to obtain a first intermediate feature.
[0129] S702: The second extraction layer in the feature extraction model performs feature extraction on the first intermediate feature with the help of a self-attention module to obtain a first local feature and a first global feature.
[0130] The input layer in the feature extraction model is used to receive the original sample and the masked sample and input them into the first extraction layer. The first extraction layer can perform feature extraction on the original sample to obtain the first intermediate feature. Then, the first intermediate feature is processed by the self-attention module. The second extraction layer can further perform feature extraction on the processing results output by the self-attention module to obtain the first local feature and the first global feature. The original sample and the masked sample can be represented as a complete piece of data or multiple data fragments.
[0131] In one embodiment, for samples of different modalities in the original samples, the first extraction layer may include a multi-layer perceptron (MLP) suitable for images, which may also be called a fully connected neural network, a convolutional neural network such as a residual network (ResNets), a ViT (Vision Transformer) network, and may also include a word embedding algorithm suitable for text, etc., and may also include related algorithms suitable for speech. For example, the second extraction layer may be the same as the first extraction layer, that is, it includes the aforementioned network suitable for samples of different modalities. For example, the second extraction layer may also include feed forward neural networks (FFN) suitable for samples of different modalities.
[0132] It should be noted that to extract features of varying scales, the first extraction layer can include multiple networks. The more networks it passes through, the smaller the scale of the extracted features, and the less low-level information and more high-level information in the extracted features. Similarly, the second extraction layer can also include multiple networks. The multiple networks in each extraction layer can be of the same or different types.
[0133] S703: The first extraction layer in the feature extraction model performs feature extraction on the mask sample to obtain a second intermediate feature.
[0134] S704: The second feature layer in the feature extraction model extracts the second intermediate feature with the help of the self-attention module to obtain a second local feature and a second global feature.
[0135] Similar to the above steps, the first extraction layer and the second extraction layer in the feature extraction model can also perform feature extraction on the mask samples corresponding to the original samples to obtain second local features and second global features. The specific implementation process of steps S703 to S704 can be described in the relevant descriptions of the above two steps and will not be repeated here. The feature extraction process provided in this embodiment can also be understood in conjunction with Figure 11.
[0136] It should also be noted that the feature extraction model can perform feature extraction on the original samples and the masked samples respectively, but in this embodiment, extracting features from the original samples first and then from the masked samples is only an illustrative feature extraction order, and this application does not limit the order of feature extraction of the two samples.
[0137] In this embodiment, based on the feature extraction model shown in Figure 2, the model can perform feature extraction on the original samples and the masked samples respectively, and the extracted global features and local features can be further provided to the server or service platform, so that the server or service platform can train the feature extraction model shown in Figure 2 according to the method provided in the embodiments shown in Figures 3 to 5 or the embodiment shown in Figure 9, thereby ensuring the training effect.
[0138] In one embodiment, when the original samples include samples of multiple modalities, different types of networks can be used to extract features from samples of different modalities. Taking the original samples including samples of both image and text modalities as an example, the feature extraction model shown in FIG11 can be transformed into FIG12 accordingly.
[0139] In the feature extraction model shown in Figure 12, the first extraction layer applicable to samples in the image modality can extract the first intermediate features of the original image and the second intermediate features of the mask image, and the first extraction layer applicable to samples in the text modality can extract the first intermediate features of the original text and the second intermediate features of the mask sample. Afterwards, the results extracted by the different first extraction layers can be input into the self-attention module of the feature extraction model, which processes the features to obtain the first processing results corresponding to the samples in the image modality and the second processing results corresponding to the samples in the text modality, respectively. Then, the first processing results can be further input into the second extraction layer applicable to samples in the image modality to ultimately extract the global features and local features of the original image and the mask image, respectively. The second processing results can be input into the second extraction layer applicable to samples in the text modality to extract the global features and local features of the original text and the mask text, respectively. The process of extracting features from samples by the above-mentioned feature extraction model can also be understood in conjunction with Figure 12.
[0140] As shown in Figure 12, the second extraction layer for samples of different modalities can share a self-attention module. This sharing of the module can reduce model parameters and speed up model convergence. It can also fuse the intermediate features of samples of different modalities, improving model training effectiveness.
[0141] In this embodiment, when the original samples include samples from multiple modalities, the model shown in Figure 2 can output global and local features of different modalities for the server or service platform to further calculate the loss used to implement model training. Furthermore, samples from different modalities share a single self-attention module, which not only speeds up convergence but also improves training effectiveness.
[0142] In one embodiment, according to actual needs, corresponding self-attention modules can be set for different second extraction layers respectively, and the modules process and input the processing results into the corresponding second extraction layers.
[0143] The following describes the specific implementation process of the model training method and service provision method provided in the above embodiments by taking a single modality sample as an example.
[0144] Assuming that the user wants to train a feature extraction model that can realize the image retrieval function, the service platform can determine that the downstream function realized by the feature extraction model is text-based image search in response to the selection operation triggered by the user on the interface of the service platform. Then, in response to the input operation triggered by the user on the interface, the original sample of the text modality input by the user is obtained, which can be referred to as the original text later. At the same time, the mask sample corresponding to the original text can also be obtained, which can be referred to as the mask text later. Among them, each word in the text can be considered as a data segment. For example, any original sample containing multiple data segments can be "two boys playing frisbee on the grass", and the corresponding mask text is "two[mask]playing[mask]on the grass".
[0145] At this time, the original text and masked text input by the user obtained by the server deployed with the service platform can be input into the feature extraction model in the form of data fragments. Based on the model structure shown in Figure 2, after the first extraction layer, the self-attention module and the second extraction layer in the model are processed successively, the model can output the first global feature and the second local feature of the original text, as well as the first global feature and the second local feature of the masked text. Afterwards, the server can determine the contrast loss of the feature extraction model based on the first global feature and the second global feature, and then use the first local feature as the supervision information of the second local feature to determine the mask loss of the feature extraction model. Among them, the smaller the mask loss and the contrast loss, the better. Finally, the server can use the aforementioned mask loss and contrast loss to train the model, that is, adjust the model parameters until the model converges. And the features extracted using the converged feature extraction model can be directly used for text-to-image search.
[0146] The above process of using single-modal samples to train the model can also be understood in conjunction with Figure 13. The technical effects that can be achieved by the above training process can also be found in the description of the above related embodiments, which will not be repeated here.
[0147] After completing the training of the feature extraction model according to the above process, the user can also use the service platform to implement image retrieval in the manner shown in Figure 8. The technical effects that can be achieved by this process can also be found in the description of the above related embodiments and will not be repeated here.
[0148] The specific implementation process of the model training method and service provision method provided in the above embodiments will be described below by taking multimodal samples as an example.
[0149] Assuming that the user wants to train a feature extraction model that can realize the image verification function, the service platform can determine that the downstream function realized by the feature extraction model is image verification in response to the selection operation triggered by the user on the interface of the service platform. Then, in response to the input operation triggered by the user on the interface, the original samples of the text modality and image modality input by the user are obtained, which can be referred to as the original text and the original image later. The mask sample of the image modality with the same semantics as the original image can also be obtained, which can be referred to as the mask image later. At the same time, the mask sample of the text modality with the same semantics as the original text can also be obtained, which can be referred to as the mask text later. Among them, each word in the text can be considered as a data segment, the image can be pre-divided into image blocks, and each image block can be considered as a data segment.
[0150] At this point, the original text, original image, masked image, and masked text with the same semantics, obtained by the server deployed with the service platform, can be input into the feature extraction model in the form of data segments. Based on the model structure shown in Figure 7, after being processed sequentially by the first extraction layer, the shared self-attention module, and the second extraction layer in the model, the model can output the first global feature and first local feature of the original text, the first global feature and first local feature of the original image, the second global feature and second local feature of the masked image, and the second global feature and second local feature of the masked text. The server can then calculate the three-class contrast loss based on the global features of samples from different modalities and the mask loss based on the local features of samples from different modalities. The calculation method of the three-class contrast loss and mask loss can be shown in Figure 5. Finally, the server can use the aforementioned mask loss and three-class contrast loss to train the model, that is, adjust the model parameters until the model converges. The features extracted by the converged feature extraction model can be directly used for image verification.
[0151] The process of model training using multimodal samples can also be understood in conjunction with Figure 14. The technical effects that can be achieved by the above training process can also be found in the description of the above related embodiments, which will not be repeated here.
[0152] After completing the feature extraction model training according to the above process, the user can also use the service platform to select search result 2 and search result 6 in sequence according to the interface shown in Figure 8 to implement image verification. The technical effects achieved by this process can also be found in the description of the above-mentioned related embodiments and will not be repeated here.
[0153] In the service provision method provided in the embodiments of the present application, data to be processed of at least one modality is input into a feature extraction model, so that the model outputs local and global features of the data to be processed. Ultimately, the data to be processed can be processed according to the features of different levels output by the model to obtain a processing result. The feature extraction model is trained using contrast loss and mask loss, which are specifically calculated based on the local and global features of the training samples, and the training samples specifically include original samples and masked samples obtained by masking the original samples.
[0154] In the above process, processing the unprocessed data of at least one modality to obtain the processing results can be considered a service provided to the data. The key to implementing this processing service is to use the feature extraction model to obtain the global and local features of the unprocessed data. Contrastive loss and mask loss are used simultaneously when training the feature extraction model. Training with mask loss can improve the model's ability to extract detailed information from samples, while training with contrastive loss can improve the model's ability to extract overall information from samples. Therefore, the feature extraction model can have higher feature extraction capabilities, ultimately ensuring the accuracy of data processing across different modalities.
[0155] In one possible design, the service provision method provided in the above embodiments may be applied in an electronic device, as shown in FIG15 , which may include: a first processor 21 and a first memory 22. The first memory 22 is used to store a program that supports the electronic device in executing the service provision method provided in the embodiments shown in FIG1 to FIG5 and FIG10 to FIG12 , and the first processor 21 is configured to execute the program stored in the first memory 22.
[0156] The program includes one or more computer instructions, wherein the one or more computer instructions, when executed by the first processor 21, can implement the following steps: obtaining data to be processed of at least one modality; inputting the data to be processed of the at least one modality into a feature extraction model so that the feature extraction model outputs local features and global features of the data to be processed; determining the processing results of the data to be processed based on the local features and the global features; wherein the feature extraction model is trained using contrast loss and mask loss calculated based on the features of training samples, and the training samples include original samples and mask samples obtained by masking the original samples.
[0157] In one embodiment, the first processor 21 is further configured to execute all or part of the steps in the embodiments shown in the aforementioned FIG. 1 to FIG. 5 and FIG. 10 to FIG. 12 .
[0158] The structure of the electronic device may further include a first communication interface 23 for the electronic device to communicate with other devices or communication systems.
[0159] In one possible design, the service provision method provided in the above embodiments can be applied in another electronic device. As shown in FIG16 , the electronic device may include: a second processor 31 and a second memory 32. The second memory 32 is used to store a program that supports the electronic device to execute the service provision method provided in the embodiment shown in FIG6 , and the second processor 31 is configured to execute the program stored in the memory 32.
[0160] The program includes one or more computer instructions, wherein the one or more computer instructions can implement the following steps when executed by the second processor 31: in response to an input operation triggered by a user on a service platform, obtaining data to be processed of at least one modality, wherein the service platform is deployed in the cloud server; inputting the data to be processed of at least one modality into a feature extraction model so that the feature extraction model outputs local features and global features of the data to be processed; determining the processing results of the data to be processed based on the local features and the global features; and displaying the processing results on the service platform; wherein the feature extraction model is trained using contrast loss and mask loss calculated based on the features of training samples, wherein the training samples include original samples and mask samples obtained by masking the original samples, and the training samples are the same modality as the data to be processed.
[0161] In one embodiment, the second processor 31 is further configured to execute all or part of the steps in the embodiment shown in FIG. 6 .
[0162] The electronic device may further include a second communication interface 33 for communicating with other devices or communication systems.
[0163] In one possible design, the service provision method provided in the above embodiments can be applied in another electronic device. As shown in FIG17 , the electronic device may include: a third processor 41 and a third memory 42. The third memory 42 is used to store a program that supports the electronic device to execute the service provision method provided in the embodiment shown in FIG7 or FIG8 , and the third processor 41 is configured to execute the program stored in the third memory 42.
[0164] The program includes one or more computer instructions, wherein the one or more computer instructions, when executed by the third processor 41, can implement the following steps: obtaining a search keyword input by a user, wherein the search keyword includes at least one of a voice modality, a text modality, and an image modality; inputting the search keyword into a feature extraction model so that the feature extraction model outputs local features and global features of the search keyword; determining an image corresponding to the search keyword based on the local features and the global features; and displaying the image to the user; wherein the feature extraction model for image retrieval is trained using contrast loss and mask loss calculated based on features of training samples, wherein the training samples include original samples and mask samples obtained by masking the original samples, and the training samples are the same modality as the search keyword.
[0165] In one embodiment, the third processor 41 is further configured to execute all or part of the steps in the embodiment shown in FIG. 7 or FIG. 8 .
[0166] The structure of the electronic device may further include a third communication interface 43 for the electronic device to communicate with other devices or communication systems.
[0167] In one possible design, the service provision method provided in the above embodiments can be applied to another electronic device. As shown in FIG18 , the electronic device may include: a fourth processor 51 and a fourth memory 52. The fourth memory 52 is used to store a program that supports the electronic device to execute the service provision method provided in the embodiment shown in FIG9 , and the fourth processor 51 is configured to execute the program stored in the fourth memory 52.
[0168] The program includes one or more computer instructions, wherein the one or more computer instructions, when executed by the fourth processor 51, can implement the following steps: in response to user input, obtain an original sample and a mask sample obtained by masking the original sample; input the original sample into a feature extraction model so that the feature extraction model outputs a first local feature and a first global feature of the original sample; input the mask sample into the feature extraction model so that the feature extraction model outputs a second local feature and a second global feature of the mask sample, wherein the mask sample is the result of masking the original sample; determine the contrast loss of the feature extraction model based on the first global feature and the second global feature; determine the mask loss of the feature extraction model using the first local feature as supervision information of the second local feature; train the feature extraction model based on the mask loss and the contrast loss; and output the feature extraction model.
[0169] In one embodiment, the fourth processor 51 is further configured to execute all or part of the steps in the embodiment shown in FIG. 9 .
[0170] The structure of the electronic device may further include a fourth communication interface 53 for the electronic device to communicate with other devices or communication systems.
[0171] In addition, an embodiment of the present application provides a computer storage medium for storing computer software instructions used by the above-mentioned electronic device, which includes programs involved in executing the service providing method shown in Figures 1 to 5 and Figures 10 to 12 above.
[0172] In addition, an embodiment of the present application provides another computer storage medium for storing computer software instructions used by the above-mentioned electronic device, which includes a program for executing the service providing method shown in Figure 6 above.
[0173] In addition, an embodiment of the present application provides another computer storage medium for storing computer software instructions used by the above-mentioned electronic device, which includes a program for executing the service providing method shown in Figure 7 or Figure 8 above.
[0174] In addition, an embodiment of the present application provides a computer storage medium for storing computer software instructions used by the above-mentioned electronic device, which includes a program for executing the service providing method shown in Figure 9 above.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A service providing method, comprising: Obtaining data to be processed of at least one modality; Inputting the data to be processed of the at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed; Determine a processing result of the data to be processed according to the local features and the global features; The feature extraction model is trained using contrast loss and mask loss calculated according to features of training samples, and the training samples include original samples and mask samples obtained by masking the original samples.
2. The method according to claim 1, wherein: The feature extraction model includes a first extraction layer and a second extraction layer including a self-attention module; The step of inputting the at least one modality of the data to be processed into a feature extraction model so that the feature extraction model outputs features of the data to be processed includes: The multiple data segments obtained by dividing the data to be processed are input into the feature extraction model, so that the first extraction layer performs feature extraction on the data segments to obtain intermediate features, and the second extraction layer performs feature extraction on the intermediate features with the help of the self-attention module to obtain local features and global features of the data to be processed.
3. The method according to claim 1, wherein: The method further comprises: Inputting the original sample into the feature extraction model so that the feature extraction model outputs a first local feature and a first global feature of the original sample; Inputting the mask sample into the feature extraction model so that the feature extraction model outputs a second local feature and a second global feature of the mask sample; Determining a contrast loss of the feature extraction model according to the first global feature and the second global feature; Using the first local feature as supervision information of the second local feature, and determining a mask loss of the feature extraction model; The feature extraction model is trained according to the mask loss and the contrast loss.
4. The method according to claim 3, wherein: The original samples and the mask samples each include samples of multiple modalities, and the semantics of the samples of the multiple modalities are the same; The determining, according to the first global feature and the second global feature, the contrast loss of the feature extraction model comprises: Determining the contrast loss according to a first global feature of a sample of any modality in the original sample and a second global feature of a sample of any modality in the mask sample; The step of using the first local feature as supervisory information of the second local feature to determine the mask loss of the feature extraction model includes: The mask loss is determined by taking the first local feature of the sample of any modality in the original sample as the supervisory information of the second global feature of the sample of any modality in the mask sample.
5. The method according to claim 4, wherein: The determining, according to the first global feature and the second global feature, the contrast loss of the feature extraction model comprises: Fusing the second global features of the samples of multiple modalities in the mask sample to obtain a fused global feature; According to the fused global feature and the first global features of the samples of multiple modalities in the original sample, determine Contrastive loss for the feature extraction model.
6. The method according to claim 4 or 5, wherein: The method further comprises: The contrast loss of the feature extraction model is determined according to the first global features of each of the samples of multiple modalities in the original sample.
7. The method according to claim 3, wherein: The step of using the first local feature as supervisory information of the second local feature to determine the mask loss of the feature extraction model includes: Dividing the historical data so that the multiple data segments obtained by the division constitute the original sample; Using a first local feature of a first data segment in the original sample as supervisory information of a second local feature of a second data segment in the mask sample, and determining a mask loss of the feature extraction model; The position of the first data segment in the original sample is the same as the position of the second data segment in the mask sample.
8. The method according to claim 3, wherein: The feature extraction model outputs a first local feature and a first global feature of the original sample, including: The first extraction layer of the feature extraction model performs feature extraction on the original sample to obtain intermediate features; The second extraction layer of the feature extraction model extracts features from the intermediate features with the help of a self-attention module to obtain the first local features and the first global features.
9. The method according to claim 8, wherein: The original samples include samples of multiple modalities, and the samples of the multiple modalities have the same semantics; The first extraction layer of the feature extraction model extracts features from the original sample, including: In the feature extraction model, a first extraction layer corresponding to any one of the multiple modalities performs feature extraction on samples of the any one modality.
10. The method according to claim 9, wherein: The second feature layer of the feature extraction model extracts features from the intermediate features by means of a self-attention module, including: In the feature extraction model, the second extraction layer corresponding to any one of the modalities performs feature extraction on the intermediate features of the samples of any one of the modalities with the help of a self-attention module, and the second extraction layers corresponding to different modalities share the self-attention module in the feature extraction model.
11. A service providing method, applied to a cloud server, comprising: Responding to an input operation triggered by a user on a service platform, obtaining data to be processed in at least one modality, wherein the service platform is deployed in the cloud server; Inputting the data to be processed of the at least one modality into a feature extraction model, so that the feature extraction model outputs local features and global features of the data to be processed; Determine a processing result of the data to be processed according to the local features and the global features; Displaying the processing result on the service platform; The feature extraction model is trained using contrast loss and mask loss calculated based on features of training samples, wherein the training samples include original samples and mask samples obtained by masking the original samples, and the training samples have the same modality as the data to be processed.
12. A service providing method, comprising: Obtain the search keyword input by the user, the search keyword includes voice mode, text mode, image mode at least one mode of Inputting the search keyword into a feature extraction model so that the feature extraction model outputs local features and global features of the search keyword; Determine the image corresponding to the search keyword according to the local feature and the global feature; displaying the image to the user; Among them, the feature extraction model for image retrieval is trained using contrast loss and mask loss calculated according to the features of training samples, wherein the training samples include original samples and mask samples obtained by masking the original samples, and the training samples have the same modality as the retrieval keyword.
13. The method according to claim 12, wherein: The method further comprises: Display various services provided on the service platform; In response to the user's selection of an image retrieval service on the service platform, determining the feature extraction model for image retrieval; The obtaining of the search keyword input by the user includes: In response to an input operation triggered by the user on the service platform, the search keyword is obtained.
14. A method for providing a service, comprising: In response to a user input, an original sample and a masked sample obtained by performing mask processing on the original sample are acquired; Inputting the original sample into the feature extraction model so that the feature extraction model outputs a first local feature and a first global feature of the original sample; Inputting the mask sample into the feature extraction model so that the feature extraction model outputs the second local feature and the second global feature of the mask sample, wherein the mask sample is the result of performing mask processing on the original sample; Determining a contrast loss of the feature extraction model according to the first global feature and the second global feature; Using the first local feature as supervision information of the second local feature, and determining a mask loss of the feature extraction model; Training the feature extraction model according to the mask loss and the contrast loss; The feature extraction model is output.
15. An electronic device, comprising: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the service providing method according to any one of claims 1 to 14.
16. A non-transitory machine-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the service providing method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Semantic representation model pre-training method and device, electronic equipment and storage medium
CN113239705A
Training method and device of visual language pre-training model, equipment and medium
CN114022735A
Text representation method and device, electronic equipment and storage medium
CN114118022A
Unsupervised optical flow estimation method based on Transform feature pyramid network
CN114187331A
Multi-modal interaction cross-modal retrieval method and system
CN115017358A
Cited By
Forgery face video detection method and device based on lip sound consistency
CN120580568A
Method and device for detecting a fake face video based on lip consistency
CN120580568B
