Notice
Recent Posts
Recent Comments
Link
«   2026/03   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Archives
Today
Total
관리 메뉴

hwchung 님의 블로그

[Paper Review] PMLR 2021, Learning Transferable Visual Models From Natural Language Supervision 논문리뷰 본문

[Paper Review]

[Paper Review] PMLR 2021, Learning Transferable Visual Models From Natural Language Supervision 논문리뷰

hwchung 2026. 1. 26. 13:37

 

Learning Transferable Visual Models From Natural Language Supervision

PMLR 2021

0. Abstrct

Learning directly from raw text about images is a promising alternative which leverages a much broader source of supervision. → 원본 텍스트를 직접 학습하는 것.

The model transfers non-trivially to most tasks and is often competitive with a fully supervised baseline without the need for any dataset specific training.

→ 고정된 라벨로 학습하는 supervised learning은 한계가 있음. 자연어는 훨씬 풍부한 supervision이라고 할 수 있음.

→ 이 논문에서는 이미지–텍스트 매칭만으로도 가능하게 할 수 있음. 그래서 학습 안 한 문제도 말로 설명하면 풀 수 있음.

 

1. Intro and Motivation

These results suggest that the aggregate supervision accessible to modern pre-training methods within web-scale collections of text surpasses that of high-quality crowd-labeled NLP datasets.

 

Could scalable pre-training methods which learn directly from web text result in a similar breakthrough in computer vision? → 컴퓨터 비젼에서도 direct하게 학습하는 걸 시도하려고 함

 

Using natural language supervision for image representation learning is still rare. → limit을 걸고 label을 거는 건 유연성이 줄어들고 zero shot을 어렵게 하는 단점으로 작용할 수 있음.

 

A crucial difference between these weakly supervised models and recent explorations of learning image representations directly from natural language is scale. → 뭔가 CLIP에서는 scale로 한 번 변화를 꾀하겠다는 게 보임.

 

Enabled by the large amounts of publicly available data of this form on the internet, we create a new dataset of 400 million (image, text) pairs and demonstrate that a simplified version of ConVIRT trained from scratch, which we call CLIP, for Contrastive Language-Image Pre-training, is an efficient method of learning from natural language supervision. → ConVIRT는 이전의 의료 도메인 이미지–텍스트 contrastive 모델. CLIP도 pre-training 모델을 사용하기는 하는데(여기서는 image encoder와 text encoder를 pre-training 함.) downstream task에 대해서 fine tuning을 하지 않는 것임(zero-shot). pre-training도 이미지와 텍스트를 하나의 embedding space에 정렬하기 위해서 pre-training 모델을 사용.

 

We additionally find that zero-shot CLIP models are much more robust than equivalent accuracy supervised ImageNet models which suggests that zero-shot evaluation of task-agnostic models is much more representative of a model’s capability. → Task agonostic 하다는 게 downstream task를 전제한다는 뜻이 아니기 때문에 다양한 Task에 추가 학습 없이 적용할 수 있다는 의미. task-agnostic 모델의 진짜 능력을 평가하려면, fine-tuning된 성능이 아니라, zero-shot 성능을 봐야 함. → zero shot은 학습 시 가정하지 않은 문제를 얼마나 일반적으로 푸는지를 드러내는 것이 목적이기 때문.

 

2. Approach

CLIP에서의 Natural Language Supervision에 대한 이해

CLIP에서 말하는 Natural Language Supervision은, 기존 computer vision에서 사용하던 고정된 정답 라벨을 supervision으로 쓰는 방식과 근본적으로 다름. 전통적인 이미지 분류 모델은 사람이 미리 정의한 클래스 집합 중 하나를 정답으로 주고, 모델이 이미지를 그 클래스 ID에 맞추도록 학습함. 이 경우 모델이 받는 supervision은 매우 제한적임. 라벨에 포함되지 않은 시각적 개념(색, 질감, 행동, 장면 맥락 등)은 직접적으로 가르쳐지지 않음.

 

반면 CLIP에서는 이미지를 설명하는 자연어 문장 자체가 supervision임. 각 이미지에는 ‘a photo of a dog’, ‘a red car on a snowy road’와 같은 문장이 함께 주어지고, 모델은 이 이미지와 문장이 서로 의미적으로 맞는지 여부를 구분하도록 학습됨. 이 과정에서 모델은 특정 클래스 ID를 외우는 것이 아니라, 이미지와 문장에 공통으로 포함된 의미(semantic information)를 포착하도록 강제됨. 즉, 자연어 문장은 단일 라벨이 아니라 여러 개의 시각적 속성과 개념을 동시에 담은 풍부한 학습 신호로 작동함.

 

