
https://openreview.net/forum?id=Ee277P3AYC

(제안: encoding=understanding과 decoding=generating을 동시에 수행할 수 있게 contrasitve loss와 captioning loss로 jointly pretrain)
(방법: decoder layer를 반으로 나눠서,
초기 layer는 unimodal text representation 학습, 후기 layer는 multimodal image-text representation 학습)
일반적인 encoder-decoder transformers에서는 decoder의 모든 layer가 encoder outputs에 대해 cross-attention을 수행하지만,
CoCa는 decoder layer의 첫 절반의 layer에서는 cross-attention을 생략하여 unimodal text representations을 encoding하고,
이후 나머지 decoder layer에서 image encoder에 대해 cross-attention을 수행함으로써
multimodal image-text representations을 형성한다.
본 model은
unimodal image and text embeddings 간의 contrastive loss와,
multimodal decoder outputs에 대해 text token을 autoregressively하게 predict하는 captioning loss를 함께 적용한다.
두 training objectives는 same computational graph를 공유하기 때문에, minimal overhead로 효율적으로 계산된다.
(실험)
(B.g: Language에서 foundation model)
(B.G.: Vision and Vision-Language에서 foundation model)
Pioneering works(Girshick et al., 2014; Long et al., 2015; Simonyan & Zisserman, 2014)은
image classification에서 cross-entropy loss로 pretraind된 single-encoder models의 효과를 보여줬다.
하지만 이러한 single-encoder model들은 annotations을 label vectors 형태로 강하게 의존하며,
free-form human antural language에 대한 지식을 내재하지 못하므로,
vision and language modalities를 동시에 다루는 downstream tasks에는 적용이 제한된다.
최근에는, web-scale noisy image-text pairs를 이용하여,
두 개의 parallel encoders를 contrasitve loss로 pretraining하는 image-text foundation model의 가능성이 제시되었다.
이러한 dual-encoder model은 vision-only tasks를 위한 visual embedding뿐만 아니라, text embedding도 동일한 latent space로 encoding할 수 있어,
zero-shot image classification이나 image-text retrieval과 같은 새로운 crossmodal alignment capabilities를 가능하게 한다.
그러나 이러한 model들은 fused image and text representations을 학습하기 위한 joint vision-language understanding이 없기 때문에,
VQA(Visual Question Answering)와 같은 복잡한 vision-language understanding tasks에는 직접적으로 적용하기 어렵다.
그러나 이러한 모델들은 이미지와 텍스트의 융합된 표현을 학습하기 위한 공동(joint) 구성 요소가 없기 때문에, 시각적 질의응답(VQA)과 같은 복합적인 비전-언어 이해 작업에는 직접적으로 적용하기 어렵다.
또 다른 연구 흐름(Vinyals et al., 2015; Wang et al., 2021b; 2022)은 encoder-decoder model을 활용한 generative pretraining을 통해
generic vision and multimodal representation을 학습하는 방법을 탐구했다.
pretraining 과정에서, model은 encoder side에 image를 입력 받고, decoder 출력에 대해 language modeling loss를 적용한다.
downstream task에서는 decoder 출력이 multimodal understanding tasks를 joint representations으로 사용될 수 있다.
이러한 pretrained encoder-decoder model은 우수한 vision-language results를 달성하였으나,
image embedding과 aligned된 text-only representation을 생성하지 못하므로,
crossmodal alignment tasks에서는 효율성과 활용성이 상대적으로 낮다.
(내가 이해한 내용: 3. 또 다른 연구 흐름에 대한 설명은 SimVLM(ICLR2022에 나온)을 설명하는 것 같다.
SimVLM은 image encoder- text decoder model로, image를 입력받아 text를 생성하는 방식으로 학습하는데,
image vector와 text vector가 독립적으로 전재하면서 서로 matching되는 구조가 없다.
즉, image encoder는 있지만 text encoder는 없다.
image와 text가 decoder 안에서 뒤섞여야만 처리가 되기 때문에, retrieval같은 task에서는 계산이 비효율적이다.
BLIP은 CoCa와 같이, 앞선 한계에 대한 문제의식을 가짐.
generation model의 alignment 부재 문제를 해결하기 위해, retrieval 같은 task를 위한 multimodal alignment(image encoder와 text encoder 각각의 결과를 contrastive loss 학습)와 generating용 multimodal decoder로 작동하게 만듦.)
내가 이해한 CoCa의 문제 제기:
CLIP에서는 image-encoder, text-encoder가 각각 존재하였지만 generating을 위한 decoder는 없었음.
즉, 두 multimodal을 align해서 understanding(retrieval)하는 것은 잘하지만 VQA와 같은 generating tasks에 적용하기 제한적인 문제가 있음.
반대로, SimVLM에서는 generating tasks에 좋은 구조이지만 understanding(retrieval)을 하기에 비효율적임.
왜 비효율적이냐면, retrieval을 하려면 모든 pair를 model에 forward시켜야 함. (?)
(SimVLM을 읽어보지 않아서 잘 이해하지 못했음...)
그래서 CoCa는 understanding(retrieval과 같은)과 generating(VQA와 같은) 동시에 할 수 있지만서도 효율적인 encoder-decoder를 제안
BLIP도 CoCa와 유사한 문제를 해결하기 위해, 즉 understanding & generating을 하기 위해 multimodal mixture encoder-decoder (MED)를 제안했음.
(아직 CoCa를 다 읽어보진 않았지만, BLIP보다 더 효율적인 설계인 것 같음...
하나의 decoder를 반으로 나눠서 text encoding과 decoding까지 할 수 있도록.)
이 연구에서, 우리는 (1) single-encoder, (2) dual-encoder and (3) encoder-decoder paradigms을 통합하여,
이 세 가지 approaches의 능력을 모두 포괄하는 one image-text foundation model을 train한다.
이를 위해 Contrastive Captioners (CoCa)라는 simple model family를 제안하며,
이는 contrastive loss와 captioning(generative) loss를 함께 사용하여 학습되는 a modified encoder-decoder architecture를 갖는다.
Figure 1에 나타난 바와 같이, 우리는 decoder transformer를 unimodal decoder와 multimodal decoder의 두 부분으로 분리한다.
unimodal decoder layer에서는 cross-attention을 제거하여 text-only representations을 encoding하고,
이후 multimodal decoder layer에서는 image encoder outputs에 대해 cross-attention을 수행하도록 layer를 cascade(연쇄적으로) 구성하여
multimodal image-text representations을 학습할 수 있도록 한다.
더 나아가, CoCa는 both image annotation data와 noisy image-text data로 train되며, 이때 모든 label을 단순히 text로 취급한다.
image annotation text에 대해 적용되는 generative loss는 single-encoder cross-entropy loss approach와 유사한 a fine-grained training signal을 제공하며,
이를 통해 세 가지 pretraining paradigms를 a single unified method로 포괄한다.

