Contrastive Caption Neural Network

The CoCa neural network addresses the inefficiencies of multi-stage training by decoupling the language model into unimodal and multimodal decoders, achieving reduced computational overhead and carbon footprint while maintaining high performance on downstream tasks.

JP7799861B2Active Publication Date: 2026-01-15GOOGLE LLC
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2024563401
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2022-05-03
Filing Date
2023-04-28
Publication Date
2026-01-15
Estimated Expiration
2043-04-28

AI Technical Summary

Technical Problem

Existing neural networks require multiple stages of training on various data sources and modalities, leading to high computational overhead and significant carbon footprint and electricity consumption during pre-training, while achieving suboptimal performance on downstream tasks.

Method used

A contrastive caption (CoCa) neural network architecture that decouples the language model into unimodal and multimodal decoders, allowing joint pre-training with a contrastive objective and caption loss in a single stage, reducing computational overhead and carbon footprint.

Benefits of technology

Achieves state-of-the-art performance on downstream tasks with fewer FLOPs and training iterations, significantly reducing CO2 emissions and electricity usage while maintaining or improving performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007799861000004
    Figure 0007799861000004
  • Figure 0007799861000005
    Figure 0007799861000005
  • Figure 0007799861000006
    Figure 0007799861000006
Patent Text Reader

Abstract

A method, system, and apparatus including a computer program encoded on a computer storage medium for processing multimodal input using a contrast caption neural network.
Need to check novelty before this filing date? Find Prior Art

Description

[Background technology]

[0001] This specification relates to processing inputs using machine learning models.

[0002] As an example, a neural network is a machine learning model that employs one or more layers of nonlinear units to predict an output for a received input. Some neural networks include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as an input to other layers in the network, such as the next hidden layer or the output layer. Each layer of the network generates an output from the received input according to the current values ​​of its respective set of weights. Summary of the Invention

[0003] Described herein is a system, implemented as a computer program on one or more computers, that processes a multimodal input that includes both visual input, i.e., images or multiple video frames from a video, and text, using a contrastive captioning neural network. As described below, the neural network is referred to as a "contrastive captioning" neural network because the neural network can be pre-trained using both a contrastive learning loss and a caption loss jointly.

[0004] Particular embodiments of the subject matter described in this specification can be implemented to realize one or more of the following advantages.

[0005] This specification describes a contrastive caption (CoCa) neural network with an architecture that allows the neural network to be jointly pre-trained with a contrastive objective and a caption loss. Unlike standard encoder-decoder transformers, in which all decoder layers attend to the encoder output, CoCa omits cross-attention in the first set of decoder layers so that the first set of decoder layers encodes a unimodal text representation. In other words, CoCa has a decoder (a language model neural network) with multiple initial self-attention layers without any cross-attention layers. CoCa then cascades the remaining decoder layers, which cross-attend to the visual encoder, to generate a multimodal image-text representation. Thus, CoCa effectively decouples the language model neural network into a unimodal text decoder followed by a multimodal text decoder.

[0006] A contrastive loss is applied between the unimodal visual and text embeddings, along with a caption loss at the multimodal decoder output that predicts text tokens.

[0007] By sharing the same computational graph, i.e., the same neural network architecture, the two training objectives are computed efficiently with minimal computational overhead: the computation of both losses is obtained by a single forward pass through the CoCa network.

[0008] This allows neural networks to be pre-trained from scratch in a single stage on a unified format of image-text pairs, including, for example, one or more of web-scale alternative text data or annotated images, seamlessly integrating natural language supervision for representation learning.

[0009] In other words, for each training pair, the system applies both a contrast objective between the output of the visual encoder and the output of the unimodal text decoder, and a caption objective at the output of the multimodal decoder.

[0010] Furthermore, CoCa can be trained on both image annotation data and noisy image-text data by simply treating all labels as text. Thus, the generative loss on image annotation text provides a fine-grained training signal similar to the single-encoder cross-entropy loss approach, effectively subsuming all three pre-training paradigms in a single unified method.

[0011] Furthermore, as a result of CoCa's decoupled decoder (language model) design, both training losses can be efficiently considered. Because the one-way language model is trained on complete sentences using causal masking, the decoder can efficiently generate outputs for both the contrastive and generative losses in a single forward propagation (compared to two passes in bidirectional approaches).

[0012] Therefore, most of the computation is shared between the two losses, and CoCa induces minimal overhead compared to standard encoder-decoder models. In contrast, while many existing methods train model components in multiple stages on various data sources and / or modalities, CoCa is pre-trained end-to-end directly from scratch using various data sources (e.g., using both annotated images and noisy text-alternative images) by treating all labels as text for both comparison and generation purposes.

[0013] Thus, the described techniques achieve improved pre-training efficiency, i.e., they can achieve comparable or better performance than conventional techniques using fewer FLOPs and fewer training iterations.

[0014] Pre-training large multi-modal models that can be used for real-world tasks typically results in large carbon dioxide (CO2) emissions and large electricity usage, for example, because the datasets on which pre-training is performed are very large and the models have a significant number of parameters. For the reasons discussed above, by reducing the number of FLOPs that need to be performed and performing fewer training iterations, the described techniques significantly reduce the CO2 footprint of the pre-training process while also significantly reducing the amount of electricity consumed by the pre-training process.

[0015] Additionally, this pre-training scheme enables neural networks to achieve state-of-the-art performance on a wide range of downstream tasks, examples of which are described in more detail below, either through zero-shot transfer or minimal task-specific adaptation.

[0016] The details of one or more embodiments of the subject matter herein are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. [Brief explanation of the drawings]

[0017] [Figure 1] 1 shows an example of a neural network system. [Figure 2] 1 is a flow diagram of an exemplary process for training a control caption neural network. [Figure 3] 1 shows the training of a control caption neural network. [Figure 4] We show the adaptation of a control caption neural network to various downstream tasks. DETAILED DESCRIPTION OF THE INVENTION

[0018] Like reference numbers and designations in the various drawings refer to like elements.

[0019] 1 illustrates an example of a neural network system 100. Neural network system 100 is an example of a system implemented as a computer program on one or more computers at one or more locations in which the systems, components, and techniques described below may be implemented.

