목차
핵심 한 줄 정리
Vision-language foundation model은 image와 text를 공통 representation으로 정렬하거나 visual token을 language model의 context로 주입해 여러 task를 하나의 pretrained model로 풀며, grounding과 promptable output, tool chaining을 더해 text 응답을 실제 pixel과 전문 vision model의 동작으로 연결한다.
반드시 기억할 개념
Task-specific model에서 foundation model로
전통적인 computer vision pipeline은 task마다 dataset과 model을 따로 만든다.
Image classification, captioning, detection, segmentation을 각각 풀려면 서로 다른 label과 architecture를 준비해야 한다. Dataset distribution이나 category가 바뀌면 다시 학습하는 경우도 많다.
Foundation model은 넓은 data와 objective로 먼저 pretraining한 뒤 여러 downstream task에 적응하는 방향이다.
Foundation model이라는 이름만으로 generalization이 보장되지는 않는다. 다만 보통 다음 특성을 목표로 한다.
- 큰 model과 넓은 training data를 사용한다.
- 직접 만든 class label보다 data 자체에서 얻는 weak 또는 self-supervised signal을 활용한다.
- 하나의 representation이나 interface를 여러 task에 재사용한다.
- 적은 labeled data, few-shot example, 또는 prompt만으로 새로운 task에 적응한다.
Vision-language model은 image와 text가 함께 존재하는 web data를 이용한다. Text는 object category뿐 아니라 color, shape, action, context를 함께 담을 수 있으므로 fixed class label보다 풍부한 supervision이 된다.
Vision-language foundation model의 세 가지 방향
강의의 model들은 대략 세 방향으로 나눌 수 있다.
| 방향 | 대표 model | 핵심 interface | 주된 output |
|---|---|---|---|
| Shared embedding | CLIP, CoCa | image와 text의 similarity | class, retrieval ranking |
| Multimodal language model | LLaVA, Flamingo, Molmo | visual token을 language model에 제공 | autoregressive text, point |
| Promptable vision model | SAM | image와 spatial prompt를 함께 encoding | segmentation mask |
마지막으로 chaining은 이 model들을 서로 연결한다. Language model이 문제를 분해하고 CLIP, detector, SAM 같은 전문 model을 tool로 호출하면 한 model의 output space를 넘어서는 task를 수행할 수 있다.
CLIP의 기본 구조
CLIP은 Contrastive Language-Image Pre-training의 약자이다. Image encoder와 text encoder가 서로 다른 modality를 같은 embedding space로 mapping한다.
는 image, 는 그 image와 연결된 text이다. 보통 두 embedding을 unit vector로 normalize한다.
Image-text similarity는 normalized embedding의 dot product와 temperature 로 계산한다.
Normalized vector의 dot product는 cosine similarity와 같다. Positive pair 의 similarity 는 높이고, minibatch 안의 mismatched pair 는 낮추는 것이 목표이다.
%% title: CLIP의 Dual-Encoder 구조
%% caption: Image encoder와 text encoder가 각각 embedding을 만들고, batch 내 모든 image-text dot product로 similarity matrix를 구성해 대각선 pair를 높이도록 학습한다.
flowchart LR
images["Image Batch<br/>I₁ … Iₙ"] --> vision["Vision Encoder"]
texts["Text Batch<br/>T₁ … Tₙ"] --> language["Text Encoder"]
vision --> ie["Normalized Image Embeddings<br/>N × d"]
language --> te["Normalized Text Embeddings<br/>N × d"]
ie --> sim["Similarity Matrix<br/>S = IE · TEᵀ / τ"]
te --> sim
sim --> i2t["Image → Text Cross-Entropy"]
sim --> t2i["Text → Image Cross-Entropy"]
i2t --> loss["Symmetric CLIP Loss"]
t2i --> loss
Symmetric image-text contrastive loss
Batch size를 라 하면 image 가 올바른 text 를 찾는 loss는 다음과 같다.
반대 방향으로 text 가 올바른 image 를 찾는 loss도 사용한다.
최종 loss는 두 방향을 평균낸 symmetric loss이다.
한 batch의 다른 sample들이 negative pair 역할을 한다. 따라서 batch가 크면 더 다양한 negative를 비교할 수 있고 fine-grained concept을 구분할 가능성이 커진다. 강의에서는 약 32,000의 매우 큰 effective batch를 hard negative가 등장할 확률을 높이는 예로 들었다.
Batch가 크다고 항상 좋은 representation이 생기는 것은 아니다. Negative가 너무 쉬우면 relation이나 세부 category를 학습하지 못하고, handcrafted hard negative만 과도하게 넣으면 broad semantic generalization이 약해질 수 있다. Data 구성과 negative distribution이 model이 배우는 similarity의 의미를 결정한다.
CLIP의 training data와 scale
CLIP은 human이 직접 부여한 fixed class label 대신 web의 image-text pair를 weak supervision으로 사용한다. 원 논문의 큰 model 예시에서는 약 4억 개 image-text pair와 3억 700만 parameter 규모의 Vision Transformer가 사용되었다.
ImageNet은 약 130만 image와 1,000개의 category를 중심으로 한다. Web caption은 noisy하지만 훨씬 큰 규모로 모을 수 있고 object name 외에도 scene과 property를 포함한다. 강의에서는 unusual pose와 context를 포함한 ObjectNet에서 CLIP representation이 ImageNet-only model보다 잘 일반화하는 예를 들었다.
Scale만으로 data quality 문제가 사라지지는 않는다. Web text는 image의 실제 spatial content보다 uploader의 감정이나 주변 맥락을 설명할 수 있고, bias와 중복도 포함한다. 어떤 pair를 filtering하고 어떤 concept을 충분히 포함할지가 model size만큼 중요하다.
CLIP을 downstream task에 사용하는 방법
Pretrained image encoder를 사용하는 방법은 세 가지로 구분할 수 있다.
- Linear probe: encoder를 고정하고 labeled feature 위에 linear classifier만 학습한다.
- Fine-tuning: pretrained encoder 일부 또는 전체를 downstream data로 update한다.
- Zero-shot classification: text encoder로 class prototype을 만들고 별도 training 없이 image와 비교한다.
Linear probe는 representation에 class 정보가 선형적으로 분리되어 있는지 측정하기 좋다. Fine-tuning은 task에 더 맞게 적응하지만 labeled data와 compute가 필요하다. Zero-shot은 class name만으로 바로 사용할 수 있지만 prompt와 training distribution에 민감하다.
Zero-shot classification
새 dataset의 class가 라고 하자. 각 class name을 text prompt에 넣어 prototype을 만든다.
Input image embedding 와 각 class prototype의 similarity를 비교한다.
이는 text embedding을 class center로 사용하는 nearest-neighbor classifier로 볼 수 있다. Classifier vocabulary를 inference 시점에 text로 정할 수 있으므로 open-vocabulary classification이 가능하다.
Open vocabulary가 model이 모든 concept을 안다는 뜻은 아니다. Class description이 pretraining data와 충분히 연결되어 있어야 하고, encoder가 그 visual property를 구분할 수 있어야 한다.
Prompt engineering과 prompt ensemble
CLIP은 internet에서 주로 phrase나 sentence와 함께 학습되었으므로 class name 하나보다 자연스러운 prompt가 잘 동작할 수 있다. 강의에서는 dog 대신 a photo of a dog를 사용했을 때 ImageNet accuracy가 약 1.3 percentage point 개선된 예를 들었다.
Prompt 하나의 표현에 의존하지 않도록 여러 template을 사용할 수 있다.
a photo of a dog, a drawing of a dog처럼 여러 prompt의 embedding을 평균하면 표현 방식에 따른 variance를 줄일 수 있다.
CLIP의 장점
CLIP representation은 다음 특성 때문에 foundation model의 중요한 출발점이 되었다.
- Open-vocabulary classification과 retrieval을 같은 similarity 계산으로 수행한다.
- Image와 text embedding을 미리 계산하면 nearest-neighbor search가 빠르다.
- Labeled category가 적거나 없는 domain에 zero-shot으로 적용할 수 있다.
- Image encoder를 detection, segmentation, multimodal language model의 backbone으로 재사용할 수 있다.
- Text description을 interface로 사용하므로 다른 language model과 연결하기 쉽다.
Image-to-text retrieval은 query image에 가까운 caption을 찾고, text-to-image retrieval은 query text에 가까운 image를 찾는다. Training loss가 이미 양방향 retrieval objective이므로 같은 embedding을 그대로 재사용할 수 있다.
CLIP의 한계
CLIP은 global image와 global text의 alignment를 학습한다. 이 objective만으로는 object 위치와 relation을 정확히 학습하기 어렵다.
강의의 대표 예는 a mug in grass와 grass in a mug이다. 두 phrase는 같은 noun을 포함하지만 relation이 반대이다. CLIP은 image 전체에서 mug와 grass가 함께 나타난다는 사실은 잡아도 어느 것이 어느 안에 있는지 구분하지 못할 수 있다.
주요 한계는 다음과 같다.
- Compositionality: 같은 concept의 다른 조합과 relation에 약하다.
- Spatial grounding: word와 pixel region의 correspondence를 직접 감독하지 않는다.
- Fine-grained distinction: 적절한 negative가 없으면 비슷한 subclass를 구분하지 못한다.
- Data dependence: web pair의 누락, noise, bias를 그대로 학습할 수 있다.
- Closed evidence: 높은 similarity가 어떤 pixel을 근거로 했는지 설명하지 않는다.
ViT의 patch token은 global class token을 만드는 attention에 참여하므로 gradient를 간접적으로 받는다. 하지만 CLIP contrastive loss는 개별 patch와 phrase를 직접 정렬하지 않는다. 따라서 patch-level localization을 자동으로 보장하지 않는다고 이해하는 편이 정확하다.
Winoground, ARO, CREPE 같은 benchmark는 object와 relation을 재조합한 example로 이런 compositional limitation을 측정한다.
CoCa의 contrastive-captioning objective
CoCa는 Contrastive Captioners의 약자이다. CLIP의 global contrastive objective에 autoregressive captioning objective를 함께 사용한다.
Image encoder에서 얻은 visual feature와 text representation으로 contrastive loss를 계산한다.
Multimodal decoder는 visual feature에 cross-attention하며 caption token을 예측한다.
전체 objective는 두 loss의 weighted sum이다.
Contrastive loss는 image와 text의 global correspondence를 학습하고 captioning loss는 image를 설명하는 데 필요한 더 세밀한 information을 요구한다. 단순히 cat과 dog를 구분하는 것보다 image 속 object, action, relation을 sentence로 생성하는 것이 강한 learning signal이 될 수 있다.
Multimodal language model의 기본 관점
Autoregressive language model은 이전 token에서 다음 token을 예측한다.
Multimodal language model은 image에서 만든 visual token을 추가 context로 사용한다.
Image를 language model이 읽을 수 있는 token sequence로 바꾸면 captioning, VQA, OCR, classification을 모두 next-token prediction 형태로 통일할 수 있다. Task-specific output head 대신 natural-language prompt와 answer format을 사용한다는 점이 중요하다.
LLaVA의 visual token 연결
LLaVA는 pretrained vision encoder, projector, pretrained language model을 연결하는 단순한 구조를 사용한다.
는 visual token 수이고 는 vision encoder dimension이다. Linear projector가 이를 language model embedding dimension 로 바꾼다.
Projected visual token과 text token을 하나의 sequence로 넣는다.
Language model의 architecture를 크게 바꾸지 않고 visual token을 prefix context처럼 사용할 수 있다는 장점이 있다.
Global CLS token 하나만 쓰면 image 전체 의미는 담을 수 있지만 spatial detail이 많이 압축된다. 실제 multimodal model은 CLIP ViT의 intermediate 또는 penultimate layer에서 patch token들을 가져오는 경우가 많다. 이 token들은 final global embedding보다 위치별 information을 더 많이 유지한다.
Input fusion과 cross-attention fusion
LLaVA식 input fusion은 projected visual token을 text token과 함께 language model input에 넣는다. 구조가 단순하지만 visual token 수가 늘면 self-attention context와 computation이 커진다.
Flamingo는 visual information을 language model의 여러 layer에 cross-attention으로 주입한다. Language hidden state가 query가 되고 compressed visual token이 key와 value가 된다.
각 language layer는 현재 token을 생성하는 데 필요한 visual region을 선택해서 읽을 수 있다.
Flamingo의 Perceiver Resampler와 gated cross-attention
Image와 video는 input 크기에 따라 visual token 수가 달라질 수 있다. Flamingo의 Perceiver Resampler는 variable-length visual feature를 fixed number의 latent token으로 압축한다.
은 image resolution과 무관하게 고정된 latent token 수이다. 이 token을 language model layer 사이의 cross-attention에 제공한다.
Flamingo는 pretrained vision encoder와 language model을 대부분 고정하고 Perceiver Resampler와 새로 삽입한 gated cross-attention block을 학습한다. Residual update를 단순화해 쓰면 다음과 같다.
는 학습 가능한 gate parameter이다. Gate를 0에 가깝게 초기화하면 training 시작 시 기존 language model의 동작을 거의 유지하면서 visual information을 점진적으로 추가할 수 있다.
%% title: LLaVA와 Flamingo의 Visual-Language Fusion
%% caption: LLaVA는 visual token을 language token sequence에 직접 삽입하고, Flamingo는 visual feature를 resample한 뒤 language model 사이의 gated cross-attention으로 참조한다.
flowchart TB
subgraph llava["LLaVA: Input Fusion"]
li["Image"] --> lv["Vision Encoder"]
lv --> lp["Projector"]
lp --> lvt["Visual Tokens"]
lt["Text Tokens"] --> lseq["Combined Token Sequence"]
lvt --> lseq
lseq --> llm1["Causal Language Model"]
end
subgraph flamingo["Flamingo: Cross-Attention Fusion"]
fi["Image / Video"] --> fv["Vision Encoder"]
fv --> pr["Perceiver Resampler"]
pr --> fixed["Fixed Visual Tokens"]
ft["Text Tokens"] --> llm2["Language Model Layers"]
fixed --> cross["Gated Cross-Attention"]
llm2 --> cross
cross --> next["Next Language Layers"]
end
Interleaved image-text training
Flamingo는 하나의 image-caption pair만 보지 않고 image와 text가 섞인 긴 sequence를 학습한다.
Image-causal masking을 사용해 text 를 생성할 때 대응하는 현재 image와 허용된 이전 context만 보도록 한다. 다른 image의 feature를 잘못 참조하는 것을 막으면서 multi-image context와 대화 형식을 학습한다.
이 방식은 다음 능력으로 이어진다.
- 한 image에 대한 multi-turn dialogue
- 여러 image의 공통점과 차이 비교
- Image-caption example을 보고 새 image를 설명하는 in-context learning
- Image-question-answer example을 보고 새 VQA 문제에 답하는 few-shot learning
- OCR와 visual arithmetic을 text generation으로 처리
Zero-shot은 task example 없이 instruction만 주는 것이고, few-shot은 같은 context 안에 몇 개 demonstration을 제공하는 것이다. 둘 다 gradient update 없이 inference context만 바꾼다.
Benchmark만으로 multimodal model을 평가하기 어려운 이유
Captioning, VQA, OCR, reasoning을 question-answer format으로 통일하면 많은 benchmark를 만들 수 있다. 하지만 평균 accuracy만으로 실제 usefulness를 모두 판단하기는 어렵다.
평가에는 다음 관점이 함께 필요하다.
- Task benchmark의 정답률
- 새로운 domain과 compositional example에서의 robustness
- Pixel-level grounding과 evidence consistency
- Hallucination과 abstention behavior
- Human preference와 실제 workflow 성공률
- Model, data, code의 재현 가능성
강의의 Molmo 사례에서는 870명가량의 participant가 약 32만 5천 pairwise comparison을 수행한 user study가 소개되었다. 이런 preference evaluation은 정답 하나로 평가하기 어려운 free-form response를 비교하는 한 방법이다. 다만 preference가 factual correctness를 자동으로 보장하지는 않는다.
Data quantity보다 빠져 있는 supervision이 중요할 수 있다
Internet caption은 incidental text인 경우가 많다. Image에 실제로 무엇이 어디 있는지보다 uploader의 감정이나 사건의 배경을 설명할 수 있다. 반면 spatial relation, relative size, material, exact text, UI location처럼 사람에게 자명한 내용은 거의 쓰이지 않는다.
강의의 Molmo 사례는 약 70만 개의 dense curated image-text pair로 다음 information을 직접 elicitation했다.
- Object의 위치와 서로의 spatial relation
- Size, shape, material, orientation
- Image 안의 written text와 number
- Point coordinate로 표현한 evidence
- Counting과 comparison 과정
비교 대상으로 언급된 model은 수십억 개 web pair를 사용했다. 이 사례의 핵심은 작은 data가 항상 큰 data보다 낫다는 뜻이 아니라, target capability에 필요한 supervision이 빠져 있다면 scale만 늘려도 문제가 해결되지 않는다는 점이다.
Annotator에게 description을 typing하게 하는 대신 말하게 한 것도 중요한 design choice였다. Spoken description은 사람이 글로 쓸 때 생략하는 obvious spatial detail을 더 많이 드러낼 수 있다.
Pixel grounding과 pointing
일반적인 multimodal language model은 answer text만 생성한다. Grounded model은 answer를 만들기 전에 또는 함께 image coordinate를 출력한다.
Counting task라면 model은 발견한 object마다 point를 생성한 뒤 point 수를 answer로 연결할 수 있다.
Pointing은 다음 장점이 있다.
- Answer가 어떤 pixel evidence를 사용했는지 사람이 확인할 수 있다.
- Counting에서 누락과 중복을 발견하기 쉽다.
- OCR이나 UI question에서 읽은 위치를 함께 제시할 수 있다.
- Point를 detector, segmenter, robot planner의 input으로 전달할 수 있다.
Grounding이 hallucination을 줄일 수는 있지만 없애지는 못한다. Model이 잘못된 위치를 자신 있게 가리킬 수 있기 때문이다. Point가 실제 object와 일치하는지 확인하는 verifier와 uncertainty estimate가 여전히 필요하다.
Segment Anything Model
Segment Anything Model, SAM은 category가 고정된 semantic segmentation 대신 user prompt로 지정한 object의 mask를 출력한다.
는 image이고 는 point, bounding box, mask 같은 spatial prompt이다. Original SAM의 native prompt는 point, box, mask이며 text prompt는 별도 text-grounding model이나 확장을 통해 연결한다.
SAM은 세 component로 나뉜다.
- Image encoder가 image embedding을 계산한다.
- Prompt encoder가 point, box, mask를 embedding한다.
- Lightweight mask decoder가 image와 prompt embedding에서 mask를 예측한다.
는 각 mask의 predicted quality score이다. Image embedding을 한 번 계산해 cache하면 여러 prompt에 대해 작은 decoder만 반복 실행할 수 있어 interactive segmentation에 적합하다.
%% title: Segment Anything Model의 Promptable Segmentation
%% caption: Image encoder는 image embedding을 한 번 계산하고, point·box·mask prompt를 따로 encoding한 뒤 가벼운 mask decoder가 여러 candidate mask와 quality score를 출력한다.
flowchart LR
image["Image"] --> imageenc["Image Encoder<br/>ViT"]
imageenc --> embedding["Reusable Image Embedding"]
point["Point Prompt"] --> promptenc["Prompt Encoder"]
box["Box Prompt"] --> promptenc
maskin["Optional Mask Prompt"] --> promptenc
embedding --> decoder["Lightweight Mask Decoder"]
promptenc --> decoder
decoder --> masks["Multiple Candidate Masks"]
decoder --> quality["Predicted Mask Quality"]
masks --> select["Select / Refine Mask"]
quality --> select
Ambiguous prompt와 multiple masks
한 point는 여러 valid object level을 가리킬 수 있다. Scissors의 handle 위 point는 한쪽 handle, handle 전체, scissors 전체를 뜻할 수 있다.
SAM은 이런 ambiguity를 한 mask로 강제하지 않고 서로 다른 granularity의 mask 여러 개를 예측한다. 강의에서는 세 mask를 출력하는 경우를 설명했다.
Training에서는 ground-truth mask와 가장 잘 맞는 candidate를 선택해 mask loss를 계산할 수 있다.
이 방식은 하나의 ambiguous prompt에 가능한 해석이 여러 개라는 사실을 model output에 반영한다.
SAM의 data engine
Promptable segmentation이 category를 넘어 일반화하려면 매우 다양한 mask가 필요하다. 강의에서는 기존 dataset과 비교해 image 수를 약 6배, mask 수를 약 400배 늘린 data collection을 소개했다.
수집은 human과 model을 반복해서 연결하는 data engine으로 이루어진다.
- Human이 초기 mask를 annotation한다.
- 초기 model을 학습한다.
- Model이 새 image에 mask proposal을 만든다.
- Human이 proposal을 수정한다.
- 개선된 data로 model을 다시 학습한다.
Model이 좋아질수록 annotation 시간이 줄고 더 많은 data를 모을 수 있으며, 늘어난 data가 다시 model을 개선한다. Foundation model의 성능은 architecture뿐 아니라 이런 data flywheel에 크게 의존한다.
Model chaining
Chaining은 한 model의 output을 다른 model의 input으로 사용해 각 model의 강점을 조합하는 방식이다.
예를 들어 CLIP이 처음 보는 fine-grained class name만으로 분류하기 어렵다면 language model이 각 class의 visual description을 만든 뒤 그 description을 CLIP prompt로 사용할 수 있다.
Class name보다 shape, color, part를 설명한 prompt가 image embedding과 더 잘 정렬될 수 있다.
다른 예로 grounded language model이 cricket bat의 point를 출력하고 SAM 2가 그 point에서 video mask를 추적할 수 있다.
Robot에서는 point를 motion planner의 target으로 전달할 수 있다. Language model이 모든 perception과 control을 직접 수행하는 대신 전문 tool에 spatially grounded command를 넘기는 구조이다.
%% title: Vision Model Chaining을 사용한 구성
%% caption: 하나의 model에 모든 기능을 넣기보다 detector·segmenter·retriever·language model을 명시적인 중간 결과로 연결해 복합 task를 풀 수 있다.
flowchart LR
request["Language Request"] --> planner["LLM Planner / Agent"]
image["Image"] --> detect["Open-Vocabulary Detector"]
detect --> boxes["Named Boxes"]
boxes --> segment["SAM"]
image --> segment
segment --> masks["Object Masks"]
masks --> crop["Masked Crops / Regions"]
crop --> vlm["CLIP / VLM / OCR"]
planner --> detect
planner --> segment
planner --> vlm
vlm --> evidence["Structured Evidence"]
boxes --> evidence
masks --> evidence
evidence --> planner
planner --> answer["Answer / Program / Action"]
Visual programming과 agent
Visual programming에서는 language model이 question을 바로 답하지 않고 실행할 program을 만든다. Program은 detector, classifier, segmenter, OCR, arithmetic function을 호출한다.
예를 들어 두 image에 있는 사람 수의 합을 묻는다면 다음 순서로 분해할 수 있다.
- 첫 image에서 person detector를 실행한다.
- 두 번째 image에서 person detector를 실행한다.
- 각 detection 수를 센다.
- 두 값을 더한다.
- 자연어 answer를 만든다.
In-context example로 question과 program pair를 보여 주면 새로운 question에서도 비슷한 program을 생성할 수 있다. 현재 question과 유사한 demonstration을 retrieval해 넣는 dynamic prompting은 무작위 example보다 효과적일 수 있다.
이 구조는 agent로도 볼 수 있다. Agent는 problem을 분석하고 사용할 tool과 실행 순서를 선택하며 intermediate result를 결합한다.
Chaining의 장점과 비용
Chaining은 모든 capability를 하나의 거대한 model에 다시 학습하지 않고 기존 전문 model을 재사용한다.
- 각 tool의 output을 inspection할 수 있어 debugging이 쉽다.
- Detector나 segmenter를 새 version으로 교체할 수 있다.
- Training data가 없는 task도 program composition으로 풀 수 있다.
- Explicit intermediate result를 verifier로 확인할 수 있다.
반면 다음 비용도 있다.
- 여러 model을 memory에 올리고 순차 실행하므로 latency와 compute가 커진다.
- 앞 단계의 error가 뒤 단계로 전파된다.
- 서로 다른 coordinate, label, confidence format을 맞춰야 한다.
- Language model이 잘못된 tool이나 argument를 선택할 수 있다.
- API model에 의존하면 reproducibility와 privacy 문제가 생길 수 있다.
자주 사용하는 chain을 하나의 model로 distillation하면 inference cost를 낮출 수 있지만 modularity와 interpretability 일부를 잃을 수 있다.
Hallucination을 줄이는 방법
Multimodal model의 fluent answer는 visual evidence와 일치하지 않을 수 있다. 강의에서 제시한 대응 방향은 다음과 같다.
- Target reasoning과 grounding을 포함한 high-quality data를 수집한다.
- Answer와 함께 point, box, mask 같은 evidence를 생성한다.
- Detector, OCR, retrieval 같은 전문 tool로 사실을 확인한다.
- 별도의 verifier가 answer와 evidence의 consistency를 검사한다.
- Confidence가 낮을 때 답을 보류하거나 추가 관측을 요청한다.
실제 system은 generator 하나의 output을 바로 사용자에게 내보내기보다 여러 verifier를 통과시키기도 한다. Grounding은 검증 가능한 interface를 제공하지만, evidence 자체가 틀릴 수 있으므로 verification과 함께 사용해야 한다.
전체 흐름 정리
Vision-language foundation model의 발전을 하나의 흐름으로 보면 다음과 같다.
- CLIP은 image와 text를 shared embedding space에 정렬해 open-vocabulary retrieval과 classification을 가능하게 했다.
- CoCa는 caption generation을 더해 global alignment보다 풍부한 visual feature를 학습했다.
- LLaVA는 visual patch token을 projector로 language model input에 연결했다.
- Flamingo는 fixed visual token과 gated cross-attention으로 image를 language model 여러 layer에 주입하고 interleaved context를 학습했다.
- Molmo 사례는 dense curated data와 pixel grounding이 model scale만큼 중요함을 보여 주었다.
- SAM은 foundation model의 output을 text에서 promptable mask로 확장했다.
- Chaining은 language model, grounding model, detector, segmenter를 program으로 묶어 새로운 capability를 구성했다.
핵심은 modality를 단순히 한 model에 넣는 것이 아니다. 어떤 representation을 공유할지, visual evidence를 language generation에 어떻게 전달할지, internet data에서 빠진 supervision을 어떻게 모을지, output을 어떻게 검증 가능한 action으로 연결할지가 vision-language system의 성능을 결정한다.
과제에서 확인할 것
CLIP similarity matrix
Batch의 image embedding 와 text embedding 를 normalize한 뒤 의 shape가 인지 확인한다. Row-wise cross entropy와 column-wise cross entropy가 각각 image-to-text, text-to-image loss가 되는 이유를 본다.
In-batch negative
Positive pair는 similarity matrix의 diagonal이고 나머지는 negative이다. Batch size와 data sampling 방식이 hard negative의 종류를 어떻게 바꾸는지 확인한다.
Zero-shot prompt classifier
Class마다 여러 prompt embedding을 normalize하고 평균낸 뒤 다시 normalize하는 순서를 확인한다. Class prototype과 image embedding의 cosine similarity가 linear classifier logit처럼 사용되는 과정도 본다.
CLIP patch token
CLS token과 patch token의 shape와 역할을 구분한다. Global contrastive loss가 patch token에 간접 gradient를 주지만 patch-level text alignment를 직접 감독하지는 않는다는 점을 확인한다.
LLaVA projector shape
Vision feature의 dimension 와 language embedding dimension 이 다를 때 projector 가 필요한 이유를 확인한다. Visual token 수가 language model context length와 self-attention cost에 미치는 영향도 계산한다.
LLaVA와 Flamingo의 fusion 비교
Visual token을 input sequence에 직접 붙이는 방식과 language layer마다 cross-attention을 삽입하는 방식의 차이를 비교한다. Frozen backbone을 유지할 때 학습되는 parameter가 무엇인지도 구분한다.
Grounding 검증
Counting answer와 point 개수가 일치하는지만 보지 말고, 각 point가 실제 target object 위에 있는지 확인한다. Text answer, point evidence, detector output 사이 consistency를 검사하는 verifier를 생각해 본다.
SAM의 ambiguous mask
Point 하나가 object 전체와 part를 동시에 가리킬 수 있는 example을 만들고, 여러 mask candidate 중 ground truth와 가장 가까운 mask에 loss를 주는 이유를 확인한다.
Chaining의 failure propagation
Language model이 만든 plan, detector result, counting logic 중 어느 단계에서 error가 발생했는지 intermediate output으로 추적한다. End-to-end model과 비교해 modular chain이 얻는 interpretability와 추가 latency의 trade-off를 정리한다.