Content tag generation method, device, electronic device and storage medium

Through multi-modal feature cross-attention processing and freezing parameter adjustment, content labels are directly generated, which solves the problem of low training efficiency in the existing technology and achieves efficient content label generation.

CN118535742BActive Publication Date: 2024-10-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410986621.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-10-29
Estimated Expiration
2044-07-23

AI Technical Summary

Technical Problem

When the existing technology uses a text generation model to generate content tags, it is necessary to train the adapter and the text generation model in stages, resulting in low training efficiency and inability to efficiently generate content tags.

Method used

By obtaining the multi-modal features of the content to be recognized, cross-attention processing is performed, and the frozen text generation model parameters are used to adjust the processing results to directly generate content labels, avoiding additional adapter training and fine-tuning processes.

Benefits of technology

It improves the training efficiency of the model, realizes efficient content label generation, and simplifies the training process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535742B_ABST
    Figure CN118535742B_ABST
Patent Text Reader

Abstract

The disclosed embodiment discloses a content label generation method, device, electronic device and storage medium, which obtains the content to be identified, extracts the modal features of at least two modalities of the content to be identified, and fuses the modal features of at least two modalities to obtain the first content feature of the content to be identified; obtains the prompt text, extracts the first text feature of the prompt text, and performs cross-attention processing on the first text feature and the first content feature; adjusts the cross-attention processing result based on the first gating parameter to obtain the target text feature; calls the text generation model to generate text based on the target text feature to obtain the content label of the content to be identified. It can inject the first content feature into the text generation model without the need for additional training adapters or fine-tuning of the text generation model, which can improve the training efficiency of the model, and then efficiently generate content labels, and is widely used in scenarios such as content classification and content recommendation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a content tag generation method, device, electronic device and storage medium. Background Art

[0002] In order to label content efficiently and accurately, content tag generation is an essential processing method. In related technologies, when using text generation models (such as large language models) to generate content tags based on multimodal features, it is often necessary to introduce adapters corresponding to different modalities to convert non-text modality features into text modality features, and then fuse them with text modality features. This model architecture often requires a two-stage training process (i.e., first training the basic functions of the adapter, and then fine-tuning the adapter and text generation model), which reduces the training efficiency of the model and cannot efficiently generate content tags. Summary of the invention

[0003] The following is a summary of the subject matter of the detailed description of the present disclosure. This summary is not intended to limit the scope of the claims.

[0004] The embodiments of the present disclosure provide a content tag generation method, device, electronic device, and storage medium, which can improve the training efficiency of the model and thus efficiently generate content tags.

[0005] In one aspect, an embodiment of the present disclosure provides a method for generating a content tag, comprising:

[0006] Acquire content to be identified, extract modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain a first content feature of the content to be identified;

[0007] Acquire a prompt text, extract a first text feature of the prompt text, and perform cross-attention processing on the first text feature and the first content feature, wherein the prompt text is used to prompt a text generation model to generate a label for the content to be identified;

[0008] Adjusting the cross attention processing result based on a first gating parameter to obtain a target text feature, wherein the first gating parameter is obtained by freezing the parameters of the text generation model and then training;

[0009] The text generation model is called to generate text based on the target text features to obtain a content label of the content to be identified.

[0010] On the other hand, an embodiment of the present disclosure provides a content tag generating device, including:

[0011] A content feature extraction module, used to obtain content to be identified, extract modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain a first content feature of the content to be identified;

[0012] A cross attention module is used to obtain a prompt text, extract a first text feature of the prompt text, and perform cross attention processing on the first text feature and the first content feature, wherein the prompt text is used to prompt a text generation model to generate a label for the content to be identified;

[0013] A gating module, used for adjusting the cross attention processing result based on a first gating parameter to obtain a target text feature, wherein the first gating parameter is obtained by training after freezing the parameters of the text generation model;

[0014] The generation module is used to call the text generation model to generate text based on the target text features to obtain the content label of the content to be identified.

[0015] Further, the cross attention processing result is adjusted based on the first gating parameter to obtain the target text feature, and the gating module is used for:

[0016] Adjusting the cross attention processing result based on the first gating parameter, and summing the adjusted cross attention processing result with the first text feature to obtain a second text feature;

[0017] The second text feature is mapped, and the mapping result is adjusted based on a second gating parameter to obtain a target text feature, wherein the second gating parameter is obtained by training after freezing the parameters of the text generation model.

[0018] Furthermore, the text generation model is provided with a plurality of sequentially cascaded encoding layers, and the calling of the text generation model generates text based on the target text features to obtain the content label of the content to be identified, and the above generation module is used for:

[0019] Encoding the target text features based on the multiple encoding layers, generating text based on the encoding results, and obtaining a content label of the content to be identified;

[0020] Wherein, the target text feature is the input of the first encoding layer;

[0021] For any encoding layer except the last one, cross-attention processing is performed on the output of the current encoding layer and the first content feature, the cross-attention processing result is adjusted based on the first gating parameter, the adjusted cross-attention processing result and the output of the current encoding layer are summed, the features obtained after the summation are mapped, the mapping result is adjusted based on the second gating parameter, and then input into the next encoding layer for encoding.

[0022] Furthermore, the content label generating device further includes a training module, each of the encoding layers corresponds to its own first gating parameter and its own second gating parameter, and before adjusting the result of the cross attention processing based on the first gating parameter, the training module is used to:

[0023] Acquire sample content, freeze the parameters of the text generation model, and initialize each of the first gating parameters and each of the second gating parameters to zero;

[0024] The first gating parameters and the second gating parameters are trained based on the sample content.

[0025] Further, the prompt text is obtained, a first text feature of the prompt text is extracted, and a cross-attention processing is performed on the first text feature and the first content feature. The cross-attention module is used for:

[0026] Retrieving a second content feature similar to the first content feature, and a reference tag associated with the second content feature, wherein the reference tag is a tag of a reference content, the second content feature is obtained by fusing features of at least two modalities of the reference content, and the modality of the feature fused by the second content feature is the same as the modality of the feature fused by the first content feature;

[0027] Constructing a prompt text based on the reference tag, and extracting a first text feature of the prompt text;

[0028] The second content feature is concatenated with the first content feature to obtain a concatenated content feature, and cross-attention processing is performed on the first text feature and the concatenated content feature.

[0029] Further, the prompt text is constructed based on the reference tag, and the cross attention module is used to:

[0030] Connecting a start tag and an end tag to both ends of the reference tag to obtain a tag text segment corresponding to the reference tag;

[0031] The start mark is spliced ​​after the last of the label text fragments to obtain the prompt text.

[0032] Furthermore, the first text feature and the concatenated content feature are subjected to cross attention processing, and the cross attention module is used for:

[0033] Performing cross attention processing on a first sub-feature of the label text segment in the first text feature and a second content feature corresponding to the first sub-feature in the spliced ​​content feature;

[0034] A cross attention process is performed on the second sub-feature of the last start mark in the first text feature and the first content feature in the concatenated content feature.

[0035] Further, the cross-attention processing is performed on the first sub-feature of the label text segment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature, and the cross-attention module is used to:

[0036] Determine a query matrix according to the first text feature, determine a key matrix according to the concatenated content feature, and obtain a target matrix according to the product of the query matrix and the transposed key matrix;

[0037] Masking the target matrix based on a mask matrix, normalizing the masked target matrix, and obtaining a cross attention weight matrix, wherein the mask matrix is ​​used to shield matrix elements other than target elements in the target matrix, and the target element is obtained by multiplying a first sub-feature of the label text segment in the first text feature and a second content feature corresponding to the first sub-feature in the spliced ​​content feature;

[0038] A value matrix is ​​determined according to the second content feature, and a cross-attention processing result is obtained according to the product of the cross-attention weight matrix and the value matrix.

[0039] Further, the retrieving of a second content feature similar to the first content feature and a reference tag associated with the second content feature, the cross attention module is used to:

[0040] Acquire a plurality of the reference contents and reference tags of each of the reference contents, fuse features of at least two modes of each of the reference contents, and obtain the second content feature of each of the reference contents;

[0041] Each of the second content features is associated with the corresponding reference tag and stored in a search library, and the second content feature similar to the first content feature and the reference tag associated with the second content feature are retrieved from the search library.

[0042] Furthermore, the reference content is a reference video, and each of the second content features is associated with the corresponding reference tag and stored in a search library, and the cross attention module is used for:

[0043] For each of the reference videos, average pooling is performed on the modal features of the reference video in the video modality to obtain visual features of the same dimension as the modal features of the reference video in the text modality;

[0044] Performing average pooling on the visual features and the modal features of the reference video in the text mode to obtain retrieval features of each of the reference videos;

[0045] Each of the search features, the second content feature and the corresponding reference tag is associated and stored in a search library.

[0046] Furthermore, the content to be identified is a video to be identified, and the extracting of modal features of at least two modalities of the content to be identified is performed by the content feature extraction module for:

[0047] Encoding each video frame of the video to be identified respectively to obtain a modal feature of the video to be identified in a video modality;

[0048] The video text in the video to be identified is extracted, the video text is encoded, and the modal features of the video to be identified in the text mode are obtained.

[0049] On the other hand, an embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned content tag generation method when executing the computer program.

[0050] On the other hand, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned content tag generation method.

[0051] On the other hand, the embodiment of the present disclosure further provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned content tag generation method.

[0052] The disclosed embodiments include at least the following beneficial effects: by acquiring content to be identified, extracting modal features of at least two modalities of the content to be identified, fusing the modal features of at least two modalities to obtain a first content feature of the content to be identified, acquiring a prompt text, extracting a first text feature of the prompt text, and performing cross-attention processing on the first text feature and the first content feature, so that the first content feature and the first text feature can be fused based on the cross-attention mechanism, and then further introducing a first gating parameter to adjust the cross-attention processing result to obtain a target text feature. Since the first gating parameter is obtained by training after freezing the parameters of the text generation model, therefore, by combining the first gating parameter with the cross-attention mechanism, on the basis of injecting the first content feature into the text generation model, there is no need to additionally train the adapter or fine-tune the text generation model, thereby realizing a one-stage training process, which can improve the training efficiency of the model and thus efficiently generate content labels.

[0053] Other features and advantages of the present disclosure will be set forth in the following description, and in part will be apparent from the description, or may be learned by practicing the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.

[0055] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure;

[0056] Figure 2 A flowchart of a method for generating content tags provided by an embodiment of the present disclosure;

[0057] Figure 3 An optional schematic diagram of training encoders corresponding to various modalities provided in an embodiment of the present disclosure;

[0058] Figure 4 An optional schematic diagram of extracting modal features of various modalities of a video to be identified and fusing them into a first content feature provided by an embodiment of the present disclosure;

[0059] Figure 5 An optional schematic diagram of cross-attention processing provided by an embodiment of the present disclosure;

[0060] Figure 6 An optional schematic diagram of generating retrieval features of a reference video and storing them in a retrieval library provided in an embodiment of the present disclosure;

[0061] Figure 7An optional schematic diagram of retrieving a second content feature provided by an embodiment of the present disclosure;

[0062] Figure 8 An optional schematic diagram of cross-attention processing provided by an embodiment of the present disclosure;

[0063] Fig. 9 An optional schematic diagram of cross-attention processing provided by an embodiment of the present disclosure;

[0064] Fig.10 An optional schematic diagram of adjusting target text features based on a first gating parameter and a second gating parameter provided in an embodiment of the present disclosure;

[0065] Fig.11 An optional schematic diagram of training a first gating parameter and a second gating parameter provided in an embodiment of the present disclosure;

[0066] Fig.12 An optional schematic diagram of generating content tags through multiple coding layers provided in an embodiment of the present disclosure;

[0067] Fig.13 An optional overall flow chart of the content tag generation method provided in the embodiment of the present disclosure

[0068] Fig.14 A schematic diagram of the structure of a content tag generating device provided by an embodiment of the present disclosure;

[0069] Fig.15 A partial structural block diagram of a terminal provided in an embodiment of the present disclosure;

[0070] Fig.16 A partial structural block diagram of a server provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

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

[0072] It should be noted that in various specific embodiments of the present disclosure, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. Among them, the target object can be a user. In addition, when the embodiment of the present disclosure needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present disclosure will be obtained.

[0073] In the embodiments of the present disclosure, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0074] To facilitate understanding of the technical solution provided by the embodiments of the present disclosure, some key terms used in the embodiments of the present disclosure are explained here:

[0075] Multimodal: refers to the various different forms of data. In the field of artificial intelligence, multimodality generally includes modalities such as text, voice, and images. In related technologies, neural network models are generally used to process text modal data and generate corresponding outputs based on text modal data. This method has poor robustness. When the quality of the input text data is not high, it is easy to generate erroneous outputs. Due to the limitations of text modal data, it cannot express some non-text modal features well, and the model cannot fully perceive the input content, which makes the related technology perform poorly in complex tasks such as label generation and sentiment analysis. Using multimodal data as the input of the model and complementing data of different modalities can improve the robustness of the model, while allowing the input of the model to more comprehensively reflect the input content, so that the model can generate corresponding outputs more accurately.

