Model training method and apparatus, and computer device and storage medium
By combining feature learning and quantitative learning in the content retrieval model, calculating the semantic loss of different feature granularities, and performing multi-feature granularity alignment, the problem of semantic deviation caused by differences in feature modalities in the retrieval model is solved, and the accuracy of content retrieval is improved. and accuracy.
Patent Information
- Application Number
- PCT/CN2023/108065
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-09-01
- Filing Date
- 2023-07-19
- Publication Date
- 2024-09-12
AI Technical Summary
During the training process of the existing content retrieval model, semantic deviation is easy to occur between the retrieval content features and the retrieval result content features, resulting in a decrease in retrieval precision and accuracy. Especially when the feature modal differences are large, the retrieval effect is not good. good.
By obtaining the sample retrieval content and its matching retrieval result content, the content retrieval model is used for feature extraction and quantification processing, the semantic loss of different feature granularities is calculated, and used for model training, combining feature learning and quantitative learning to optimize model training. The goal is to reduce semantic deviation and reduce modal differences through alignment at multiple feature granularities.
It effectively improves the precision and accuracy of the content retrieval model, especially in cross-modal retrieval between different feature modes, reducing the semantic deviation of quantized features and improving the retrieval effect and user experience.
Smart Images

Figure CN2023108065_12092024_PF_FP_ABST
Abstract
Description
Model training method, device, computer equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on September 1, 2022, with application number 2022110645445 and application name “Model training method, device, computer equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] This application relates to the field of artificial intelligence technology, and specifically to machine learning technology. Background Art
[0003] In a content retrieval scenario, the content retrieval model can be trained using sample data so that the trained model can meet the expected content retrieval requirements, for example, the trained model can determine the retrieval result content that matches the retrieval content.
[0004] However, the current content retrieval model based on content features still needs to be improved. For example, as the training process progresses, there will be a large semantic deviation between the retrieval content features and the retrieval result content features, resulting in a decrease in retrieval accuracy. For example, when the difference between the retrieval content features and the retrieval result content features is large, the retrieval accuracy will also decrease accordingly.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a model training method, apparatus, computer device, and storage medium, which can improve model training for a content retrieval model and enhance the content retrieval accuracy of the content retrieval model.
[0007] The present invention provides a model training method, which is performed by a computer device and includes:
[0008] Obtaining sample search content and sample search result content matching the sample search content;
[0009] Performing feature extraction processing on the sample search content and the sample search result content through a content search model to obtain feature information of multiple different feature granularities, wherein the feature information includes search content features and search result content features;
[0010] Performing feature quantization processing on the search content features and the search result content features through the content retrieval model to obtain quantized feature information of each feature granularity;
[0011] Calculating the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information;
[0012] The content retrieval model is trained based on the retrieval semantic loss corresponding to each feature granularity.
[0013] Accordingly, an embodiment of the present application further provides a content retrieval method, which is executed by a computer device and includes:
[0014] Get the content to be retrieved;
[0015] Performing feature extraction processing on the content to be retrieved by using a content retrieval model to obtain multiple features of the content to be retrieved with different feature granularities;
[0016] Based on the features of the content to be retrieved at each of the feature granularities, calculating the similarity between the content to be retrieved and the candidate search result content at each of the feature granularities;
[0017] Based on the similarities corresponding to the feature granularities, the search result content corresponding to the content to be searched is determined.
[0018] Accordingly, an embodiment of the present application further provides a model training device, comprising:
[0019] A sample acquisition unit, configured to acquire sample search content and sample search result content matching the sample search content;
[0020] a feature extraction unit configured to perform feature extraction processing on the sample search content and the sample search result content through a content search model to obtain feature information of multiple different feature granularities, wherein the feature information includes search content features and search result content features;
[0021] A feature quantization unit, configured to perform feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity;
[0022] A loss calculation unit, configured to calculate the retrieval semantic loss corresponding to each of the feature granularities based on the feature information and the quantized feature information;
[0023] The model training unit is used to perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each of the feature granularities.
[0024] Accordingly, an embodiment of the present application further provides a content retrieval device, comprising:
[0025] A content acquisition unit, used to acquire content to be retrieved;
[0026] An extraction processing unit, configured to perform feature extraction processing on the content to be retrieved through a content retrieval model to obtain a plurality of features of the content to be retrieved at different feature granularities;
[0027] A similarity calculation unit, configured to calculate the similarity between the content to be retrieved and the candidate search result content at each feature granularity based on the features of the content to be retrieved at each feature granularity;
[0028] The result determination unit is configured to determine the search result content corresponding to the to-be-searched content based on the similarities corresponding to the respective feature granularities.
[0029] Correspondingly, an embodiment of the present application also provides a storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, the steps in the model training method or content retrieval method shown in the embodiment of the present application are implemented.
[0030] Correspondingly, an embodiment of the present application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the computer program, the steps in the model training method or content retrieval method shown in the embodiment of the present application are implemented.
[0031] Accordingly, embodiments of the present application further provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of the model training method or content retrieval method described in the embodiments of the present application.
[0032] The embodiments of the present application can obtain sample retrieval content and sample retrieval result content that matches the sample retrieval content; perform feature extraction processing on the sample retrieval content and the sample retrieval result content through a content retrieval model to obtain feature information of multiple different feature granularities, wherein the feature information includes retrieval content features and retrieval result content features; perform feature quantization processing on the retrieval content features and the retrieval result content features through a content retrieval model to obtain quantized feature information of each feature granularity; calculate the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information; and perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity.
[0033] This solution can combine the feature learning of content and the quantitative learning of features, so that the feature quantization module is added to the training of feature learning. In this way, the semantic loss of feature quantization can be added to the goal of model training optimization, so that the semantic information of the sample retrieval content and the sample retrieval result content can be better retained in the quantized features, avoiding the quantization loss caused by feature quantization when feature learning and feature quantization are performed independently, resulting in a large semantic deviation between the quantized content features of the sample retrieval content and the quantized content features of the sample retrieval result content. In addition, this solution also takes into account the case where there is a large difference between the retrieval content features and the retrieval result content features (for example, when the retrieval content features and the retrieval result content features correspond to different feature modalities), by extracting feature information of multiple different feature granularities, it is convenient to perform feature alignment according to multiple feature granularities in the future, thereby reducing the modal difference between content features and achieving better content retrieval effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] FIG1 is a schematic diagram of a scenario of a model training method provided in an embodiment of the present application;
[0035] FIG2 is a flow chart of a model training method provided in an embodiment of the present application;
[0036] FIG3 is a schematic diagram of the model architecture of the model training method provided in an embodiment of the present application;
[0037] FIG4 is another flow chart of the model training method provided in an embodiment of the present application;
[0038] FIG5 is another flow chart of the model training method provided in an embodiment of the present application;
[0039] FIG6 is a schematic diagram of another scenario of the model training method provided in an embodiment of the present application;
[0040] FIG7 is a flow chart of a content retrieval method according to an embodiment of the present application;
[0041] FIG8 is a schematic structural diagram of a model training device provided in an embodiment of the present application;
[0042] FIG9 is another structural diagram of the model training device provided in an embodiment of the present application;
[0043] FIG10 is another structural diagram of the model training device provided in an embodiment of the present application;
[0044] FIG11 is another structural diagram of the model training device provided in an embodiment of the present application;
[0045] FIG12 is another structural diagram of the model training device provided in an embodiment of the present application;
[0046] FIG13 is another structural diagram of the model training device provided in an embodiment of the present application;
[0047] FIG14 is another structural diagram of the model training device provided in an embodiment of the present application;
[0048] FIG15 is a schematic structural diagram of a content detection device provided in an embodiment of the present application;
[0049] FIG16 is another structural diagram of a content detection device provided in an embodiment of the present application;
[0050] FIG17 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0052] The embodiments of the present application provide a model training method, device, computer equipment and storage medium. Specifically, the method provided in the embodiments of the present application is applicable to a model training device in a first computer device, and to a content retrieval device in a second computer device. The first computer device may be a server or terminal device, and the second computer device may be a server or terminal device. Specifically, the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal may include but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0053] For example, the model training device can be deployed in a terminal or in a server; the content retrieval device can be deployed in a terminal or in a server.
[0054] In the embodiment of the present application, the first computer device is used as a server and the second computer device is used as a server as an example to introduce the model training method and the content retrieval method.
[0055] Referring to Figure 1, when executing the model training method, the server 10 can obtain sample retrieval content and sample retrieval result content that matches the sample retrieval content. Furthermore, the server 10 can perform feature extraction processing on the sample retrieval content and the sample retrieval result content through the content retrieval model to obtain feature information of multiple different feature granularities, wherein the feature information includes retrieval content features and retrieval result content features; perform feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity; calculate the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information; and perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity, thereby obtaining a trained content retrieval model.
[0056] As an example, in actual applications, the trained content retrieval model can be deployed on the server 10. The server 10 can obtain the content to be retrieved sent by the terminal 20, and determine the retrieval result content corresponding to the content to be retrieved through the trained content retrieval model, so that the terminal 20 can display the retrieval result content accordingly, thereby realizing the content retrieval function.
[0057] When executing the content retrieval method, server 10 can obtain the content to be retrieved. For example, terminal 20 can send the content to be retrieved to server 10. Furthermore, server 10 can perform feature extraction on the content to be retrieved using a trained content retrieval model to obtain features of the content to be retrieved at multiple different feature granularities. Based on the features of the content to be retrieved at each feature granularity, server 10 calculates the similarity between the content to be retrieved and the candidate search result content at each feature granularity. Based on the similarity at each feature granularity, server 10 determines the search result content corresponding to the content to be retrieved. In actual applications, server 10 can send the search result content corresponding to the content to be retrieved to terminal 20.
[0058] It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0059] The embodiment of the present application provides a model training method, which can be executed independently by a terminal or a server, or jointly by a terminal and a server. The embodiment of the present application takes the execution of the model training method by the server as an example for explanation. Specifically, the model training method is executed by a model training device integrated in the server, as shown in FIG2 . The specific process of the model training method can be as follows:
[0060] 101. Obtain sample search content and sample search result content matching the sample search content.
[0061] Sample search content refers to the sample data corresponding to the search content, and sample search result content refers to the sample data corresponding to the search result content. Content can include text, images, videos, audio, links, etc.; for example, content can be a combination of multiple types of content, such as page content or advertising content, which is a combination of text and images.
[0062] For example, content retrieval scenarios may include retrieving video content based on text content, retrieving image content based on text content, retrieving web page content based on text content, etc. As an example, in an application scenario of retrieving video content based on text content, the retrieval content is text content, and the video content that matches the text content is the retrieval result content that matches the retrieval content.
[0063] In this application, the content modalities corresponding to the sample search result content can be various, for example, it can include at least one of the content modalities of image, video, web page, audio, etc. Similarly, the content modalities corresponding to the sample search content can also be various.
[0064] Content modality refers to the modality of the content. Specifically, modality refers to the form in which data exists, such as text, audio, image, video, and other file formats. Some data exists in different forms but all describe the same object (such as the same thing or event). However, our information retrieval needs often extend beyond data in a single modality for the same object. We may also need data in other modalities to enrich our understanding of the same object. This is when cross-modal retrieval is needed to enable retrieval between data in different modalities.
[0065] In one embodiment, the sample search content and the sample search result content may correspond to different content modalities. In this way, the model training method described herein can be used to train a model for cross-modal content retrieval. For example, the content modality corresponding to the sample search content may be text, while the content modality corresponding to the sample search result content may be an image, video, web page, or other content modalities.
[0066] In the present application, there are various ways to obtain sample search content and sample search result content that matches the sample search content. For example, a server may receive sample data sent by a terminal or other server, where the sample data may specifically include sample search content and sample search result content that matches the sample search content. For another example, a server may store a sample data set, where the sample data set may include sample search content required for model training and sample search result content that matches the sample search content.
[0067] As an example, taking the content retrieval scenario as an example, specifically retrieval of video content based on text content, the server can obtain a set of training sample pairs, which may include at least one training sample pair, each training sample pair may include sample text content, and sample video content matching the sample text content. Specifically, each training sample pair may include a query text and a video matching the query text.
[0068] 102. Through the content retrieval model, feature extraction processing is performed on the sample retrieval content and the sample retrieval result content to obtain feature information of multiple different feature granularities, and the feature information includes retrieval content features and retrieval result content features.
[0069] Among them, the content retrieval model is a neural network model used to realize content retrieval. In this application, the content retrieval model can specifically be a model to be trained. Specifically, the content retrieval model can be trained based on sample retrieval content and sample retrieval result content, so that the trained content retrieval model can be put into practical application and used to retrieve retrieval result content that matches the retrieval content provided by the user.
[0070] As an example, a content retrieval model may include multiple functional modules, each of which may be used to implement different functions, and content retrieval may be achieved by combining multiple functional modules.
[0071] Feature extraction can start from an initial set of measurement data and establish derived values (features) that are intended to provide information and are non-redundant, thereby facilitating subsequent learning and generalization steps and, in some cases, leading to better interpretability. Feature extraction can be performed on content to obtain relevant features that characterize the content.
[0072] Feature granularity refers to the granularity used to describe features. Feature extraction can be performed on content to obtain relevant features that characterize the content. For example, feature granularity can be divided based on the content scope involved in feature extraction, and feature granularity can be divided into coarse-grained and fine-grained. When feature extraction is performed based on global content information, the extracted features can be determined as coarse-grained features; when feature extraction is performed based on local content information, the extracted features can be determined as fine-grained features.
[0073] As an example, the content to be feature extracted is text. When feature extraction is performed based on the global information of the text and a feature representing the global text is obtained, the feature can be determined as a coarse-grained feature, or a global feature; when feature extraction is performed based on the local information of the text (such as word segmentation in the text) and a feature representing the local part of the text is obtained, the feature can be determined as a fine-grained feature, or a local feature.
[0074] As another example, taking the content to be feature extracted as a video, when feature extraction is performed based on the global information of the video and a feature representing the global state of the video is obtained, the feature can be determined as a coarse-grained feature, or a global feature; when feature extraction is performed based on the local information of the video (such as information corresponding to different modes of the video) and a feature representing the local state of the video is obtained, the feature can be determined as a fine-grained feature, or a local feature.
[0075] The retrieval content features are features obtained by performing feature extraction processing on the sample retrieval content. In this application, feature extraction processing can be performed on the sample retrieval content through the content retrieval model to obtain retrieval content features of multiple different feature granularities for the sample retrieval content.
[0076] The retrieval result content features are features obtained by performing feature extraction processing on the sample retrieval result content. In this application, feature extraction processing can be performed on the sample retrieval result content through the content retrieval model to obtain retrieval result content features of multiple different feature granularities for the sample retrieval result content.
[0077] In one embodiment, taking coarse-grained content as an example, the content retrieval model performs feature extraction processing on the sample retrieval result content to obtain coarse-grained retrieval result content features of the sample retrieval result content. Specifically, the content retrieval model may include a feature extraction module corresponding to performing coarse-grained feature extraction on the sample retrieval result content, namely, a first coarse-grained feature extraction module. Specifically, the step of "performing feature extraction processing on the sample retrieval result content using the content retrieval model" may include:
[0078] Obtaining modal content features corresponding to at least one content modality of the sample retrieval result content;
[0079] Through the first coarse-grained feature extraction module, the modal content features are encoded based on the self-attention mechanism to obtain the encoded features corresponding to each content modality;
[0080] Feature aggregation processing is performed on the encoded features corresponding to each content modality to obtain coarse-grained retrieval result content features of the sample retrieval result content.
[0081] The modal content features corresponding to the sample retrieval result content in a certain content modality refer to features obtained by performing feature extraction processing on the data corresponding to the sample retrieval result content in the content modality.
[0082] As an example, the sample retrieval result content may be preprocessed to obtain modal content features corresponding to at least one content modality of the sample retrieval result content.
[0083] For example, taking the sample retrieval result content as a video, the video can be preprocessed to obtain modal content features corresponding to multiple content modalities of the video. For example, the features of 30 frames of images uniformly sampled from the video, the voice features of the video, the text features of the video transcribed based on optical character recognition (OCR), and the text features of the video transcribed based on automatic speech recognition technology (ASR), etc. can be obtained.
[0084] The first coarse-grained feature extraction module may be used to perform coarse-grained feature extraction processing on the sample retrieval result content to obtain coarse-grained retrieval result content features of the sample retrieval result content.
[0085] As an example, the modal content features corresponding to the sample retrieval result content in at least one content modality can be used as input data of the first coarse-grained feature extraction module, so that the first coarse-grained feature extraction module can generate coarse-grained retrieval result content features of the sample retrieval result content based on the modal content features corresponding to the sample retrieval result content in at least one content modality.
[0086] The attention mechanism mimics the internal process of biological observation, aligning internal experience with external sensations to increase the precision of observation in certain areas. The self-attention mechanism is an improvement on the attention mechanism, reducing its reliance on external information and better capturing the internal correlations of data or features.
[0087] Feature encoding is used to extract representational information from features by encoding them as input data. In this application, feature encoding can be performed on at least one modal content feature of the sample retrieval result content based on a self-attention mechanism, thereby further extracting representational information from each modal content feature. This representational information can be specifically expressed as encoded features obtained after feature encoding.
[0088] Among them, feature aggregation processing is used to aggregate multiple features to obtain a comprehensive representation of multiple features. There are many ways to implement feature aggregation processing, for example, it can be obtained by weighting the features. In the present application, feature aggregation processing can be performed on the encoded features corresponding to each content mode of the sample retrieval result content, and the features obtained after aggregation can be used as coarse-grained retrieval result content features of the sample retrieval result content. In this way, by combining the feature data corresponding to the sample retrieval result content in multiple content modes, the coarse-grained retrieval result content features that represent the global characteristics of the sample retrieval result content can be extracted.
[0089] As an example, the sample retrieval result content can be taken as a video, and the first coarse-grained feature extraction module can be a functional module implemented based on the encoder in the Transformer model. Referring to Figure 3, the multimodal video features obtained by pre-processing the video can be obtained. For example, the image features of 30 frames uniformly sampled from the video, the speech features of the video, and the text features of the video transcribed based on OCR and ASR are collected, and a special identifier (for example, it can be recorded as "[AGG]") for modal information aggregation is inserted at the end of the feature sequence of each content modality. Embedding vectors are combined into a sequence of feature embedding vectors. For each of these features, a position encoding vector and a modal tag vector can be added, and then input into a 4-layer Transformer model for encoding, wherein the position encoding vector can be used to capture the temporal information, position information, etc. corresponding to the feature.
[0090] In this example, the first coarse-grained feature extraction module can further generate a vector corresponding to the "[AGG]" identifier. And the output corresponding to each modal content feature Among them, E refers to the number of content modes of the sample retrieval result content, for example, in this example, the number of content modes corresponding to the video is 3 (picture, voice, and text); N refers to the number of modal content features, for example, in this example, the number of modal content features corresponding to the video is 33 (30 picture features, 1 voice feature, and 2 text features); v is used as a distinguishing mark corresponding to the video (English: video). Among them, the feature vector in this example is That is, the encoded features corresponding to each content mode of the video.
[0091] In this example, the first coarse-grained feature extraction module can further perform feature aggregation processing on the encoded features corresponding to each content modality, for example, the feature vector corresponding to the "[AGG]" identifier Perform feature averaging: Thus, the global representation feature v of the video is obtained Coarse , that is, the coarse-grained content features of the retrieval results.
[0092] In one embodiment, taking coarse-grained content as an example, the content retrieval model performs feature extraction processing on sample retrieval content to obtain coarse-grained retrieval content features of the sample retrieval content. Specifically, the content retrieval model may include a feature extraction module corresponding to the coarse-grained feature extraction of the sample retrieval content, i.e., a second coarse-grained feature extraction module. Specifically, the step of "performing feature extraction processing on the sample retrieval content using the content retrieval model" may include:
[0093] Extracting semantic representation features of sample retrieval content through a second coarse-grained feature extraction module;
[0094] Based on the self-attention mechanism, feature projection processing is performed on the semantic representation features to obtain the coarse-grained retrieval content features of the sample retrieval content.
[0095] The semantic representation features of the sample retrieval content refer to features of the semantic representation extracted from the sample retrieval content.
[0096] The second coarse-grained feature extraction module may be used to perform coarse-grained feature extraction processing on the sample search content to obtain coarse-grained search content features of the sample search content.
[0097] As an example, the sample search content may be used as input data of the second coarse-grained feature extraction module, so as to generate coarse-grained search content features of the sample search content through the second coarse-grained feature extraction module.
[0098] Among them, feature projection processing is a type of feature extraction. Feature projection can convert feature data in a high-dimensional space into data in a low-dimensional space, wherein the data conversion can be linear or nonlinear. In this application, feature projection processing can be performed on the semantic representation features of the sample retrieval content based on the self-attention mechanism, and then the data in the high-dimensional space during the processing of the semantic representation features is converted into data in a low-dimensional space, thereby obtaining the coarse-grained retrieval content features of the sample retrieval content.
[0099] As an example, taking the sample retrieval content as text as an example, the second coarse-grained feature extraction module can be a functional module implemented based on the encoder in the Transformer model. Specifically, the second coarse-grained feature extraction module can be composed of a bidirectional encoder representation model based on transformers (Bidirectional Encoder Representation from Transformers, BERT) and a self-attention projection module, wherein the BERT model is a text Transformer pre-training model, and the self-attention projection module can be used to implement feature projection processing based on the self-attention mechanism.
[0100] In this example, see Figure 3, the query text can be input into the second coarse-grained feature extraction module. Specifically, the special identifier "[CLS]" can be concatenated at the head of the text, and the concatenated text is recorded as T. T can be input into a pre-trained BERT model to obtain the feature vector embedding corresponding to the special identifier "[CLS]". And the word vector sequence of the word segmentation contained in the text Among them, N refers to the number of word segments in the text, and t is used as the distinguishing mark corresponding to the text (English: text). Among them, the feature vector in this example is That is the semantic representation feature of the query text.
[0101] In this example, the second coarse-grained feature extraction module can further perform feature projection processing on the semantic representation feature based on the self-attention mechanism to obtain the coarse-grained retrieval content feature of the sample retrieval content. Specifically, the second coarse-grained feature extraction module can be composed of a Bert model and a number of linear projection layers (it can be assumed that the number of linear projection layers is k, where k is a positive integer). After obtaining the semantic representation feature extracted by the Bert model, the self-attention projection module can further perform weighted summation on the outputs of the k linear projection layers, and use the weighted summation result as the global representation feature of the query text, that is, the coarse-grained retrieval content feature, where the weighted score is calculated based on the self-attention mechanism. Specifically, the coarse-grained retrieval content feature t of the query text Coarse , which can be represented by the semantic features of the query text It is obtained through self-attention projection, that is where φ k represents the kth linear projection layer, weighted score Among them, a k refers to the weight of the output of the k-th linear projection layer in the summation, is the model parameter to be trained, and exp() is the exponential function.
[0102] In one embodiment, taking fine-grained content as an example, the content retrieval model may include a fine-grained feature extraction module. This fine-grained feature extraction module can be used to perform fine-grained feature extraction on sample retrieval content to obtain fine-grained retrieval content features of the sample retrieval content. Furthermore, this fine-grained feature extraction module can also be used to perform fine-grained feature extraction on sample retrieval result content to obtain fine-grained retrieval result content features of the sample retrieval result content. That is, the content retrieval model may include a fine-grained feature extraction module shared by the sample retrieval content and the sample retrieval result content. Specifically, the step of "performing feature extraction processing on the sample retrieval content and the sample retrieval result content through the content retrieval model to obtain feature information of multiple different feature granularities" may include:
[0103] Obtaining multiple content features to be clustered of the sample search content and the sample search result content;
[0104] Through the fine-grained feature extraction module, feature clustering processing is performed on the content features to be clustered;
[0105] Based on the clustering results of the feature clustering process, a plurality of feature information of different fine-grained levels is determined, where the feature information includes retrieval content features and retrieval result content features.
[0106] Among them, the fine-grained feature extraction module can be used to extract fine-grained features of the content. In this application, the fine-grained feature extraction module can be shared by the sample retrieval content side and the sample retrieval result content side, that is, the fine-grained feature extraction module can be used to perform fine-grained feature extraction on the sample retrieval content to obtain the fine-grained retrieval content features of the sample retrieval content, and the fine-grained feature extraction module can also be used to perform fine-grained feature extraction on the sample retrieval result content to obtain the fine-grained retrieval result content features of the sample retrieval result content.
[0107] There are many ways for the fine-grained feature extraction module to implement fine-grained feature extraction. For example, it can be implemented based on a clustering processing mechanism, where clustering refers to the process of dividing a collection of physical or abstract objects into multiple classes consisting of similar objects.
[0108] Taking the sample retrieval content as an example, multiple content features to be clustered of the sample retrieval content can be obtained, and the fine-grained feature extraction module can be used to perform feature clustering processing on the content features to be clustered; based on the clustering results, multiple different fine-grained retrieval content features of the sample retrieval content can be determined. Taking the sample retrieval result content as an example, multiple content features to be clustered of the sample retrieval result content can be obtained similarly, and the fine-grained feature extraction module can be used to perform feature clustering processing on the content features to be clustered; based on the clustering results, multiple different fine-grained retrieval result content features of the sample retrieval result content can be determined.
[0109] Among them, feature clustering processing refers to the process of clustering the features of the clustered content. There are many ways to implement feature clustering processing. For example, it can be implemented using a clustering algorithm with parameters. The parameter-containing here means that, unlike the common K-means clustering algorithm (k-means clustering algorithm, kmeans), this clustering algorithm has trainable model parameters (such as cluster centers).
[0110] As an example, we can take the fine-grained feature extraction module to extract fine-grained features from the sample search content to obtain the fine-grained search content features of the sample search content, and the sample search content is specifically a query text. Then, we can obtain multiple content features to be clustered of the sample search content. For example, we can use the word vector sequence of the word contained in the query text obtained in the process of feature extraction of the query text by the second coarse-grained feature extraction module. As the content features to be clustered of the query text.
[0111] In this example, when performing feature clustering processing on the cluster content features through the fine-grained feature extraction module, a cluster with L+1 cluster centers c0, c1, ..., c L The semantic space of , further, we can calculate the proportion coefficient of each content feature to be clustered that should be assigned to each cluster center, that is, calculate the proportion coefficient of each vector in the word vector sequence that should be assigned to each cluster center. For example, the proportion coefficient assigned to the lth cluster center can be recorded as And can be set In this way, we can calculate To determine the i-th word segmentation vector of the query text Belongs to the lth cluster center c l and use the probability as the corresponding weight score.
[0112] Taking text-based video retrieval as an example, since the fine-grained feature extraction module is shared by both the text and video sides, each cluster center can represent a semantic concept, such as "sports," "education," or "entertainment." Since the entire semantic space is composed of these cluster centers, by clustering the content features to be clustered from the video and text sides within this semantic space, it is possible to extract, through training, representations of different "semantic concepts" for a query text (or video).
[0113] In this example, after calculating all the word segmentation vectors in the word vector sequence and assigning them to the cluster centers, the fine-grained feature extraction module can further determine multiple different fine-grained retrieval content features of the sample retrieval content based on the clustering results. For example, the fine-grained feature extraction module can determine the sum of the residuals collected by each cluster center, and then determine multiple different fine-grained fine-grained features of the query text, that is, multiple different fine-grained retrieval content features of the sample retrieval content. Specifically, taking the lth cluster center c l For example, the sum of the collected residuals can be recorded as And can be set In this way, according to The calculation results of , determine the multiple fine-grained features of the query text, that is, Determined as the lth fine-grained representation on the text side.
[0114] Taking the retrieval of video content based on text content as an example, is the eigenvector representing the sum of the residuals, so it can be obtained by To represent a query text about a semantic concept (represented by the cluster center). Through training, the content retrieval model will learn to use this residual to preserve semantic information. In addition, since each The information extracted is a single semantic concept, not the overall semantic information, so it can be Determined as a fine-grained representation, that is, the sample retrieval content is a fine-grained retrieval content feature.
[0115] In addition, in practical applications, in order to avoid the decrease in accuracy caused by noise interference, when the fine-grained feature extraction module implements fine-grained privilege extraction, cluster 0 can be designated as the noise collection cluster. Its function is to aggregate some non-semantic noise information in the sequence, such as definite articles in text, background information in video, etc. The sum of the residuals generated by this cluster will be discarded. In this way, the output of the fine-grained representation extraction module is L fine-grained features, that is,
[0116] Taking the retrieval of video content based on text content as an example, during the training process, it can be set to always discard the information of cluster 0, and only use clusters 1 to L to align text and video. In this way, through the backpropagation step during the model training process, the content retrieval model can learn to classify noise information into cluster 0 and collect useful semantic information using clusters 1 to L.
[0117] In this application, since the fine-grained feature extraction module can be shared by the sample retrieval content side and the sample retrieval result content side, and the fine-grained feature extraction module can specifically determine multiple different fine-grained feature information by performing feature clustering processing on the content features to be clustered, please refer to the above for details. Therefore, the following can explain how to obtain multiple content features to be clustered of the sample retrieval result content and how to obtain multiple content features to be clustered of the sample retrieval content.
[0118] In one embodiment, content features to be clustered of the sample retrieval result content may be determined based on modal content features corresponding to different content modalities of the sample retrieval result content. Specifically, the step of "obtaining multiple content features to be clustered of the sample retrieval result content" may include:
[0119] determining at least one content modality of the sample search result content;
[0120] Extracting modal content features corresponding to the sample retrieval result content and content modality;
[0121] According to the modal content features, multiple content features to be clustered of the sample retrieval result content are determined.
[0122] For example, if the sample search result content is a video, the content modalities of the sample search result content may include images, text, audio, etc. Correspondingly, image features corresponding to several frames in the video can be extracted, voice features corresponding to the video can be extracted, and text features corresponding to the video can be extracted based on methods such as OCR or ASR.
[0123] For example, the sample retrieval result content may be preprocessed to obtain modal content features corresponding to at least one content modality of the sample retrieval result content.
[0124] There are many ways to determine multiple content features to be clustered of the sample retrieval result content based on the modal content features. For example, the modal content features can be feature encoded based on the self-attention mechanism, and multiple content features to be clustered of the sample retrieval result content can be selected from the obtained encoded features.
[0125] For example, considering that the process of coarse-grained feature extraction for the sample retrieval result content by the first coarse-grained feature extraction module includes the step of feature encoding processing of the modal content features based on the self-attention mechanism, therefore, multiple content features to be clustered of the sample retrieval result content can be selected from the encoded features obtained by the first coarse-grained feature extraction module through feature encoding processing of the modal content features based on the self-attention mechanism.
[0126] As an example, the sample retrieval result content can be specifically a video. The first coarse-grained feature extraction module can perform feature encoding processing on the modal content features based on the self-attention mechanism and generate a vector corresponding to the "[AGG]" identifier. And the output corresponding to each modal content feature in, The encoded features corresponding to each content modality are specifically used to generate coarse-grained retrieval result content features of the sample retrieval result content, and the output corresponding to each modality content feature is These can be used as multiple content features to be clustered for the sample retrieval result content.
[0127] In one embodiment, content features to be clustered of the sample search content may be determined based on sub-content features corresponding to different sub-contents in the sample search content. Specifically, the step of "obtaining multiple content features to be clustered of the sample search content" may include:
[0128] Performing content division processing on the sample search content to obtain at least one sub-content of the sample search content;
[0129] Extracting sub-content features corresponding to the sub-content;
[0130] According to the sub-content features, multiple content features to be clustered of the sample retrieval content are determined.
[0131] Content segmentation refers to the process of segmenting content to generate smaller sub-content. For example, if the sample search content is text, word segmentation can be performed on the text to generate word segments with a smaller granularity than the text. If the sample search content is an image, image segmentation can be performed on the image to generate smaller partial images with a smaller granularity than the image itself.
[0132] The sub-content feature corresponding to the sub-content may be obtained by performing feature extraction processing on the sub-content. For example, the sub-content feature may specifically be a semantic representation feature corresponding to the sub-content.
[0133] For example, considering that the process of coarse-grained feature extraction for sample retrieval content in the second coarse-grained feature extraction module includes the step of extracting semantic representation features of the sample retrieval content, multiple content features to be clustered of the sample retrieval content can be selected from the semantic representation features of the sample retrieval content extracted by the second coarse-grained feature extraction module.
[0134] As an example, the sample search content can be specifically text. The second coarse-grained feature extraction module can extract the semantic representation features of the sample search content, including the feature vector embedding corresponding to the special identifier "[CLS]" And the word vector sequence of the word segmentation contained in the text in, is the coarse-grained semantic representation feature of the query text, and the word vector sequence of the word segmentation is the fine-grained semantic representation feature of the query text, so the fine-grained semantic representation feature of the query text can be Multiple content features to be clustered as sample retrieval content.
[0135] 103. Through the content retrieval model, the retrieval content features and the retrieval result content features are quantized to obtain quantized feature information of each feature granularity.
[0136] Among them, feature quantization processing is a processing method for encoding features, which aims to simplify and compress the features by encoding, and generate quantized features of the features to ensure that the quantized features can maintain the representation ability of the features to the greatest extent.
[0137] In the present application, similar to the feature information specifically including the search content feature and the search result content feature, the quantized feature information specifically includes the quantized search content feature and the quantized search result content feature.
[0138] In the present application, after performing feature extraction processing on the sample retrieval content through the content retrieval model, multiple retrieval content features of different feature granularities of the sample retrieval content can be obtained. For example, at least one coarse-grained retrieval content feature and at least one fine-grained retrieval content feature of the sample retrieval content can be obtained. Similarly, after performing feature extraction processing on the sample retrieval result content through the content retrieval model, multiple retrieval result content features of different feature granularities of the sample retrieval result content can be obtained. For example, at least one coarse-grained retrieval result content feature and at least one fine-grained retrieval result content feature of the sample retrieval result content can be obtained.
[0139] In order to be able to perform feature quantization processing on at least one coarse-grained retrieval content feature and at least one fine-grained retrieval content feature of the sample retrieval content, as well as at least one coarse-grained retrieval result content feature and at least one fine-grained retrieval result content feature of the sample retrieval result content, this can be achieved by setting up multiple independent feature quantization modules.
[0140] For example, referring to FIG3 , after step 102, a coarse-grained retrieval content feature of the sample retrieval content and a coarse-grained retrieval result content feature of the sample retrieval result content are extracted as an example, then a feature quantization module shared by the sample retrieval content and the sample retrieval result content can be set up for quantifying the coarse-grained feature. In addition, considering that when the content retrieval model performs fine-grained feature extraction, the fine-grained feature extraction module shared by the sample retrieval content and the sample retrieval result content can be used to extract fine-grained features from the sample retrieval content and the sample retrieval result content, so that the sample retrieval content and the sample retrieval result content can have the same number of fine-grained features (which can be assumed to be L, where L can be an integer greater than or equal to 1), referring to FIG3 , L feature quantization modules shared by the sample retrieval content and the sample retrieval result content can be set up for quantifying the fine-grained features.
[0141] In this way, the content retrieval model can specifically include L+1 independent feature quantization modules, which are used to compress coarse-grained features and L fine-grained features respectively, wherein the feature quantization modules at each level are shared by the sample retrieval content and the sample retrieval result content. In particular, when the sample retrieval content and the sample retrieval result content correspond to different content modalities, the feature quantization modules at each level are shared across modalities by the sample retrieval content and the sample retrieval result content.
[0142] In one embodiment, considering that the content retrieval model may include feature quantization modules corresponding to respective feature granularities, each feature quantization module may be used to perform feature quantization processing on feature information of the feature granularity corresponding to it. Therefore, taking the feature quantization processing of the retrieval content features on the sample retrieval content side by the feature quantization module as an example, specifically, the step of "performing feature quantization processing on the retrieval content features by the content retrieval model" may include:
[0143] For each feature granularity, the feature quantization module corresponding to the feature granularity is used to perform feature division processing on the search content feature corresponding to the feature granularity to obtain the divided sub-search content feature corresponding to the feature granularity;
[0144] Performing feature quantization processing on the divided sub-search content features corresponding to the feature granularity to obtain quantized sub-search content features corresponding to the feature granularity;
[0145] The quantized sub-search content features corresponding to each feature granularity are subjected to feature fusion processing to obtain the quantized search content features of each feature granularity.
[0146] Feature partitioning refers to the process of dividing a feature into smaller sub-features. For example, a D-dimensional feature can be partitioned into M sub-features, each of which has D / M dimensions, where D and M are both positive integers. For example, a 128-dimensional feature can be partitioned into 8 sub-features, each of which has 16 dimensions. Therefore, by performing feature partitioning on a search content feature, the partitioned sub-search content features can be obtained.
[0147] As an example, we can take the feature quantization processing of the coarse-grained retrieval content features of the sample retrieval content as an example. Specifically, the sample retrieval content can be text, and the coarse-grained retrieval content features of the sample retrieval content are t Coarse , t Coarse The dimension of is D, and satisfies D = Md. Then the coarse-grained retrieval content feature t on the text side can be Coarse The sub-search content is evenly divided into M segments according to the dimension, and the sub-search content features after each division are d dimensions.
[0148] Furthermore, in order to perform feature quantization processing on the sub-search content features after division through the feature quantization module, the feature quantization module may be configured to specifically include M codebooks C 1 ,C 2 ,…,C M , where each codebook can contain K d-dimensional codeword vectors, such as C m Include
[0149] When the feature quantization module performs feature quantization on the sub-search content features after division, the feature quantization module can be used to quantify the sub-search content features after division. Using C m Perform feature quantization to obtain quantified sub-search content features Specifically, you can set The weight coefficient The weight coefficient represents the classification probability, that is, the sub-search content characteristics after the mth division Use codebook C m The kth codeword vector in Represents the probability.
[0150] Feature fusion refers to the process of fusing multiple features to obtain a fused feature. Feature fusion can be implemented in a variety of ways, such as through feature concatenation (concat) or feature addition (add).
[0151] In this application, feature fusion processing can be performed on the quantized sub-search content features corresponding to the feature granularity, and the fused features can be used as the quantized search content features of the feature granularity. For example, in the above example, feature fusion can be achieved by splicing M quantized sub-search content features together, and the spliced features can be used as the quantized search content features of the feature granularity. As a coarse-grained quantized retrieval content feature, Among them, concatenate() represents feature concatenation processing.
[0152] In one embodiment, when the feature quantization module performs feature quantization processing on the content features of the sample retrieval results, the implementation method can refer to the above explanation of the step "performing feature quantization processing on the retrieval content features using the content retrieval model" using the example of performing feature quantization processing on the retrieval content features of the sample retrieval results using the feature quantization module. That is, the step "performing feature quantization processing on the content features of the retrieval results using the content retrieval model" can include:
[0153] For each feature granularity, feature division processing is performed on the retrieval result content features corresponding to the feature granularity through the feature quantization module corresponding to the feature granularity to obtain the divided sub-retrieval result content features corresponding to the feature granularity; feature quantization processing is performed on the divided sub-retrieval result content features corresponding to the feature granularity to obtain the quantized sub-retrieval result content features corresponding to the feature granularity; feature fusion processing is performed on the quantized sub-retrieval result content features corresponding to the feature granularity to obtain the quantized retrieval result content features of the feature granularity.
[0154] 104. Based on the feature information and the quantized feature information, calculate the retrieval semantic loss corresponding to each feature granularity.
[0155] Retrieval semantic loss refers to the model training loss used when training the content retrieval model. Specifically, because the content retrieval model can be implemented based on features that represent semantics during the content retrieval process, the model training loss during the content retrieval model training process can be called retrieval semantic loss.
[0156] There are many ways to calculate retrieval semantic loss. For example, contrastive learning can be used to calculate retrieval semantic loss. For example, metric learning can be used to calculate retrieval semantic loss, and so on.
[0157] The feature information may include retrieval content features of the sample retrieval content at different feature granularities, and retrieval result content features of the sample retrieval result content at different feature granularities. For example, the retrieval content features of the sample retrieval content at different feature granularities may specifically include coarse-grained retrieval content features of the sample retrieval content and multiple fine-grained retrieval content features of the sample retrieval content; similarly, the retrieval result content features of the sample retrieval result content at different feature granularities may specifically include coarse-grained retrieval content features of the sample retrieval result content and multiple fine-grained retrieval content features of the sample retrieval result content.
[0158] The quantized feature information may include quantized retrieval content features of different feature granularities of the sample retrieval content, and quantized retrieval result content features of different feature granularities of the sample retrieval result content. For example, the quantized retrieval content features of different feature granularities of the sample retrieval content may specifically include the coarse-grained quantized retrieval content features of the sample retrieval content, and multiple fine-grained quantized retrieval content features of the sample retrieval content; similarly, the quantized retrieval result content features of different feature granularities of the sample retrieval result content may specifically include the coarse-grained quantized retrieval result content features of the sample retrieval result content, and multiple fine-grained quantized retrieval result content features of the sample retrieval result content.
[0159] In the present application, when calculating the retrieval semantic loss of the content retrieval model, although the content retrieval model is specifically used to retrieve the sample retrieval result content matched based on the sample retrieval content, considering that the content retrieval model specifically performs feature analysis on the sample retrieval content side and the sample retrieval result content side, therefore, when calculating the retrieval semantic loss of the content retrieval model, the first semantic retrieval direction representing the semantic retrieval from the sample retrieval content to the sample retrieval result content and the second semantic retrieval direction representing the semantic retrieval from the sample retrieval result content to the sample retrieval content can be taken into account, and the semantic retrieval loss of the content retrieval model can be determined based on the first retrieval semantic loss corresponding to the first semantic retrieval direction and the second retrieval semantic loss corresponding to the second semantic retrieval direction. In this way, the limited sample data can be fully utilized to improve the semantic retrieval accuracy of the content retrieval model through two-way semantic retrieval training. Specifically, the step of "calculating the retrieval semantic loss corresponding to each feature granularity based on feature information and quantized feature information" can include:
[0160] Based on the feature information and the quantized feature information, calculating the first retrieval semantic loss of each feature granularity in the first semantic retrieval direction, and the second retrieval semantic loss of each feature granularity in the second semantic retrieval direction;
[0161] Perform loss aggregation processing on the first retrieval semantic loss and the second retrieval semantic loss;
[0162] According to the processing results of the loss aggregation process, the retrieval semantic loss corresponding to each feature granularity is determined.
[0163] Among them, the first semantic retrieval direction represents the direction of semantic retrieval from the sample retrieval content to the sample retrieval result content. Correspondingly, the retrieval semantic loss calculated based on the first semantic retrieval direction can be called the first retrieval semantic loss.
[0164] Among them, the second semantic retrieval direction represents the direction of semantic retrieval from the sample retrieval result content to the sample retrieval content. Correspondingly, the retrieval semantic loss calculated based on the second semantic retrieval direction can be called the second retrieval semantic loss.
[0165] As an example, we can take the retrieval of video content based on text content, that is, the sample retrieval content is specifically text, the sample retrieval result content is specifically video, and the feature granularity is specifically coarse-grained, and contrastive learning is used to calculate the retrieval semantic loss. The retrieval semantic loss from the text side to the video side can be recorded as That is, the first retrieval semantic loss, the retrieval semantic loss from the video side to the text side can be recorded as That is, the second retrieval semantic loss.
[0166] The loss aggregation processing of the first retrieval semantic loss and the second retrieval semantic loss refers to a method for performing data aggregation on the calculated first retrieval semantic loss and the second retrieval semantic loss. Specifically, the data aggregation method may include calculating the mean, summing, taking the maximum value, etc. For example, the first retrieval semantic loss corresponding to the coarse granularity can be calculated by calculating the mean. With the second retrieval semantic loss Perform loss aggregation processing to obtain the coarse-grained retrieval semantic loss L Coarse ,Right now
[0167] In one embodiment, the first semantic search direction may be taken as an example to illustrate the calculation of the first search semantic loss of each feature granularity in the first semantic search direction based on the feature information and the quantized feature information. Specifically, the step of “calculating the first search semantic loss of each feature granularity in the first semantic search direction based on the feature information and the quantized feature information” may include:
[0168] According to the first semantic retrieval direction, a target feature is determined from the feature information, and a target quantized feature is determined from the quantized feature information, wherein the target feature and the target quantized feature correspond to different feature modes;
[0169] According to the feature granularity, the target features and the target quantized features are aligned;
[0170] Based on the feature similarity between the aligned target features and the aligned target quantized features, the first retrieval semantic loss of each feature granularity in the first semantic retrieval direction is calculated.
[0171] When calculating the first search semantic loss in the first semantic search direction, the search content features of the sample search content in the feature information can be used as target features, and the quantized search result content features of the sample search result content in the quantized feature information can be used as target quantized features. In particular, when the sample search content and the sample search result content correspond to different content modalities, the target feature and the target quantized feature can be considered to also correspond to different feature modalities.
[0172] Specifically, for the sake of ease of explanation and understanding, we can take the feature granularity as coarse granularity as an example. In the example of retrieving video content based on text content, that is, the sample retrieval content is specifically text, and the sample retrieval result content is specifically video, the coarse granularity retrieval content feature of the i-th sample text can be recorded as t Coarse,i , that is, the target feature, and the coarse-grained quantized retrieval result content feature of the i-th sample video is recorded as That is, the target quantized feature. Coarse,i and are all coarse-grained content features, so it can be considered that t Coarse,i is the target feature after alignment, and That is the target quantitative feature after alignment.
[0173] The aligned target feature t Coarse,i Quantized features after alignment with the target The feature similarity between There are many ways to calculate feature similarity, for example, it can be calculated by cosine similarity. Here, cos(·) represents the cosine similarity between vectors.
[0174] Furthermore, based on the aligned target feature t Coarse,i Quantized features after alignment with the target The feature similarity between Calculate the coarse-grained first retrieval semantic loss in the first semantic retrieval direction For example, the first retrieval semantic loss can be calculated by contrastive learning, and then where τ>0 is the temperature hyperparameter in contrastive learning, It represents the coarse-grained retrieval content feature t of the i-th sample text Coarse,i , and the coarse-grained quantized retrieval result content features of the j-th sample video The feature similarity between .
[0175] Similarly, the step of "calculating the second retrieval semantic loss corresponding to each feature granularity in the second semantic retrieval direction based on the feature information and the quantized feature information" may include: determining the target feature from the feature information according to the second semantic retrieval direction, and determining the target quantized feature from the quantized feature information, the target feature and the target quantized feature corresponding to different feature modes; performing feature alignment processing on the target feature and the target quantized feature according to the feature granularity; and calculating the second retrieval semantic loss of each feature granularity in the second semantic retrieval direction based on the feature similarity between the aligned target feature and the aligned target quantized feature.
[0176] When calculating the second retrieval semantic loss corresponding to the second semantic retrieval direction, the retrieval result content feature of the sample retrieval result content in the feature information can be used as the target feature, and the quantized retrieval content feature of the sample retrieval content in the quantized feature information can be used as the target quantized feature. In particular, when the sample retrieval content and the sample retrieval result content correspond to different content modalities, the target feature and the target quantized feature can be considered to also correspond to different feature modalities.
[0177] Similarly, we can take the example of a coarse-grained feature granularity. In the example of retrieving video content based on text content, that is, the sample retrieval content is specifically text, and the sample retrieval result content is specifically video, the coarse-grained retrieval result content feature of the i-th sample video can be recorded as v Coarse,i , that is, the target feature, and the coarse-grained quantized retrieval content feature of the i-th sample text is recorded as That is, the target quantized feature. Coarse,i and are all coarse-grained content features, so it can be considered that v Coarse,i is the target feature after alignment, and That is the target quantitative feature after alignment.
[0178] Similarly, the aligned target feature v Coarse,i Quantized features after alignment with the target The feature similarity between There are many ways to calculate feature similarity, for example, it can be calculated by cosine similarity. Here, cos(·) represents the cosine similarity between vectors.
[0179] Furthermore, based on the aligned target feature v Coarse,i Quantized features after alignment with the target The feature similarity between Calculate the second retrieval semantic loss corresponding to the coarse-grained second semantic retrieval For example, the second retrieval semantic loss can be calculated by contrastive learning, then we can have where τ>0 is the temperature hyperparameter in contrastive learning, It represents the coarse-grained retrieval result content feature v of the i-th sample video Coarse,i , and the coarse-grained quantized retrieval content features of the j-th sample text The feature similarity between .
[0180] It is worth noting that the above description is based on the example of coarse-grained feature granularity. The cross-modal alignment of features at the fine-grained level, the calculation of the first retrieval semantic loss in the first semantic retrieval direction, and the calculation of the second retrieval semantic loss in the second semantic retrieval direction are similar to those at the coarse-grained level. Please refer to the above for details.
[0181] Specifically, since the fine-grained feature extraction module in this application is shared by the sample retrieval content and the sample retrieval result content, the fine-grained feature extraction module can be used to extract retrieval content feature 1 corresponding to fine granularity 1, retrieval content feature 2 corresponding to fine granularity 2, ..., and retrieval content feature L corresponding to fine granularity L of the sample retrieval content; and to extract retrieval result content feature 1 corresponding to fine granularity 1, retrieval result content feature 2 corresponding to fine granularity 2, ..., and retrieval result content feature L corresponding to fine granularity L of the sample retrieval result content. Therefore, feature alignment processing can be performed on the retrieval content features and the retrieval result content features based on feature granularity. Specifically, retrieval content feature 1 can be aligned with retrieval result content feature 1, retrieval content feature 2 can be aligned with retrieval result content feature 2, ..., and retrieval content feature L can be aligned with retrieval result content feature L.
[0182] That is, referring to the method in the previous example, the retrieval semantic loss based on contrastive learning can be calculated from L fine-grained levels (L is a positive integer), and the retrieval semantic loss corresponding to each fine-grained level can be obtained and recorded as L Fine(1) ,L Fine(2) ,…,L Fine(L) ,in, and is the first retrieval semantic loss of the fine-grained l in the first semantic retrieval direction, Fine-grained second retrieval semantic loss in the second semantic retrieval direction.
[0183] 105. Based on the retrieval semantic loss corresponding to each feature granularity, the content retrieval model is trained.
[0184] Since this application performs feature extraction and feature quantification on sample retrieval content and sample retrieval result content from multiple different feature granularities, and then obtains the retrieval semantic loss corresponding to each feature granularity, therefore, in order to be able to combine the semantic representations extracted from multiple different feature granularities and take into account the retrieval semantic losses corresponding to multiple different feature granularities, the final retrieval semantic loss required for model training of the content retrieval model can be determined based on the retrieval semantic loss corresponding to each feature granularity, and then the content retrieval model can be trained according to the determined retrieval semantic loss.
[0185] For example, content retrieval models can be trained based on the backpropagation (BP) algorithm. The BP algorithm is a learning algorithm suitable for multi-layer neural networks, based on the gradient descent method. The input-output relationship of a BP network is essentially a mapping relationship: a BP neural network with n inputs and m outputs performs a continuous mapping from n-dimensional Euclidean space to a finite field in m-dimensional Euclidean space. This mapping is highly nonlinear. Its information processing capabilities derive from the multiple compounding of simple nonlinear functions, resulting in strong function reproduction capabilities.
[0186] In one embodiment, the granularity type of the feature granularity may include coarse granularity and fine granularity. For example, in the aforementioned example, it includes 1 coarse granularity and L fine granularities (e.g., fine granularity 1, fine granularity 2, ..., fine granularity L), a total of L+1 feature granularities, to perform feature extraction, feature quantification, etc. on the sample retrieval content and the sample retrieval result content. Moreover, since coarse granularity can consider content from a global perspective, and different fine granularities can consider content from different local perspectives, the granularity type of the feature granularity can be taken into consideration when determining the final retrieval semantic loss required for model training based on the retrieval semantic loss corresponding to each feature granularity. Specifically, the step of "training the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity" may include:
[0187] According to the granularity type of the feature granularity, the retrieval semantic loss corresponding to each feature granularity is aggregated;
[0188] The content retrieval model is trained based on the aggregated retrieval semantic loss.
[0189] For example, the granularity types of the feature granularity may include a coarse granularity type and a fine granularity type. For example, in the aforementioned example of dividing the feature granularity into 1 coarse granularity and L fine granularities, it can be considered that it specifically includes 1 coarse granularity type feature granularity and L fine granularity types.
[0190] Among them, loss aggregation processing refers to a processing method for data aggregation of related retrieval semantic losses. Specifically, data aggregation methods can include calculating the mean, summing, taking the maximum value, etc.
[0191] For example, based on the granularity type of the feature granularity, the retrieval semantic loss corresponding to each feature granularity can be aggregated to obtain the aggregated retrieval semantic loss corresponding to each granularity type. As an example, the feature granularity can include L fine-grained types of feature granularity, that is, L fine granularities. Then, the retrieval semantic loss corresponding to the L fine granularities can be aggregated, such as calculating the mean of the retrieval semantic loss corresponding to the L fine granularities: This results in the aggregated retrieval semantic loss corresponding to the fine-grained type.
[0192] Furthermore, the final retrieval semantic loss required for model training of the content retrieval model can be determined based on the aggregated retrieval semantic loss corresponding to each granularity type. For example, it can be calculated by summing, weighted calculation, etc. As an example, in the example of dividing the feature granularity into 1 coarse granularity and L fine granularities, the retrieval semantic loss corresponding to the coarse granularity type L can be used to calculate the final retrieval semantic loss required for model training of the content retrieval model. Coarse , the retrieval semantic loss corresponding to the fine-grained type Sum them up to get the final retrieval semantic loss L required for model training, that is
[0193] Through the aforementioned steps, the content retrieval model is trained to obtain a trained content retrieval model. The trained content retrieval model can be integrated into a server or terminal to retrieve the retrieval result content corresponding to the content to be retrieved through the trained content retrieval model. Specifically, the content to be retrieved can be obtained; the trained content retrieval model is used to perform feature extraction processing on the content to be retrieved to obtain multiple features of the content to be retrieved at different feature granularities; based on the features of the content to be retrieved at each feature granularity, the trained content retrieval model is used to calculate the similarity between the content to be retrieved and the candidate retrieval result content at each feature granularity; based on the similarity corresponding to each feature granularity, the trained content retrieval model is used to determine the retrieval result content corresponding to the content to be retrieved. Specifically, the content retrieval process can refer to the description of the following embodiments.
[0194] As can be seen from the above, this embodiment can obtain sample retrieval content and sample retrieval result content that matches the sample retrieval content; perform feature extraction processing on the sample retrieval content and the sample retrieval result content through the content retrieval model to obtain feature information of multiple different feature granularities, and the feature information includes retrieval content features and retrieval result content features; perform feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity; calculate the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information; and perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity.
[0195] This solution can combine the feature learning of content and the quantitative learning of features, so that the feature quantization module is added to the training of feature learning. In this way, the semantic loss of feature quantization can be added to the goal of model training optimization, so that the semantic information of the sample retrieval content and the sample retrieval result content can be better retained in the quantized features, avoiding the quantization loss caused by feature quantization when feature learning and feature quantization are performed independently, resulting in a large semantic deviation between the quantized content features of the sample retrieval content and the quantized content features of the sample retrieval result content. In addition, this solution also takes into account the case where there is a large difference between the retrieval content features and the retrieval result content features (for example, when the retrieval content features and the retrieval result content features correspond to different feature modalities), by extracting feature information of multiple different feature granularities, it is convenient to perform feature alignment according to multiple feature granularities in the future, thereby reducing the modal difference between content features and achieving better content retrieval effects.
[0196] In addition, this solution fully explores and utilizes the multimodal information in the sample retrieval result content, strengthening the model's ability to understand the semantics of the sample retrieval result content, thereby obtaining a better quality representation of the sample retrieval result content. In addition, in application scenarios where the sample retrieval content and the sample retrieval result content correspond to different content modalities, such as the application scenario of retrieving video content based on text content, this solution can significantly reduce the modal difference between the sample retrieval content side and the sample retrieval result content side through cross-modal alignment of multiple feature granularities, thereby achieving better cross-modal retrieval results.
[0197] More specifically, in the application scenario of text-based video retrieval, this application provides an end-to-end method for optimizing text video vectorized retrieval, uses the Transformer model to model video multimodal information, and designs a fine-grained cross-modal representation alignment scheme, which can effectively optimize the index representation of text and video, improve video retrieval accuracy, and optimize user experience.
[0198] According to the method described in the above embodiment, the following examples are given to further illustrate the method in detail.
[0199] In this embodiment, the model training device is integrated into a server and a terminal as an example. The server can be a single server or a server cluster composed of multiple servers; the terminal can be a mobile phone, tablet computer, laptop computer and other devices.
[0200] As shown in Figure 4, a model training method has the following specific process:
[0201] 201. The server obtains sample search content and sample search result content matching the sample search content.
[0202] In this application, the sample search content and the sample search result content can correspond to different content modalities. A content search model can be trained to enable cross-modal search. For example, searching for images based on text, searching for web pages based on text, searching for videos based on text, etc.
[0203] The sample search result content may specifically include text content, image content, video content, audio content, link content, etc.; for another example, the sample search result content may be obtained by combining multiple content, such as web page content, advertising content, etc. Similarly, the sample search content may specifically include text content, image content, video content, audio content, link content, etc.; for another example, the sample search content may be obtained by combining multiple content, such as web page content, advertising content, etc.
[0204] For example, referring to Figure 5 , the sample search content may be text content, and the sample search result content may be video content. The server may obtain the sample text data and sample video data to be processed to form a training sample pair, i.e., each training sample pair may include a query text and a video matching the query text.
[0205] 202. The server performs feature extraction processing on the sample search content and the sample search result content through the content search model to obtain feature information of multiple different feature granularities, wherein the feature information includes search content features and search result content features.
[0206] In the application scenario of text-based video retrieval, see Figure 5, the global representation and fine-grained representation of the text can be extracted by inputting the text into the text encoder, wherein the global representation of the text refers to the coarse-grained retrieval content features of the text, and the fine-grained representation of the text refers to the fine-grained retrieval content features of the text. In addition, the multimodal features of the video can be input into the video encoder to extract the global representation and fine-grained representation of the video, wherein the global representation of the video refers to the coarse-grained retrieval result content features of the video, and the fine-grained representation of the video refers to the fine-grained retrieval result content features of the video. It is worth noting that this application does not limit the implementation methods of the text encoder and the video encoder. For example, in addition to the Transformer mechanism, models such as the long short-term memory artificial neural network LSTM (Long Short-Term Memory, LSTM), convolutional LSTM (Convolutional LSTM, ConvLSTM) and the like that can learn fragment / sentence sequences can also be applied.
[0207] For example, in the example of text-based video retrieval, the model architecture diagram of the content retrieval model can be shown in Figure 3. By preprocessing the video, 30 frames of uniformly sampled image features, speech features, and text features transcribed by OCR and ASR can be obtained as input to the video multimodal Transformer. Furthermore, the text can be input into the text Transformer encoder for processing, and the video multimodal features can be input into the video Transformer for processing. In turn, the global representation of the text and the global representation of the video can be obtained from the text encoder and the video encoder, respectively, and a fine-grained representation extraction module shared by the text and video sides can be used to obtain fine-grained representations of the text and the video.
[0208] 203. The server performs feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity.
[0209] For example, referring to FIG. 5 , the retrieval content features and the retrieval result content features obtained in step 202 may be compressed using a product quantization module.
[0210] 204. The server calculates the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information.
[0211] For example, referring to FIG5 , contrastive learning can be applied to the representations of multiple feature granularities to align cross-modal representations, and the retrieval semantic loss corresponding to each feature granularity can be calculated based on the contrastive learning mechanism.
[0212] It is worth noting that this application does not restrict the cross-modal alignment method. For example, in addition to using contrastive learning, a metric learning mechanism can also be selected, such as changing the contrastive learning loss to a triplet loss.
[0213] 205. The server performs model training on the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity to obtain a trained content retrieval model.
[0214] For example, based on the granularity type of the feature granularity, the retrieval semantic loss corresponding to each feature granularity can be aggregated to obtain the aggregated retrieval semantic loss corresponding to each granularity type. Furthermore, based on the aggregated retrieval semantic loss corresponding to each granularity type, the final retrieval semantic loss for model training can be determined. Based on this final retrieval semantic loss and the BP algorithm, the content retrieval model can be trained to obtain a trained content retrieval model.
[0215] 206. The terminal sends the content to be retrieved to the server.
[0216] For example, referring to FIG6 , in an application scenario of text-based video retrieval, the terminal can respond to the content retrieval operation triggered by the user based on the content discovery page 2001, display the content retrieval page 2002, and obtain the text to be retrieved (such as “Health Tips” in FIG6 ) input by the user, that is, the content to be retrieved, through the content retrieval control 2003 in the content retrieval page 2002.
[0217] 207. The server determines the search result content that matches the content to be searched through the trained content retrieval model.
[0218] For example, the server can use the trained content retrieval model to determine the video that matches the text to be retrieved "health tips", that is, the retrieval result content that matches the content to be retrieved.
[0219] 208. The terminal determines a search result of the content to be searched based on the search result content that matches the content to be searched.
[0220] The terminal can determine the search result content that matches the content to be retrieved through the server, and determine the search results of the content to be retrieved based on the search result content. For example, after the terminal determines the video that matches "health tips" through the server, it can display the retrieved video in the search result display page 2004.
[0221] From the above, it can be seen that the embodiment of the present application can combine the feature learning of the content and the quantitative learning of the features, so that the feature quantization module is added to the training of the feature learning. In this way, the semantic loss of feature quantization can be added to the goal of model training optimization, so that the semantic information of the sample retrieval content and the sample retrieval result content can be better retained in the quantized features, avoiding the quantization loss caused by feature quantization when feature learning and feature quantization are performed independently, resulting in a large semantic deviation between the quantized content features of the sample retrieval content and the quantized content features of the sample retrieval result content. The scheme also takes into account that when there is a large difference between the retrieval content features and the retrieval result content features (for example, when the retrieval content features and the retrieval result content features correspond to different feature modalities), by extracting feature information of multiple different feature granularities, it is convenient to perform feature alignment according to multiple feature granularities in the future, thereby reducing the modal difference between the content features and achieving better content retrieval effects.
[0222] In the application scenario of text-based video retrieval, this application combines representation learning and representation compression into a single-stage method to directly optimize the representation after product quantization. By adding the product quantization module to the training of the representation model and adding the semantic loss of product quantization to the optimization target, the semantic information of text and video can be better retained in the representation after product quantization. In addition, this solution can mine and utilize multimodal information in the video to learn the multimodal representation of the video. In addition to utilizing the image features of a single frame, this solution also extracts audio information from the video, as well as text information transcribed by ASR and OCR, as input to the video encoder. In addition, in addition to global, coarse-grained cross-modal alignment, this solution also proposes cross-modal alignment on fine-grained semantics. Specifically, in addition to extracting the global representation of text and video, this solution also extracts a fine-grained semantic representation sequence of text and video. Through fine-grained representation alignment, this solution can greatly reduce the modal difference between the text side and the video, thereby achieving better cross-retrieval effect.
[0223] According to the method described in the above embodiment, the following examples are given to further illustrate the method in detail.
[0224] This embodiment will be described from the perspective of a content retrieval device, which may be integrated into a server or a terminal.
[0225] The present application provides a content retrieval method. The method can be executed by a terminal or a server, or by both the terminal and the server. The present application takes the content retrieval method executed by the server as an example for explanation. Specifically, the method is executed by a content retrieval device integrated in the server. As shown in FIG7 , the specific process of the content retrieval method can be as follows:
[0226] 301. Obtain the content to be retrieved.
[0227] The content modalities corresponding to the content to be retrieved may include various situations, for example, text, image, video, web page, audio, etc.
[0228] There are many ways for the server to obtain the content to be retrieved. For example, the terminal can send the content to be retrieved to the server. For example, in the application scenario of text-based video retrieval shown in Figure 6, the terminal can send the target retrieval text input by the user to the server, and the target retrieval text is the content to be retrieved.
[0229] 302. Perform feature extraction processing on the content to be retrieved through the content retrieval model to obtain multiple features of the content to be retrieved with different feature granularities.
[0230] The model training method of the present application can be used to train a content retrieval model (i.e., the trained content retrieval model mentioned above). For details, please refer to the description of the aforementioned embodiment and will not be repeated here. For example, the content retrieval model can be integrated into a server to provide content retrieval services to a terminal; for another example, the content retrieval model can be integrated into a terminal so that the terminal directly provides content retrieval services.
[0231] The features of the content to be retrieved are features obtained by extracting features from the content to be retrieved. The content to be retrieved can be extracted using a content retrieval model to obtain multiple retrieval content features of different feature granularities.
[0232] As an example, the feature granularity may include coarse granularity, and the content retrieval model may include a second coarse-grained feature extraction module. During model training, the second coarse-grained feature extraction module may be used to extract coarse-grained retrieval content features of sample retrieval content; during content retrieval, the second coarse-grained feature extraction module may be used to extract coarse-grained content features of the content to be retrieved. Specifically, the second coarse-grained feature extraction module may be used to extract semantic representation features of the content to be retrieved; based on the self-attention mechanism, the semantic representation features may be subjected to feature projection processing to obtain coarse-grained content features of the content to be retrieved.
[0233] As an example, the feature granularity may include fine granularity, and the content retrieval model may include a fine-grained feature extraction module. During model training, the fine-grained feature extraction module is shared by the sample retrieval content and the sample retrieval result content. During model training, the fine-grained extraction module can be used to extract multiple retrieval content features of different fine granularities, as well as multiple retrieval result content features of different fine granularities. During content retrieval, the fine-grained feature extraction module can be used to extract multiple retrieval content features of different fine granularities of the content to be retrieved. Specifically, multiple content features to be clustered of the content to be retrieved can be obtained; the fine-grained feature extraction module can be used to perform feature clustering on the content features to be clustered; and based on the clustering results, multiple content features to be retrieved of different fine granularities of the content to be retrieved can be determined.
[0234] As an example, when obtaining multiple content features to be clustered of the content to be retrieved, the content to be retrieved can be specifically divided into content parts to obtain at least one sub-content of the content to be retrieved; sub-content features corresponding to the sub-content can be extracted; and multiple content features to be clustered of the content to be retrieved can be determined based on the sub-content features.
[0235] 303. Based on the features of the content to be retrieved at each feature granularity, calculate the similarity between the content to be retrieved and the candidate search result content at each feature granularity.
[0236] The candidate search result content refers to the search result content that may match the searched content. Specifically, the search result content that matches the searched content can be determined from the candidate search result content by calculating the similarity between the searched content and the candidate search result content at each feature granularity.
[0237] In one embodiment, the similarity between the features of the content to be retrieved at each feature granularity and the quantized features of the retrieval result content can be calculated to calculate the similarity between the content to be retrieved at each feature granularity and the features of the quantized retrieval result content. Specifically, the step of "calculating the similarity between the content to be retrieved and the candidate retrieval result content at each feature granularity based on the features of the content to be retrieved at each feature granularity" may include:
[0238] Determine the quantized retrieval result content features corresponding to the candidate retrieval result content at each feature granularity;
[0239] According to the feature granularity, the similarity between the features of the content to be retrieved and the features of the quantized retrieval result content is calculated to obtain the similarity corresponding to each feature granularity.
[0240] For example, the content retrieval model can be used to calculate the quantized retrieval result content features corresponding to multiple feature granularities of the candidate retrieval result content. For example, the content retrieval model can be used to perform feature extraction processing on the candidate retrieval result content to obtain retrieval result content features of the candidate retrieval result content at multiple different feature granularities; the content retrieval model can be used to perform feature quantization processing on the retrieval result content features to obtain quantized retrieval result content features of each feature granularity of the candidate retrieval result content.
[0241] As an example, the feature granularity may include coarse granularity, and the content retrieval model may include a first coarse-grained feature extraction module. During model training, the first coarse-grained feature extraction module may be used to extract coarse-grained retrieval result content features of the sample retrieval result content; during content retrieval, the first coarse-grained feature extraction module may be used to extract coarse-grained retrieval result content features of the candidate retrieval result content. Specifically, the modal content features corresponding to at least one content modality of the candidate retrieval result content may be obtained; through the first coarse-grained feature extraction module, the modal content features are feature encoded based on the self-attention mechanism to obtain the encoded features corresponding to each content modality; the encoded features corresponding to each content modality are subjected to feature aggregation processing to obtain the coarse-grained retrieval result content features of the candidate retrieval result content.
[0242] As an example, the feature granularity may include fine granularity, and the content retrieval model may include a fine-grained feature extraction module. During model training, the fine-grained feature extraction module is shared by the sample retrieval content and the sample retrieval result content. During model training, the fine-grained extraction module can be used to extract multiple retrieval content features of different fine granularities, as well as multiple retrieval result content features of different fine granularities. During content retrieval, the fine-grained feature extraction module can be used to extract multiple retrieval result content features of different fine granularities for the candidate retrieval result content. Specifically, multiple content features to be clustered of the candidate retrieval result content can be obtained; the fine-grained feature extraction module is used to perform feature clustering processing on the content features to be clustered; and based on the clustering results, multiple retrieval result content features of the candidate retrieval result content of different fine granularities are determined.
[0243] As an example, when obtaining multiple content features to be clustered of the candidate retrieval result content, it is possible to specifically determine at least one content modality of the candidate retrieval result content; extract the modal content features corresponding to the content modality of the candidate retrieval result content; and determine multiple content features to be clustered of the candidate retrieval result content based on the modal content features.
[0244] As an example, the content retrieval model may include feature quantization models corresponding to each feature granularity, and each feature quantization model may be used to perform feature quantization processing on the retrieval result content features of the corresponding feature granularity of the candidate retrieval result content. Specifically, the feature quantization module may be used to perform feature division processing on the retrieval result content features of the corresponding feature granularity of the candidate retrieval result content to obtain divided sub-retrieval result content features; perform feature quantization processing on the divided sub-retrieval result content features to obtain quantized sub-retrieval result content features; and perform feature fusion processing on the quantized sub-retrieval result content features to obtain quantized retrieval result content features of each feature granularity of the candidate retrieval result content.
[0245] Furthermore, the feature granularity can be used to align the features of the content to be retrieved with the features of the quantized search result content, and by calculating the similarity between the aligned features of the content to be retrieved and the quantized search result content, such as the cosine similarity, the similarity corresponding to each feature granularity can be obtained.
[0246] 304. Determine the search result content corresponding to the to-be-searched content based on the similarities corresponding to the feature granularities.
[0247] As an example, data aggregation processing can be performed on the similarities corresponding to each feature granularity based on the granularity type of the feature granularity; and based on the aggregated similarities, the retrieval result content corresponding to the to-be-retrieved content can be determined from the candidate retrieval result content. For example, based on the aggregated similarities of each candidate retrieval result content, the candidate retrieval result content corresponding to the candidate retrieval result content with the maximum aggregated similarity can be determined as the retrieval result content corresponding to the to-be-retrieved content.
[0248] The specific implementation method and corresponding beneficial effects of this embodiment can be specifically referred to the above-mentioned model training method embodiment, and this embodiment will not be described in detail here.
[0249] From the above, it can be seen that the content retrieval method provided in the embodiment of the present application can accurately implement content retrieval through the content retrieval model. For example, when the content to be retrieved and the retrieval result content correspond to different content modalities, the embodiment of the present application can achieve high-precision cross-modal content retrieval.
[0250] To better implement the above method, the present application also provides a model training device, which can be integrated into a server or terminal. The server can be a single server or a server cluster consisting of multiple servers; the terminal can be a mobile phone, tablet computer, laptop computer, or other device.
[0251] For example, as shown in FIG8 , the model training apparatus may include a sample acquisition unit 401 , a feature extraction unit 402 , a feature quantization unit 403 , a loss calculation unit 404 , and a model training unit 405 , as follows:
[0252] The sample acquisition unit 401 may be used to acquire sample search content and sample search result content matching the sample search content;
[0253] The feature extraction unit 402 may be configured to perform feature extraction processing on the sample search content and the sample search result content using a content search model to obtain feature information of multiple different feature granularities, wherein the feature information includes search content features and search result content features;
[0254] The feature quantization unit 403 may be configured to perform feature quantization processing on the search content features and the search result content features through the content retrieval model to obtain quantized feature information of each feature granularity;
[0255] The loss calculation unit 404 may be configured to calculate the retrieval semantic loss corresponding to each of the feature granularities based on the feature information and the quantized feature information;
[0256] The model training unit 405 may be configured to perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each of the feature granularities.
[0257] In one embodiment, referring to FIG9 , the loss calculation unit 404 may include:
[0258] The bidirectional calculation subunit 4041 may be configured to calculate, based on the feature information and the quantized feature information, a first retrieval semantic loss for each feature granularity in a first semantic retrieval direction and a second retrieval semantic loss for each feature granularity in a second semantic retrieval direction;
[0259] The loss aggregation subunit 4042 may be configured to perform loss aggregation processing on the first retrieval semantic loss and the second retrieval semantic loss;
[0260] The loss determination subunit 4043 may be configured to determine the retrieval semantic loss corresponding to each of the feature granularities according to the processing result of the loss aggregation processing.
[0261] In one embodiment, the bidirectional calculation subunit 4041 may be used to:
[0262] According to the first semantic retrieval direction, a target feature is determined from the feature information, and a target quantized feature is determined from the quantized feature information, wherein the target feature and the target quantized feature correspond to different feature modes; according to the feature granularity, feature alignment processing is performed on the target feature and the target quantized feature; based on the feature similarity between the aligned target feature and the aligned target quantized feature, the first retrieval semantic loss corresponding to each feature granularity in the first semantic retrieval direction is calculated.
[0263] In one embodiment, referring to FIG10 , the content retrieval model includes a feature quantization module corresponding to each feature granularity, each of which is configured to perform feature quantization processing on feature information of the corresponding feature granularity. The feature quantization unit 403 may include:
[0264] The feature division subunit 4031 may be configured to perform feature division processing on the search content features corresponding to each feature granularity through a feature quantization module corresponding to the feature granularity to obtain the divided sub-search content features corresponding to the feature granularity;
[0265] The feature quantization subunit 4032 may be configured to perform feature quantization processing on the sub-search content feature distribution after the division corresponding to the feature granularity, to obtain the quantized sub-search content feature corresponding to the feature granularity;
[0266] The feature fusion subunit 4033 may be configured to perform feature fusion processing on the quantized sub-search content features corresponding to the feature granularity to obtain the quantized search content features of the feature granularity.
[0267] In one embodiment, referring to FIG11 , the feature granularity includes coarse granularity, and the content retrieval model includes a first coarse-grained feature extraction module for the sample retrieval result content; the feature extraction unit 402 may include:
[0268] The first acquisition subunit 4021 may be configured to acquire modal content features corresponding to at least one content modality of the sample search result content;
[0269] The feature encoding subunit 4022 may be configured to perform feature encoding processing on the modal content features based on the self-attention mechanism through the first coarse-grained feature extraction module to obtain encoded features corresponding to each of the content modalities;
[0270] The feature aggregation subunit 4023 may be configured to perform feature aggregation processing on the encoded features corresponding to each of the content modalities to obtain coarse-grained retrieval result content features of the sample retrieval result content.
[0271] In one embodiment, referring to FIG. 12 , the feature granularity includes coarse granularity, and the content retrieval model includes a second coarse granularity feature extraction module for the sample retrieval content; the feature extraction unit 402 may include:
[0272] The feature extraction subunit 4024 may be configured to extract semantic representation features of the sample search content through the second coarse-grained feature extraction module;
[0273] The feature projection subunit 4025 can be used to perform feature projection processing on the semantic representation features based on the self-attention mechanism to obtain coarse-grained retrieval content features of the sample retrieval content.
[0274] In one embodiment, referring to FIG. 13 , the feature granularity includes fine granularity, and the content retrieval model includes a fine-grained feature extraction module shared by the sample retrieval content and the sample retrieval result content; the feature extraction unit 402 may include:
[0275] The second acquisition subunit 4026 may be used to acquire a plurality of content features to be clustered of the sample search content and the sample search result content;
[0276] The feature clustering subunit 4027 may be configured to perform feature clustering processing on the content features to be clustered through the fine-grained feature extraction module;
[0277] The information determination subunit 4028 may be configured to determine a plurality of different fine-grained feature information based on the clustering result of the feature clustering process, wherein the feature information includes retrieval content features and retrieval result content features.
[0278] In one embodiment, the second obtaining subunit 4026 may be configured to:
[0279] Determine at least one content modality of the sample retrieval result content; extract modal content features corresponding to the content modality of the sample retrieval result content; and determine multiple content features to be clustered of the sample retrieval result content based on the modal content features.
[0280] In one embodiment, the second obtaining subunit 4026 may be configured to:
[0281] The sample search content is divided into content to obtain at least one sub-content of the sample search content; sub-content features corresponding to the sub-content are extracted; and multiple content features to be clustered of the sample search content are determined based on the sub-content features.
[0282] In one embodiment, referring to FIG14 , the model training unit 405 may include:
[0283] The loss aggregation subunit 4051 may be configured to perform loss aggregation processing on the retrieval semantic losses corresponding to the respective feature granularities according to the granularity type of the feature granularity;
[0284] The model training subunit 4052 can be used to perform model training on the content retrieval model based on the aggregated retrieval semantic loss.
[0285] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can be found in the previous method embodiments and will not be repeated here.
[0286] As can be seen from the above, in the model training device of this embodiment, the sample acquisition unit 401 acquires the sample retrieval content and the sample retrieval result content matching the sample retrieval content; the feature extraction unit 402 performs feature extraction processing on the sample retrieval content and the sample retrieval result content through the content retrieval model to obtain feature information of multiple different feature granularities, and the feature information includes retrieval content features and retrieval result content features; the feature quantization unit 403 performs feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity; the loss calculation unit 404 calculates the retrieval semantic loss corresponding to each feature granularity based on the feature information and the quantized feature information; the model training unit 405 performs model training on the content retrieval model based on the retrieval semantic loss corresponding to each feature granularity.
[0287] This solution can combine the feature learning of content and the quantitative learning of features, so that the feature quantization module is added to the training of feature learning. In this way, the semantic loss of feature quantization can be added to the goal of model training optimization, so that the semantic information of the sample retrieval content and the sample retrieval result content can be better retained in the quantized features, avoiding the quantization loss caused by feature quantization when feature learning and feature quantization are performed independently, resulting in a large semantic deviation between the quantized content features of the sample retrieval content and the quantized content features of the sample retrieval result content. In addition, this solution also takes into account the case where there is a large difference between the retrieval content features and the retrieval result content features (for example, when the retrieval content features and the retrieval result content features correspond to different feature modalities), by extracting feature information of multiple different feature granularities, it is convenient to perform feature alignment according to multiple feature granularities in the future, thereby reducing the modal difference between content features and achieving better content retrieval effects.
[0288] In order to better implement the above method, accordingly, an embodiment of the present invention further provides a content retrieval device, wherein the content retrieval device can be integrated into a server or a terminal.
[0289] For example, as shown in FIG15 , the content retrieval apparatus may include a content acquisition unit 501 , an extraction processing unit 502 , a similarity calculation unit 503 , and a result determination unit 504 , as follows:
[0290] The content acquisition unit 501 can be used to acquire the content to be retrieved;
[0291] The extraction processing unit 502 may be configured to perform feature extraction processing on the content to be retrieved through a content retrieval model to obtain a plurality of features of the content to be retrieved at different feature granularities;
[0292] The similarity calculation unit 503 may be configured to calculate the similarity between the content to be retrieved and the candidate search result content at each feature granularity based on the features of the content to be retrieved at each feature granularity;
[0293] The result determination unit 504 may be configured to determine the search result content corresponding to the to-be-searched content based on the similarities corresponding to the respective feature granularities.
[0294] In one embodiment, referring to FIG16 , the similarity calculation unit 503 may include:
[0295] The quantization determination subunit 5031 may be used to determine the quantized retrieval result content features corresponding to each feature granularity of the candidate retrieval result content;
[0296] The similarity calculation subunit 5032 may be configured to calculate the similarity between the features of the content to be retrieved and the features of the quantized retrieval result content according to feature granularity, and obtain the similarity corresponding to each feature granularity.
[0297] The content retrieval device provided in the embodiment of the present application can accurately implement content retrieval through a content retrieval model. For example, when the content to be retrieved and the retrieval result content correspond to different content modalities, the embodiment of the present application can implement high-precision cross-modal content retrieval.
[0298] In addition, an embodiment of the present application further provides a computer device, which may be a server or terminal device, as shown in FIG17 , which shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application. Specifically:
[0299] The computer device may include one or more processing cores of a processor 601, one or more computer-readable storage media of a memory 602, a power supply 603, an input unit 604, and other components. Those skilled in the art will appreciate that the computer device structure shown in FIG17 does not limit the computer device, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0300] Processor 601 is the control center of the computer device. It connects all components of the computer device using various interfaces and circuits. It executes software programs and / or modules stored in memory 602 and accesses data stored in memory 602 to perform various computer functions and process data. Optionally, processor 601 may include one or more processing cores. Preferably, processor 601 may integrate an application processor and a modem processor. The application processor primarily processes the operating system, user interfaces, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 601.
[0301] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0302] The computer device also includes a power supply 603 for supplying power to various components. Preferably, the power supply 603 can be logically connected to the processor 601 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 603 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0303] The computer device may further include an input unit 604, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0304] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically, in this embodiment, the processor 601 in the computer device loads the executable files corresponding to one or more application processes into the memory 602 according to the following instructions, and the processor 601 runs the application stored in the memory 602, thereby implementing the model training method or content retrieval method provided in the embodiments of the present application.
[0305] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0306] To this end, an embodiment of the present application provides a storage medium storing a plurality of instructions, which can be loaded by a processor to execute the steps of any model training method or content retrieval method provided in an embodiment of the present application.
[0307] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0308] Since the instructions stored in the storage medium can execute the steps in any model training method or content retrieval method provided in the embodiments of the present application, the beneficial effects that can be achieved by any model training method or content retrieval method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0309] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the aforementioned model training or content retrieval methods.
[0310] The above is a detailed introduction to a model training method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model training method, performed by a computer device, include: Acquire sample search content and sample search result content matching the sample search content; By using a content retrieval model, feature extraction processing is performed on the sample retrieval content and the sample retrieval result content to obtain feature information of multiple different feature granularities, wherein the feature information includes retrieval content features and retrieval result content features; Through the content retrieval model, the retrieval content features and the retrieval result content features are subjected to feature quantization processing to obtain quantized feature information of each feature granularity; Based on the feature information and the quantized feature information, calculating the retrieval semantic loss corresponding to each feature granularity; The content retrieval model is trained based on the retrieval semantic loss corresponding to each of the feature granularities.
2. The model training method according to claim 1, wherein the retrieval semantic loss corresponding to each feature granularity is calculated based on the feature information and the quantized feature information. include: Based on the feature information and the quantized feature information, calculating a first retrieval semantic loss of each feature granularity in a first semantic retrieval direction, and a second retrieval semantic loss of each feature granularity in a second semantic retrieval direction; Performing loss aggregation processing on the first retrieval semantic loss and the second retrieval semantic loss; According to the processing result of the loss aggregation processing, the retrieval semantic loss corresponding to each of the feature granularities is determined.
3. The model training method according to claim 2, wherein the first retrieval semantic loss of each feature granularity in the first semantic retrieval direction is calculated based on the feature information and the quantized feature information. include: According to the first semantic retrieval direction, determining a target feature from the feature information, and determining a target quantized feature from the quantized feature information, wherein the target feature and the target quantized feature correspond to different feature modes; According to the feature granularity, performing feature alignment processing on the target feature and the target quantized feature; Based on the feature similarity between the aligned target features and the aligned target quantized features, a first retrieval semantic loss of each feature granularity in the first semantic retrieval direction is calculated.
4. According to the model training method according to any one of claims 1 to 3, the content retrieval model comprises a feature quantization module corresponding to each feature granularity, each of the feature quantization modules is used to perform feature quantization processing on feature information of the feature granularity corresponding to it; The feature quantification process is performed on the search content feature by using the content search model, including: For each feature granularity, a feature quantization module corresponding to the feature granularity is used to perform feature division processing on the search content feature corresponding to the feature granularity to obtain the divided sub-search content feature corresponding to the feature granularity; feature quantization processing is performed on the divided sub-search content features corresponding to the feature granularity to obtain the quantized sub-search content feature corresponding to the feature granularity; A feature fusion process is performed on the quantized sub-search content features corresponding to the feature granularity to obtain the quantized search content features of the feature granularity.
5. According to the model training method according to any one of claims 1 to 4, the feature granularity includes coarse granularity, and the content retrieval model includes a first coarse-grained feature extraction module for the sample retrieval result content; The sample search result content is subjected to feature extraction processing by using a content search model, including: Obtaining modal content features corresponding to at least one content modality of the sample search result content; Through the first coarse-grained feature extraction module, feature encoding processing is performed on the modal content features based on the self-attention mechanism to obtain encoded features corresponding to each of the content modalities; Feature aggregation processing is performed on the encoded features corresponding to each of the content modalities to obtain coarse-grained retrieval result content features of the sample retrieval result content.
6. The model training method according to any one of claims 1 to 4, wherein the feature granularity includes a coarse granularity, and the content retrieval model includes a second coarse granularity feature extraction module for the sample retrieval content; The sample search content is subjected to feature extraction processing by using a content search model, including: Extracting semantic representation features of the sample search content through the second coarse-grained feature extraction module; Based on the self-attention mechanism, feature projection processing is performed on the semantic representation features to obtain coarse-grained retrieval content features of the sample retrieval content.
7. According to the model training method according to any one of claims 1 to 6, the feature granularity includes fine granularity, and the content retrieval model includes a fine-grained feature extraction module shared by the sample retrieval content and the sample retrieval result content; The content retrieval model is used to perform feature extraction processing on the sample retrieval content and the sample retrieval result content to obtain feature information of multiple different feature granularities. include: Acquire a plurality of content features to be clustered of the sample search content and the sample search result content; Performing feature clustering processing on the content features to be clustered by the fine-grained feature extraction module; Based on the clustering result of the feature clustering process, a plurality of feature information of different fine-grained levels are determined, wherein the feature information includes retrieval content features and retrieval result content features.
8. The model training method according to claim 7, obtaining a plurality of content features to be clustered of the sample retrieval result content, include: Determining at least one content modality of the sample search result content; Extracting modal content features corresponding to the sample search result content and the content modality; According to the modal content features, a plurality of content features to be clustered of the sample retrieval result content are determined.
9. The model training method according to claim 7, obtaining a plurality of content features to be clustered of the sample search content, include: Performing content division processing on the sample search content to obtain at least one sub-content of the sample search content; Extracting sub-content features corresponding to the sub-content; According to the sub-content features, a plurality of content features to be clustered of the sample search content are determined.
10. The model training method according to any one of claims 1 to 9, wherein the content retrieval model is trained based on the retrieval semantic loss corresponding to each of the feature granularities. include: According to the granularity type of the feature granularity, performing loss aggregation processing on the retrieval semantic losses corresponding to the respective feature granularities; Based on the aggregated retrieval semantic loss, the content retrieval model is trained.
11. A content retrieval method, executed by a computer device, include: Get the content to be retrieved; By using a content retrieval model, feature extraction processing is performed on the content to be retrieved to obtain multiple features of the content to be retrieved with different feature granularities; Based on the features of the content to be retrieved at each of the feature granularities, calculating the similarity between the content to be retrieved and the candidate search result content at each of the feature granularities; Based on the similarities corresponding to the feature granularities, the search result content corresponding to the content to be searched is determined.
12. The content retrieval method according to claim 11, wherein the similarity between the content to be retrieved and the candidate retrieval result content at each feature granularity is calculated based on the features of the content to be retrieved at each feature granularity. include: Determine the quantized search result content features corresponding to the candidate search result content at each feature granularity; According to the feature granularity, the similarity between the feature of the content to be searched and the feature of the quantized search result content is calculated to obtain the similarity corresponding to each feature granularity.
13. A model training device, include: A sample acquisition unit, used to acquire sample search content and sample search result content matching the sample search content; A feature extraction unit, configured to perform feature extraction processing on the sample search content and the sample search result content through a content search model to obtain feature information of multiple different feature granularities, wherein the feature information includes search content features and search result content features; A feature quantization unit, used to perform feature quantization processing on the retrieval content features and the retrieval result content features through the content retrieval model to obtain quantized feature information of each feature granularity; A loss calculation unit, used for calculating the retrieval semantic loss corresponding to each of the feature granularities based on the feature information and the quantized feature information; The model training unit is used to perform model training on the content retrieval model based on the retrieval semantic loss corresponding to each of the feature granularities.
14. A content retrieval device, include: A content acquisition unit, used to acquire content to be retrieved; An extraction processing unit, used to perform feature extraction processing on the content to be retrieved through a content retrieval model to obtain multiple features of the content to be retrieved with different feature granularities; A similarity calculation unit, configured to calculate the similarity between the content to be retrieved and the candidate search result content at each of the feature granularities based on the features of the content to be retrieved at each of the feature granularities; The result determination unit is used to determine the search result content corresponding to the to-be-searched content based on the similarities corresponding to the respective feature granularities.
15. A computer device comprising a memory and a processor; the memory stores an application, and the processor is used to run the application in the memory to perform operations in the model training method described in any one of claims 1 to 10 or the content retrieval method described in any one of claims 11 to 12.
16. A storage medium, It is characterized in that The storage medium stores a plurality of instructions, which are suitable for loading by a processor to execute the steps in the model training method described in any one of claims 1 to 10 or the content retrieval method described in any one of claims 11 to 12.
17. A computer program product, comprising a computer program or instructions, which, when executed by a processor, implements the model training method described in any one of claims 1 to 10 or the content retrieval method described in any one of claims 11 to 12.