최근 수년간 vision-language pretraining(VLP)는 vision과 language를 하나의 fusion model로 jointly encoding하는 것을 목표로 빠른 발전을 이루어왔다.
초기 연구들은 Faster R-CNN과 같은 pretrained object detection modules을 활용하여 visual representations을 extract하는 방식에 의존했다.
이후 ViLT(Kim et al., 2021)와 VLMo(Wang et al., 2021a)와 같은 연구들은 vision과 language transformers를 통합하고,
multimodal transformer를 from scratch로 train시키는 방향으로 발전하였다.
더 최근에는 pretrained LLMs을 re-using하여 vision-language tasks에서 zero-shot/few-shot learning을 수행하는 연구들 또한 제안되었다.
기존 방법들과 비교하여, 본 논문은 multimodal understanding and generation을 scratch부터 학습하는 데 집중한다.
최근 연구들은 vision and VLP를 동시에 포괄할 수 있는 image-text foundation models을 제안해왔다.
CLIP과 ALIGN은 noisy image-text pairs에 대해 contrastive objectives로 pretrained된 dual-encoder model이
crossmodal alignment tasks 및 zero-shot image classification에서 strong and text representations을 학습할 수 있음을 보였다.
Florence는 unified contrastive objective를 도입하여 이 접근법을 확장하였으며,
다양한 vision and image-text benchmarks에 적응 가능한 foundation models을 학습한다.
zero-shot image classification accuracy를 더욱 향상시키기 위해,
본 연구에서는 이러한 접근법들을 통합하기 위해, a single pretraining stage에서 image-text foundation model을 scratch부터 train하는 데 초점을 맞춘다.
최근의 일부 연구 역시 image-text image-text unification을 탐구하였으나, 우수한 성능을 달성하기 위해 unimodal 및 multimodal module에 대해 multiple pretraining stages가 필요했다.
예를 들어, ALBEF(Li et al., 2021)는 dual-encoder design에서 contrastive loss와 masked language modeling(MLM)을 결합한다.
반면, 우리의 방법은 학습이 simpler and more efficient하면서도 더 다양한 model capabilities를 제공한다:
여기서 는 a one-hot, multi-hot or smoothed label distribution from GT label 를 의미한다.
여기서 와 는 각각 -th pair에서 normalized embeddings of the images이고
은 은 loss weighting hyper-parameters이다.
contrastive approach는 an unconditional text representation을 사용하는 것과 달리,
captioning approach는 the conditional likelihood of text를 optimize한다.
이러한 dilemma를 해결하고 두 methods를 a single model로 결합하기 위해,
우리는 a simple decoupled decoder를 설계한다.
decoupled decoder는 decoder를 unimodal decoder과 multimodal decoder로 split한다.
여기서 unimodal decoder에서는 cross-attention mechanism을 생략한다.
모든 decoder layers는 future tokens에 대한 attention을 금지한다. (masked)
그리고 multimodal text decoder output을 captioning objective 에 직접 사용할 수 있다.
contrastive objective 에 대해, 우리는 input sentence 끝에 learnable token을 붙이고 그 unimodal decoder의 결과를 text embedding으로 사용한다.
우리는 처럼 decoder의 절반을 split했다.
ALIGN에 따라, 우리는 image resolution of and patch size , resulting in a total of image tokens 으로 Pretrain했다.
Our largest CoCa model ("CoCa" in short)은 image encoder로 1B-params을 갖고 text decoder로 2.1B-params을 갖는 ViT-giant setup을 따른다.
또한 우리는 two smaller variants of "CoCa-Base" and "CoCa-Large"를 Table 1에 자세히 적어놨다.