[0076] Attention Mechanism: The attention mechanism is the core mechanism of the large language model. Based on the attention mechanism, the model can consider all other elements in the input sequence while processing each element of the input sequence, thereby capturing the complex dependencies between the elements in the input sequence. It converts the input sequence to be processed into the corresponding query sequence, key sequence and value sequence, and then performs a series of matrix operations on the query sequence, key sequence and value sequence to obtain the corresponding attention results, and then decodes based on the attention results to generate the corresponding output sequence.

[0077] Cross-Attention: It is a variant of the attention mechanism. The cross-attention mechanism is a technology used to process the dependency between two different sequences, thereby capturing the semantic association between the two sequences. In the cross-attention mechanism, the query sequence and the key sequence and value sequence are obtained based on two different sequences. For example, when it is necessary to capture the dependency between sequence A and sequence B, the query sequence is generated based on sequence A, and the key sequence and value sequence are generated based on sequence B. The cross-attention mechanism can learn the dependency between the two sequences and generate the output corresponding to the other sequence based on the input of one sequence. For example, in the machine translation scenario, the texts of the two languages ​​are used as two samples input to the cross-attention mechanism to train the cross-attention mechanism, so that the model can capture the dependency between the two languages ​​through the cross-attention mechanism. After that, the text of one language is used as the input of the model, and the model can generate the translation text corresponding to the input text based on the cross-attention mechanism.

[0078] In the related art, when a content label is generated by a text generation model, in order to improve the accuracy of the label, the content label is often predicted based on the features of multiple modalities of the content. However, most existing text generation models (such as large language models) can only process text data. Therefore, when generating content labels based on the features of multiple modalities of the content, it is often necessary to convert the features of the non-text modality into the features of the text modality through a corresponding adapter, and then fuse the converted features of each modality and input them into the text generation model, so that the text generation model generates the content label based on the multimodal fusion features. In this scheme, both the adapter and the text generation model need to be trained so that the adapter can accurately learn to convert the features of the non-text modality into the features of the text modality, and the text generation model can predict the content label based on the multimodal fusion features; and since the features of multiple modalities of the content themselves contain text features, if the adapter and the text generation model are jointly trained, overfitting may occur, that is, the adapter actually learns how to ignore the features of the non-text modality, and the text generation model learns how to predict the content label based on the text features of the content. Based on this, in the related art, the adapter and the text generation model need to be trained in stages, that is, first train the adapter so that the adapter can accurately learn how to convert the features of the non-text modality into the features of the text modality, and then generate multimodal fusion features based on the trained adapter, and train the text generation model based on the multimodal fusion features so that the text generation model learns how to predict the content label based on the multimodal fusion features. This staged training method is inefficient and cannot efficiently generate content labels.

[0079] Based on this, the embodiments of the present disclosure provide a content tag generation method, device, electronic device and storage medium, which can improve the training efficiency of the model and thus efficiently generate content tags.

[0080] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network.

[0081] Exemplarily, the server 102 can obtain the content to be identified from the terminal 101, extract the modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain the first content feature of the content to be identified; the server 102 can also obtain the prompt text, extract the first text feature of the prompt text, and perform cross-attention processing on the first text feature and the first content feature, wherein the prompt text is used to prompt the text generation model to generate a label for the content to be identified; adjust the cross-attention processing result based on the first gating parameter to obtain the target text feature, wherein the first gating parameter is obtained by freezing the parameters of the text generation model and then training; the server 102 can also call the text generation model to generate text based on the target text feature, obtain the content label of the content to be identified, and send the content label of the content to be identified to the terminal 101.

[0082] In addition, the server 102 may not send the content tags of the content to be identified to the terminal 101, but instead perform corresponding processing on the content to be identified based on the content tags, such as classifying the content to be identified based on the content tags, or searching for other content similar to the content to be identified based on the content tags, so as to perform content recommendation, content distribution and other processing.

[0083] The server 102 obtains the content to be identified, extracts the modal features of at least two modalities of the content to be identified, fuses the modal features of at least two modalities to obtain the first content feature of the content to be identified, obtains the prompt text, extracts the first text feature of the prompt text, and performs cross-attention processing on the first text feature and the first content feature, so as to be able to fuse the first content feature and the first text feature based on the cross-attention mechanism, and further introduces the first gating parameter to adjust the cross-attention processing result to obtain the target text feature. Since the first gating parameter is obtained by training after freezing the parameters of the text generation model, therefore, by combining the first gating parameter with the cross-attention mechanism, on the basis of injecting the first content feature into the text generation model, there is no need to additionally train the adapter or fine-tune the text generation model, thereby realizing a one-stage training process, which can improve the training efficiency of the model and thus efficiently generate content tags.

[0084] It can be seen that compared with the method of first training the adapter and then generating multimodal fusion features through the trained adapter to fine-tune the text generation model, the content label generation method provided in the embodiment of the present disclosure only needs to perform one-stage training on the first gating parameter, and there is no need to perform two-stage training on the adapter and the text generation model in sequence, which can improve the training efficiency of the model and thus improve the efficiency of content label generation.