이런 방식의 supervision이 중요한 이유는 자연어가 본질적으로 열린(open-ended) 표현 체계이기 때문임. 사람이 미리 정의한 클래스 집합은 항상 닫혀 있지만, 자연어는 새로운 개념이나 조합을 언제든지 설명할 수 있음. CLIP은 사전학습 단계에서 이미지와 텍스트를 같은 임베딩 공간에 정렬해 두기 때문에, 학습 중에 보지 못한 개념이라도 자연어로 설명만 주어지면 그 의미에 가장 잘 맞는 이미지를 선택할 수 있음. 이것이 CLIP이 downstream task에 대해 추가 학습 없이도 zero-shot으로 동작할 수 있는 이유.

 

We constructed a new dataset of 400 million (image, text) pairs collected form a variety of publicly available sources on the Internet. To attempt to cover as broad a set of visual concepts as possible, we search for (image, text) pairs as part of the construction process whose text includes one of a set of 500,000 queries.

 

Recent work in contrastive representation learning for images has found that contrastive objectives can learn better representations than their equivalent predictive objective. → 정답을 만들어내게 하는 것(predictive objective)보다 의미적으로 같은 것과 다른 것을 구분하게 하는 것(contrastive objective)이 더 효과적임.

 

Other work has found that although generative models of images can learn high quality image representations, they require over an order of magnitude more compute than contrastive models with the same performance. → generative model은 계산량이 너무 많음. → 결국에는 다양한 것들 중에 contrastive를 선택했다는 것을 보이기 위함.

 

Noting these findings, we explored training a system to solve the potentially easier proxy task of predicting only which text as a whole is paired with which image and not the exact words of that text. → 여러 개의 텍스트가 있을 때, 여러 개의 이미지가 있을 때, 어떤 텍스트가 어떤 이미지와 짝인지를 맞추는 것. → 즉, CLIP은 텍스트를 생성하거나 단어를 예측하지 않고, 이미지와 텍스트가 서로 대응되는지를 구분하는 contrastive learning problem.

Given a batch of N (image, text) pairs, CLIP is trained to predict which of the N ×N possible (image, text) pairings across a batch actually occurred. CLIP learns a multi-modal embedding space by jointly training an image encoder and text encoder to maximize the cosine similarity of the image and text embeddings of the N real pairs in the batch while minimizing the cosine similarity of the embeddings of the N² − N incorrect pairings. → 나머지 N² − N개는 전부 틀린 쌍이기 때문에 cosine similarity를 minimize를 해야함. 즉 CLIP은 이미지와 텍스트를 같은 임베딩 공간에 매핑하고, 배치 안에서 실제로 짝인 이미지–텍스트 쌍은 가깝게, 짝이 아닌 모든 조합은 멀어지도록 학습함.

 

We train CLIP from scratch without initializing the image encoder with ImageNet weights or the text encoder with pre-trained weights. → CLIP을 구현함에 있어서 이미지 인코더를 ImageNet으로 미리 학습된 가중치로 시작하지 않고, 텍스트 인코더도 기존에 학습된 언어모델 가중치를 쓰지 않고 완전히 처음부터 학습함. → text, image contrastive learning 자체의 효과를 보여주기 위함.

 

We instead use only a linear projection to map from each encoder’s representation to the multi-modal embedding space. → non-linear를 사용하지 않으면서, 구조를 최대한 단순화하면서 contrastive 정렬 자체에 집중하는 것을 볼 수 있음. → non-linear projection, linear projection이나 성능 차이를 크게 못 느꼈다는 것이 후술되기는 함.

 

A random square crop from resized images is the only data augmentation used during training. → 복잡한 augmentation 기법은 사용하지 않음.

 

Finally, the temperature parameter which controls the range of the logits in the softmax, τ, is directly optimized during training as a log-parameterized multiplicative scalar to avoid turning as a hyper-parameter. → contrastive loss의 parameter를 학습 과정 중에 최적화되게 하였음. → 어떤 loss인지?

 

Image encoder 방법1

For the first, we use ResNet-50 as the base architecture for the image encoder due to its widespread adoption and proven performance.

We make several modifications to the original version using the ResNet-D improvements and the antialiased rect-2 blur pooling. → Aliasing을 줄이기 위해 blur pooling 사용.

We also replace the global average pooling layer with an attention pooling mechanism. → 평균 내는 것이 아니라 중요한 부분에 집중하겠다는 말.