decoupled autoregressive decoder design의 key benefit 중 하나는 two training losses를 효율적으로 계산할 수 있다는 점이다.
unidirectional language models은 전체 sentences에 대해 causal masking을 적용하여 학습되므로,
decoder는 단 한 번의 forward propagation만으로 contrastive loss와 generative loss를 모두 계산할 수 있다 (bidirectional approach에서는 two passes가 필요함).
그 결과, 대부분의 연산이 two losses 간에 공유되며, CoCa는 standard encoder-decoder models에 비해 매우 적은 overhead만을 유발한다.
한편, 기존의 많은 방법들은 다양한 데이터 소스 및/또는 모달리티에 대해 여러 단계에 걸쳐 모델 구성 요소를 학습하는 반면, CoCa는 주석이 달린 이미지와 노이즈가 포함된 alt-text 이미지 등 다양한 데이터 소스를 사용하여, 모든 라벨을 텍스트로 취급함으로써 대조적 목표와 생성적 목표를 동시에 고려하는 방식으로 처음부터 끝까지(end-to-end) 사전학습된다.
skip




skip...
BLIP과 CoCa이 가진 문제 제기는 똑같기 때문에 BLIP과 공통점?
BLIP과 CoCa의 차이점은? CoCa 논문의 핵심은?
architecture 관점:
BLIP의 architecture는 Multimodal mixture of encoder-decoder(MED)임.
즉, image encoder 1개 + text encoder 1개 + image-grounded text encoder 1개 + imge-grounded text decoder 1개.
image encoder를 제외한 나머지들은 서로 weight sharing을 하되 mask와 cross-attention 유무에 따라 역할을 다르게 함.
text encoder는 Bi Self-Attn, Cross-Attn X
image-grouned text encoder에서는 Bi Self-Attn, Cross-Attn O
image-grouned text decoder에서는 Causal Self-Attn, Cross-Attn O

CoCa의 architecture는 decoupled head임.
즉, image encoder 1개 + (unimodal=text decoder 1개 + multimodal=image-grounded text decoder 1개)
understanding task에서 중요한 image-text feature의 alignmnet를 하기 위해 unimodal decoder에 token을 추가하여 image encoder의 token과 contrastive learning.
(근데 내 생각은 decoder를 분리했다고 설명하긴 하지만, 사실상 text encoder 1개와 multimodal text decoder 1개를 순차적으로 이어붙인거 아닌가?)

training 시 연산 효율성
pretraining dataset