[0085] Server 102 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 (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 may also be a node server in a blockchain network.

[0086] The terminal 101 may be a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present disclosure.

[0087] The method provided in this embodiment can be applied to various scenarios, including but not limited to content classification, content recommendation, content distribution and the like. For example, after obtaining the content tag of the content to be identified, the content to be identified is distributed based on the content tag.

[0088] Reference Figure 2 , Figure 2 An optional flow chart of a content tag generation method provided in an embodiment of the present disclosure is provided. The content tag generation method can be executed by a server, or by a terminal, or by a server and a terminal. The content tag generation method includes but is not limited to steps 201 to 204.

[0089] Step 201: Obtain content to be identified, extract modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain a first content feature of the content to be identified.

[0090] In step 201, the content to be identified is media content generated and sent by the object through the terminal, such as video, image, article, etc.; modality refers to the information expression form of the content to be identified, such as text, image, audio, video, etc., and the content to be identified contains at least two modalities, such as the subtitle text of the video and the video frame image, the text of the article and the image inserted in the article, etc.; the modal feature is a feature vector or feature matrix that can reflect the information contained in the corresponding modality of the content to be identified, for example, the modal feature of the text modality can be a text feature vector corresponding to the text extracted from the content to be identified, and the modal feature of the image modality is an image feature matrix corresponding to the image in the content to be identified, etc.; the first content feature refers to a multimodal fusion feature obtained by fusing multiple modal features of the content to be identified.

[0091] Specifically, since different modalities correspond to different information representation forms, the methods of encoding information of different modalities into corresponding modal features are different. Therefore, for each modality, it is necessary to set corresponding encoders to encode the information of each modality into corresponding modal features, that is, the modal features of the content to be identified in different modalities are obtained by encoding the information of the corresponding modalities by different encoders. It can be understood that in this embodiment, the modal features of the content to be identified in each modality are all corresponding to the content to be identified, and the semantics corresponding to the modal features of different modalities will have consistent parts. For example, the content to be identified is an introduction video of a certain digital product. The video modality of the video will show the product parameters of the digital product, and the text modality of the video will also have corresponding product parameter description text. If the modal features of the video modality corresponding to the same semantics are relatively different from the modal features of the text modality, then the first content feature obtained by fusing the modal features of the text modality and the modal features of the video modality may not accurately represent the semantics; therefore, when encoding the modal features of multiple modalities of the content to be identified, multiple modal features of different modalities but with the same semantics should have a high similarity. Based on this, in this embodiment, the encoders corresponding to each modality can be trained by a comparative learning method, so that the encoders corresponding to each modality can encode data with the same semantics but different modalities into multiple modal features with high similarity, wherein, after the encoders corresponding to each modality are trained, their parameters are frozen during the subsequent gating parameter training process.

[0092] Specifically, the encoder can be trained by using information in two modes, and the information in the two modes has the same semantics. Figure 3 The training sample set includes a plurality of sample pairs consisting of one-to-one corresponding sample video frames and sample video texts. Each sample video frame in the training sample set is input into a first encoder, so that the first encoder generates a corresponding sample video modal feature based on each sample video frame. Each sample video text is input into a second encoder, so that the second encoder generates a sample text modal feature based on each sample video text. The matching probability of each sample video modal feature and each sample text modal feature is predicted. The cross entropy is calculated based on the predicted matching probability and the actual matching relationship between the sample video frame and the sample video text. The first encoder and the second encoder are trained by minimizing the cross entropy, so that the first encoder and the second encoder learn how to encode video frames and video texts with the same semantics into modal features with higher similarity.

[0093] It is understandable that the information that can be reflected by the modal features of each modality has certain limitations. A single modal feature often cannot fully reflect the content to be identified. For example, the content to be identified is a video of a conversation between two parties. The modal features of the text modality can more accurately express the content of the conversation, but cannot well express the action expressions, conversation scenes and other information of the two parties to the conversation; on the contrary, the modal features of the video modality can better reflect the action expressions, conversation scenes and other information of the two parties to the conversation, but cannot accurately express the content of the conversation. At this time, if the content label is generated based only on the modal features of a single modality, the generated content label is difficult to accurately and comprehensively reflect the characteristics of the content to be identified, which will cause errors in the subsequent classification of the content to be identified or content push based on the content label. Based on this, in the present disclosure, the modal features of the content to be identified in at least two modalities are fused to obtain the first content feature of the content to be identified, so that the content label corresponding to the content to be identified generated based on the first content feature can more accurately and comprehensively reflect the characteristics of the content to be identified.

[0094] Specifically, since the encoders corresponding to different modalities are trained through the contrastive learning method, in the contrastive learning process, in order to make the two encoders generate highly similar feature matrices for content containing the same semantics, it is first necessary to ensure that the shapes of the feature matrices encoded by the corresponding encodings of each modality are the same. In this way, the shapes of the modal features of the content to be identified in each modality are the same. At this time, the modal features of different modalities can be directly spliced ​​to fuse the modal features of different modalities and obtain the first content feature corresponding to the content to be identified.

[0095] In one possible implementation, the content to be identified is a video to be identified, and extracting modal features of at least two modalities of the content to be identified can specifically be: encoding each video frame of the video to be identified separately to obtain the modal features of the video to be identified in the video modality; extracting video text from the video to be identified, encoding the video text, and obtaining the modal features of the video to be identified in the text modality.

[0096] Based on this, when the content to be identified is a video to be identified, the modal features of the video to be identified in the video mode and the modal features of the video to be identified in the text mode are extracted. Based on the modal features in the video mode and the modal features in the text mode, the information to be expressed by the video to be identified can be fully and relatively accurately reflected. In this way, content labels are subsequently generated based on the modal features in the video mode and the modal features in the text mode. The generated content labels can accurately reflect the content characteristics of the video to be identified, and the content classification or content recommendation of the video to be identified can be accurately performed based on the content labels.

[0097] Specifically, a video frame refers to a frame image extracted from a video to be identified and can reflect the visual information of the video to be identified; a video text refers to a text extracted from a video to be identified and has a high correlation with the video content of the video to be identified.

[0098] Specifically, the video to be identified is composed of a large number of continuous video frames. If all video frames are encoded, the scale of the modal features of the video to be identified in the video mode will be relatively large. In addition, adjacent video frames in the video to be identified often contain a large amount of repeated information. If each video frame in the video to be identified is encoded, it will cause serious information redundancy. Based on this, refer to Figure 4 , the video to be identified can be divided into a first number of segments, and then a video frame is extracted from each segment, and the extracted video frame is encoded by an encoder to obtain features corresponding to the extracted multiple video frames, and then the features of the extracted video frames are sequentially spliced ​​to obtain the modal features of the video to be identified in the video modality. For example, the video to be identified is divided into M segments, and a frame in the middle of each segment is extracted as a video frame of the video to be identified, thereby obtaining M video frame images, and then the encoder corresponding to the video modality is used to encode the features of each video frame image to obtain M video frame features, where the i-th video frame feature can be recorded as , since each video frame feature is obtained based on a video frame image of the video to be identified, the resolution of the video to be identified is fixed, and the resolution of each video frame image extracted from the video to be identified is actually consistent, the dimension of the corresponding video frame feature is also consistent, for example, each video frame feature is an N*K matrix, based on this, the modal features of the video to be identified in the video modality can be obtained by sequentially splicing the various video frame features along the direction of the matrix column. For example, the video to be identified includes M video frame features, among which the i-th video frame feature is recorded as ,and The shape of is N*K, then the modal features of the video to be identified in the video mode can be recorded as , The shape is N*(K*M).

[0099] Specifically, when creating a video to be identified, the subject often adds a title of the video to be identified and summarizes the subject content of the video to be identified in the title; the video screen of the video to be identified also contains some text information that is highly correlated with the content of the video to be identified, such as certain geographical signs or the main content of the video copy; the audio in the video to be identified contains a large amount of text information that is highly correlated with the content of the video to be identified, such as the conversation content between the subjects in the video to be identified, the narration of the video to be identified, etc. Based on this, refer to Figure 4, the video text may at least include: the title of the video to be identified, the text information in the video screen of the video to be identified, the speech text of the object in the video to be identified, and the narration text. Specifically, the original form of the video title is text, which can be directly extracted; and the text information in the video screen of the video to be identified can be obtained by processing the screen of the video to be identified through the optical character recognition technology (Optical Character Recognition, OCR); and the dialogue speech text and narration text in the video to be identified can be obtained by recognizing the audio of the video to be identified through the automatic speech recognition technology (Automatic Speech Recognition, ASR). After extracting all the text information related to the video to be identified from the video to be identified, all the text information is spliced ​​in sequence to obtain the video text corresponding to the video to be identified, and the video text is encoded by the encoder corresponding to the text modality to obtain the modal features of the video to be identified in the text modality. The modal features under the text modality can be recorded as .

[0100] Specifically, after obtaining the modal features of the video to be identified in the video mode and the modal features in the text mode, the multimodal fusion features corresponding to the video to be identified, i.e., the first content features, can be obtained by directly splicing the modal features in the video mode and the modal features in the text mode. For example, the modal features in the video mode are , the modal features under text mode are , after splicing the modal features of the video modality and the modal features of the text modality along the direction of the matrix column, a multimodal fusion feature is obtained, which is recorded as , the multimodal fusion feature is the first content feature corresponding to the content to be identified.

[0101] In some other embodiments, modal features of other modalities besides video modality and text modality can also be extracted from the video to be identified. It should be noted that when the content to be identified is a video to be identified, the object that created the video to be identified may add background music to the video to be identified, and the content correlation between these background music and the video to be identified is relatively low. In addition, there may be a situation where the same background music is added to multiple videos with unrelated content. At this time, combining the modal features of the audio modality to generate the content label of the video to be identified may result in a decrease in the accuracy of the content label, and may even make the content labels of multiple videos with unrelated content but using the same background music closer, resulting in errors in the subsequent classification of videos according to the content labels. Based on this, in this embodiment, when the content to be identified is a video to be identified, the modal features of multiple modalities at least do not include the modal features of the audio modality.

[0102] Step 202: Obtain a prompt text, extract a first text feature of the prompt text, and perform cross-attention processing on the first text feature and the first content feature.

[0103] The prompt text is used to prompt the text generation model to generate labels for the content to be recognized. The text generation model can be a large language model. The text generation model includes at least one decoder for decoding the result of the cross-attention processing to generate corresponding text. Specifically, the prompt text can be a template text segment containing a special identifier for prompting the text generation model to generate labels for the recognized content. For example, the prompt text is " <video>______",in, <video>is a special identifier for indicating the first content feature. The prompt text is used to prompt the text generation model based on <video>The indicated feature predicts the text that needs to be filled in "______" in the prompt text, thereby generating a corresponding content label. In another embodiment, the prompt text may also be a pre-set text template. For example, the prompt text may also be "Content label corresponding to the content to be identified: ". The specific prompt text may be constructed according to actual needs. The first text feature is a feature sequence for cross-attention processing obtained by encoding the prompt text. Specifically, the prompt text may be first segmented, and multiple words may be extracted from the prompt text. Then, the sequence corresponding to each word is determined by looking up the vocabulary. The sequences corresponding to each word are sequentially spliced ​​to obtain the first text feature. It should be noted that since cross-attention processing needs to be performed based on the first text feature and the first content feature in the subsequent process, the process involves matrix multiplication operations between feature matrices. Based on this, when generating the first text feature, it is necessary to ensure that the dimension of the first text feature and the dimension of the first content feature match each other. For example, referring to Figure 5 , the dimension of the first content feature is N*(K*M+1), and the dimension of the first text feature is B*(K*M+1).

[0104] After obtaining the first text feature, cross attention processing is performed based on the first text feature and the first content feature. Specifically, the process of performing cross attention processing is used to predict the text to be filled in the prompt text based on the first content feature, thereby generating a content label, based on which a query matrix is ​​determined according to the first text feature, and a key matrix and a value matrix are determined based on the first content feature to perform attention calculation.

[0105] Specifically, each matrix row of the query matrix corresponds to an element in the prompt text, each matrix row of the key matrix represents the key information of an element in the first content feature, and each matrix row of the value matrix represents the real information of an element in the first content feature. In the process of cross-attention processing, the key matrix is ​​first transposed, that is, the matrix rows and matrix columns of the key matrix are interchanged. For example, referring to Figure 5 , the key matrix is ​​a matrix of shape N*(K*M+1). After transposition, a transposed key matrix of shape (K*M+1)*N is obtained. After that, the query matrix and the transposed key matrix are matrix multiplied to obtain an attention score matrix. Each attention score in the attention score matrix represents the correlation between the elements corresponding to each matrix row of the query matrix and the elements corresponding to each matrix row of the key matrix. For example, the attention score in the first row and the first column of the attention score matrix represents the correlation between the elements corresponding to the first matrix row of the query matrix and the elements corresponding to the first matrix row of the key matrix.

[0106] It is understandable that the process of performing matrix multiplication on the query matrix and the key matrix is ​​actually to sum the dot product of the data of each matrix row in the query matrix and the data of each matrix column in the key matrix. This makes the range of attention scores in the obtained attention score matrix not fixed. On the one hand, since the range of attention scores is not fixed, the sum of the attention scores of an element of the query matrix to each element in the key matrix is ​​also not fixed, which makes it difficult for the model to intuitively perceive the importance of each element. In addition, attention score underflow may occur, that is, a certain attention score is negative, which will lead to a decrease in the stability of the model. Based on this, refer to Figure 5 After obtaining the attention score matrix, the attention score matrix is ​​exponentially normalized to convert the attention score into a standard probability distribution to obtain the attention weight matrix. Specifically, each attention score is first used as the exponent of the preset base e to obtain the power index corresponding to the attention score. For example, if a certain attention score in the attention score matrix is ​​3, the corresponding power index is ; Then, for each matrix row in the attention score matrix, calculate the sum of the power indices corresponding to all attention scores in the matrix row; Then, based on the ratio of the power indices corresponding to each attention score and the sum of the power indices corresponding to the matrix row where the attention score is located, determine the attention weight corresponding to each attention score. For example, the multiple attention scores of a matrix row in the attention score matrix are: 8, 16, 12, 20, and the corresponding power indices are , the sum of the power exponents corresponding to the rows of the matrix is , the attention weights corresponding to each attention score are , , , Thus, the attention score is converted into a standard probability distribution and the attention weight matrix is ​​obtained.

[0107] After obtaining the attention weight matrix, the attention weight matrix reflects the attention weights between the elements corresponding to each matrix row of the query matrix and the elements corresponding to each matrix row of the key matrix. Then, the attention weight matrix and the value matrix are matrix multiplied to obtain the corresponding attention processing result.

[0108] Specifically, the calculation process of cross attention can be expressed by the following formula:

[0109]

[0110] in, represents the result of attention processing, represents the query matrix determined based on the first text feature, represents a key matrix determined based on the first content feature, represents the transposed key matrix, represents a value matrix determined based on the first content feature, represents the exponential normalization function, Represents the dimension of the key matrix, that is, the number of matrix columns of the transposed key matrix.

[0111] In one embodiment, during the cross-attention processing, since the attention score matrix needs to be exponentially normalized, the relative gap between different attention scores will be exponentially magnified during the exponential normalization. For example, the multiple attention scores of a certain matrix row of the attention score matrix are 8, 16, 12, and 20, respectively. Before the exponential normalization, the ratios of these four attention scores are 2:4:3:5; after the exponential normalization, the ratios of the attention weights corresponding to these four attention scores are : : : , which will cause the gradient to vanish or explode during the back propagation process of model training, that is, the gradients corresponding to some attention weights are close to 1, while the gradients corresponding to some attention weights are close to 0, which makes the training process unstable. Since the attention score is obtained by calculating the dot product sum of the data of each matrix row of the query matrix and the data of each matrix column of the transposed key matrix, the value range of the attention score is positively correlated with the number of matrix columns of the transposed key matrix. Based on this, the attention score can be scaled based on the square root of the dimension of the key matrix (that is, the number of matrix columns of the transposed key matrix) before exponential normalization, and then the scaled attention score matrix can be exponentially normalized to narrow the gap between the attention weights after exponential normalization. For example, the dimension of the key matrix is ​​4, and the multiple attention scores of a certain matrix row of the corresponding attention score matrix are 8, 16, 12, and 20, respectively. Without scaling, the ratio of the corresponding attention weights is : : : ; The attention scores obtained by scaling the attention scores based on the square root of the dimension of the key matrix are 4, 8, 6, and 10. After exponential normalization, the corresponding attention weight ratio is : : : As a result, the relative gap between the attention weights obtained after exponential normalization is smaller, avoiding the gradient vanishing in the neural network layer after exponential normalization during the back propagation process, and improving the stability of model training.

[0112] The above embodiment shows an implementation method of directly performing cross-attention processing based on the first content feature and the first text feature. Since the first content feature is a multimodal fusion feature, the process of generating a content label of the content to be identified by processing the multimodal fusion feature involves the understanding and generation of cross-modal data. In order to improve the accuracy of the content label finally generated, in a possible implementation method, the prompt text is obtained, the first text feature of the prompt text is extracted, and the first text feature and the first content feature are cross-attention processed, which may include: retrieving a second content feature similar to the first content feature, and a reference tag associated with the second content feature; constructing a prompt text based on the reference tag, extracting the first text feature of the prompt text; splicing the second content feature with the first content feature to obtain a spliced ​​content feature, and performing cross-attention processing on the first text feature and the spliced ​​content feature.

[0113] Based on this, by retrieving the second content feature similar to the first content feature and the reference tag associated with the second content feature, the reference tag is added to the prompt text to regenerate the first text feature corresponding to the prompt text, and the second content feature and the first content feature are spliced ​​into a spliced ​​content feature, and then cross-attention processing is performed based on the first text feature and the spliced ​​content feature, so that the result of the cross-attention processing can provide additional contextual information. Since the reference content and the content to be identified have a high degree of similarity, the logic of generating the reference tag of the reference content and the logic of generating the content tag of the content to be identified also have a high degree of similarity. Based on the contextual information provided by the reference tag and the second content feature, the text generation model can learn the logic of generating the reference tag of the reference content, thereby improving the accuracy of the generated content tag when generating the content tag of the content to be identified.

[0114] Specifically, the reference label is a label of the reference content, and the second content feature is obtained by fusing features of at least two modalities of the reference content, and the modality of the features fused by the second content feature is the same as the modality of the features fused by the first content feature. It can be understood that the reference content and the content to be identified have the same information representation form, for example, the content to be identified is a video to be identified, and the reference content is a reference video. The reference label is a label used to indicate the characteristics of the reference content. For example, the reference content is a popular science video, and the corresponding reference label can be "popular science" or "popularization of knowledge", etc. The second content feature is a multimodal fusion feature corresponding to the reference content. The second content feature is obtained by fusing the modal features of the reference content in at least two modalities. The detailed process of generating the second content feature corresponding to the reference content will be described later and will not be repeated here. The number of second content features similar to the first content feature can be one or more, which is not limited in this embodiment.

[0115] Specifically, the second content feature and the reference tag can be stored in a dedicated database, and the retrieval library stores the second content feature corresponding to each reference content, and each second content feature has the same shape as the first content feature. The cosine similarity between the first content feature and each second content feature is calculated as the similarity between each second content feature and the first content feature. It can be understood that since the first content feature and the second content feature are actually a feature matrix, when calculating the similarity, each matrix row of the feature matrix can be extracted as a feature vector, and each matrix row of the second content feature in the retrieval library can be extracted as a corresponding feature vector; then, the cosine similarity is calculated based on the feature vector corresponding to each matrix row to obtain the similarity between each matrix row of the first content feature and the second content feature, and then the similarity corresponding to each matrix row is summed to obtain the similarity between the first content feature and the second content feature. For example, the first content feature and the second content feature are both A*B matrices, and each matrix row of the first content feature is used as a feature vector to obtain A feature vectors. These A feature vectors can be recorded in sequence as , , ,in, represents the eigenvector corresponding to the i-th matrix row in the first content feature. Similarly, A eigenvectors are obtained based on each matrix row of the second content feature, which are recorded as , , , then, based on and Perform a cosine similarity calculation to determine the similarity of the first matrix row of the first content feature and the second content feature, based on and Perform cosine similarity calculation to determine the similarity of the second matrix row of the first content feature and the second content feature, and so on, determine the similarity between each matrix row of the first content feature and the second content feature, and then determine the similarity between the first content feature and the second content feature based on the sum or mean of the similarities of each matrix row. Specifically, refer to the following formula:

[0116]

[0117] Where S represents the similarity between the first content feature and the second content feature, The number of matrix rows representing the first content feature, represents the eigenvector consisting of the i-th matrix row in the first content feature, represents the eigenvector formed by the i-th matrix row in the second content feature, Represents the cosine similarity function.

[0118] After obtaining the similarity between the first content feature and each second content feature, second content features similar to the first content feature are determined based on the similarity. For example, each second content feature is sorted from large to small based on the similarity, and the first several second content features in the sorting are determined as second content features similar to the first content feature.

[0119] For another example, a similarity threshold may be preset, and after calculating the cosine similarity between the first content feature and each second content feature, multiple second content features having cosine similarity greater than the similarity threshold are determined as second content features similar to the first content feature.

[0120] For another example, a second content feature similar to the first content feature is determined by combining a similarity threshold and a similarity ranking. Specifically, after calculating the cosine similarity between the first content feature and each second content feature, the second content features are ranked based on the cosine similarity, and the second content features whose cosine similarity is greater than the similarity threshold and are in the top several positions in the similarity ranking are determined as second content features similar to the first content feature.

[0121] It can be understood that the above embodiment retrieves the second content feature similar to the first content feature from the search library by calculating the cosine similarity. In addition to the cosine similarity, the similarity between each second content feature and the first content feature can also be determined by calculating the Euclidean distance between the first content feature and the second content feature.

[0122] In one possible implementation, retrieving a second content feature similar to a first content feature and a reference tag associated with the second content feature includes: acquiring a plurality of reference contents and a reference tag of each reference content, fusing features of at least two modes of each reference content to obtain a second content feature of each reference content; associating each second content feature with a corresponding reference tag and storing it in a retrieval library, and retrieving a second content feature similar to the first content feature and a reference tag associated with the second content feature from the retrieval library.

[0123] Specifically, each reference content has information of at least two modalities that are the same as the content to be identified. By extracting the information of the reference content in at least two modalities and encoding it through the corresponding encoder, the modal features of the reference content in at least two modalities can be obtained, and then the modal information of the parameter content in at least two modalities is fused to obtain the second content feature. Among them, the modality of the feature fused by the second content feature is the same as the modality of the feature fused by the first content feature. For example, the first content feature is obtained by fusing the modal features of the content to be identified in the video modality and the modal features in the text modality, and the second content feature is obtained by fusing the modal features of the reference content in the video modality and the modal features in the text modality. The detailed process of extracting the modal features of the reference content in each modality and fusing them into the second content feature can refer to the process of extracting the modal features of the content to be identified in at least two modalities and fusing them into the first content feature in step 201, which will not be repeated here. It should be noted that the encoder that encodes the information of the reference content in each modality into the corresponding modal features is the same as the encoder that encodes the information of the content to be identified in each modality into the corresponding modal features. Therefore, when the reference content and the content to be identified have a high degree of similarity, the second content feature of the reference content has a high degree of similarity with the first content feature of the content to be identified.

[0124] The reference tag may be a pre-marked tag for indicating the attributes of the reference content, or the reference tag may be a tag generated based on the reference content by applying the content tag generation method of this embodiment. Specifically, when the reference content is other content for which the corresponding content tag has been generated by the content tag generation method of this embodiment before obtaining the current content to be identified, the reference tag is the tag obtained by processing the reference content by the content tag generation method of this embodiment; when the reference content is content pre-marked with a corresponding reference tag, the reference tag is the pre-marked tag. It is understandable that the reference tag and the reference content can be pre-stored in a content database.

[0125] Specifically, the search library is a database for storing the second content feature and reference tag of the reference content. After obtaining the reference tag and the second content feature corresponding to the reference content, the reference tag and the second content feature corresponding to the same reference content are associated and stored in the search library. For example, the second content feature and the reference tag corresponding to the same reference content form a data pair, and the data pair is stored in the search library; or, an index item corresponding to the reference tag is added to the second content feature, and the second content feature and the reference tag are stored in the search library. In this way, after the second content feature is retrieved from the search library, the reference tag associated with the second content feature can be obtained based on the data pair, or the corresponding reference tag can be found based on the index item added to the second content feature.

[0126] The above embodiment shows a method for directly retrieving a similar second content feature from a search library based on a first content feature. However, since the first content feature and the second content feature are obtained by directly splicing modal features under different modalities, the matrix size of the first content feature and the second content feature is relatively large, and the amount of calculation for directly performing similarity calculation based on the first content feature and the second content feature is large, which makes the efficiency of retrieving the second content feature similar to the first content feature low.

[0127] In a possible implementation, the reference content is a reference video, and each second content feature is associated with a corresponding reference tag and stored in a retrieval library, including: for each reference video, average pooling the modal features of the reference video in video mode to obtain visual features of the same dimension as the modal features of the reference video in text mode; average pooling the visual features and the modal features of the reference video in text mode to obtain retrieval features of each reference video; and associating each retrieval feature, second content feature and corresponding reference tag and storing them in the retrieval library.

[0128] Based on this, by performing multiple average pooling processing on the modal features of the reference video in the video modality and the modal features in the text modality, the modal features of the video modality and the modal features of the text modality are compressed into smaller retrieval features, and then similarity calculation is performed based on the retrieval features. Based on the similarity, the second content feature similar to the first content feature is retrieved, which can reduce the amount of calculation required in the retrieval process and improve the retrieval efficiency.

[0129] Specifically, the reference content and the content to be identified have the same modal features of at least two modalities. When the content to be identified is a video to be identified, the reference content is a reference video, and the reference video has at least modal features in video modality and modal features in text modality. The detailed process of extracting the modal features of the reference video in video modality and modal features in text modality from the reference video can refer to the process of extracting the modal features of the video to be identified in video modality and modal features in text modality from the video to be identified in the above steps. That is, the reference video is equally divided into a first number of reference video segments, and a video frame is extracted from each reference video segment, and each video frame feature is generated by an encoder corresponding to the video modality, so as to obtain the modal features of the reference video in the video modality; at the same time, the title of the reference video is extracted, the screen text of the reference video is recognized by optical character recognition technology, and the voice text of the reference video is recognized by automatic speech recognition technology, and then the title, screen text and voice text of the reference video are spliced ​​to obtain the information of the reference video in the text modality, and the information of the reference video in the text modality is encoded by the encoder of the text modality to obtain the modal features of the reference video in the text modality.

[0130] After obtaining the modal features of the reference video in the video modality and the modal features in the text modality, the modal features in the video modality and the modal features in the text modality can be compressed into vector form through average pooling processing to obtain retrieval features. It can be understood that since the modal features in the video modality are obtained by encoding each video frame separately to obtain the corresponding video frame features, and then splicing multiple video frame features, and each video frame feature is actually a feature matrix, that is, the modal features in the video modality contain multiple feature matrices, and the modal features in the text modality are obtained by splicing all the texts of the reference video and then encoding them, and the modal features in the text modality only contain one feature matrix. Since the shape of each video frame feature is the same as the shape of the modal feature under the text modality, if multiple video frame features and modal features under the text modality are directly concatenated and average pooled, the contribution of the modal features of the text modality to the average pooling result will be very small. For example, the modal features of the video modality include M video frame features, that is, M feature matrices, while the modal features under the text modality only include one feature matrix. If the M video frame features and the modal features of the text modality are directly concatenated and average pooled, the contribution of the modal features under the text modality to the pooling result will be 1 / (M+1), while the contribution of the modal features under the video modality to the pooling result will be M / (M+1). That is, the retrieval features at this time can only represent the modal features under the video modality, but cannot reflect the modal features under the text modality. This will result in that during the retrieval process, only the reference video and the video to be identified are concerned with whether they are similar in video mode, but basically not whether they are similar in text mode. This will lead to errors in the retrieval results, making it impossible for the retrieved second content features and reference tags to provide effective contextual information for the text generation model. For example, the video to be identified X is an interpretation video of film and television work C, and the reference video Y is a secondary creation video obtained by re-dubbing film and television work C. The two are actually completely different, but because the video images of both are obtained by editing film and television work C, the two have a high degree of similarity in video mode, and a relatively low degree of similarity in text mode. At this time, if the multiple video frame features in the video mode and the modal features of the text mode are directly spliced ​​and averaged pooled to obtain the retrieval features, it is possible to retrieve the reference video Y as a reference content similar to the video to be identified X.

[0131] Based on this, in this embodiment, the modal features of the reference video in the video modality are first average pooled to convert the modal features of the video modality into visual features with the same dimensions as the modal features in the text modality. Then, the visual features and the modal features in the text modality are average pooled. In this way, in the process of generating retrieval features, the contributions of the modal features in the text modality and the modal features in the video modality are the same, and the retrieval features can simultaneously reflect the modal features of the reference video in the video modality and the modal features in the text modality.

[0132] Specifically, refer to Figure 6 , multiple video frame features of the reference video can be spliced, and the spliced ​​multiple video frame features can be averaged and pooled. Since the shape of each video frame feature is consistent with the shape of the modal feature of the text modality, the size of the pooling window is determined based on the number of video frame features and the multiple video frame features are averaged and pooled, so that the modal features under the video modality can be pooled into visual features with the same dimension as the modal features under the text modality. For example, the reference video includes M video frame features in the video modality, and the shape of each video frame feature and the modal feature under the text modality is N*K. The size of the pooling window can be set to (M*1), and the M video frame features are spliced ​​along the direction of the matrix row to obtain a matrix with a shape of (N*M)*K. Based on the pooling window of size (M*1), the spliced ​​video frame features are averaged and pooled to obtain a matrix with a shape of N*K, that is, the visual feature, which has the same dimension as the modal feature under the text modality. Afterwards, the visual features and the modal features under the text modality are average pooled for the second time. At this time, the size of the pooling window can be set to 2*1. Since the visual features and the modal features under the text modality have the same dimension, the modal features under the visual features and the text modality are pooled based on the pooling window, that is, the mean of the modal features under the visual features and the text modality is calculated, and finally a retrieval feature with a shape of N*K can be obtained. Compared with concatenating the modal features of the reference video in the video modality and the modal features in the text modality to obtain the second content matrix (with a shape of N*(K*M+1) or (N*M+1)*K), the scale of the retrieval features is greatly reduced. During the retrieval process, the computational complexity of the similarity calculation is greatly reduced, thereby improving the retrieval efficiency.

[0133] In another possible implementation, when performing average pooling on the modal features of the visual features and the text modality, the size of the pooling window can also be set based on the matrix dimension of the modal features of the text modality. For example, the dimension of the modal features of the text modality is N*K. At this time, the size of the pooling window can be set to 2N*1. After that, the modal features of the text modality and the visual features are spliced ​​along the matrix row direction to obtain a splicing matrix with a shape of 2N*K. After that, the splicing matrix is ​​average pooled based on the pooling window of size 2N*1 to obtain a feature vector with a shape of 1*K. In this way, when performing similarity calculation, only the similarity between the feature vectors needs to be calculated, which minimizes the amount of calculation of the similarity calculation and improves the retrieval efficiency.

[0134] It can be understood that after obtaining the retrieval features of each reference video and associating the retrieval features, the second content features and the corresponding reference tags to be stored in the retrieval library, when retrieving the second content features similar to the first content features, the modal features of the video to be identified in the video mode and the modal features in the text mode can be processed accordingly to obtain the first retrieval features corresponding to the video to be identified, and similarity calculation is performed based on the first retrieval features and the retrieval features corresponding to each reference video, thereby retrieving the second content features similar to the first content features and the reference tags associated with the second content features. Based on this, in a possible implementation, retrieving the second content features similar to the first content features and the reference tags associated with the second content features includes: averaging the modal features of the video to be identified in the video mode to obtain visual features of the same dimension as the modal features of the video to be identified in the text mode; averaging the visual features and the modal features of the video to be identified in the text mode to obtain the first retrieval features of the video to be identified; retrieving retrieval features similar to the first retrieval features in the retrieval library to obtain the second content features and reference tags associated with the retrieval features.

[0135] Specifically, the detailed process of generating the first retrieval feature of the video to be identified can refer to the process of generating the retrieval feature of the reference video in the above steps. Figure 7 First, the size of the first pooling window is determined based on the number of video frame features of the video to be identified, multiple video frame features of the video to be identified in the video modality are spliced ​​and average pooled based on the first pooling window to obtain visual features of the same dimension as the modal features of the video to be identified in the text modality; then the visual features of the video to be identified and the modal features in the text modality are average pooled for a second time to obtain the first retrieval features of the video to be identified.

[0136] Specifically, after obtaining the first retrieval feature of the video to be identified, refer to Figure 7 , calculate the similarity between the first retrieval feature and the retrieval features corresponding to each reference video in the retrieval library, and determine several retrieval features with the highest similarity. Since the retrieval features, second content features and reference tags of each reference video are stored correspondingly in the retrieval library, the corresponding second content features and reference tags are obtained from the retrieval library based on the retrieval features, and the second content features similar to the first content features and the reference tags associated with the second content features can be obtained.

[0137] After retrieving a second content feature similar to the first content feature and a reference tag associated with the second content feature, the second content feature, the reference tag and the first content feature are cross-attention processed together, and the result of the cross-attention processing is input into the text generation model, so that the text generation model can learn how to generate tags for similar content based on the contextual information provided by the second content feature and the reference tag, thereby improving the accuracy of content tags.

[0138] Specifically, reference tags can be added to the prompt text, so as to construct the prompt text based on the reference tags. For example, each reference tag is spliced ​​in sequence to obtain the prompt text; and the second content feature is spliced ​​into the first content feature to obtain a spliced ​​content matrix. It can be understood that there can be multiple reference tags and second content features. When adding reference tags to the prompt text, each reference tag is added in sequence before the text segment corresponding to the content to be identified in the prompt text. Correspondingly, each second content feature is also spliced ​​in sequence before the first content feature according to the splicing order of the corresponding reference tags in the prompt text. For example, three reference contents similar to the content to be identified are retrieved. In the prompt text, reference tag 1, reference tag 2, and reference tag 3 are spliced ​​in sequence. The spliced ​​content matrix can be expressed as: ,in, The second content features corresponding to reference tag 1, reference tag 2 and reference tag 3 are shown in order. It is the first content feature. It should be noted that each second content feature and the first content feature are spliced ​​along the dimension of the matrix column, so when the spliced ​​content matrix is ​​used as a key matrix for cross attention processing, a matrix column only contains part of the features in a second content feature.

[0139] Afterwards, a first text feature is generated based on the prompt text, and the query matrix in the cross-attention calculation process is further determined. The key matrix and the value matrix in the cross-attention calculation process are further determined by the concatenated content matrix, and cross-attention calculation is performed based on the query matrix, the key matrix and the value matrix to obtain the cross-attention processing result. After the cross-attention processing result is input into the text generation model, the text generation model will first generate text based on the second content feature and the attention result corresponding to the reference label, so as to learn how to accurately generate content labels based on the second content feature and the reference label, thereby improving the accuracy of subsequent generation of content labels for the content to be identified.

[0140] In a possible implementation, constructing a prompt text based on a reference tag includes: splicing a start tag and an end tag at both ends of the reference tag to obtain a tag text segment corresponding to the reference tag; and splicing a start tag after the last tag text segment to obtain the prompt text.

[0141] Based on this, by splicing the start mark and the end mark at both ends of each reference tag, each reference tag is separated and the position of the second content feature corresponding to each reference tag in the spliced ​​content feature is determined. In this way, after the corresponding first text feature is generated based on the prompt text, the first sub-feature corresponding to each reference tag can be determined from the first text feature based on the end mark, and the second content feature corresponding to each reference tag can be determined from the spliced ​​content feature based on the start mark. Therefore, when performing cross-attention processing, the attention weight between the reference tags and the second content features corresponding to different reference contents can be made zero, ensuring the accuracy of the context information provided by the second content feature and the reference tag. At the same time, by splicing a start mark after the last label text segment, the text generation model can first learn based on the context information provided by each reference tag and the second content feature, and then generate the content label of the content to be identified based on the cross-attention processing result of the last start mark and the first content feature, thereby improving the accuracy of the content label of the content to be identified.

[0142] Specifically, the start mark and the end mark are respectively a special identifier. The start mark is used to represent the position of the second content feature corresponding to the reference tag in the spliced ​​content feature, wherein the last start mark is used to represent the position of the first content feature in the spliced ​​content feature; the end mark is used to represent the end position of the corresponding reference tag, and the reference tags in the prompt text can be separated based on the end mark.

[0143] For example, the start tag can be recorded as <video>, the end tag can be recorded as <eoc>, two reference contents similar to the content to be identified are retrieved from the search library. At this time, the prompt text can be expressed as:

[0144] <video>The reference tag of the first reference content. <eoc>

[0145] <video>The reference tag of the second reference content. <eoc>

[0146] <video>

[0147] Specifically, since each second content feature and reference label are in one-to-one correspondence, each reference label is only associated with the corresponding second content feature, but not with other second content features. When performing cross-attention processing based on the first text feature and the spliced ​​content feature, and calculating the attention weight between each reference label and the second content feature, the attention weight between each reference label and other second content features except the corresponding second content feature should be zero. Based on this, each reference label is separated by an end mark, and the position of the second content feature corresponding to the reference label in the spliced ​​content feature is represented by a start mark. When calculating the attention weight between each reference label and each second content feature, each reference label is separated based on the end mark, and the position of the second content feature corresponding to the reference label in the spliced ​​content feature is determined based on the start mark. In this way, when calculating the attention weight between the reference label and the second content feature, the features other than the second content feature corresponding to the reference label are masked, so that the attention weight between the reference label and the features other than the corresponding second content feature is zero; or, after calculating the attention scores between the reference label and each feature in the spliced ​​content feature, based on the position of the second content feature corresponding to the reference label in the spliced ​​content feature, the attention scores representing the reference label and the features other than the second content feature corresponding to the reference label in the attention score matrix are masked, so that the attention weight between the reference label and the features other than the corresponding second content feature is zero.

[0148] In one possible implementation, cross-attention processing is performed on the first text feature and the spliced ​​content feature, including: cross-attention processing is performed on the first sub-feature of the label text fragment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature; cross-attention processing is performed on the second sub-feature of the last starting mark in the first text feature and the first content feature in the spliced ​​content feature.

[0149] Based on this, in the process of cross-attention calculation, the first sub-feature corresponding to each label text segment is only cross-attention calculated with the corresponding second content feature, and not with other second content features, so as to ensure that the attention weight between each label text segment and other second content features is zero, and the accuracy of the context information carried in the cross-attention processing result is ensured, so that the text generation model can learn how to generate content labels based on the context information provided by the reference label and the second content feature. Finally, the second sub-feature corresponding to the last start mark in the first text feature is cross-attention processed with the first content feature in the spliced ​​content feature to obtain the cross-attention processing result corresponding to the content to be identified, and output it to the text generation model, so that the text generation model generates the content label of the content to be identified.

[0150] Specifically, in the first text feature, the first sub-feature corresponding to each label text segment includes several matrix rows in the first text feature. The spliced ​​content feature is obtained by splicing each second content feature and the first content feature along the direction of the matrix column, and each second content feature and the first content feature include several matrix columns in the spliced ​​content feature. Since the start mark and the end mark are added to both ends of each reference label in the prompt text, the first sub-features corresponding to each label text segment in the first text feature can be separated based on the end mark. For example, the first end mark indicates that the first 4 matrix rows in the first text feature constitute the first sub-feature corresponding to the first text label segment. At the same time, the position of the second content feature corresponding to each first sub-feature in the spliced ​​content feature can be determined based on the start mark. When performing cross-attention processing, the first sub-feature and the second sub-feature corresponding to each label text segment are determined from the first text feature based on the end mark, and the second content feature corresponding to the first sub-feature is determined from the spliced ​​content feature based on the start mark, and then the first sub-feature and the corresponding second content feature are cross-attention processed. The process of cross-attention processing of the first sub-feature and the corresponding second content feature will be described later and will not be repeated here.

[0151] Based on the last end tag, the second sub-feature corresponding to the last start tag of the prompt text is determined from the first text feature. The last start tag indicates the position of the first content feature in the spliced ​​content feature. Based on this, the first content feature can be extracted from the spliced ​​content feature based on the last start tag, and then the second sub-feature and the first content feature are cross-attention processed.

[0152] In a possible implementation, cross-attention processing is performed on a first sub-feature of a label text segment in a first text feature and a second content feature corresponding to the first sub-feature in a spliced ​​content feature, including: determining a query matrix according to the first text feature, determining a key matrix according to the spliced ​​content feature, and obtaining a target matrix according to the product of the query matrix and the transposed key matrix; masking the target matrix based on a mask matrix, and normalizing the masked target matrix to obtain a cross-attention weight matrix, wherein the mask matrix is ​​used to shield matrix elements in the target matrix except for target elements, and the target elements are obtained by multiplying the first sub-feature of the label text segment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature; determining a value matrix according to the second content feature, and obtaining a cross-attention processing result according to the product of the cross-attention weight matrix and the value matrix.

[0153] Specifically, when performing cross-attention processing on the first text feature and the spliced ​​content feature, the first text feature can be used as a query matrix, and the spliced ​​content feature can be used as a key matrix. The query matrix and the transposed key matrix are subjected to matrix multiplication to obtain a target matrix, which is used as an attention score matrix between each feature of the query matrix and each feature of the key matrix. Each element in the target matrix is ​​used as an attention score, which represents the correlation between the feature corresponding to a matrix row of the query matrix and the feature corresponding to a matrix column in the transposed key matrix, that is, the correlation between the feature corresponding to a matrix row in the first text feature and the feature corresponding to a matrix row in the spliced ​​content feature. For example, the attention score of the i-th row and j-th column of the target matrix is ​​the correlation between the feature corresponding to the i-th matrix row in the first text feature and the feature corresponding to the j-th matrix column in the transposed spliced ​​content matrix. Since each label text segment is only associated with the corresponding second content feature, but not with other features in the spliced ​​content feature, and the attention weight between two unrelated features should be zero, for example, the label text segment A and the second content feature Correspondingly, the label text segment B and the second content feature Correspondingly, the label text segment A and the second content feature Not related, label text segment B and second content feature When calculating the attention weight, the sub-feature corresponding to the label text segment A in the first text feature should be equal to the sub-feature corresponding to the second content feature. The attention weight between them is zero, and the sub-feature corresponding to the label text segment B in the first text feature is consistent with the second content feature. The attention weight between is also zero. Based on this, after obtaining the target matrix, the attention scores obtained based on the first sub-feature and the second content feature corresponding to the first sub-feature are determined as target elements, and the other elements in the target matrix except the target element are masked by the mask matrix, so as to mask the attention scores between the first text feature and the two unrelated features in the spliced ​​content feature, wherein the mask operation refers to setting the attention scores of the masked positions to negative infinity.

[0154] Specifically, the target element in the target matrix can be determined based on the position of the first sub-feature corresponding to each label text segment in the first text feature, and the position of the first content feature and the second content feature corresponding to each first sub-feature in the spliced ​​content feature, and the mask matrix can be determined based on the position of the target element in the target matrix, and then the target matrix is ​​masked by the mask matrix. It can be understood that the mask matrix is ​​a matrix with the same shape as the target matrix, and takes negative infinity at the mask position and 1 at the non-mask position, where the non-mask position in the mask matrix is ​​the same as the position of the target element in the target matrix, and the attention score matrix is ​​masked by performing a dot product of the mask matrix and the attention score matrix. For example, for the attention score of the i-th row and j-th column in the attention score matrix , if and only if the label text segment corresponding to the i-th row of the first text feature corresponds to the second content feature corresponding to the j-th column of the concatenated content feature, Determine as the target element, and determine the i-th row and j-th column in the mask matrix as the non-mask position.

[0155] For example, refer to Figure 8 , the first text feature includes four first sub-features q1 to q4 and a second sub-feature q5, q1 to q5 respectively include n1, n2, n3, n4, n5 matrix rows sequentially spliced ​​in the first text feature, the corresponding spliced ​​content feature includes four second content features corresponding to q1 to q4, namely k1 to k4, and the first content feature k5, k1 to k1 respectively include m1, m2, m3, m4, m5 matrix columns sequentially spliced ​​in the spliced ​​content feature, based on this, in the first n matrix rows of the mask matrix, the first k1 columns are all non-masked positions, and the k1+1th column to the last column are all masked positions. Similarly, the mask positions and non-masked positions in the mask matrix can be determined based on the positions of each first sub-feature in the first text feature and the positions of the second content features corresponding to the first sub-feature in the spliced ​​content matrix, thereby obtaining the mask matrix. Afterwards, the first text feature and the spliced ​​content feature are matrix multiplied to obtain the target matrix. The target matrix can be regarded as several matrix blocks, where each matrix block is obtained by multiplying a first sub-feature and a second content feature. For example, the matrix block q1k1 is obtained by multiplying the first sub-feature q1 and the second content feature k1, where the matrix block q1k1 is located in the first m1 matrix columns of the first n1 matrix rows of the target matrix. It is not difficult to find that in the target matrix, the position of the matrix block obtained by multiplying the first sub-feature and the corresponding second content feature coincides with the non-masked position in the mask feature. Based on this, the target matrix can be masked after performing a dot product between the target matrix and the mask matrix. In the masked target matrix, only the matrix block obtained by multiplying the first sub-feature and the corresponding second content feature has a non-zero attention score. For example, in Figure 8 In , after the target matrix is ​​masked based on the mask feature, only matrix block q1k1, matrix block q2k2, matrix block q3k3, matrix block q4k4, and matrix block q5k5 are not masked, and the attention scores of the remaining positions are masked.

[0156] After masking the target matrix, the masked target matrix is ​​subjected to exponential normalization. Since the process of exponential normalization is to use the attention score of the corresponding position as the exponent of the natural base e, and then normalize each matrix row of the target matrix, = 0, so after the exponential normalization, the attention weight of the mask position is zero, which makes the attention weight between two unrelated features zero. For example, refer to Figure 8 , after exponential normalization of the masked target matrix, in the obtained attention weight matrix, only S_11, S_22, S_33, S_44, and S_55 corresponding to the matrix blocks q1k1, q2k2, q3k3, q4k4, and q5k5 are not zero, and S_11 represents the attention weight between q1 and k1, and similarly S_22 represents the attention weight between q2 and k2, that is, in the attention weight, for each first sub-feature and second sub-feature, only the attention weight between the corresponding second content feature or the first content feature is not zero, and the attention weights between other features are all zero. At this time, the attention weight matrix accurately reflects the correlation between each reference label and the corresponding second content feature. Afterwards, the concatenated content matrix is ​​used as the value matrix, and the attention weight matrix and the value matrix are matrix multiplied to obtain the cross attention processing result.

[0157] In another possible implementation, cross-attention processing is performed on the first sub-feature of the label text fragment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature, including: determining a query matrix based on the first sub-feature of the label text fragment in the first text feature, masking the spliced ​​content feature based on a mask matrix, and determining a key matrix based on the masked spliced ​​content feature, and obtaining a target matrix based on the product of the query matrix and the transposed key matrix, wherein the mask matrix is ​​used to shield other features in the spliced ​​content feature except the second content feature corresponding to the first sub-feature; normalizing the target matrix to obtain a cross-attention weight matrix; determining a value matrix based on the second content feature corresponding to the first sub-feature, and obtaining a cross-attention processing result based on the product of the cross-attention weight matrix and the value matrix.

[0158] Specifically, refer to Fig. 9 , when calculating the attention score corresponding to the first sub-feature q1, the other features in the spliced ​​content features except the second content feature k1 corresponding to the first sub-feature q1 are masked through the mask matrix (the value of the mask position is set to negative infinity), and the masked spliced ​​content features are used as the key matrix. The query matrix and the key matrix are matrix multiplied to obtain the attention score matrix corresponding to q1. Similarly, when calculating the attention score corresponding to the second sub-feature q2, the other features in the spliced ​​content features except k2 are masked, and the masked spliced ​​content features are used as the key matrix and matrix multiplied with q2. In this way, in the target matrix, the cross-attention scores between the first sub-feature and the masked features are all negative infinity, and only the cross-attention score between the first sub-feature and the corresponding second content feature is not negative infinity.

[0159] Exemplarily, the first sub-feature corresponding to the label text segment A includes the first N matrix rows in the first text feature, and the second content feature corresponding to the label text segment A includes the first K matrix columns in the spliced ​​content feature. When calculating the attention weight of the first sub-feature corresponding to the label text segment A, the K+1th to the last column of the spliced ​​content feature are masked, that is, the values ​​of the K+1th to the last column of the spliced ​​content feature are set to negative infinity. The masked spliced ​​content feature can actually be regarded as the second content feature corresponding to the first sub-feature. Then, the first sub-feature corresponding to the label text segment A (that is, the first N matrix rows in the first text feature) is matrix multiplied with the corresponding second content feature (that is, the masked spliced ​​content feature) to obtain the corresponding attention score matrix. Among the first N matrix rows of the attention score matrix, only the attention scores of the first K matrix columns are not negative infinity, and the attention scores of the K+1th to the last column are all negative infinity, that is, only the attention score between the first sub-feature and the corresponding second content feature is not negative infinity, and the attention scores between the first sub-feature and other features are all negative infinity.

[0160] After that, the attention score matrix is ​​subjected to exponential normalization. In the process of exponential normalization, the attention score is used as the exponent of the natural base e. When the attention score is negative infinity, Based on this, after exponential normalization, the attention weights between the first sub-feature and other features except the corresponding second content feature are all zero, and only the attention weight between the first sub-feature and the corresponding second content feature is not zero. Thus, an accurate attention weight matrix is ​​obtained. Then, the concatenated content matrix is ​​used as the value matrix, and the cross-attention processing result is obtained based on the product of the attention weight matrix and the value matrix.

[0161] Similarly, instead of extracting the first content feature from the spliced ​​content feature, all second content features in the spliced ​​content feature may be masked, and then cross-attention processing may be performed on the second sub-feature and the masked spliced ​​content feature.

[0162] Step 203: Adjust the cross-attention processing result based on the first gating parameter to obtain the target text feature.

[0163] The first gating parameter is obtained by freezing the parameters of the text generation model and then training. The first gating parameter is used to adjust the output of the cross-attention mechanism to the parameters required for the target text feature, and the target text feature is a feature matrix used to enable the text generation model to generate a content label corresponding to the content to be identified. The training process of the first gating parameter will be described later and will not be repeated here.

[0164] Specifically, the target text feature can be obtained by multiplying the first gating parameter and the cross-attention processing result, thereby adjusting the cross-attention processing result based on the first gating parameter.

[0165] In one possible implementation, the cross-attention processing result is adjusted based on the first gating parameter to obtain the target text feature, including: adjusting the cross-attention processing result based on the first gating parameter, summing the adjusted cross-attention processing result and the first text feature to obtain the second text feature; mapping the second text feature, and adjusting the mapping result based on the second gating parameter to obtain the target text feature.

[0166] The second gating parameter is obtained by freezing the parameters of the text generation model and then training. The second gating parameter is used to adjust the mapping result to the parameter required for the target text feature. The training process of the second gating parameter will be described later and will not be repeated here.

[0167] Based on this, the cross-attention processing result is first adjusted by the first gating parameter, and the adjusted cross-attention processing result is summed with the first text feature to obtain the second text feature, and then the second text feature is nonlinearly mapped, thereby introducing nonlinearity into the second text feature, so that the input of the text generation model can have a richer expression form. At the same time, the mapping result of the nonlinear mapping is adjusted by the second gating parameter, which not only enriches the input of the text generation model, but also ensures that the target text features input to the text generation model can be accurately encoded by the text generation model as content labels of the content to be identified.

[0168] Specifically, refer to Fig.10 , add a gating unit corresponding to the first gating parameter at the output of the cross-attention mechanism (shown as the first gating parameter in the figure), so as to adjust the result of the cross-attention processing based on the first gating parameter. At the same time, by adding a residual connection between the input and output of the cross-attention mechanism, the adjusted cross-attention processing result and the first text feature of the input cross-attention mechanism are summed to obtain the second text feature. In this way, even if the network layer is too deep, the input first text feature can be passed to the deeper level of the model. Specifically, the process can be expressed as:

[0169] ; (1)

[0170] in, represents a second text feature; Representing the query matrix used for cross attention calculation can be directly the first text feature; Respectively represent the key matrix and value matrix used for cross attention calculation, which can be directly concatenated content features; () represents the cross attention processing function; Represents the first gating parameter.

[0171] After obtaining the second text feature, nonlinear mapping is performed on the second text feature to obtain a mapping result. Specifically, nonlinear mapping can be performed through a feedforward neural network, which is composed of two linear layers and an activation function. The first linear layer includes a first linear transformation matrix, which is used to map the second text feature to a higher dimension. For example, the first linear transformation matrix is ​​an h*4h matrix, where h is the dimension of the second text feature. After passing through the first linear transformation matrix, the dimension of the second text feature is expanded from h to 4h; then, the second text feature with expanded dimension is activated through an activation function, and the activation function can be a ReLU activation function, thereby introducing nonlinearity into the second text feature; the activated second text feature passes through a second linear layer, and the second linear layer is used to compress the second text feature back to the original dimension. For example, referring to Fig.10 , the linear transformation matrix of the first linear layer is an h*4h matrix, which is used to expand the dimension of the second text feature from h to 4h, and the transformation matrix of the second linear layer is a 4h*h matrix, which is used to compress the dimension of the second text feature from 4h back to h, so that the output dimension and input dimension of the feedforward neural network are consistent.

[0172] After mapping the second text feature, nonlinearity is introduced into the mapping result, so that the input of the text generation model can have a more complex expression. A gating unit corresponding to the second gating parameter is added to the output end of the feedforward neural network (shown as the second gating parameter in the figure). Before the attention result after the introduction of nonlinearity is input into the text generation model, the mapping result is adjusted by the second gating parameter. Specifically, the mapping result can be multiplied by the second gating parameter, so that the mapping result is adjusted by the second gating parameter. In addition, the second text feature and the adjusted mapping result can be added as the target text feature through the residual connection, so that the input first text feature can be passed to a deeper level of the model. Specifically, the process of determining the target text feature based on the second text feature can be expressed as the following formula:

[0173] ; (2)

[0174] in, represents the target text features, represents a second text feature; represents the second gating parameter; Indicates the mapping result.

[0175] In a possible implementation, each encoding layer corresponds to its own first gating parameter and its own second gating parameter. Before adjusting the result of the cross-attention processing based on the first gating parameter, the content label generation method also includes: obtaining sample content, freezing the parameters of the text generation model, initializing each first gating parameter and each second gating parameter to zero; and training each first gating parameter and each second gating parameter based on the sample content.

[0176] Based on this, by freezing the parameters of the text generation model, and initializing the first gating parameter and the second gating parameter to zero, and then training the first gating parameter and the second gating parameter based on the sample content, the first gating parameter and the second gating parameter are continuously optimized, and the result of the cross-attention processing is adjusted based on the optimized first gating parameter and the second gating parameter and input into the text generation model, so that the text generation model generates a corresponding label based on the adjusted cross-attention processing result, and then calculates the loss value based on the generated label and the real label in the sample content, and continuously optimizes each first gating parameter and the second gating parameter based on the loss value, so that the first gating parameter and the second gating parameter can accurately adjust the cross-attention processing result to the text feature corresponding to the real label. In this process, only the first gating parameter and the second gating parameter need to be trained, so that the first gating parameter and the second gating parameter can adjust the cross-attention processing result to the target text feature corresponding to the content label, and the entire training process is a one-stage process, thereby improving the efficiency of model training, thereby improving the efficiency of content label generation.

[0177] Specifically, the sample content includes multiple groups of sample pairs consisting of multimodal sample content and corresponding sample labels. During the training process, the parameters of the text generation model are frozen so that the parameters of the text generation model do not change during the training process. The first gating parameter and the second gating parameter are then trained based on the sample content. During the training process, the cross-attention processing result output from the cross-attention mechanism to the text generation model is adjusted based on the first gating parameter and the second gating parameter, so that the text generation model generates labels based on the adjusted cross-attention processing result, determines the loss value based on the label generated by the text generation model and the real sample label, and optimizes the first gating parameter and the second gating parameter based on the loss value.

[0178] Specifically, refer to Fig.11 , when training the first gating parameter and the second gating parameter, first extract the modal features of the multimodal sample content in at least two modes, and fuse them into sample content features corresponding to the multimodal sample content, and at the same time construct a prompt text and generate the first sample text features based on the prompt text; use the first sample text features as a query matrix, and use the sample content features as a key matrix and a value matrix to perform cross attention processing; adjust the result of the cross attention processing based on the first gating parameter, and add the adjusted cross attention processing result and the first sample text feature through a residual connection to obtain the second sample text feature; map the second sample text feature, and based on the second gating parameter Parameter adjustment maps the result to obtain sample target text features; the sample target text features are input into the text generation model to generate content labels, loss values ​​are calculated based on the sample labels generated by the text generation model and the real sample labels corresponding to the multimodal sample content, back propagation is performed based on the loss values, and the first gating parameters and the second gating parameters are optimized during the back propagation process until the trained first gating parameters and the second gating parameters can adjust the cross-attention processing results to the sample target text features corresponding to the real sample labels, so that the text generation model can generate labels consistent with the real sample labels based on the adjusted sample target text features.

[0179] It should be noted that in this embodiment, since the first gating parameter and the second gating parameter are both initialized to zero before training, it can be seen from the above formulas (1) and (2) that the first text feature will be directly input into the text generation model at this time, and the text generation model will directly generate a sample video label based on the first text feature, and then calculate the loss value based on the generated sample video label and the real label of the sample video, thereby determining the loss value when the prompt text is directly input into the text generation model. It can be understood that when the first gating parameter and the second gating parameter are adjusted, the loss value between the generated label and the real label is greater than the loss value when the cross-attention processing result is not adjusted, which means that the adjustment direction of the first gating parameter and the second gating parameter is incorrect; otherwise, it means that the adjustment direction of the first gating parameter and the second gating parameter is correct. Therefore, by initializing the first gating parameter and the second gating parameter to zero before training, at this time, referring again to Fig.10 , the processing module before the text generation model is degenerated into a unit mapping, that is, the input first text feature still outputs the first text feature after the cross-attention mechanism and the feedforward neural network processing, which can better determine the adjustment direction of the first gating parameter and the second gating parameter, thereby improving the training efficiency of the first gating parameter and the second gating parameter.

[0180] In addition, since the parameters of the text generation model are frozen during the training of the first gating parameter and the second gating parameter, that is, this embodiment actually adjusts the input of the text generation model to achieve content label generation by training the first gating parameter and the second gating parameter to adjust the cross-attention processing result, rather than adjusting the parameters of the text generation model to enable the text generation model to learn how to generate content labels based on the original cross-attention processing result. Therefore, the content label generation method proposed in this embodiment can be flexibly transplanted to various text generation models.

[0181] Step 204: Calling the text generation model to generate text based on the target text features to obtain a content label of the content to be identified.

[0182] Specifically, the text generation model can be a large language model, such as ChatGLM, BLOOM, etc. The text generation model is provided with at least one decoder. After the target text features are input into the text generation model, the text generation model decodes the target text features through the decoder based on autoregression, thereby generating a content label for the content to be identified.

[0183] In a possible implementation, a text generation model is provided with a plurality of encoding layers cascaded in sequence, and the text generation model is called to generate text based on target text features to obtain a content label of the content to be identified, including: encoding the target text features based on a plurality of encoding layers, generating text based on the encoding results, and obtaining a content label of the content to be identified; for any encoding layer except the last encoding layer, performing cross-attention processing on the output of the current encoding layer and the first content feature, adjusting the cross-attention processing result based on a first gating parameter, summing the adjusted cross-attention processing result and the output of the current encoding layer, mapping the features obtained after the summation, adjusting the mapping result based on a second gating parameter, and then inputting the features into the next encoding layer for encoding.

[0184] Based on this, the target text features are encoded layer by layer through multiple cascaded encoding layers, and content labels are generated layer by layer based on the encoding results, so as to capture the semantic information of the target text features at different levels and generate content labels more accurately.

[0185] Specifically, refer to Fig.12 The text generation model can be a large language model, including multiple cascaded encoding layers, each encoding layer can be composed of a self-attention module and a feedforward neural network, each encoding layer is correspondingly configured with a gated cross-attention module, the gated cross-attention module includes a cross-attention mechanism, a first gating parameter, a feedforward neural network and a second gating parameter, wherein the parameters of the encoding layer are frozen, and the parameters of each gated cross-attention module are trainable (that is, the first gating parameter and the second gating parameter are trainable).

[0186] For the first gated cross-attention module, the first text feature is used as the query matrix, and the first content feature is used as the key matrix and the value matrix for cross-attention processing. The cross-attention result is adjusted by the first gating parameter of the current gated cross-attention module, and then based on a residual connection, the adjusted cross-attention processing result and the first text feature are summed. The features obtained after the summation are nonlinearly mapped through the feedforward neural network of the current gated cross-attention module, the mapping result is adjusted based on the second gating parameter, and then based on a residual connection, the target text feature corresponding to the first encoding layer is obtained.

[0187] For the nth gated cross-attention module, the output of the previous encoding layer is used as the query matrix, the first content feature is used as the key matrix and the value matrix, and the cross-attention processing is performed, and the cross-attention processing result of the current gated cross-attention module is adjusted by the first gate parameter of the current gated cross-attention module, and the adjusted cross-attention processing result and the output of the previous encoding layer are summed through a residual connection, and then the summation result is nonlinearly mapped based on the feedforward neural network of the current gated cross-attention module, and the mapping result is adjusted by the second gate parameter of the current gated cross-attention module to obtain the target text feature corresponding to the nth encoding layer, and the target text feature corresponding to the nth encoding layer is input into the nth encoding layer for encoding, and the encoding result is decoded to obtain the content label. In this way, since each gated cross-attention module uses the output of the previous encoding layer as the query matrix and then performs cross-attention processing with the first content feature, the cross-attention processing result of each gated cross-attention module can capture deeper semantic information than the previous gated cross-attention module, thereby more accurately generating the content label of the content to be identified.

[0188] Reference Fig.13 , Fig.13 This is an optional overall flow chart of the content tag generation method provided in the embodiment of the present disclosure, which fully describes the content tag generation method in the embodiment of the present disclosure in general.

[0189] First, the parameters of the text generation model are frozen, and the first gating parameter and the second gating parameter are trained through the sample content. The modal features of the sample multimodal content in each mode are extracted and fused into the sample content features. At the same time, the prompt text is constructed, and the sample text features are generated based on the prompt text. The sample text features are used as the query matrix, and the sample content features are used as the key matrix and the value matrix. The query matrix and the key matrix are cross-attention processed to obtain the cross-attention processing results corresponding to the sample multimodal content, and the cross-attention processing results are adjusted through the first gating parameter. The adjusted cross-attention processing results and the sample text features are summed, and the summation results are nonlinearly mapped. The mapping results are adjusted through the second gating parameter to obtain the sample target text features. The sample target text features are input into the text generation model with frozen parameters for content label generation, and the loss value is calculated based on the sample labels generated by the text generation model and the real sample labels. Back propagation is performed based on the loss value to optimize the first gating parameter and the second gating parameter. Then, the sample content features and sample text features are cross-attended again, and the cross-attention processing results are adjusted again using the optimized first gating parameters. The adjusted cross-attention processing results and sample text features are summed, and the summation results are mapped. The mapping results are adjusted using the optimized second gating parameters to obtain new sample target text features and input them into the text generation model for content label generation, until the text generation model can generate real sample labels based on the sample target text features obtained by adjusting the cross-attention processing results. Thus, the trained first gating parameters and second gating parameters are obtained.

[0190] When it is necessary to generate content tags for the video to be identified, first, obtain the video to be identified uploaded by the object, divide the video to be identified into multiple segments, extract a frame in the middle of each segment, obtain multiple video frames of the video to be identified, encode the video frame by the encoder corresponding to the video mode, obtain multiple video frame features, and splice the multiple video frame features to obtain the modal features of the video to be identified in the video mode. Extract the video title of the video to be identified, and identify the video screen of the video to be identified by optical character recognition technology to obtain the text in the video screen; identify the audio of the video to be identified by automatic speech recognition technology to obtain the text in the video audio; splice the video title, the text in the recognition screen, and the text in the video audio to obtain the information of the video to be identified in the text mode, and encode the information of the video to be identified in the text mode to obtain the modal features of the video to be identified in the text mode; splice the modal features of the video to be identified in the video mode and the modal features in the text mode to obtain the multimodal fusion features of the video to be identified, that is, the first content feature.

[0191] Next, multiple video frame features of the video to be identified are average pooled to obtain visual features of the same dimension as the modal features of the video to be identified in the text mode, the visual features and the modal features of the video to be identified in the text mode are average pooled to obtain the first retrieval feature of the video to be identified, the similarity between the first retrieval feature and the retrieval features of each reference video in the retrieval library is calculated, the reference videos corresponding to the several retrieval features with the highest similarity are determined as reference videos similar to the video to be identified, and the second content features of the reference video and the reference label associated with the second content features are obtained from the retrieval library.

[0192] Next, the second content feature and the first content feature are concatenated to obtain a concatenated content feature; a start tag and an end tag are added to both ends of the reference tag, and a start tag is added after the last end tag to obtain a prompt text, and the prompt text is encoded to generate a first text feature. The first text feature is used as a query matrix, the concatenated content feature is used as a key matrix, and the query matrix and the transposed key matrix are multiplied to obtain a target matrix; based on the position of each first sub-feature in the first text feature, and the position of the second content feature corresponding to the first sub-feature in the concatenated content feature, a mask matrix is ​​generated, and the target matrix is ​​masked based on the mask matrix, and the elements in the target matrix except the target elements obtained by multiplying each sub-feature with the corresponding second content feature are masked, and the elements at the mask position in the target matrix are set to negative infinity; the masked target matrix is ​​subjected to exponential normalization processing, and the attention weights between each first sub-feature and the corresponding second content feature, as well as the second sub-feature corresponding to the video to be identified and the first content feature are determined to obtain an attention weight matrix. The concatenated content features are taken as the value matrix, and the cross attention processing result is obtained based on the product of the attention weight matrix and the value matrix.

[0193] Next, the cross-attention processing result is adjusted based on the first gating parameter, and the adjusted cross-attention processing result and the first text feature are summed to obtain the second text feature; the second text feature is nonlinearly mapped, and the mapping result is adjusted based on the second gating parameter to obtain the target text feature, the target text feature is input into the first encoding layer of the text generation model, the target text feature is encoded in the first encoding layer, text is generated based on the encoding result, and the output of the first encoding layer is obtained.

[0194] Next, for any coding layer except the last coding layer of the text generation model, cross-attention processing is performed on the output of the current coding layer and the spliced ​​content features, the cross-attention processing result is adjusted based on the first gating parameter of the current coding layer, and the adjusted cross-attention processing result is summed with the output of the current coding layer, and the summed result is mapped, the mapping result is adjusted based on the second gating parameter of the current coding layer, and the adjusted mapping result is input into the next coding layer for encoding, until the encoding result of the last coding layer of the text generation model is obtained, and the content label of the video to be identified is obtained.

[0195] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.

[0196] Exemplarily, the content tag generation method provided by the embodiments of the present disclosure can be applied to different scenarios, including but not limited to content classification, content push, content distribution and other scenarios.

[0197] Reference Fig.14 , Fig.14 The content tag generation device 1400 is a schematic diagram of the structure of the content tag generation device provided in the embodiment of the present disclosure. The content tag generation device 1400 includes:

[0198] The present disclosure embodiment provides a content tag generating device 1400, including:

[0199] The content feature extraction module 1401 is used to obtain the content to be identified, extract the modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain the first content feature of the content to be identified;

[0200] A cross attention module 1402 is used to obtain a prompt text, extract a first text feature of the prompt text, and perform cross attention processing on the first text feature and the first content feature, wherein the prompt text is used to prompt the text generation model to generate a label for the content to be identified;

[0201] A gating module 1403 is used to adjust the cross attention processing result based on a first gating parameter to obtain a target text feature, wherein the first gating parameter is obtained by training after freezing the parameters of the text generation model;

[0202] The generation module 1404 is used to call the text generation model to generate text based on the target text features to obtain the content label of the content to be identified.

[0203] Further, the cross attention processing result is adjusted based on the first gating parameter to obtain the target text feature. The gating module 1403 is used to:

[0204] Adjusting the cross attention processing result based on the first gating parameter, and summing the adjusted cross attention processing result with the first text feature to obtain a second text feature;

[0205] The second text feature is mapped, and the mapping result is adjusted based on the second gating parameter to obtain the target text feature, wherein the second gating parameter is obtained by training after freezing the parameters of the text generation model.

[0206] Furthermore, the text generation model is provided with a plurality of sequentially cascaded encoding layers, and the text generation model is called to generate text based on the target text features to obtain the content label of the content to be identified. The generation module 1404 is used to:

[0207] Encode the target text features based on multiple encoding layers, generate text based on the encoding results, and obtain the content label of the content to be identified;

[0208] Among them, the target text features are the input of the first encoding layer;

[0209] For any coding layer except the last one, cross-attention processing is performed on the output of the current coding layer and the first content feature, the cross-attention processing result is adjusted based on the first gating parameter, the adjusted cross-attention processing result and the output of the current coding layer are summed, the features obtained after the summation are mapped, the mapping result is adjusted based on the second gating parameter, and then input into the next coding layer for encoding.

[0210] Furthermore, the content label generating device 1400 further includes a training module. Each coding layer corresponds to its own first gating parameter and its own second gating parameter. Before adjusting the result of the cross attention processing based on the first gating parameter, the training module is used to:

[0211] Obtain sample content, freeze parameters of the text generation model, and initialize each first gating parameter and each second gating parameter to zero;

[0212] The first gating parameters and the second gating parameters are trained based on the sample content.

[0213] Further, the prompt text is obtained, the first text feature of the prompt text is extracted, and cross-attention processing is performed on the first text feature and the first content feature. The cross-attention module 1402 is used to:

[0214] Retrieving a second content feature similar to the first content feature and a reference tag associated with the second content feature, wherein the reference tag is a tag of the reference content, the second content feature is obtained by fusing features of at least two modalities of the reference content, and the modality of the feature fused by the second content feature is the same as the modality of the feature fused by the first content feature;

[0215] Constructing a prompt text based on the reference label and extracting a first text feature of the prompt text;

[0216] The second content feature is concatenated with the first content feature to obtain a concatenated content feature, and cross-attention processing is performed on the first text feature and the concatenated content feature.

[0217] Further, based on the reference tag, the prompt text is constructed, and the cross attention module 1402 is used to:

[0218] The start tag and the end tag are respectively spliced ​​at both ends of the reference tag to obtain a tag text segment corresponding to the reference tag;

[0219] Add the start tag after the last label text segment to get the prompt text.

[0220] Further, cross attention processing is performed on the first text feature and the concatenated content feature, and the cross attention module 1402 is used to:

[0221] Performing cross-attention processing on a first sub-feature of the label text segment in the first text feature and a second content feature corresponding to the first sub-feature in the concatenated content feature;

[0222] Cross-attention processing is performed on the second sub-feature of the last start tag in the first text feature and the first content feature in the concatenated content feature.

[0223] Further, cross attention processing is performed on the first sub-feature of the label text segment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature. The cross attention module 1402 is used to:

[0224] Determine a query matrix according to the first text feature, determine a key matrix according to the concatenated content feature, and obtain a target matrix according to the product of the query matrix and the transposed key matrix;

[0225] The target matrix is ​​masked based on the mask matrix, and the masked target matrix is ​​normalized to obtain a cross attention weight matrix, wherein the mask matrix is ​​used to shield matrix elements other than the target element in the target matrix, and the target element is obtained by multiplying the first sub-feature of the label text segment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature;

[0226] A value matrix is ​​determined according to the second content feature, and a cross-attention processing result is obtained according to the product of the cross-attention weight matrix and the value matrix.

[0227] Further, a second content feature similar to the first content feature and a reference tag associated with the second content feature are retrieved, and the cross attention module 1402 is used to:

[0228] Acquire multiple reference contents and reference tags of each reference content, fuse features of at least two modes of each reference content, and obtain second content features of each reference content;

[0229] Each second content feature is associated with a corresponding reference tag and stored in a search library, and a second content feature similar to the first content feature and a reference tag associated with the second content feature are retrieved from the search library.

[0230] Furthermore, the reference content is a reference video, and each second content feature is associated with a corresponding reference tag and stored in a search library. The cross attention module 1402 is used to:

[0231] For each reference video, average pooling is performed on the modal features of the reference video in the video mode to obtain visual features of the same dimension as the modal features of the reference video in the text mode;

[0232] Perform average pooling on the visual features and the modal features of the reference video in the text mode to obtain the retrieval features of each reference video;

[0233] Each search feature, second content feature and corresponding reference tag are associated and stored in the search library.

[0234] Furthermore, the content to be identified is a video to be identified, and modal features of at least two modalities of the content to be identified are extracted. The content feature extraction module 1401 is used to:

[0235] Encode each video frame of the video to be identified respectively to obtain the modal features of the video to be identified in the video modality;

[0236] The video text is extracted from the video to be identified, and the video text is encoded to obtain the modal features of the video to be identified in the text mode.

[0237] The electronic device for executing the above content tag generation method provided by the embodiment of the present disclosure may be a terminal. Fig.15 , Fig.15 This is a partial structural block diagram of a terminal provided in an embodiment of the present disclosure, and the terminal includes: a camera assembly 1510, a first memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a first processor 1580, and a first power supply 1590. Those skilled in the art can understand that Fig.15 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0238] The camera assembly 1510 can be used to capture images or videos. Optionally, the camera assembly 1510 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting, and the VR (Virtual Reality) shooting function or other fusion shooting functions.