The attention pooling is implemented as a single layer of ‘transformer-style’ multi-head QKV attention where the query is conditioned on the global average-pooled representation of the image. → Transformer 전체를 쓰는 것이 아니라 attention 연산만 가져와서 쓰겠다는 말.

Image encoder 방법2

For the second architecture, we experiment with the recently introduced Vision Transformer (ViT).

with only the minor modification of adding an additional layer normalization to the combined patch and position embeddings. → Layer 하나 정도 추가함.

Text encoder 방법

The text encoder is a Transformer with the architecture modifications described in Radford et al. (2019). → 기본 구조는 Transformer, GPT 계열에서 사용된 architecture modification을 따른다고 할 수 있음.

The text sequence is bracketed with [SOS] and [EOS] tokens and the activations of the highest layer of the transformer at the [EOS] token are treated as the feature representation of the text which is layer normalized and then linearly projected into the multi-modal embedding space. → 문장 앞뒤에 토큰을 붙임. 문장과 시작과 끝을 나누기 위함. → Transformer의 마지막 레이어, 그중에서도 [EOS] 토큰 위치의 hidden state를 문장 전체를 대표하는 벡터로 사용함.

Masked self-attention was used in the text encoder to preserve the ability to initialize with a pre-trained language model or add language modeling as an auxiliary objective, though exploration of this is left as future work. → 나중에 GPT 같은 사전학습 언어모델 가중치를 그대로 가져와서 초기화할 수 있게 하려는 것.

For the text encoder, we only scale the width of the model to be proportional to the calculated increase in width of the ResNet and do not scale the depth at all, as we found CLIP’s performance to be less sensitive to the capacity of the text encoder.

 

3. Experiments

We instead use the term in a broader sense and study generalization to unseen datasets. → Class 뿐 아니라 dataset 자체도 처음 보는 걸로 의미를 넓혔음.

 

While much research in the field of unsupervised learning focuses on the representation learning capabilities of machine learning systems, we motivate studying zero-shot transfer as a way of measuring the task-learning capabilities of machine learning systems. → 새로운 task에 대해서 추가 학습없이 바로 할 수 있는 가가 중요함. → zero-shot 성능을 어떻게 해석해야 하는가에 대해서 모든 데이터셋이 specific한 task를 대표하는 건 아님. 어떤 데이터셋은 task generalization에 집중함. 어떤 데이터셋은 분포 변화에 대한 강인함(distribution shift, domain generalization)에 집중함. 따라서, zero shot 성능 하나로 모델이 새로운 태스크를 배웠다고 단정하면 안 됨. 즉, CIFAR-10과 같은 벤치마크에서의 zero-shot 성능은 새로운 태스크를 수행하는 능력이라기보다, CLIP이 다른 데이터 분포와 도메인 변화에 얼마나 강인한지를 보여주는 지표로 해석하는 것이 더 적절함.

 

This analysis served as the basis for GPT-2 which focused excluively on studying the task-learning capabilities of language models via zero-shot transfer. → 대규모 사전학습 모델은, 명확하게 task를 가르치지 않아도 학습이 진행되는 과정에서 ‘task를 수행하는 능력’ 자체를 획득할 수 있음. 이 능력을 zero shot으로 확인.

 

핵심은 loss를 거치고 backpropagation을 가야 함.

The cosine similarity of these embeddings is then calculated, scaled by a temperature parameter τ, and normalized into a probability distribution via a softmax. Note that this prediction layer is a multinomial logistic regression classifier with L2-normalized inputs, L2-normalized weights, no bias, and temperature scaling.

 

For zero-shot evaluation, we cache the zero-shot classifier once it has been computed by the text encoder and reuse it for all subsequent predictions. This allows the cost of generating it to be amortized across all the predictions in a dataset. → 본질은 이거임. 초기에는 반드시 pair가 필요하고 그 이후 zero shot에서는 pair가 필요없음.

 

Another issue we encountered is that it’s relatively rare in our pre-training dataset for the text paired with the image to be just a single word. → 이미지와 pair인 text가 single word인 경우가 거의 없음.

 

Usually the text is a full sentence describing the image in some way. To help bridge this distribution gap, we found that using the prompt template “A photo of a {label}.” to be a good default that helps specify the text is about the content of the image. → Template가 있는 게 좋음.

 

On ImageNet, we ensemble 80 different context prompts and this improves performance by an additional 3.5% over the single default prompt discussed above. → 여러가지 ensemble prompt를 하는 게 성능이 더 올라감. → 같은 클래스라도 다양한 문장으로 표현한 텍스트 임베딩을 평균내면, 프롬프트 선택에 따른 편향과 노이즈가 줄어들어 성능이 올라감.