[0020] The system 100 is a system that processes visual input 102, i.e., multimodal input that includes both text and multiple video frames from an image or video, using a contrastive caption neural network 110.

[0021] As will be described below, neural network 110 is referred to as a "contrastive caption" neural network because neural network 110 can be pre-trained using both the contrastive learning loss and the caption loss jointly.

[0022] The control caption neural network 110 includes (i) a visual encoder neural network 112 configured to process a visual input 102 including one or more images to generate an encoded representation 114 of the visual input 102, and (ii) a language model neural network 120 including a set of initial unimodal neural network layers 122 and a set of subsequent neural network layers 126 including both cross-modal and unimodal layers.

[0023] That is, when processing a multimodal input that includes both visual input 102 and a text sequence, the representations generated by the initial layers 122 in the language model neural network 120 are unimodal representations 124 that depend only on the text sequence, while the representations generated by the subsequent layers 126 are multimodal representations that depend on both the representations 124 of the text sequence generated by the initial layers 122 and the visual input 102.

[0024] Generally, the language model neural network 120 is configured to process the current text sequence 104 to generate an output that defines new tokens 128 to be added to the current text sequence 104 .

[0025] The output, which defines the new tokens 128 to be added to the current text sequence 104, generally includes a respective score for each token in the token vocabulary. The token vocabulary may include any of letters, subwords, words, punctuation marks, sign tokens (e.g., #, $, and other signs), mathematical symbols, etc. The token vocabulary may also include one or more special tokens to be added to the input text sequence processed by the neural network, such as a start-of-sequence token, an end-of-sequence token, a designated "class" token, etc.

[0026] During training, the language model neural network 120 can generate respective outputs for each of the multiple tokens in the input sequence in a single forward pass, i.e., in parallel, by processing a single “current sequence” 104 that represents the entire input text sequence.

[0027] After training, at each time step, the language model neural network 120 may be used to autoregressively generate a text sequence by processing the current text sequence 104 as of that time step, then updating the current text sequence 104 by selecting a token from the vocabulary using the output for the current text sequence, and then appending the selected token to the end of the current text sequence 104.

[0028] The visual encoder neural network 112 is a neural network that has parameters (“visual encoder neural network parameters” or “visual encoder parameters”), receives the visual input 102, and processes the visual input 102 according to the parameters to generate an encoded representation 114 of the visual input 102.

[0029] Generally, the encoded representation 114 includes a respective embedding (also referred to as an "updated token") for each of multiple patches of the visual input 102, e.g., for each of multiple spatial patches (regions) of each of the images of the visual input 102, or, in some cases where the visual input 102 includes multiple images, for each of multiple spatio-temporal patches (regions) of the visual input 102.

[0030] As used herein, an "embedding" is a vector of numerical values, e.g., floating-point or other values, having a given dimensionality. The space of possible vectors having a given dimensionality is referred to as the "embedding space."

[0031] The visual encoder neural network 112 may have any suitable architecture that enables the neural network 112 to map the input visual input 102 to the encoded representation 114. For example, the visual encoder neural network 112 may be a convolutional neural network. As another example, the visual encoder neural network 112 may be a vision transformer neural network with one or more self-attention layers. As yet another example, the visual encoder neural network 112 may be a neural network with a mixture of both convolutional and self-attention layers.

[0032] The language model neural network 120 may have any suitable architecture that enables the language model neural network 120 to map the tokens of a text sequence to respective unimodal representations 124 for each of the tokens, and then map the unimodal representations 124 to an output that defines the next token 128.

[0033] In a particular example, the language model neural network 120 may have an attention-based architecture, for example, the architecture of a decoder-only transformer neural network.

[0034] In this example, the set of initial unimodal neural network layers 122 may include a sequence of initial attention layers, each configured to receive as input a respective current representation of each text token of the current text sequence and process the respective current representation to generate as output a respective updated representation of each text token of the current text sequence. For example, each initial attention layer may apply a causally masked self-attention mechanism to the respective current representation to generate the respective updated representation.

[0035] The self-attention mechanism for each current representation refers to the attention mechanism that computes the query, key, and value from each current representation.

[0036] A causally masked self-attention mechanism for each current representation refers to an attention mechanism in which a given position in the current text sequence does not attend to, i.e., does not have a non-zero attention weight for, any position after the given position in the current text sequence.

[0037] Each attention layer can optionally apply other operations to the representation as part of updating the representation, such as by utilizing a position-wise forward propagation neural network, by applying layer normalization, by utilizing residual connections, etc.

[0038] In this example, each current representation received as input by the first initial attention layer in the sequence of initial attention layers is a respective embedding of each text token in the current text sequence (e.g., generated by an embedding layer of the language model neural network 120), and each current representation received as input by each subsequent initial attention layer, i.e., each initial attention layer after the first initial attention layer in the sequence of initial attention layers, is a respective updated representation of the text token in the current text sequence generated as output by the preceding initial attention layer in the sequence of initial attention layers.

[0039] Thus, the unimodal representation of each of the text tokens of the current text sequence is the updated representation of each of the text tokens of the current text sequence produced as output by the last initial attention layer in the sequence of initial attention layers.

[0040] More specifically, when the language model neural network 120 has an attention-based architecture, the initial attention layer includes multiple self-attention layers but does not include any cross-attention layers to ensure that the updated representation of each text token of the current text sequence is a unimodal representation that depends only on the current text sequence and not on the visual input.

[0041] Further, the set of subsequent neural network layers 126 includes a sequence of subsequent attention layers, each subsequent attention layer configured to receive as input a respective current representation of each text token of the current text sequence, and to process the respective current representation to generate as output a respective updated representation of each text token of the current text sequence.

[0042] Thus, each current representation received as input by the first subsequent attention layer in a sequence of subsequent attention layers is a respective unimodal representation of each text token in the current text sequence (produced by the initial attention layer), and each current representation received as input by each subsequent attention layer after the first subsequent attention layer in a sequence of subsequent attention layers is a respective updated representation of the text token in the current text sequence produced as output by the preceding subsequent attention layer in the sequence of subsequent attention layers.

[0043] In this example, similar to the initial attention layer, the sequence of subsequent attention layers also includes one or more self-attention layers. That is, for one or more of the subsequent neural network layers, processing each current representation to generate as output an updated representation for each text token in the current text sequence includes applying a causally masked self-attention mechanism. Each of these attention layers can optionally apply other operations to the representation as part of updating the representation, such as by utilizing a position-wise forward propagation neural network, by applying layer normalization, by utilizing residual connections, etc.

[0044] Unlike the initial layers, the sequence of subsequent attention layers also includes one or more cross-modal layers, each of which processes a respective current representation to generate as output an updated representation of each text token of the current text sequence by applying a cross-attention mechanism between an input derived from (generated from) the encoded representation of the visual input and the respective current representation of the text token of the current text sequence received as input by the cross-modal layer.

[0045] "Cross-attention" between input derived from the encoded representation of the visual input and the current representation of each of the text tokens of the current text sequence received as input by the cross-modal layer refers to an attention mechanism that uses queries derived from the current representation of each of the text tokens of the current text sequence and keys and values ​​derived from the input generated from the encoded representation of the visual input.

[0046] Specific examples of self-attention, cross-attention, and causally masked self-attention mechanisms that may be employed by the system are described below. Vaswani et al. “Attention is all you need”, 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA; Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J Liu “Exploring the limits of transfer learning with a unified text-to-text transformer”, arXiv preprint arXiv:1910.10683,2019;Daniel Adiwardana,Minh-Thang Luong,David R.So,Jamie Hall,Noah Fiedel,Romal Thoppilan,Zi Yang,Apoorv Kulshreshtha,Gaurav Nemade,Yifeng Lu,Quoc V.Le“Towards a human-like open-domain chatbot”,CoRR,abs / 2001.09977,2020;Tom B Brown,Benjamin Mann,Nick Ryder,Melanie Subbiah,Jared Kaplan,Prafulla Dhariwal,Arvind Neelakantan,Pranav Shyam,Girish Sastry,Amanda Askell,et al.“Language models are few-shot learners”,arXiv preprint arXiv:2005.14165,2020;Hua,et al. “Transformer Quality in Linear Time”,arXiv preprint arXiv:2202.10447,2022.

[0047] In some implementations, the input derived from the encoded representation (also referred to below as the caption representation) is an embedding of the encoded representation 114 .

[0048] In some other implementations, the neural network 110 applies one or more transformations to the encoded representation 114 to generate the inputs provided to the cross-modal layer. An example of these transformations is described in more detail below with reference to FIG. 3.

[0049] Thus, the updated representation produced by a given cross-modal layer is a multi-modal representation that depends on the visual input and the text tokens of the current text sequence. Each of these cross-modal layers can optionally apply other operations to the representation as part of updating it, such as by utilizing a position-wise forward propagation neural network, by applying layer normalization, by utilizing residual connections, etc.

[0050] As one example, the sequence of subsequent attention layers can alternate between self-attention layers and cross-modal layers. As another example, the sequence of subsequent attention layers can include a cross-modal layer after every two, three, or four self-attention layers.

[0051] Therefore, due to the presence of the cross-modal layer, the representation generated by the subsequent attention layer at the end of the sequence is a multi-modal representation, as described above.

[0052] To generate the score distribution, the set of subsequent neural network layers 126 may also include an output layer block.

[0053] The output layer block is a set of one or more neural network layers, e.g., one or more fully connected layers followed by a softmax layer, configured to receive one or more of the updated representations of each of the text tokens of the current text sequence generated as output by the last subsequent attention layer in the sequence of subsequent attention layers, and to process the one or more respective updated representations to generate an output defining new tokens to be appended to the current text sequence, i.e., to generate a score distribution for the tokens of the vocabulary.

[0054] For example, during training, when the current output sequence is the entire training sequence, the output layer block can generate, in parallel, a respective score distribution for each of the text tokens by processing, for each text token, an updated representation of the token that immediately precedes the text token in the training sequence to generate a score distribution for the text token. In this example, the system can augment the training sequence with the beginning of a specified sequence of tokens before processing the training sequence using the language model neural network.

[0055] After training, when system 100 is operating autoregressively, the output layer block can generate a single score distribution for the current output sequence by processing the updated representation for the last token of the current output sequence. System 100 can then use the score distribution generated by the output layer block to select the next token to be added to the current output sequence. For example, system 100 can select the token with the highest score in the score distribution or sample a token from the score distribution.

[0056] Generally, system 100 or other training system can pre-train the contrastive caption neural network 110 on both the contrastive loss and the caption loss.

[0057] The contrastive loss may depend on the encoded representations 124 generated by the visual encoder 112 and the representations 124 generated by the initial neural network layer 122, while the caption loss may depend on the encoded representations 124 generated by the visual encoder and the representations generated by the subsequent neural network layer 126.

[0058] That is, the architecture of the neural network 110 allows the contrastive caption neural network 110 to be effectively pre-trained by jointly using both the contrastive loss and the caption loss without increasing the number of forward passes that need to be made through the language model neural network 120 and the visual encoder neural network 112.

[0059] Pre-training the neural network 110 is described in more detail below with reference to FIGS.

[0060] After the control caption neural network 110 is pre-trained, the visual encoder 112, the early layers 122, the subsequent layers 126, or some combination of the above can be used for downstream tasks.

[0061] In some implementations, the downstream tasks may be performed in a zero-shot manner, that is, without further training any of the components of the control caption neural network 110.

[0062] In some other implementations, the downstream task may be performed after fine-tuning one or more of the components of the control caption neural network 110 with labeled training data for the downstream task.

[0063] For example, system 100 can fix any portions of visual encoder 112 and language model neural network 120 used for downstream tasks, while training a customized attention pooling layer and, optionally, one or more additional output layers specialized for the downstream task that receive the output of the attention pooling layer, the output of one of the layers of language model neural network 120, or both.

[0064] As another example, the system 100 can also fine-tune any portions of the visual encoder 112 and language model neural network 120 that are used for downstream tasks.

[0065] In some examples, the downstream task may be an image or video processing task.

[0066] In some examples, the downstream task is a visual categorization task that requires classifying visual input into one of a set of categories, each corresponding to a different object type.

[0067] In some other examples, the downstream task is a visual action recognition task that requires classifying a video input into one of a set of action categories.

[0068] In some examples, the downstream task is a cross-modal search task that requires (i) retrieving one or more text sequences that are most similar to a visual input, or (ii) retrieving one or more visual inputs that are most similar to a text sequence.

[0069] In some examples, the downstream task is a multimodal understanding task, for example, the task may be a visual question answering (VQA) task that requires generating answers to questions posed with respect to visual input.

[0070] In some examples, the downstream task is an image captioning task that requires generating text captions for visual input.

[0071] Downstream tasks are described in further detail below with reference to FIG.

[0072] 2 is a flow diagram of an exemplary process 200 for training a caption neural network. For convenience, process 200 is described as being performed by one or more computer systems located at one or more locations. For example, a neural network system, such as neural network system 100 of FIG. 1 , appropriately programmed, can perform process 200.

[0073] The system can perform repeated iterations of process 200 with different batches of training examples to update the parameters of the visual encoder neural network, the language model neural network, or both.

[0074] That is, in each iteration of process 200, the system obtains a batch of training pairs, for example, by sampling a batch from a larger set of training data, and uses one or more batches of training pairs to update the parameters of the visual encoder neural network and the language model neural network.

[0075] The system may continue to perform iterations of process 200 until a termination criterion for training the neural network is met, for example, until the parameters converge, until a threshold amount of wall clock time has elapsed, or until a threshold number of iterations of process 200 have occurred.

[0076] The system obtains one or more batches of training pairs (step 202).

[0077] Each training pair includes a visual input and an input text sequence.

[0078] Specifically, the input text sequence has been determined by the system or an external source to be explanatory of or related to the content of the visual input, or in other words, the visual input and the input text sequence have been determined to be semantically similar.

[0079] For example, within a given training pair, the text sequences may be text annotations of the visual input from a set of manually or automatically generated image annotations, or alternative text associated with the visual input from a set of alternative text data. Alternative text is text that is displayed in place of an image on a web page, for example, if the image cannot be properly rendered or cannot be loaded. For example, the system may obtain alternative text data from data maintained by internet search engines or other software that automatically crawls web pages on the internet.

[0080] For each training pair, the system uses a control caption neural network to process each visual input and each text sequence of the training pair (step 204).

[0081] Specifically, for each training pair, the system processes the visual input of the training pair using a visual encoder neural network to generate an encoded representation of the visual input.

[0082] The system processes the text sequences of the training pairs using a set of initial neural network layers to generate a respective unimodal representation for each text token in the text sequence. The representations are called "unimodal" because they do not depend on the visual input, but only on the text tokens in the text sequence.

[0083] The system processes the unimodal representation of each of the text tokens of the text sequences using a set of subsequent neural network layers to generate, for each of a plurality of text tokens from each of the text sequences, a respective score distribution over the vocabulary of the text tokens. As described above, the system can generate these score distributions in parallel for each of the plurality of text tokens.

[0084] For each training pair, processing the text sequence of the training pair using a set of initial neural network layers and processing each unimodal representation using a set of subsequent neural network layers is performed in a single forward pass through the language modeling neural network. That is, the system only needs to make a single forward pass through the language model neural network to generate both the unimodal representation (used to calculate the contrastive loss) and the score distribution (used to calculate the caption loss).

[0085] The system trains the neural network to minimize a loss function including (i) a contrastive learning loss term based on the similarity between a contrastive representation derived from the encoded representation of the visual input and one or more unimodal representations of text tokens from each of the text sequences of the training pair, and (ii) for each training pair, a captioning loss term based on respective score distributions for multiple text tokens in the respective text sequence (step 206).

[0086] That is, the system can calculate the gradient of the loss function with respect to the parameters of the visual encoder neural network and the language model neural network, for example through backpropagation, and then apply an optimizer to the gradient to update the parameters of the visual encoder neural network and the language model neural network.

[0087] As mentioned above, because the system only needs to make a single forward pass through the language model neural network to generate both the unimodal representation (used to calculate the contrastive loss) and the score distribution (used to calculate the caption loss), the system can use different outputs of the same forward pass to calculate the amounts required for each of the two losses.

[0088] Therefore, even though the neural networks are trained on both the contrastive loss and the caption loss, only a single forward pass through the visual encoder neural network and the language model neural network is required to evaluate both losses.

[0089] More specifically, the contrastive loss is based on a "contrastive representation" of each of the visual inputs of the batch and, for each text sequence of the batch, one or more of the unimodal representations for one or more of the text sequences of the batch.

[0090] As a specific example, each text sequence in a batch may contain the same designated token located in the same position within each text sequence. For example, the system or another system may augment each text sequence with a designated token, e.g., a "CLS" token placed at the end of every text sequence. The system may then use the unimodal representation of that designated token to compute the contrastive loss.

[0091] Computing the contrast representation is described in more detail below with reference to FIG.

[0092] The goal of contrastive loss is to train the visual encoder 112 and language model 120 so that they can embed image and text inputs into a representation space, i.e., a space of contrastive and unimodal representations, such that inputs with similar semantics are mapped to nearby points regardless of their modality.

[0093] Therefore, the system can calculate the visual input x i and the text sequence y i For all training pairs in the batch containing x i The embedding (i.e., contrastive representation) of y i Neural networks 112 and 120 can be trained to encourage embeddings (unimodal representations for a given token) of the text segments to be closer to each other, while distancing them from all other embeddings of all other visual inputs and text segments in the batch.

[0094] Next, a specific example of contrast loss 130 will be described.

[0095] Based on the image and text segment embeddings of the mini-batch pairs, an N × N similarity matrix A is calculated, and A i;j is x i The embedding of y j It is a value that represents how similar the embedding of A is to that of B. For example, i;j is x i Embedding of y j can be the dot product between the embedding of

[0096] The system can then train the language model neural network and the visual encoder neural network using the gradient of the contrastive loss calculated using matrix A. For example, the contrastive loss can be a cross-entropy loss on the rows and columns of A, where the diagonal entries are treated as the correct class while the other entries are treated as incorrect classes. An example of such a loss is:

number

[0097] As this loss is minimized, for every pair in the batch, x i and y i The embeddings of will be close to each other while being far from all other embeddings of all other visual inputs and text segments in the batch, thereby achieving the goal of contrastive learning.

[0098] The caption loss term, for each training pair and for each of multiple tokens from a respective text sequence, measures the quality of the respective score distribution for the token compared to the corresponding token in the text sequence. As mentioned above, the score distribution is generated using the output of subsequent attention layers of the language model neural network, and therefore the score distribution depends on both the visual input and the text sequence.

[0099] As a specific example, the caption loss for a given training pair is

number

[0100] The overall loss for pre-training can be, for example, a weighted sum of the caption loss and the control loss.

[0101] FIG. 3 illustrates an example of training the neural network 110 with contrastive and caption losses.

[0102] Specifically, FIG. 3 shows an example of how neural network 110 is trained on a training pair that includes image 310 and text sequence 320, "two dogs running in a field."

[0103] As shown in FIG. 3, the system processes an image 310 using a visual encoder neural network 112 to generate an encoded representation of the image 310 .

[0104] The system then generates two representations from the encoded representation: a contrastive representation that is used for contrastive loss, as described above, and a caption representation (i.e., which is an input derived from the encoded representation) that is used to condition a cross-modal layer in the language model neural network 120, as described above.

[0105] The system can generate the contrast representation in any of a variety of ways.

[0106] As an example, the system can use the embedding of a specified token in the encoded representation as the contrast representation. That is, when dividing a given visual input into patches, the neural network 112 can add a placeholder patch that does not correspond to any of the patches in the visual input. The system can then use the embedding of this placeholder patch as the contrast representation.

[0107] As another example, the system can use pooling to generate the contrast representation. As one example, the system can apply a pooling operation, such as global average pooling (GAP), to the embedding of the encoded representation and use the resulting pooled embedding as the contrast representation.

[0108] As yet another example, the system can use learned attention pooling to generate contrastive representations. To do so, the system can incorporate an attention pooling layer within the contrastive caption neural network 110.

[0109] The attention pooling layer applies attention to the updated tokens, i.e., the encoded representation embeddings, and the set of learned query tokens to generate a respective updated query token for each of the learned query tokens in the second set. That is, the system uses the learned query tokens to generate queries for the attention mechanism applied by the attention pooling layer and the encoded representation embeddings to generate keys and values ​​for the attention mechanism. Thus, the output of the attention pooling layer is an updated query token for each of the set of query tokens.

[0110] The set of learned query tokens and the parameters of the attention mechanism are jointly learned with the parameters of the language model neural network and the visual encoder neural network during pre-training.

[0111] To generate the contrasting representation, the system can use a learned set of query tokens that has only a single query token, and can use updated query tokens for the single query token as the contrasting representation.

[0112] The system can generate the caption representation in any of a variety of ways.

[0113] As an example, the system can use the encoded representation directly as the caption representation.

[0114] As another example, the system can incorporate another attention pooling layer where the set of learned query vectors has multiple query vectors, and then use the updated query tokens generated by the attention pooling layer as the encoded representation.

[0115] When used, the attention pooling layer can act as a "task adapter" that (i) ensures that captioning tasks receive finer-grained input that separately represents different regions in the visual input, while contrast tasks receive a global representation that represents the entire visual input, and (ii) allows the output of the visual encoder to be adapted in different learned ways for each of the tasks, improving the quality of pre-training in many situations.

[0116] The system then processes the text sequence 320 using the language model neural network 120, as described above. Specifically, the language model neural network 120 first generates unimodal representations by processing the text sequence 320 using an initial layer 122 (the "unimodal text decoder"), and then processes these unimodal representations, conditioned by cross-attention on the caption representations, using a subsequent layer 126 (the "multimodal text decoder") to generate output that defines the tokens of the text sequence 320.

[0117] In the example of Figure 3, the system then computes a contrastive loss using the unimodal representation for the "[CLS]" token and the contrastive representation generated using attention pooling while computing the caption loss using the output for the tokens in text sequence 320 as described above.

[0118] FIG. 4 shows how the contrastive caption neural network 110 can be used for various downstream tasks.

[0119] As shown in FIG. 4, the system first pre-trains 402 the "CoCa" neural network 110 as described above.

[0120] The system can then perform a zero-shot, frozen feature, or fine-tuning downstream adaptation 404 to use at least a portion of the CoCa neural network 110 for downstream tasks.

[0121] That is, in some implementations, the neural network 110 can be adapted to the downstream task in a zero-shot manner, i.e., without further training any of the components of the control caption neural network 110 or any additional components.

[0122] In some other implementations, the downstream task may be performed after fine-tuning one or more of the components of the control caption neural network 110, e.g., via supervised learning, with labeled training data for the downstream task.

[0123] For example, in the case of frozen feature adaptation, the system can fix any portions of the visual encoder 112 and language model neural network 120 used for the downstream task, while training an attention pooling layer customized for the task, and optionally one or more additional output layers specialized for the downstream task that receive the output of the attention pooling layer, the output of one of the layers of the language model neural network 120, or both.

[0124] As another example, in the case of fine-tuning adaptation, the system can also fine-tune any parts of the visual encoder 112 and language model neural network 120 that are used for downstream tasks.

[0125] In some examples, the downstream task is a visual classification task 406 that requires classifying visual input into one of a set of categories, each corresponding to a different object type. In this example, the system may use at least the visual encoder 112 and then process the encoded representations produced by the visual encoder 112 to generate a classification.

[0126] For example, the system may perform zero-shot visual classification by processing text labels for a set of categories using a language model neural network to generate a unimodal representation for each category, and processing the visual input using the visual encoder 112 to generate a contrast representation for the visual input. The system may then select the category with the unimodal representation that is most similar to the contrast representation as the classification of the visual input.

[0127] In some other examples, the downstream task is a visual action recognition task that requires classifying a video input into one of a set of action categories.

[0128] In these examples, the system can use only the visual encoder 112 and train an attention pooling layer and one or more output layers customized for the visual action recognition task. As a specific example, the system can take multiple frames of a video and feed each frame individually to a shared visual encoder. For frozen feature estimation or fine-tuning, the system can train an additional pooler in addition to the spatial and temporal feature tokens using a softmax cross-entropy loss. Note that because the pooler has a single query token, the computation of pooling for all spatial and temporal tokens is not expensive.

[0129] In some examples, the downstream task is a cross-modal alignment task 408 that requires (i) retrieving one or more text sequences that are most similar to a visual input, or (ii) retrieving one or more visual inputs that are most similar to a text sequence. In these examples, the system may use a visual encoder neural network 112 and an early layer (unimodal text decoder) of a language model neural network. For example, for zero-shot video-to-text retrieval, the system may use a simple approach in which the system computes an average embedding of a set of frames of a video (the frames are evenly sampled from the video) and uses the average embedding as a representation of the video.

[0130] In some examples, the downstream task is a multimodal understanding task 410. In these examples, the system may use the entire language model neural network 120 (both unimodal and multimodal decoders) and the visual encoder 112.

[0131] For example, the task may be a visual question answering task (VQA) that requires generating answers to questions posed regarding visual input.

[0132] As another example, a downstream task is an image captioning task that requires generating text captions for visual input.

[0133] Thus, after performing downstream adaptation 404, the system can receive new inputs for the downstream task, process the new inputs using the neural network of the downstream task, and generate task outputs for the downstream task. Depending on the downstream task, the neural network for the downstream task can include one or more of: (i) a visual encoder, (ii) an initial set of neural network layers, or (iii) a subsequent set of neural network layers, to generate an output task for the downstream task.

[0134] Table 1 shows examples of CoCa's performance on two downstream tasks—image classification (left) and video action recognition (right)—compared to existing techniques. Table 1 shows the performance of downstream adaptation using the frozen technique, in which CoCa's components are not further trained, and the fine-tuning technique, in which CoCa's components are fine-tuned. [Table 1]

[0135] As can be seen from Table 1, the described techniques are competitive with existing techniques without fine-tuning, and outperform existing techniques in both tasks with fine-tuning.

[0136] This specification uses the term "configured" in the context of systems and computer program components. To say that one or more computer systems are configured to perform a particular operation or action means that the system has installed thereon software, firmware, hardware, or a combination thereof that, when running, causes the system to perform the operation or action. To say that one or more computer programs are configured to perform a particular operation or action means that the one or more programs contain instructions that, when executed by a data processing device, cause the device to perform the operation or action.

[0137] Embodiments of the subject matter and functional operations described herein may be implemented in digital electronic circuitry, in tangibly embodied computer software or firmware, in computer hardware, or one or more combinations thereof, including the structures disclosed herein and structural equivalents thereof. Embodiments of the subject matter described herein may be implemented as one or more modules of computer program instructions, i.e., as one or more computer programs encoded on a tangible, non-transitory storage medium for execution by or controlling the operation of a data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or one or more combinations thereof. Alternatively or additionally, the program instructions may be encoded in an artificially generated propagated signal, such as a mechanically generated electrical, optical, or electromagnetic signal, generated to encode information for transmission to a receiving device suitable for execution by a data processing apparatus.

[0138] The term "data processing apparatus" refers to data processing hardware and encompasses all kinds of apparatus, devices, and machines for processing data, including, by way of example, a programmable processor, a computer, or multiple processors or computers. An apparatus can also be or further include special-purpose logic circuitry, such as an FPGA (field-programmable gate array) or an ASIC (application-specific integrated circuit). In addition to hardware, an apparatus can optionally include code that creates an execution environment for a computer program, such as code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or one or more combinations thereof.

[0139] A computer program (also referred to or described as a program, software, software application, app, module, software module, script, or code) can be written in any form of programming language, including compiled or interpreted, or declarative or procedural, and can be deployed in any form, including as a standalone program or as a module, or including components, subroutines, or other units suitable for use in a computing environment. A program may, but need not, correspond to a file in a file system. A program can be stored in a portion of a file that holds other programs or data, e.g., one or more scripts stored in a markup language document, in a single file dedicated to the program, or in multiple cooperating files, e.g., files storing one or more modules, subprograms, or portions of code. A computer program can be deployed to be executed on one computer or on multiple computers located at one site or distributed across multiple sites and interconnected by a data communications network.

[0140] The term "database" is used broadly herein to refer to any collection of data. The data need not be structured in any particular way, or even at all, and may be stored on storage devices in one or more locations. Thus, for example, an index database may contain multiple collections of data, each of which may be organized and accessed in a different way.

[0141] Similarly, the term "engine" is used broadly herein to refer to a software-based system, subsystem, or process programmed to perform one or more specific functions. Generally, an engine is implemented as one or more software modules or components and installed on one or more computers in one or more locations. In some cases, one or more computers are dedicated to a particular engine, and in other cases, multiple engines may be installed and run on the same computer or computers.

[0142] The processes and logic flows described herein may be performed by one or more programmable computers that execute one or more computer programs to perform functions by performing operations on input data to generate output. The processes and logic flows may also be performed by special purpose logic circuitry, such as an FPGA or an ASIC, or a combination of special purpose logic circuitry and one or more programmed computers.

[0143] A computer suitable for running a computer program may be based on a general-purpose or special-purpose microprocessor, or both, or on other types of central processing units. Generally, the central processing unit receives instructions and data from a read-only memory, a random-access memory, or both. The essential elements of a computer are a central processing unit for implementing and executing instructions and one or more memory devices for storing instructions and data. The central processing unit and memory may be supplemented by, or incorporated into, special-purpose logic circuitry. Generally, a computer also includes one or more mass storage devices, such as magnetic, magneto-optical, or optical disks, for storing data, or is operatively coupled to receive data from or transmit data to them, or both. However, a computer need not have such devices. Furthermore, a computer may be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device, such as a universal serial bus (USB) flash drive, to name a few.

[0144] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, including, by way of example, semiconductor memory devices such as EPROM, EEPROM, and flash memory devices, magnetic disks such as internal hard disks or removable disks, magneto-optical disks, and CD-ROM and DVD-ROM disks.

[0145] To provide for user interaction, embodiments of the subject matter described herein may be implemented in a computer having a display device, such as a CRT (cathode ray tube) or LCD (liquid crystal display) monitor, for displaying information to the user, as well as a keyboard and pointing device, such as a mouse or trackball, through which the user can provide input to the computer. Other types of devices may also be used to provide for user interaction. For example, feedback provided to the user may be any form of sensory feedback, such as visual feedback, auditory feedback, or tactile feedback, and input from the user may be received in any form, including acoustic input, voice input, or tactile input. Furthermore, a computer may interact with a user by sending and receiving documents to a device used by the user, for example, by sending a web page to a web browser on the user's device in response to a request received from the web browser. A computer may also interact with a user by sending text messages or other types of messages to a personal device, such as a smartphone running a messaging application, and receiving a reply message from the user in return.

[0146] A data processing apparatus for implementing machine learning models may also include dedicated hardware accelerator units for handling, for example, the general and numerically intensive parts of the machine learning training or machine learning production, i.e., inference, workload.

[0147] The machine learning model may be implemented and deployed using a machine learning framework, for example, the TensorFlow framework or the Jax framework.

[0148] Embodiments of the subject matter described herein may be implemented in a computing system that includes a back-end component, e.g., a data server, or includes a middleware component, e.g., an application server, or includes a front-end component, e.g., a client computer having a graphical user interface, web browser, or app that allows a user to interact with an embodiment of the subject matter described herein, or any combination of one or more such back-end, middleware, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication, e.g., a communications network. Examples of communications networks include a local area network (LAN), a wide area network (WAN), e.g., the Internet.

[0149] A computing system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. In some embodiments, a server sends data, e.g., HTML pages, to a user device, e.g., for the purpose of displaying the data to and receiving user input from a user interacting with the device acting as a client. Data generated at the user device, e.g., results of user interaction, may be received from the device by the server.

[0150] While the specification contains many specific implementation details, these should not be construed as limiting the scope of any invention or the scope of patentable subject matter, but rather as descriptions of features that may be unique to particular embodiments of a particular invention. Certain features described herein in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features of the invention that are described in the context of a single embodiment may also be implemented in multiple embodiments separately or in any suitable subcombination. Furthermore, even if features may be described above as functioning in a particular combination and originally claimed as such, one or more features from a claimed combination may, in some cases, be deleted from the combination, and the claimed combination may be directed to subcombinations or variations of the subcombination.

[0151] Similarly, although operations may be illustrated in the figures or recited in the claims in a particular order, this should not be construed as requiring that such operations be performed in the particular order or sequence shown, nor should it be construed as requiring that all of the illustrated operations be performed in order to achieve desirable results. In certain situations, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems may generally be integrated into a single software product or packaged into multiple software products.

[0152] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve desirable results. As an example, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some cases, multitasking and parallel processing may be advantageous.

Claims

1. 1. A system comprising: one or more computers; and one or more storage devices storing instructions that, when executed by the one or more computers, cause the one or more computers to implement a contrast caption neural network, the contrast caption neural network comprising: a visual encoder neural network configured to process a visual input comprising one or more images to generate an encoded representation of the visual input; 1. A language model neural network configured to process a current text sequence to generate an output defining new tokens to be appended to the current text sequence, the current text sequence including a respective text token at each of one or more input positions, the language model neural network comprising: a set of initial neural network layers configured to process an input including each text token of the current text sequence to generate a respective unimodal representation of each text token of the current text sequence that is independent of the visual input; a set of subsequent neural network layers configured to process an input including the respective unimodal representations of the text tokens of the current text sequence to generate the output defining the new tokens to be appended to the current text sequence, the subsequent neural network layers including one or more cross-modal layers conditioned on the encoded representation of the visual input; Including, the system.

2. The set of initial unimodal neural network layers includes a sequence of initial attention layers, each initial attention layer is configured to receive as an input a respective current representation of each of the text tokens of the current text sequence; and to process the respective current representation to generate as an output an updated representation of each of the text tokens of the current text sequence; the respective current representations received as input by a first initial attention layer of the initial attention layer sequence are respective embeddings of each text token of the current text sequence; the respective current representations received as input by each initial attention layer after the first initial attention layer in the sequence of initial attention layers are updated representations of the respective text tokens of the current text sequence generated as output by a preceding initial attention layer in the sequence of initial attention layers. The system of claim 1 .

3. 3. The system of claim 2, wherein the unimodal representation of each of the text tokens of the current text sequence is an updated representation of each of the text tokens of the current text sequence produced as output by a last initial attention layer of the sequence of initial attention layers.

4. 3. The system of claim 2, wherein processing the respective current representations to generate as output respective updated representations of each of the text tokens of the current text sequence includes applying a causally masked self-attention mechanism.

5. 2. The system of claim 1, wherein the output defining the new tokens to be appended to the current text sequence includes a score distribution that assigns a respective score to each text token in a vocabulary of text tokens.

6. the set of subsequent neural network layers includes a sequence of subsequent attention layers; each subsequent attention layer is configured to receive as an input a respective current representation of each of the text tokens of the current text sequence, and to process the respective current representation to generate as an output an updated representation of each of the text tokens of the current text sequence; the respective current representations received as input by a first subsequent attention layer of the sequence of subsequent attention layers are the respective unimodal representations of each of the text tokens of the current text sequence; the respective current representations received as input by each subsequent attention layer after the first subsequent attention layer in the sequence of subsequent attention layers are updated representations of the respective text tokens of the current text sequence generated as output by a preceding subsequent attention layer in the sequence of subsequent attention layers; The system of claim 1.

7. The set of subsequent neural network layers an output layer block configured to receive one or more of the respective updated representations of the text tokens of the current text sequence generated as output by a last initial subsequent attention layer of the sequence of subsequent attention layers, and to process the one or more respective updated representations to generate the output defining the new token to be appended to the current text sequence. The system of claim 6 further comprising:

8. 7. The system of claim 6, wherein processing the respective current representations to generate as outputs, for one or more of the subsequent neural network layers, respective updated representations for each of the text tokens of the current text sequence includes applying a causally masked self-attention mechanism.

9. 7. The system of claim 6, wherein each of the one or more cross-modal layers is a respective one of the subsequent attention layers in the sequence of subsequent attention layers, and wherein, for each cross-modal layer, processing the respective current representation to generate as output an updated representation of each of the text tokens of the current text sequence comprises applying a cross-attention mechanism between an input derived from the encoded representation of the visual input and the respective current representation of the text tokens of the current text sequence received as input by the cross-modal layer.

10. The system of claim 9 , wherein the encoded representation includes a respective updated token for each of a plurality of patches of the visual input.

11. The control caption neural network a first attention pooling layer that applies attention to the updated query tokens and the first set of learned query tokens to generate a respective updated query token for each of the learned query tokens, wherein each cross-modal layer further includes a first attention pooling layer that receives the respective updated query token as an input; The system of claim 10.

12. The system of claim 11 , wherein the input derived from the encoded representation is the respective updated query token.

13. The system of claim 10 , wherein the visual encoder neural network is a vision transformer neural network.

14. The control caption neural network a second attention pooling layer that applies attention to the updated query tokens and the second set of learned query tokens to generate a respective updated query token for each learned query token in the second set. The system of claim 10.

15. The system of claim 14 , wherein the second set of learned query tokens includes only a single learned query token.

16. 10. A computer-implemented method for training the contrastive caption neural network of claim 1, comprising: obtaining a set of one or more training pairs, each including a respective visual input and a respective text sequence; for each training pair, processing the respective visual input and the respective text sequence of the training pair using the control caption neural network; processing the visual inputs of the training pairs using the visual encoder neural network to generate encoded representations of the visual inputs; processing the text sequences of the training pairs using the set of initial neural network layers to generate respective unimodal representations of each text token of the text sequences; processing the respective unimodal representations of the text tokens of the text sequences using the set of subsequent neural network layers to generate, for each of a plurality of text tokens from the respective text sequences, a respective score distribution over a vocabulary of the text tokens; training the contrastive caption neural network to minimize a loss function, the loss function including (i) a contrastive learning loss term based on similarity between a contrastive representation derived from the encoded representation of the visual input and one or more unimodal representations of the text tokens from each of the text sequences of the training pairs, and (ii) for each training pair, a caption loss term based on the respective score distributions for the plurality of text tokens of the respective text sequence; A method comprising:

17. 17. The method of claim 16, wherein, for each training pair, processing the text sequence of the training pair with the initial set of neural network layers and processing the respective unimodal representation with the subsequent set of neural network layers is performed in a single forward pass through the language model neural network.

18. 17. The method of claim 16, wherein the caption loss term, for each training pair and for each of the plurality of tokens from the respective text sequence, measures the quality of the respective score distribution for the token compared to a corresponding token in the text sequence.

19. 17. The method of claim 16, wherein each training text sequence in each training pair contains the same designated token, and the contrastive learning loss term is based on a similarity between the contrastive representation derived from the encoded representation for the visual input of the training pair and the respective unimodal representation for the designated token of the training text sequence of the training pair.

20. The method of claim 16, wherein the contrastive caption neural network further includes a second attention pooling layer that applies attention to the updated query tokens and the second set of learned query tokens to generate a respective updated query token for each learned query token in the second set, wherein the second set of learned query tokens includes only a single learned query token, and the contrastive representation for each visual input is the updated query token for the single query token in the second set.

21. The method described in claim 16, wherein the encoded representation includes a respective updated token for each of a plurality of patches of the visual input, and the contrast representation for each visual input is generated by pooling the respective updated tokens for each of the plurality of patches of the visual input.

22. 17. The method of claim 16, further comprising, after the training, using one or more of: (i) a visual encoder, (ii) the initial set of neural network layers, or (iii) the subsequent set of neural network layers to perform a downstream task.

23. 23. The method of claim 22, further comprising fine-tuning one or more components of the control caption neural network with labeled training data for the downstream task after the training and before using one or more of: (i) the visual encoder, (ii) the initial set of neural network layers, or (iii) the subsequent set of neural network layers to perform a downstream task.

24. 23. The method of claim 22, further comprising, after the training and prior to using one or more of: (i) the visual encoder, (ii) the initial set of neural network layers, or (iii) the subsequent set of neural network layers to perform a downstream task, fine-tuning a downstream neural network comprising the one or more components of the control caption neural network with labeled training data for the downstream task.

25. 25. The method of claim 24, wherein fine-tuning the downstream neural network comprises training one or more additional components of the downstream neural network while holding fixed the one or more of: (i) the visual encoder, (ii) the initial set of neural network layers, or (iii) the subsequent set of neural network layers.

26. 1. A method performed by one or more computers, comprising: receiving new input for a downstream task; and processing the new input using a neural network for the downstream task, the neural network including one or more of (i) a visual encoder, (ii) an initial set of neural network layers, or (iii) a subsequent set of neural network layers to generate a task output for the downstream task, wherein the one or more of (i) a visual encoder, (ii) an initial set of neural network layers, or (iii) a subsequent set of neural network layers to generate a task output for the downstream task have been trained by performing the respective operations of claim 16. method.

27. One or more computer-readable storage media storing instructions that, when executed by one or more computers, cause the one or more computers to implement the contrastive caption neural network of any one of claims 1 to 15.

28. A method comprising said respective operations being performed by a contrastive caption neural network according to any one of claims 1 to 15.

29. 17. A system including one or more computers and one or more storage devices storing instructions that, when executed by the one or more computers, cause the one or more computers to perform each of the operations of the method of claim 16.

30. 17. One or more computer-readable storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform each of the operations of the method of claim 16.

Citation Information

Patent Citations

  • Spatial attention model for image captioning

    JP2020123372A

  • Image captioning augmented with understanding of the surrounding text

    US20200175063A1

  • Bidirectional attention-based image-text cross-modal retrieval method

    US20210012150A1

  • Systems and methods for contrastive learning of visual representations

    US20210319266A1

  • Contrastive pre-training for language tasks

    WO2021061555A1