[0239] The first memory 1520 may be used to store software programs and modules. The first processor 1580 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the first memory 1520 .

[0240] The input unit 1530 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532 .

[0241] The display unit 1540 may be used to display input information or provided information and various menus of the terminal. The display unit 1540 may include a display panel 1541 .

[0242] The audio circuit 1560 , the speaker 1561 , and the microphone 1562 may provide an audio interface.

[0243] The first power source 1590 may be alternating current, direct current, a disposable battery, or a rechargeable battery.

[0244] The number of sensors 1550 may be one or more, and the one or more sensors 1550 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:

[0245] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The first processor 1580 can control the display unit 1540 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting game or user motion data.

[0246] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The first processor 1580 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0247] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1540. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the first processor 1580 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1540, the first processor 1580 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1540. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0248] The optical sensor is used to collect the ambient light intensity. In one embodiment, the first processor 1580 can control the display brightness of the display unit 1540 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1540 is increased; when the ambient light intensity is low, the display brightness of the display unit 1540 is decreased. In another embodiment, the first processor 1580 can also dynamically adjust the shooting parameters of the camera assembly 1510 according to the ambient light intensity collected by the optical sensor.

[0249] In this embodiment, the first processor 1580 included in the terminal can execute the content tag generating method of the previous embodiment.

