How CLIP's Contrastive Training Works CLIP contrastive 학습 정리

CLIP aligns an image encoder and a text encoder into one shared embedding space.

  • For the N (image, caption) pairs in a batch, build an N×N similarity matrix.
  • Pull the diagonal (real pairs) close and push everything else (fake pairs) away: a bidirectional InfoNCE loss.
  • Bigger batches, more negatives, better training. The original paper went all the way to 32,768.

What you get out is the aligned space itself, not a classifier. That’s the whole point. Zero-shot classification, text-based retrieval, text conditioning in diffusion: every one of them runs on top of this single space.

CLIP은 이미지 인코더와 텍스트 인코더를 같은 임베딩 공간으로 정렬한다.

  • 배치 안의 N개 (이미지, 캡션) 쌍에 대해 N×N 유사도 행렬을 만든다.
  • 대각선(진짜 쌍)은 가깝게, 나머지(가짜 쌍)는 멀게 — 양방향 InfoNCE 손실.
  • 배치가 클수록 negative가 많아져 학습이 좋아진다 (원 논문은 32,768).

결과물은 분류기가 아니라 정렬된 공간 그 자체. 그래서 zero-shot 분류, 텍스트 기반 검색, diffusion의 텍스트 컨디셔닝까지 전부 이 공간 위에서 돌아간다.

← home← 랜딩으로