Lecture 19: Multimodal Models Pre-training
Presenters: Eric Wang & Shengye Chen
Slides created for CS886 at UWaterloo
1
CS886: Recent Advances on Foundation Models
Overview
Slides created for CS886 at UWaterloo
2
Introduction & Background
Slides created for CS886 at UWaterloo
3
Multimodal Representations
Slides created for CS886 at UWaterloo
4
"Multimodal Machine Learning: A Survey and Taxonomy." https://arxiv.org/abs/1705.09406
Multimodal Tasks - Understanding
Slides created for CS886 at UWaterloo
5
Multimodal Tasks - Understanding
Slides created for CS886 at UWaterloo
6
Multimodal Tasks - Generation
Slides created for CS886 at UWaterloo
7
VLP Methods prior to 2020
Slides created for CS886 at UWaterloo
8
Existing methods (e.g., VisualBERT) simply concatenate visual region features and word embeddings of the paired text as input to the model and use self-attention to implicitly align elements of the text and image regions
"VisualBERT: A Simple and Performant Baseline for Vision and Language." https://arxiv.org/abs/1908.03557
VLP Methods prior to 2020
Slides created for CS886 at UWaterloo
9
Existing methods (e.g., VisualBERT) simply concatenate visual region features and word embeddings of the paired text as input to the model and use self-attention to implicitly align elements of the text and image regions
"VisualBERT: A Simple and Performant Baseline for Vision and Language." https://arxiv.org/abs/1908.03557
Visual Representation Improvement
Slides created for CS886 at UWaterloo
10
OSCAR: Object-Semantics Aligned Pre-training for Vision-Language Tasks
“Semantic alignments between texts and images using object tags”
March 2020
Slides created for CS886 at UWaterloo
11
OSCAR - Background & Motivation
Slides created for CS886 at UWaterloo
12
Motivation:
Challenges:
OSCAR - Extracting Anchor Points
Slides created for CS886 at UWaterloo
13
To extract visual embeddings v
OSCAR - Extracting Word Embeddings
Slides created for CS886 at UWaterloo
14
To extract tag embeddings q
To extract text embeddings w
Looking at the same input from 2 perspectives
15
Now that we have embeddings for texts (w), tags (q) and image regions (v), all in dim H
OSCAR - Loss for Modality View
Slides created for CS886 at UWaterloo
16
w
h’ = [q, v]
OSCAR - Loss for Dictionary View
Slides created for CS886 at UWaterloo
17
h = [w, q]
v
OSCAR - Pre-training
Slides created for CS886 at UWaterloo
18
OSCAR - Quantitative Results
Slides created for CS886 at UWaterloo
19
Note that the dataset size of
With fewer image-text pairs than SoTAL, OSCARB achieves higher score than its counterpart in 5 out of 6 tasks, highlighting OSCAR’s parameter efficiency, partially because the use of object tags as anchor points eases the learning of semantic alignments between images and texts
OSCAR - The Effect of Object Tags
Slides created for CS886 at UWaterloo
20
OSCAR - Qualitative Results
Slides created for CS886 at UWaterloo
21
Intra-class: same object between two modalities is closer (e.g., person)
Inter-class: classes of related semantics are closer but still distinguishable, such as animal (zebra, elephant, sheep), transportation (train, car, truck), furniture (couch, chair, bowl).
OSCAR - Limitations
Slides created for CS886 at UWaterloo
22
A few good reasons to start with country line dance
VinVL: Revisiting Visual Representations in Vision-Language Models
"Extract better visual representation rather than just fuse multi-modal information"
Slides created for CS886 at UWaterloo
23
VinVL: Background & Motivation
Slides created for CS886 at UWaterloo
24
VinVL: Improve Vision in Vision Language
Slides created for CS886 at UWaterloo
25
VinVL: Improve Vision in Vision Language
Slides created for CS886 at UWaterloo
26
Zhang, Pengchuan, et al. "Vinvl: Revisiting visual representations in vision-language models." Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. 2021.
VinVL: Improve Vision in Vision Language
Slides created for CS886 at UWaterloo
27
2. Fine-tuning
VinVL: Revisit VL Models
Slides created for CS886 at UWaterloo
28
VinVL: OSCAR+ Pre-training
Slides created for CS886 at UWaterloo
29
Pre-train an OSCAR+ to learn the joint image-text representations using image tags as anchors for image-text alignment.
OSCAR+ pre-training loss:
VinVL: OSCAR+ Pre-training
Slides created for CS886 at UWaterloo
30
OSCAR+ pre-training loss:
Masked Token Loss:
VinVL: OSCAR+ Pre-training
Slides created for CS886 at UWaterloo
31
OSCAR+ pre-training loss:
Three-way Contrastive Loss:
Negative examples for contrastive learning:
VinVL: OSCAR+ Pre-training
Slides created for CS886 at UWaterloo
32
VinVL: Adapt to VL Tasks
Slides created for CS886 at UWaterloo
33
VinVL: Adapt to VL Tasks
Slides created for CS886 at UWaterloo
34
Contrastive Language-Image Pre-training
Slides created for CS886 at UWaterloo
35
Learning Transferable Visual Models From Natural Language Supervision (CLIP)
"Introduce self-supervised signals widely used in NLP into Vision"
Slides created for CS886 at UWaterloo
36
CLIP: Background & Motivation
Slides created for CS886 at UWaterloo
37
CLIP: Contribution
Slides created for CS886 at UWaterloo
38
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
CLIP: Method
Slides created for CS886 at UWaterloo
39
CLIP: Efficient Pre-Training Method
Slides created for CS886 at UWaterloo
40
CLIP: Pre-training
Slides created for CS886 at UWaterloo
41
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
CLIP: Contrastive Training
Slides created for CS886 at UWaterloo
42
1
3
2
4
5
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
CLIP: Contrastive Training
Slides created for CS886 at UWaterloo
43
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
CLIP: Inference
Slides created for CS886 at UWaterloo
44
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
CLIP: Zero-Shot Classification Results
Slides created for CS886 at UWaterloo
45
Radford, Alec, et al. "Learning transferable visual models from natural language supervision." International conference on machine learning. PMLR, 2021.
Across a 27 dataset eval suite, a zero-shot CLIP classifier outperforms a fully supervised linear classifier fitted on ResNet-50 features on 16 datasets, including ImageNet.
CLIP: Limitations
Slides created for CS886 at UWaterloo
46
ALIGN: Scaling Up Visual and Vision-Language Representation Learning With Noisy Text Supervision
"Scale of the corpus makes up for noise and leads to SoTA representations"
Slides created for CS886 at UWaterloo
47
ALIGN: Background & Motivation
Slides created for CS886 at UWaterloo
48
ALIGN: Noisy Image-Text Dataset
Slides created for CS886 at UWaterloo
49
Scale up visual and vision-language representation learning.
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
ALIGN: Method
Slides created for CS886 at UWaterloo
50
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
Visual and language representations are jointly learned from noisy image alt-text data. The representations can be used for vision-only or vision-language task transfer. Without any fine-tuning, ALIGN powers zero-shot visual classification and cross-modal search including image-to-text search, text-to-image search and even search with joint image+text queries.
ALIGN: Pre-training on Noisy Data
Slides created for CS886 at UWaterloo
51
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
ALIGN: Pre-training on Noisy Data
Slides created for CS886 at UWaterloo
52
Minimize the sum of two losses:
Image-to-text classification:
Text-to-image classification:
ALIGN: Transferring
Slides created for CS886 at UWaterloo
53
ALIGN: Results
Slides created for CS886 at UWaterloo
54
Image-text retrieval
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
Zero-shot Visual Classification
ALIGN: Ablation Study
Slides created for CS886 at UWaterloo
55
A large scale training set is essential to allow scaling up of the models and to achieve better performance. A larger model is required to fully utilize the larger dataset.
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
Model quality improves nicely with larger backbones. As expected, scaling up image encoder capacity is more important for vision tasks. In image-text retrieval tasks the image and text encoder capacities are equally important.
ALIGN: Analysis of Learned Embeddings
Slides created for CS886 at UWaterloo
56
A simple image retrieval system to study the behaviors of embeddings trained by ALIGN.
ALIGN can align images and texts with similar semantics and generalize to novel complex concepts.
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
ALIGN: Analysis of Learned Embeddings
Slides created for CS886 at UWaterloo
57
ALIGN shows that word2vec-like linear relationships between word vectors emerge as a result of training them to predict adjacent words in sentences and paragraphs.
Given a query image and a text string, add their ALIGN embeddings together and use it to retrieve relevant images.
Jia, Chao, et al. "Scaling up visual and vision-language representation learning with noisy text supervision." International conference on machine learning. PMLR, 2021.
Generative Language-Image Pre-training
Slides created for CS886 at UWaterloo
58
BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation
“Improving text quality by bootstrapping contrastive training”
January 2022
Slides created for CS886 at UWaterloo
59
BLIP - Background & Motivation
Slides created for CS886 at UWaterloo
60
1. From model perspective: CLIP & ALIGN adopt encoder-based models
To improve CLIP and ALIGN from 2 perspectives:
BLIP - Background & Motivation
Slides created for CS886 at UWaterloo
61
2. From data perspective:
BLIP - Improving Caption Quality
Slides created for CS886 at UWaterloo
62
To solve the text quality issue, a natural approach is to build
Generator
(captioner)
Discriminator
(filter)
BLIP - Unimodal Encoder
Slides created for CS886 at UWaterloo
63
A multimodal alignment task to encourage matched image-text pairs to have similar representations in contrast to the negative pairs
Image-Text Contrastive (ITC) Loss
BLIP - Discriminator (Filter)
Slides created for CS886 at UWaterloo
64
A binary classification task to predict whether an image-text pair is matched or nor, given multimodal features
Hard negative sampling strategy: negative pairs with higher contrastive similarity from ITC are more likely to be selected so that training is meaningful
Image-Text Matching (ITM) Loss
BLIP - Generator (Captioner)
Slides created for CS886 at UWaterloo
65
A generative task to produce textual descriptions in an autoregressive manner given an image
Language Modeling (LM) Loss
BLIP - Architecture
Slides created for CS886 at UWaterloo
66
The same color of blocks indicates shared parameters
BLIP - Bootstrapping Dataset with CapFilt
Slides created for CS886 at UWaterloo
67
1. Pre-train encoder & decoder with noisy web-scale dataset
2. Fine-tune filter and captioner using human annotated dataset (e.g., COCO)
3. Generate synthetic caption for web dataset.
Noisy text
Clean text
BLIP - Bootstrapping Dataset with CapFilt
Slides created for CS886 at UWaterloo
68
4. Filter synthetic and web captions to get high quality image-text pairs
5. Use high quality image-text pairs (129M, larger and cleaner) to pre-train a new model
Continue training does not help. This observation agrees with the common practice in knowledge distillation, where the student model cannot be initialized from the teacher
Noisy text
Clean text
BLIP - Bootstrapping Dataset with CapFilt
Slides created for CS886 at UWaterloo
69
These examples showcase the effectiveness of both captioner and filter
BLIP - Downstream Tasks
70
BLIP - Quantitative Results
71
Comparison between using captioner only and using filter only
BLIP - Quantitative Results
72
Comparison between using CapFilt base and using CapFilt large
BLIP - Quantitative Results
73
CoCa: Contrastive Captioners are Image-Text Foundation Models
“Combining contrastive training + generative training”
May 2022
Slides created for CS886 at UWaterloo
74
CoCa - Background & Motivation
75
CoCa - Replacing Text Encoder with Decoder
Slides created for CS886 at UWaterloo
76
Append a [CLS] token at the end of input sentence and use its corresponding output of decoder as the text embedding
BLIP
CoCa
CoCa - Decoupled Decoder
Slides created for CS886 at UWaterloo
77
CoCa - Attentional Poolers
Slides created for CS886 at UWaterloo
78
Task-specific attentional pooling
CoCa - Benefits of Attentional Poolers
Slides created for CS886 at UWaterloo
79
Adaptor for downstream tasks
Enhanced frozen-feature evaluation
CoCa - Pre-Training Details
Slides created for CS886 at UWaterloo
80
Loss Function
Number of unimodal and multimodal decoder layers
Dataset (4.8B): ALIGN (1.8B) + JFT-3B (internal Google dataset)
CoCa - Evaluations
Slides created for CS886 at UWaterloo
81
CoCa outperforms foundation models and task-specialized models on 12 benchmarks including significant improvements in image-text retrieval, image captioning and VQA
Training Scaling Up
Slides created for CS886 at UWaterloo
82
SigLIP: Sigmoid Loss for Language Image Pre-Training
"Scaling up training with sigmoid loss"
Slides created for CS886 at UWaterloo
83
SigLIP: Background & Motivation
Slides created for CS886 at UWaterloo
84
SigLIP: Softmax-based Contrastive Loss
Slides created for CS886 at UWaterloo
85
When using the softmax loss to formalize this objective, an image model f(·) and a text model g(·) are trained to minimize the following objective:
Due to the asymmetry of the softmax loss, the normalization is independently performed two times: across images and across texts.
, , scalar t is parametrized as exp(t′) , and
is a global freely learnable parameter.
Given a mini-batch B = {(I1, T1), (I2, T2), . . . } of image-text pairs.
SigLIP: Softmax-based Contrastive Loss
Slides created for CS886 at UWaterloo
86
Contrastive training typically utilizes data parallelism. Computing the loss when data is split across D devices necessitates gathering all embeddings with expensive all-gathers and the materialization of a memory-intensive |B| × |B| matrix of pairwise similarities.
Zhai, Xiaohua, et al. "Sigmoid loss for language image pre-training." arXiv preprint arXiv:2303.15343 (2023).
SigLIP: Sigmoid Loss
Slides created for CS886 at UWaterloo
87
Sigmoid loss does not require computing global normalization factors. It processes every image-text pair independently, effectively turning the learning problem into the standard binary classification on the dataset of all pair combinations, with a positive labels for the matching pairs (Ii , Ti ) and negative labels for all other pairs (Ii, Tj̸=i) . The loss is defined as:
zij is the label for a given image and text input, which equals 1 if they are paired and −1 otherwise.
An additional learnable bias term b similar to the temperature t is introduced to overcome heavy imbalance coming from the many negatives dominating the loss.
SigLIP: Sigmoid Loss
Slides created for CS886 at UWaterloo
88
L =
pair: - =
unpair: - =
SigLIP: Efficient Loss Implementation
Slides created for CS886 at UWaterloo
89
(a) (b)
Zhai, Xiaohua, et al. "Sigmoid loss for language image pre-training." arXiv preprint arXiv:2303.15343 (2023).
SigLIP: Efficient Loss Implementation
Slides created for CS886 at UWaterloo
90
(c) (d)
Zhai, Xiaohua, et al. "Sigmoid loss for language image pre-training." arXiv preprint arXiv:2303.15343 (2023).
SigLIP: Batch Size
Slides created for CS886 at UWaterloo
91
Apply sigmoid-based loss with CLIP and LiT:
Zhai, Xiaohua, et al. "Sigmoid loss for language image pre-training." arXiv preprint arXiv:2303.15343 (2023).
SigLiT results: Sigmoid loss outperforms the softmax loss significantly with small batch sizes, and performs similarly at larger batch sizes.
SigLIP results: Both sigmoid loss and softmax loss saturate at a reasonable batch size, while the peak of the sigmoid loss comes earlier and slightly outperforms the peak of the softmax loss.
SigLIP: Label Noise Robustness
Slides created for CS886 at UWaterloo
92
Sigmoid-training increases robustness to data noise.
Titles show the type of corruption applied, and x-axes show the probability with which they are applied. With increasing corruption severity, M-scale models trained with sigmoid loss for 3.6 billion examples retain superiority over corresponding softmax baseline.
Models trained with sigmoid loss are increasingly robust to all kinds of added noise.
Zhai, Xiaohua, et al. "Sigmoid loss for language image pre-training." arXiv preprint arXiv:2303.15343 (2023).
Summarizations
Slides created for CS886 at UWaterloo
93
Loss
Slides created for CS886 at UWaterloo
94
Contrastive loss
Image-Text Matching (ITM) loss
Language Modeling (LM) loss
Masked Language Modeling (MLM) loss
Uni-Encoder Family
Slides created for CS886 at UWaterloo
95
OSCAR
VinVL
Architecture | First published | Model Name | Image-text Pairs (M) | VQA (test-dev) | GQA (test-dev) | NLVR2 (dev) | I2T retrieval (COCO R@1) | T2I retrieval (COCO R@1) | Image Captioning (BLEU@4) | NoCaps (Valid CIDEr) | NoCaps (Valid SPICE) |
Uni-encoder | 2020/03 | OSCAR | 7 | 73.82 | 61.58 | 80.37 | 73.5 (FT) | 57.5 (FT) | 41.7 | 80.9 | 11.3 |
2021/01 | VinVL | 9 | 76.6 | 65.05 | 82.7 | 75.4 (FT) | 58.8 (FT) | 41 | 105.1 | 14.4 |
Dual-Encoder Family
Slides created for CS886 at UWaterloo
96
CLIP
ALIGN
SigLIP
Architecture | First published | Model Name | Image-text Pairs (M) | I2T retrieval (COCO R@1) | T2I retrieval (COCO R@1) | I2T retrieval (Flickr R@1) | T2I retrieval (Flickr R@1) |
Dual-encoder | 2021/02 | CLIP | 400 | 58.4 (ZS) | 37.8 (ZS) | 88.0 (ZS) | 68.7 (ZS) |
2021/02 | ALIGN | 1800 | 58.6 (ZS) | 45.6 (ZS) | 88.6 (ZS) | 75.7 (ZS) | |
2023/03 | SigLIP | 40000 | 70.6 (ZS) | 52.7 (ZS) | -- | -- |
Encoder-Decoder Family
Slides created for CS886 at UWaterloo
97
BLIP
CoCa
Architecture | First published | Model Name | Image-text Pairs (M) | VQA (test-dev) | NLVR2 (dev) | I2T retrieval (Flickr R@1) | T2I retrieval (Flickr R@1) | Image Captioning (BLEU@4) | NoCaps (CIDEr) |
Encoder-decoder | 2022/01 | BLIP | 129 | 78.3 | 82.2 | 96.7 (ZS) | 86.7 (ZS) | 40.4 | 113.2 (ZS) |
2022/05 | CoCa | 4800 | 82.3 | 86.1 | 92.5 (ZS) | 80.4 (ZS) | 40.9 | 122.4 (ZS) |