[0250] The electronic device for executing the above-mentioned content tag generation method provided in the embodiment of the present disclosure may also be a server. Fig.16 , Fig.16 Partial structural block diagram of a server provided in an embodiment of the present disclosure. The server may have relatively large differences due to different configurations or performances, and may include one or more second processors 1610 and a second memory 1630, and one or more storage media 1640 (e.g., one or more mass storage devices) storing application programs 1643 or data 1642. Among them, the second memory 1630 and the storage medium 1640 may be short-term storage or persistent storage. The program stored in the storage medium 1640 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the second processor 1610 may be configured to communicate with the storage medium 1640 to execute a series of instruction operations in the storage medium 1640 on the server.

[0251] The server may also include one or more second power supplies 1620, one or more wired or wireless network interfaces 1650, one or more input and output interfaces 1660, and / or one or more operating systems 1641, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0252] The second processor 1610 in the server may be configured to execute the content tag generating method.

[0253] The embodiments of the present disclosure further provide a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the content tag generation method of each of the aforementioned embodiments.

[0254] The embodiment of the present disclosure also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned content tag generation method.

[0255] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate to describe the embodiments of the present disclosure, such as being able to be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0256] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.

[0257] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood as not including the number, and above, below, within, etc. are understood as including the number.

[0258] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0259] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0260] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0261] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0262] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.

