S UPERVISION E XISTS E VERYWHERE : A D ATA E FFICIENT C ONTRASTIVE L ANGUAGE -I MAGE P RE - TRAINING P ARADIGM
Anonymous authors
Paper under double-blind review
A BSTRACT
Recently, large-scale Contrastive Language-Image Pre-training (CLIP) (Radford et al., 2021) has attracted unprecedented attention for its impressive zero-shot recognition ability and excellent transferability to downstream tasks.
However,
CLIP is quite data-hungry and requires 400M image-text pairs for pre-training, thereby restricting its adoption.
This work proposes a novel training paradigm,
Data efﬁcient CLIP (DeCLIP), to alleviate this limitation.
We demonstrate that by carefully utilizing the widespread supervision among the image-text pairs,
our
DeCLIP can learn generic visual features more efﬁciently.
Instead of using the single image-text contrastive supervision, we fully exploit data potential through the use of (1) self-supervision within each modality; (2) multi-view supervision across modalities; (3) nearest-neighbor supervision from other similar pairs.
Beneﬁting from these intrinsic supervision, our DeCLIP-ResNet50 can achieve 60.4% zero-shot top1 accuracy on ImageNet, which is 0.8% above the CLIP-ResNet while using 7.1 × fewer data.
Our DeCLIP-ResNet50 outperforms its counterpart in 8 out of 11 visual datasets when transferred to downstream tasks.
Moreover,
Scaling up the model and computing also works well in our framework.
I NTRODUCTION
Over the last few years, pre-trained models have greatly revolutionized computer vision (CV) and natural language processing (NLP).
The ﬁrst wave of exploring pre-trained models took place in the ﬁeld of CV.
Deep convolutional neural nets (Krizhevsky et al., 2012; Simonyan & Zisserman, 2014;
He et al., 2016) are pre-trained on well-labeled ImageNet (Deng et al., 2009) and then transferred to downstream CV tasks (Girshick et al., 2014;
Long et al., 2015; Vinyals et al., 2015).
Standardly,
CV models are pre-trained to predict a ﬁxed set of pre-deﬁned object categories, e.g., 1000 classes in ImageNet.
However, this supervised pre-training is hard to scale since we need arduous human labeling to specify new visual concepts.
When pre-training meets NLP, the intrinsic supervision within the natural language
makes the pretraining more scalable (Devlin et al., 2018;
Radford et al., 2019; Brown et al., 2020).
Witnessing the progress in NLP, researchers use natural language supervision to learn visual features.
The language-image pre-training can scale up to a very large size, beneﬁting from abundant image-text pairs on the Internet.
For instance, CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) adopt the contrastive loss to push the embedding of matched image-text pairs together while pushing those of non-matched pairs apart.
They achieve prestigious performance by learning from an enormous dataset that contains 400M/1B image-text pairs.
However, these methods also require huge storage and computing resources, which is not affordable for most laboratories and companies.
We argue that these prior arts only use the single image-text contrastive supervision while overlooking the widespread supervision within the pairs, thus is inefﬁcient.
Firstly, there underlies rich structural information within each modality itself (LeCun & Misra, 2021).
We can tweak some words/pixels in a sentence/image while retaining a similar semantic meaning.
This sort of self-supervision can be exploited to learn a more common-sense representation for each modality (Devlin et al., 2018;
He et al., 2020; Chen et al., 2020a).
Moreover, inspired
[Figure]
I m a g
[Figure]
N e
[Figure] T o p A cc . [Figure]
[Figure]
Average by contrasting multi-crops in an image (Caron et al., 2020), we further extend the multi-view 1 supervision into our multi-modality setting.
Speciﬁcally, each image is paired with multiple textual descriptions obtained via stochastic augmentations, vice versa.
The beneﬁt is intuitive: this auxiliary multi-view supervision brings more invariant and robust information.
[Figure]
n NN Besides these overlooked supervision, we propose a novel nearest-neighbor (NN) supervision from other similar pairs.
This NN supervision is mainly based on the intuition that one image is likely to have other similar text descriptions among the dataset.
As shown in right ﬁgure, the image with the text ’going to see a lot of vintage tractors this week’ can also be described by ’vintage at tractors a gathering’ .
For this reason, we sample the NN in the embedding space and utilize them as additional supervisory signals.
Aggregating these supervision leads to our novel training paradigm DeCLIP, which stands for D ata e fﬁcient C ontrastive L anguage- I mage
P retraining.
Extensive experiments show the effectiveness and efﬁciency of our DeCLIP.
As shown in Fig.
1, with a ResNet50 image encoder and a Transformer text encoder, our model can achieve 60.4% zero-shot top1 accuracy on ImageNet, which is 0.8% above the CLIPResNet50 while using 7.1 × fewer data.
Using only 88M image-text pairs, our best ResNet50/ViTB32 models boost the zero-shot performance to 62.5% and 66.2%, nearly 3.0% higher than the best number reported for these two architectures.
We further verify the transferability of our models on downstream tasks.
As indicated in Fig.
2, our DeCLIP-ResNet50 outperforms its counterpart inout of 11 visual datasets.
Moreover, Scaling up the model and computing also works well in our framework.
Using 4.5 × fewer data, our DeCLIP-RegNetY-64GF achieves 73.7% zero-shot ImageNet top1 accuracy, which is on-pair with CLIP-R50 × 64.
Pre-trained models, code, and datasets shall be released to the community.
The contributions are summarized as follows:
• To the best of our knowledge, this is the ﬁrst work to study self-supervision and cross-modal multi-view supervision in the million-scale image-text pre-training task.
Our work opens a new direction to fully exploit the intrinsic supervision within the multi-modal data instead of scaling up data naively.
• We propose novel cross-modal Nearest-Neighbor Supervision (NNS) to harness information from other similar pairs.
The NNS can also be regarded as a semantic-level augmentation.
R ELATED W ORK 2. P RE - TRAINED M ODELS
The critical idea of pre-training is to ﬁrst extract general knowledge implicitly from the massive amount of data and then transfer the knowledge to versatile downstream tasks (Han et al., 2021).
With the transformer architecture (Vaswani et al., 2017), big pre-trained NLP models, such as BERTseries (Devlin et al., 2018; Liu et al., 2019) and GPT-series (Radford et al., 2019; Brown et al., 2020), have dominated this area (Han et al., 2021).
Besides the exquisite architecture, the great success comes from the tremendous language data over the Internet and labor-free supervision (Yang et al., 2019; Radford et al., 2019;
Devlin et al., 2018) within the language itself.
In the ﬁeld of CV, supervised pre-training on ImageNet is still the standard practice.
While achieving great success on downstream CV tasks (Girshick et al., 2014; Long et al., 2015; Vinyals et al., 2015) , this supervised manner is hard to scale.
To address this challenge, our DeCLIP learns directly from image-text pairs that are abundant across the Internet.
More importantly, by exploiting the widespread supervision within the pairs, our DeCLIP is more data-efﬁcient than the prior art.
2. S UPERVISION WITHIN D ATA
Language supervision Joulin et al.
; Gomez et al.
; Zhang et al.
Sariyildiz et al.
; Desai & Johnson (2021) demonstrate the effectiveness of learning transferable visual features from language supervision.
However, these works are limited to a small dataset such as
Flickr (Young et al., 2014) or COCO (Lin et al., 2014).
Pioneering work CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) achieve prestigious performance via learning from 400M/1B image-text pairs.
We are following these two works to improve their data efﬁciency.
Visual self-supervision
Our work is also highly related to self-supervised learning (SSL) (LeCun &
Misra, 2021).
Contrastive learning, as a pretext task of SSL, has achieved remarkable success in visual representation learning (He et al., 2020;
Chen et al., 2020a; Caron et al., 2020; Grill et al., 2020;
Chen et al., 2020a).
Researchers also extend contrastive learning into multi-modal settings (Yuan et al., 2021).
However, it is only limited to a small COCO dataset (Yuan et al., 2021).
Nearest-neighbor supervision
Recently, researchers have exploited nearest-neighbor supervision to learn visual features (Dwibedi et al., 2021; Van Gansbeke et al., 2021).
They ﬁnd that using nearest-neighbor as positive samples in the contrastive loss improves the performances on multiple downstream tasks.
However, they mainly focus on the single visual modality pretraining on relatively small datasets, such as ImageNet.
We propose novel nearest-neighbor supervision for multi-modal learning to harness information from other similar pairs.
2. M ULTI -M ODAL L EARNING
Multi-modal learning aims to build models that can process and relate information from multiple modalities (Baltruˇsaitis et al., 2018).
Vision-language tasks, such as VQA (Antol et al., 2015; Gao et al., 2019), image captioning (Xu et al., 2015), require an understanding of both textual and visual semantics.
Most vision-language models use a bunch of cross-modal transformers to fuse and align the information between text and image, such as LXMERT (Tan & Bansal, 2019), UNITER (Chen et al., 2020b), ViLBERT (Lu et al., 2019), VisualBERT (Li et al., 2019), OSCAR (Li et al., 2020), Pixel-BERT (Huang et al., 2020).
These methods either need an off-the-shelf object detector to extract region features or dedicated cross-modal transformer layers, signiﬁcantly hindering their scalability.
Our DeCLIP, by contrast, uses a simple yet effective two-tower framework with multimodal interaction only at the top.
Moreover, this series of models (Radford et al., 2021; Jia et al., 2021; Huo et al., 2021) can perform zero-shot recognition, adapting to new categories with no seen labeled data.
Shen et al.
(2021) also shows that the pre-trained CLIP model can signiﬁcantly beneﬁt the downstream VQA and image caption tasks.
Our DeCLIP is supposed to be compatible with more modalities, e.g., acoustic signals (Akbari et al., 2021).
More modalities included, more correlated supervision are expected to be exploited.
We hope our DeCLIP can inspire and advance the future study of multi-modal learning.
[Figure]
[Figure] [Figure]
①
[Figure]
… … … … … … ③
Nearest
[Figure]
Sup
[Figure]
Feature Queue … 𝑧 !"
= 𝑁𝑁(𝑧 ! )
⓪
Original Sup.
… … … … … … ⓪ … … … … … … ②
Textenc.
Img
[Figure]
… … … … … … … … ⓪ ..
[Figure]
[Figure] [Figure]
[Figure] [Figure]
[Figure]
… … … … ② … … … … … … ② … … … … … … ③ ① 𝑧 #
[Figure]
[Figure]
𝑧
[Figure]
$
[Figure]
𝑧 %!
𝑧 &! …
𝑧 #$ 𝑧 %$ 𝑧 &$ … 𝑧 #!
𝑧 %!
𝑧 &!
̃𝑧 #$ ̃𝑧 %$ ̃𝑧
[Figure]
$ ̃𝑧 &!
̃𝑧 #!
̃𝑧 %!
𝑧 #!"
𝑧 %!"
𝑧 &!"
modal learning.
A PPROACH
In this section, we ﬁrst revisit CLIP and denote some basic concepts, such as image-text contrastive supervision (i.e., the InfoNCE loss).
Next, we present the overview of our DeCLIP framework.
Then we introduce every auxiliary supervision: Self-Supervision(SS), Multi-View Supervision(MVS), and Nearest-Neighbor Supervision(NNS).
3. R EVISITING CLIP
Contrastive Language-Image Pre-training (CLIP) (Radford et al., 2021) aims to learn directly from the raw text about images.
They use a dual-encoder architecture as in Fig. 4(a).
The model consists of an image encoder (e.g., CNN (He et al., 2016) or ViT (Dosovitskiy et al., 2020)) and a text encoder(e.g.
, Transformer (Vaswani et al., 2017) or its variants (Radford et al., 2019)), with a multimodal interaction at the top.
The image and text features are projected to the same dimension and followed by L2 normalization before interaction.
At the training phase, a contrastive objective pushes the embeddings of matched image-text pairs together while pushing those of non-matched pairs apart.
In a batch of N image-text pairs { ( x Ii , x Ti ) } , we denote x Ii and x Ti as image and text of the i th pair.
Let z Ii and z
Tj be the normalized embedding of the i th image and j th text, respectively.
CLIP uses InfoNCE loss (Oord et al., 2018).
The loss for the image encoder can be denoted as Eq. 1.
[Equation]
Here, the similarity function sim( , ) is measured by dot product, and τ is a learnable temperature variable to scale the logits.
We have a symmetrical loss for image and text encoder, thus the overall loss function L CLIP is the average of L I and L T .
At the test phase, the learned text encoder synthesizes a zero-shot linear classiﬁer by embedding the arbitrary categories of the test dataset.
Because it is rare in the dataset that image caption is just a single word, CLIP uses prompts to make up the context of the category { label } , such as "a photo of a { label } " .
Unless otherwise speciﬁed, we use the same prompt engineering and ensembling techniques as CLIP.
Details can be found in Appendix E.
3. O VERVIEW OF D E CLIP
As shown in Fig. 4(b), our DeCLIP has three additional supervisory signals.
1 We ﬁrst use existing methods to exploit image and text Self-Supervision (SS) within its modality.
For image SS, we adopt the simple yet effective SimSiam (Chen & He, 2021).
The objective is to maximize the similarity between two augmented image features.
For text SS, we adopt the most widely used Masked Language Modeling (MLM) (Devlin et al., 2018) as the pre-text task.
We believe other kinds of self-supervised learning algorithms (e.g. MoCo (He et al., 2020), SimCSE (Gao et al., 2021) are orthogonal with our framework.
2 While SS only focuses on a single modality, we further propose cross-modal Multi-View Supervision (MVS).
We apply stochastic data augmentations for both images and texts, resulting in two correlated views 1 of each example.
Then, the image-text contrastive loss is calculated for all the 2 × 2 pairs.
Worth mentioning, the original CLIP does not use text augmentations and only uses random square crop image augmentations, thereby is data-hungry.
The extension is instinctive and straightforward.
Speciﬁcally, we contrast the 2 × 2 pairs and resulting in 3 × more additional supervision.
3 We also propose novel Nearest-Neighbor Supervision (NNS) mined in embedding space to make better use of similar text descriptions among the dataset.
In detail, we maintain a ﬁrst-in-ﬁrst-out feature queue that is representative of the whole data distribution.
We use the nearest-neighbor search in embedding space to get the semantically similar text descriptions.
Then we use the imagetext contrastive loss to get additional supervision.
3. S UPERVISION EXISTS EVERYWHERE
[Table]
[Figure]
Self-Supervision within each modality Following SimSiam (Chen & He, 2021) (depicted in Fig 5(a)), we ﬁrst have two augmented views ( x I , ˜ x I ) for each image.
These two views are sent to the image encoder (weights are shared between views).
We also use the popularized nonlinear predictor module, which is typically a 2-layer MLP, to improve the representation quality in the encoder (Chen et al., 2020a).
The objective is to maximize the similarity between
˜ z
I and p I , which is a negative cosine similarity in this paper.
To avoid the trivial “collapsing” solution, we follow (Chen &
He, 2021) to adopt a stop-grad technique.
As shown in Fig.
5(b), we follow the method in BERT (Devlin et al., 2018) for our text self-supervision.
In detail, we ﬁrst randomly choose 15% of all tokens in each sequence.
Then the token is replaced with (1) the [mask] token 80% of the time (2) a random token 10% of the time (3) the unchanged token 10% of the time.
Then, the output of the language module for the corresponding token is used to predict the original token with cross-entropy loss.
Multi-View Supervision
The authors only contrast the original text (w/o augmentation) with a single ‘global view’ of the image in the original CLIP.
However, the text annotation of the image might not describe the whole picture, instead depicts a small local view of this image.
For instance, as shown in the image with the text "a cute white cat" in Fig. 4, the central concept (cat) only occupies a small part of the picture.
To mitigate this discrepancy, we get a closer look at the local region and utilize it as our auxiliary supervision, as shown in the augmented view in Fig. 4(b).
This intuitive idea is akin to the successful Multi-crop transformation (Caron et al., 2020; Van Gansbeke et al., 2021) in image SSL.
We further extend it into the multi-modal setting.
More speciﬁcally, we reuse the two image views introduced in SS, which contains the
RandomResizedCrop policy to obtain a small local view.
For text, as our goal is to understand the overall semantic meaning of a sentence, we adopt text classiﬁcation augmentation EDA (Wei & Zou, 2019) to generate two text views.
Besides the original contrastive loss between ( z I , z T ), we can contrast ( z I , ˜ z T ), ( ˜ z
I , z T ) and ( ˜ z I , ˜ z T ), leading to 3 × diverse and high-quality additional supervision.
More conveniently, they are naturally compatible with the image-text contrastive loss as denoted in Eq.
[Figure]
z T (cid:48) is the NN of feature z T in the embedding space.
z T (cid:48) will serve as an additional objective for z I .
We use the feature-level nearest neighbor for the text descriptions as the supervision.
Nearest-Neighbor Supervision As shown in Fig 3, one image is likely to have other similar text descriptions among the dataset.
To harness the information from other pairs and go beyond single pairs, we propose using nearest-neighbor (NN) to obtain more diverse supervision.
More formally, we aim to ﬁnd the NN feature z T (cid:48) of text feature z T in the embedding space.
The distance between two features could be measured by a simple cosine similarity.
It is infeasible to search NN in the whole million-scale dataset.
Thus, we maintain a FIFO queue Q to simulate the whole data distribution.
The size of Q is 64K in our implementation.
As shown in Fig.
6, we further get the contrastive loss between ( z I , z T (cid:48) ).
Since there are two augmented image features, we also calculate the contrastive loss between ( ˜ z I , z T (cid:48) ).
Fortunately, NNS is also compatible with Eq. 1.
In summary, we denote L ISS and L TSS as the loss function of image SS and text SS, respectively.
L MV S is multi-view loss, and L NNS is nearest-neighbor loss.
We have the overall loss function of our
DeCLIP as in Eq. 2.
[Equation]
E XPERIMENTS 4. D ATASETS
[Table]
Pre-training datasets We summarize our pre-training dataset as in Tab.
Our DeCLIP full data consists of two parts: open-source data and web-crawled data.
The open-source data comes from three different datasets: Conceptual Captions (CC3M) (Sharma et al., 2018),
Conceptual 12M (CC12M) (Changpinyo et al., 2021), and YFCC (Thomee et al., 2016).
Worth mentioning, due to the download failure or nonEnglish caption, we do not obtain the complete data for these datasets.
We further use the
YFCC15M query to crawl about 59M ﬁltered web data on the Internet, together with open-source data to form the 88M DeCLIP full pre-training dataset.
More details can be seen in Appendix C.
Downstream datasets We assess our model performances in a wider variety of distributions and tasks.
Following the CLIP (Radford et al., 2021), we evaluate the image encoder transferability onwidely used downstream datasets, such as Food-101, CIFAR-10, etc.
To conduct a fair comparison, the metric and division for each dataset that can be collected are consistent with those of CLIP.
More details of downstream datasets can be found in Tabel 6 of Appendix D.
[Table]
4. E XPERIMENTS S ETUP
Network architectures Following CLIP, we ﬁrst consider two different architectures for the image encoder: a modiﬁed version of ResNet50 (Radford et al., 2021) and ViT-B/32 (Dosovitskiy et al., 2020).
The text encoder is a Transformer (Vaswani et al., 2017) with the architecture modiﬁcations described in Radford et al.
The image and text features are projected to the samedimension, followed by L2 normalization before interaction.
Beneﬁting from the rapid progress of large CV models, we further scale up our model.
Our largest model is a RegNetY-64GF (Radosavovic et al., 2020; Goyal et al., 2021) image encoder with a BERT (Devlin et al., 2018) text encoder, which is on-pair with the largest CLIP-R50 × 64 model.
Pre-training setup For a fair comparison with CLIP, we train our DeCLIP-ResNet50 and
DeCLIP-ViT-B/32 from scratch for 32 epochs.
Unless otherwise speciﬁed, we use full data, i.e., 88M image-text pairs, to obtain the best performance.
The input resolution of the image encoder is 224 × 224 , and the maximum context length of the text encoder is 76.
The learnable temperature parameter τ is initialized to 0.07.
The loss weights of additional supervision α , β and γ are all set to 0.2.
More details can be found in Appendix C.
Downstream evaluation setup We evaluate our model transferability by performing linear classiﬁcation on frozen features, i.e., the pre-trained image encoder is ﬁxed and serves as a feature extractor.
After feature extraction, we train the linear classiﬁer with the L-BFGS optimizer as the same in Radford et al.
4. M AIN R ESULTS
Zero-shot recognition on ImageNet After pre-training
, we use natural language to refer to visual concepts enabling the zero-shot ability of our model.
As shown in Fig.
1, our DeCLIP-ResNet consistently outperforms the CLIP-ResNet50 across all dataset sizes.
When the data amount reaches 56M (29M open-source + 27M web-crawled), our model can achieve 60.4% accuracy, 0.8% above the CLIP-ResNet50, while using 7.1 × fewer data.
As described in Tab. 2, with our full data, our best ResNet50/ViT-B32 models boost the zero-shot performance to 62.5% and 66.2%, nearly 3.0% higher than the best number reported for these two architectures.
Moreover, our DeCLIP-ResNet is even 0.3% better than CLIP-ResNet101, revealing the effectiveness and efﬁciency of our framework.
Scaling up model capacity works in our framework as well.
Our biggest DeCLIP-RegNetY64GF achieves 73.7% accuracy, which is 0.1% above CLIP ResNet50 × 64 with fewer parameters.
Downstream evaluation results We report our linear probe performance on 11 downstream datasets in Tab.
Our DeCLIP-ResNet50 outperforms its CLIP counterpart in 8 out of 11 datasets, with a 0.8% average improvement.
There are some datasets that our models perform worse than
CLIP models, such as SUN and Food101.
We conjecture that this is caused by the different distribution of the pre-trained dataset.
Interestingly, our ResNet50 and ViT-B/32 models might have distinct performance on several datasets, such as Pets and Aircraft. We infer that these two types [Table] [Table]
[Table]
denotes Self-Supervision, Multi- [Table]
Supervision and
NearestNeighbor Supervision, respectively.
[Table]
[Figure]
[Table]
[Figure]
of neural networks
might have different data preferences, i.e., different feature extraction capacities when they meet the same data.
4. A BLATION S TUDY
Ablation on additional supervision In order to understand the effectiveness of each additional supervision, we conduct an ablation study as indicated in Tab. 4.
We follow the DeCLIP-ResNet protocol in the pre-training setup except for a smaller 1024 batch size on a smaller CC3M dataset.
The single image-text contrastive supervision (CLIP) results in 20.6% zero-shot top1 accuracy on
ImageNet.
We can observe that MVS boost amazing 4.2% improvement over the original CLIP.
As discussed in Sec. 3.3, the beneﬁts might come from two sides: 1).
the MVS can look at a small local view of an image which might be a better ﬁt with the text description.
2 ×augmented views can provide 3 × diverse and high-quality additional supervision, thus leading to more robust representations.
SS can further contribute an additional 0.6% improvement on the basis of MVS.
We believe SS could bring more improvements with proper dedicated SSL methods.
NNS further brings 1.8% improvement on the high basis of SS.
We will discuss more about NNS at
Sec. 4.5.
On the YFCC15M dataset, our DeCLIP using full additional supervision gets signiﬁcant effect improvement, Appendix F shows the details.
Ablation on training cost Since we need to encode twice for each image-text pair, we admit our DeCLIP needs a higher training cost than CLIP.
Regarding the training time, one DeCLIP iteration equals 1.5 × CLIP iteration.
In this ablation, we train the original CLIP-ResNet50 longer than our DeCLIP-ResNet50.
As shown in Fig.
7, longer 64 epochs training can bring about 1.1% improvement.
However, our model has 27.2% top1 accuracy, which is still 5.3% higher than the time-equivalent CLIP.
It reveals that our framework can extract richer and more representative features through our proposed supervision.
We also include memory usage ablation in Appendix F.
4. A NALYSIS
Class activation maps We try to understand what renders our DeCLIP effective.
As shown in
Fig.
8, we visualize the class activation maps (CAM)
(Zhou et al., 2016) of different models trained
[Figure]
[Figure]
r i g i n a l p a i r
NN p a i r
[Figure]
on the YFCC dataset.
The validate that
Nearest neighbor samples In Fig 9, we show some nearest neighbor (NN) samples from different datasets.
The ﬁrst row is the original image-text pair, while the second row is the NN pair.
In general, we can see that the texts have similar intellectual meanings.
Therefore, the NN pair can provide high-quality supervision.
When taking datasets into consideration, the matching performs very well in well-ﬁltered datasets, such as CC3M and CC12M.
This matching might be a little worse in more noisy datasets, such as YFCC and web-crawled, but it can still provide some beneﬁcial guidance.
C ONCLUSION
This paper introduces DeCLIP, a Data efﬁcient Contrastive Language-Image Pre-training paradigm.
Our goal is to learn visual representations through the use of broader and scalable supervision.
Speciﬁcally, instead of using the single image-text contrastive supervision, we fully exploit data potential through the use of (1) self-supervision within each modality; (2) multi-view supervision across modalities; (3) nearest-neighbor supervision from other similar pairs.
Experimentally, DeCLIP shows superior effectiveness and efﬁciency with different types of neural nets(CNN and ViT) and different amounts of data.
We hope our work could bring insights about exploiting the multimodal data.
A P SEUDO CODE OF D E CLIP
The training pseudo code of DeCLIP is as follows:
Algorithm
Input: I , ˜ I , T , ˜ T , image encoder , text encoder , Feature Queue 1: function B ATCH -U
PDATING ( I , ˜ I , T , ˜ T ) 2: # Get The Features of The Current Batch.
I f , ˜ I f ← image encoder ( I ) , image encoder (˜ I ) 4:
T f , ˜ T f ← text encoder ( T ) , text encoder ( ˜ T ) 5:
T NN ← N EAREST -N EIGHBOR ( Feature Queue, T f ) 6: 7: # Calculate The losses.
L CLIP ← I NFO NCE-L OSS ( I f , T f ) 9:
L SS ← I MAGE -SS-L OSS ( I f , ˜ I f )
+ T EXT -SS-L OSS ( T f ) 10:
L MV S ← I NFO NCE-L OSS ( I f , ˜ T f )
+ I NFO NCE-L OSS ( ˜ I f , T f )
+ I NFO NCE-L OSS ( ˜ I f , ˜ T f ) 11:
L NNS ← I NFO NCE-L OSS ( ˜ I f , ˜ T NN ) 12:
L DeCLIP ← (1 − α − β − γ
L CLIP + αL SS + βL MV S + γL NNS 13: 14: # Update The Network.
15: image encoder ← B ACKWARD -U PDATE ( image encoder, L DeCLIP ) 16: text encoder ← B ACKWARD -U PDATE ( text encoder, L DeCLIP ) 17:
Feature Queue ← FIFO-U PDATE ( Feature Queue, T f ) 18: end function 19: 20: function I MAGE -SS-L OSS ( I f , ˜ I f ) 21: z, ˜
z ← image encoder.proj ( I f ) , image encoder.proj (˜ I f ) 22: p, ˜
p ← image encoder.pred ( z ) , image encoder.pred (˜ z ) 23: z, ˜
z ← z.detach () , ˜ z.detach () 24: # Calculate the Negative Cosine Similarity loss.
L Image − SS ← NCS ( p, ˜ z ) / 2 + NCS (˜ p, z ) /26:
return L Image − SS 27: end function 28: 29: function T EXT -SS-L OSS ( T f ) 30:
# Get The Masking GT when performing the text-encoder.
W f , W gt ← T f .word feat, T f .mask
id 32:
W pred ← text encoder.pred ( W f ) 33: # Calculate the Cross-Entropy loss.
L Text − SS ← CE ( W gt , W pred ) 35: return L Text − SS 36: end function
B D ATA A UGMENTATION
Details of SS The image SS uses SimSiam (Chen & He, 2021) method as the image selfsupervision.
The prediction module is a 2-layer MLP, in which the hidden dimensions areand output dimensions are 1024, the projection module is a 3-layer MLP, in which the hidden and output dimensions are both 1024.
The text SS uses the Masked Language Model (Devlin et al., 2018) as the pretext task.
In detail, we ﬁrst randomly choose 15% of all tokens in each sequence.
Then the token is replaced with (1) the [mask] token 80% of the time (2) a random token 10% of the time (3) the unchanged token 10% of the time.
Image augmentations
The augmentation policy includes: RandomResizedCrop with scale in [0.2,1.0] (Wu et al., 2018), ColorJitter containing { brightness, contrast, saturation, hue } strength of { 0.4, 0.4, 0.4, 0.1 } with an applying probability of 0.8, RandomGrayscale with an applying probability of 0.2.
Blurring augmentation (Chen et al., 2020a) has a Gaussian kernel with std in [0.1, 2.0], and RandomHorizontalFlip .
Text augmentations We use the EDA (Wei & Zou, 2019) method as our text augmentation strategy, which contains three types of text augmentation strategies: synonym replacement, random swap, and random deletion.
Each text will randomly select one of these three types for text augmentation.
C P RE - TRAINING DATASETS & IMPLEMENTATION DETAILS
Open-source data.
Conceptual Captions (Sharma et al., 2018) is a 3.3 M image caption opensource data.
Due to the failure of the download link, we only download about 3M data(CC3M).
Conceptual 12M (Sharma et al., 2018) contains approximately 12M of image-text pairs(CC12M), which is larger than the CC3M and covers a more diverse set of visual concepts.
Also, due to the failure of the download link, we only download about 11M data.
YFCC
(Thomee et al., 2016), the
Yahoo Flickr Creative Commons 100M data, is a dataset for vision language tasks.
We download about 86.5M data from the YFCC website and use four ﬁltering rules to ﬁlter the DeCLIP YFCC15M dataset to benchmark against CLIP YFCC15M. The four rules are: ﬁltering data with damaged images, ﬁltering data without the caption, ﬁltering data with a caption English word ratio less than 0.8, ﬁltering data with a caption only including one part of speech.
Web-crawled data.
We use the user tags and machine tags of YFCC15M to form a tag list, and use WordNet (Miller, 1995) to ﬁnd synonyms for each tag in the tag list to form a synonym tag list.
The tag list and synonym tag list form a query list.
Then we use the query list to crawl images from the Internet, after ﬁltering data with smaller images, ﬁltering data with damaged images, ﬁltering data without the caption, and ﬁltering data with Chinese in the caption, we collect 59M web crawled data.
Tabel 5 shows the source link of pre-training datasets, and Figure 10 shows some cases random sampled from each dataset.
[Table]
Implementation details We train DeCLIP-ResNet50 (abbr.
as R50) and DeCLIP-ViT-B/32 (abbr.
as V-B32) from scratch for 32 epochs.
For R50, we use the FP16-SGD optimizer with the batch size of 10,240 (128 × 80).
Starting with an 0.01 learning rate (lr), we ﬁrst linearly increasing the lr to 0.
(a.k.a warm-up) in one epoch.
Then we use cosine anneal lr decay to decrease the lr.
The weight decay is set to 0.0001.
For V-B32, we use a hybrid FP16-AdamW-SGD optimizer with bacth size 10,240(128 × 80).
For the ViT image encoder, we use AdamW optimizer with the lr warming up from 1e-4 to 1e-3 in one epoch.
The weight decay is set to 0.05.
For the text encoder, we use the
SGD optimizer with the lr warming up from 1e-3 to 0.02 in one epoch.
The weight decay is set to 1e-4.
Pre-training cost Our R50 and V-B32 took 8/10 days to train on 80 V100 GPUs, respectively.
Our largest DeCLIP-RegNetY-64GF took 21 days on 160 V100 GPUs, while the largest CLIP-R50 ×from (Radford et al., 2021) spent 18 days on 592 V100 GPUs.
[Figure]
D D OWNSTREAM D ATASETS & IMPLEMENTATION DETAILS
Downstream data.
We begin with the 12 datasets from the well-studied evaluation suite introduced by Kornblith et al.
Within these 12 datasets, Birdsnap can not be downloaded, and
PASCAL VOC 2007 classiﬁcation is replaced by more challenging ImageNet-1K, resulting in our 11 datasets. They are: Food-101, CIFAR-10, CIFAR-100, SUN397, Stanford Cars, FGVC Aircraft,
Describable Textures, Oxford-IIIT Pets, Caltech-101, Oxford Flowers 102.
Tab. 6 is the detailed information of these datasets
[Table] [Table]
Implementation details We follow CLIP (Radford et al., 2021) to train a logistic regression classiﬁer using L-BFGS, with maximum 1,000 iterations, and report the corresponding metric for each dataset.
We determine the L2 regularization strength λ using a hyperparameter sweep on the validation sets over the range between 10 − 6 and 10 6 , with 96 logarithmically spaced steps.
To save compute required for the sweeps, we perform a parametric binary search that starts with λ =
[ 10 − 6 , 10 − 4 , 10 − 2 , 1, 10 2 , 10 4 , 10 6 ] and iteratively halves the interval around the peak until it reaches a resolution of 8 steps per decade.
The hyperparameter sweeps are performed on a validation split of each dataset.
For the datasets that contains a validation split in addition to from the test split, we use the provided validation set to perform the hyperparameter search, and for the datasets that do not provide a validation split or have not published labels for the test data, we split the training dataset to perform the hyperparameter search and report the performance on the validation data.
E P ROMPT E NGINEERING
Due to the reason that it’s relatively rare in the dataset for the text to be a single word, we use prompts such as "a photo of a { label } " for zero-shot classiﬁcation.
For a fair comparison, we use the same prompts as proposed in Radford et al.
(2021) for the ImageNet dataset.
As shown in Fig 11, the prompts reduce the domain gap between the training dataset and testset, and fully consider the different situations for the picture.
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
label}.
a photo of the large {label}. a black and white photo of a {label}. the plushie {label}. a dark photo of a {label}.
itap of a {label}.
graffiti of the {label}.
a toy {label}.
itap of my {label}.
a photo of a cool {label}.
a photo of a small {label}.
a tattoo of the {label}.
F A DDITIONAL STUDY
[Table]
Different Pre-training Datasets Data is critical for language-image pre-training task.
As shown in Tab.
[Table]
we evaluate our DeCLIP on different sources of datasets.
Combining Tab.7 and Fig.
[Table]
we can see that when the amount of training data continues to scale up, the zero-shot recognition ability continues to improve as well.
In addition, we can see that the open source data has high quality.
The 29M open source data can achieve 49.3% zero-shot top1 accuracy on ImageNet through the DeCLIP training paradigm.
Our open-source data is an affordable benchmark, which would be beneﬁcial for explorations.
Our YFCC re-implementation
Although we use the same number of image-text pairs as the
CLIP YFCC-15M, our YFCC data is different from CLIP.
We also reproduce the naive CLIP on our
YFCC-
M data, which results in 35.9% zero-shot top1 accuracy on ImageNet-1K (see Fig.
It is relatively higher than the number in CLIP paper (31.1%).
We conjecture the improvements might be caused by the different data cleaning strategies.
However, our DeCLIP can achieve 41.9% zero-shot accuracy which is also 6.0% higher than our CLIP re-implementation.
[Table]
Memory usage Because of the additional views, our DeCLIP is more memory-consuming.
Thanks to the ICLR anonymous review comments: a fairer comparison might be doubling the batch size of CLIP.
Flowing the ablation study in Fig.
7, we double the batch size and train CLIP-ResNet for 64 epochs.
The ﬁnal result is 22.3% which is still 4.9% lower than our DeCLIP model.
We summarize the memory usage, training cost, and the ﬁnal accuracy as below.
All experiments are conducted on CC-3M with 16 V100 GPUs.
[Table]