[0263] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present disclosure. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present disclosure.< / video> < / eoc> < / video> < / eoc> < / video> < / eoc> < / video> < / video> < / video> < / video>

Claims

1. A method for generating content tags, characterized in that: include: Acquire content to be identified, extract modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain a first content feature of the content to be identified; Retrieving a second content feature similar to the first content feature and a reference tag associated with the second content feature, constructing a prompt text based on the reference tag, extracting a first text feature of the prompt text, concatenating the second content feature with the first content feature to obtain a concatenated content feature, performing cross-attention processing on the first text feature and the concatenated content feature, wherein the prompt text is used to prompt a text generation model to generate a label for the content to be identified; Obtaining an adjusted cross-attention processing result based on the product of the first gating parameter and the cross-attention processing result, obtaining a second text feature based on the sum of the adjusted cross-attention processing result and the first text feature, mapping the second text feature, obtaining an adjusted mapping result based on the product of the second gating parameter and the mapping result, and obtaining a target text feature based on the sum of the adjusted mapping result and the second text feature; The text generation model is called to generate text based on the target text features to obtain a content label of the content to be identified.

2. The content tag generation method according to claim 1, characterized in that: The first gating parameter is obtained by training after freezing the parameters of the text generation model, and the second gating parameter is obtained by training after freezing the parameters of the text generation model.

3. The content tag generation method according to claim 1, characterized in that: The text generation model is provided with a plurality of sequentially cascaded encoding layers, and the calling of the text generation model to generate text based on the target text features to obtain the content label of the content to be identified includes: Encoding the target text features based on the multiple encoding layers, generating text based on the encoding results, and obtaining a content label of the content to be identified; Wherein, the target text feature is the input of the first encoding layer; For any encoding layer except the last one, cross-attention processing is performed on the output of the current encoding layer and the first content feature, the cross-attention processing result is adjusted based on the first gating parameter, the adjusted cross-attention processing result and the output of the current encoding layer are summed, the features obtained after the summation are mapped, the mapping result is adjusted based on the second gating parameter, and then input into the next encoding layer for encoding.

4. The content tag generation method according to claim 3, characterized in that: Each of the encoding layers corresponds to its own first gating parameter and its own second gating parameter. Before adjusting the cross-attention processing result based on the first gating parameter, the content label generation method further includes: Acquire sample content, freeze the parameters of the text generation model, and initialize each of the first gating parameters and each of the second gating parameters to zero; The first gating parameters and the second gating parameters are trained based on the sample content.

5. The content tag generation method according to claim 1, characterized in that: The reference tag is a tag of the reference content, the second content feature is obtained by fusing features of at least two modalities of the reference content, and the modality of the feature fused by the second content feature is the same as the modality of the feature fused by the first content feature.

6. The content tag generation method according to claim 1, characterized in that: The step of constructing a prompt text based on the reference tag includes: Connecting a start tag and an end tag to both ends of the reference tag to obtain a tag text segment corresponding to the reference tag; The start mark is spliced ​​after the last of the label text fragments to obtain the prompt text.

7. The content tag generation method according to claim 6, characterized in that: The performing cross attention processing on the first text feature and the spliced ​​content feature includes: Performing cross attention processing on a first sub-feature of the label text segment in the first text feature and a second content feature corresponding to the first sub-feature in the spliced ​​content feature; A cross attention process is performed on the second sub-feature of the last start mark in the first text feature and the first content feature in the concatenated content feature.

8. The method for generating content tags according to claim 7, characterized in that: The performing cross attention processing on the first sub-feature of the label text segment in the first text feature and the second content feature corresponding to the first sub-feature in the spliced ​​content feature includes: Determine a query matrix according to the first text feature, determine a key matrix according to the concatenated content feature, and obtain a target matrix according to the product of the query matrix and the transposed key matrix; Masking the target matrix based on a mask matrix, normalizing the masked target matrix, and obtaining a cross attention weight matrix, wherein the mask matrix is ​​used to shield matrix elements other than target elements in the target matrix, and the target element is obtained by multiplying a first sub-feature of the label text segment in the first text feature and a second content feature corresponding to the first sub-feature in the spliced ​​content feature; A value matrix is ​​determined according to the second content feature, and a cross-attention processing result is obtained according to the product of the cross-attention weight matrix and the value matrix.

9. The content tag generation method according to claim 1, characterized in that: The retrieving a second content feature similar to the first content feature and a reference tag associated with the second content feature includes: Acquire a plurality of the reference contents and reference tags of each of the reference contents, fuse features of at least two modes of each of the reference contents, and obtain the second content feature of each of the reference contents; Each of the second content features is associated with the corresponding reference tag and stored in a search library, and the second content feature similar to the first content feature and the reference tag associated with the second content feature are retrieved from the search library.

10. The content tag generation method according to claim 9, characterized in that: The reference content is a reference video, and the associating each of the second content features with the corresponding reference tag and storing it in a search library includes: For each of the reference videos, average pooling is performed on the modal features of the reference video in the video modality to obtain visual features of the same dimension as the modal features of the reference video in the text modality; Performing average pooling on the visual features and the modal features of the reference video in the text mode to obtain retrieval features of each of the reference videos; Each of the search features, the second content feature and the corresponding reference tag is associated and stored in a search library.

11. The method for generating content tags according to claim 1, characterized in that: The content to be identified is a video to be identified, and the extracting modal features of at least two modalities of the content to be identified includes: Encoding each video frame of the video to be identified respectively to obtain a modal feature of the video to be identified in a video modality; The video text in the video to be identified is extracted, the video text is encoded, and the modal features of the video to be identified in the text mode are obtained.

12. A content tag generating device, characterized in that: include: A content feature extraction module, used to obtain content to be identified, extract modal features of at least two modalities of the content to be identified, and fuse the modal features of at least two modalities to obtain a first content feature of the content to be identified; a cross attention module, configured to retrieve a second content feature similar to the first content feature and a reference tag associated with the second content feature, construct a prompt text based on the reference tag, extract a first text feature of the prompt text, concatenate the second content feature with the first content feature to obtain a concatenated content feature, and perform cross attention processing on the first text feature and the concatenated content feature, wherein the prompt text is used to prompt a text generation model to generate a label for the content to be identified; A gating module, configured to obtain an adjusted cross-attention processing result based on a product of a first gating parameter and a cross-attention processing result, obtain a second text feature based on summing the adjusted cross-attention processing result and the first text feature, map the second text feature, obtain an adjusted mapping result based on a product of a second gating parameter and the mapping result, and obtain a target text feature based on summing the adjusted mapping result and the second text feature; The generation module is used to call the text generation model to generate text based on the target text features to obtain the content label of the content to be identified.

13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the content tag generating method according to any one of claims 1 to 11 is implemented.

14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the content tag generating method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the content tag generating method according to any one of claims 1 to 11 is implemented.

Citation Information

Patent Citations

  • Image-text data matching detection method and device, equipment and medium

    CN117992800A

  • Label classification method and device, equipment, storage medium and computer program product

    CN118171149A