Görsel Yapay Zeka KILAVUZU

CLIP ve Vizyon-Dil Modelleri

CLIP (Contrastive Language-Image Pre-training) is a 2021 OpenAI model that trains an image encoder and a text encoder to place matching pictures and captions close together in one shared vector space.

Bu kılavuzu dinleyinAI tarafından anlatılan · ~9 min

Bu sayfada10 min read
  1. Genel Bakış
  2. Önemli çıkarımlar
  3. Derin Dalış
  4. Zero-shot classification of one photo with CLIP
  5. Gerçek Dünya Uygulaması
  6. CLIP ve Vizyon-Dil Modellerinin Geleceği
  7. Uygulamaya koymak
  8. Kaynaklar ve ek okuma
  9. Keşfetmeye Devam Edin
  10. Sık sorulan sorular

Genel Bakış

That shared space lets software classify, search and filter images with plain-language descriptions, and CLIP-style encoders became the visual front end of many text-to-image and multimodal chat systems.

Önemli çıkarımlar

  1. CLIP trains an image encoder and a text encoder together so matching images and captions end up close in one shared embedding space.
  2. OpenAI trained CLIP on 400 million web image-text pairs with a batch size of 32,768.
  3. The best CLIP model reached 76.2% zero-shot ImageNet accuracy, matching a supervised ResNet-50 without using ImageNet's labeled training images.
  4. CLIP scores how well text matches an image; it does not generate images or captions by itself.
  5. Stable Diffusion v1 uses a CLIP text encoder, and LLaVA uses a CLIP image encoder feeding a language model.
  6. The CLIP paper documents weak spots in counting, fine-grained categories and handwritten digits, scoring 88% on MNIST.

Derin Dalış

CLIP, short for Contrastive Language-Image Pre-training, is a pair of neural networks described by OpenAI researchers in the paper "Learning Transferable Visual Models From Natural Language Supervision", posted to arXiv on 26 February 2021. One network, the image encoder, turns a picture into a fixed-length list of numbers called an embedding. The other, the text encoder, turns a sentence into an embedding of the same length. Training pulls the embedding of an image toward the embedding of its real caption and pushes mismatched pairs apart. CLIP does not draw images or write captions. It scores how well a piece of text describes an image, and that single ability supports classification, search, content filtering and the conditioning of image generators. A vision-language model (VLM) is the broader family of systems that process images and text together, and CLIP is the encoder much of that family was built on.

The training data came from the web. The authors assembled 400 million image-text pairs from publicly available internet sources, keeping pairs whose text contained one of 500,000 search queries and capping each query at about 20,000 pairs. In every training step a batch of N pairs (32,768 in the paper) passes through both encoders. Each output is projected by a single linear layer into the shared space and normalized to unit length. The model then computes the cosine similarity of every image with every text, an N by N grid. The N true pairs sit on the diagonal and every other cell is a negative example. A cross-entropy loss asks each row to pick its correct caption and each column to pick its correct image, and the two losses are averaged. A learned temperature scales the similarities before the softmax; the paper initializes it to the equivalent of 0.07 and clips it so logits are never multiplied by more than 100.

Zero-shot classification reuses that scoring ability without any task-specific training, which is what zero-shot means. To sort an image into 1,000 categories, write one short sentence per category, such as "a photo of a dog", embed all of them with the text encoder, embed the image, and choose the sentence with the highest similarity. The paper points out that the text embeddings behave like the weights of a linear classifier, so they are computed once and cached. Wording matters. Prompt engineering combined with an ensemble of 80 context templates improved ImageNet accuracy by almost 5 percentage points over bare class names, with the ensemble alone adding 3.5 points.

The headline results set the template for later work. OpenAI trained five ResNet and three Vision Transformer (ViT) image encoders for 32 epochs each. The largest ResNet, RN50x64, took 18 days on 592 V100 GPUs; the largest ViT took 12 days on 256 V100 GPUs. The best model, ViT-L/14 given one extra epoch at 336-pixel resolution, reached 76.2% zero-shot top-1 accuracy on ImageNet, matching the original supervised ResNet-50, and 95% top-5. On seven natural distribution-shift test sets, including ImageNet Sketch and ObjectNet, zero-shot CLIP models shrank the gap between ImageNet accuracy and shifted accuracy by up to 75%. The paper also showed smooth scaling: average zero-shot error across 39 evaluations followed a log-log linear trend over a 44x range of compute.

Milestones followed quickly. Stable Diffusion v1 used a frozen CLIP ViT-L/14 as its text encoder. The OpenCLIP project reproduced the recipe on open data such as LAION-2B and DataComp-1B. Google's SigLIP paper (March 2023) swapped the softmax loss for a pairwise sigmoid loss and, combined with locked-image tuning, reported 84.5% zero-shot ImageNet accuracy after two days on four TPUv4 chips. LLaVA (April 2023) turned CLIP into the eyes of a chat assistant: features from a pretrained CLIP ViT-L/14 pass through a projection matrix into the Vicuna language model, which was then tuned on 158,000 machine-generated instruction-following samples. Its authors report an 85.1% relative score against GPT-4 on a synthetic benchmark and 92.53% on ScienceQA when combined with GPT-4. In this design CLIP no longer makes the final decision; it supplies visual features that a large language model reads alongside text.

Compared with a supervised classifier trained on a fixed label list, CLIP trades some peak accuracy on any one benchmark for flexibility, because any category that can be described in words is a valid label. The paper measured why the contrastive design was chosen: matching whole captions learned zero-shot ImageNet transfer 4x more efficiently than predicting a bag-of-words version of the caption, which was itself 3x more efficient than a transformer predicting the exact caption. ViTs were about 3x more compute-efficient than ResNets as CLIP image encoders. Fine-tuning a CLIP model on ImageNet raised ImageNet accuracy by 9.2% but erased most of its robustness advantage on shifted data. Against SigLIP, standard CLIP needs a softmax normalized over the whole batch, while the sigmoid loss treats each image-text pair as an independent yes-or-no decision and, per its authors, outperforms softmax by a large margin below batch sizes of 16,000.

The limitations are documented in the paper itself. Zero-shot CLIP is weak at fine-grained distinctions such as car models, flower species and aircraft variants, at counting objects, and at unfamiliar tasks such as estimating the distance to the nearest car, where it can be near chance. It scored 88% on MNIST handwritten digits, below logistic regression on raw pixels, because almost no digit-like images appear in its training data, and 51% on full street-number recognition (SVHN). Because CLIP learned to read text in images, OpenAI researchers described typographic attacks in the March 2021 Distill article "Multimodal Neurons in Artificial Neural Networks", where written words in a photo can steer the classification. Web-scraped captions also carry the associations and gaps of their sources, so outputs should be audited before use in sensitive settings.

In practice, running CLIP is cheap and training it is not. Classification costs one image-encoder pass per image plus one text-encoder pass per label, and label embeddings are reused across all images. Search systems store image embeddings in a vector index and compare each query by cosine similarity. Training from scratch is the expensive part: the original runs used hundreds of V100 GPUs for up to 18 days, and a batch of 32,768 forced the similarity computation to be sharded across GPUs. SigLIP found that a batch of about 32,000 is sufficient and that gains fade as batches grow toward one million, which lowers the bar for smaller labs. Most practitioners start from released weights, such as OpenAI's checkpoints or OpenCLIP models, and add a small trained linear layer when zero-shot accuracy is not enough.

04Çalışılan örnek

Zero-shot classification of one photo with CLIP

  1. Load a released CLIP checkpoint, for example an OpenAI ViT-B/32 or an OpenCLIP model, together with its image preprocessing and tokenizer.

  2. Write one prompt per candidate label, such as 'a photo of a cat', 'a photo of a dog' and 'a photo of a car'.

  3. Run the prompts through the text encoder and L2-normalize the three resulting embeddings; cache them for reuse.

  4. Resize and crop the photo with the model's preprocessing, run it through the image encoder, and L2-normalize the embedding.

  5. Compute the dot product between the image embedding and each text embedding, multiply by the model's learned scale, and apply a softmax.

  6. Read off the label with the highest probability, then add more template wordings and average their embeddings to see whether the prediction stabilizes.

Ne gösteriyor?

A probability for each label, computed without any task-specific training. To check it, run a small labeled set of your own images through the same steps and compare accuracy with and without prompt ensembling; the CLIP paper reports that ensembling helps on ImageNet.

Gerçek Dünya Uygulaması

Stable Diffusion v1-4 conditions its image generator on a frozen, pretrained CLIP ViT-L/14 text encoder, so the prompt a user types becomes CLIP text embeddings before any denoising starts.

LLaVA (2023) connects a pretrained CLIP ViT-L/14 image encoder to the Vicuna language model through a simple projection matrix, letting a chat model answer questions about photos.

Zero-shot image classification: the original CLIP paper reports 76.2% top-1 ImageNet accuracy from class names alone, without training on any of ImageNet's 1.28 million labeled images.

Text-to-image search over a photo collection: every image is embedded once, a query such as 'a red bicycle in snow' is embedded at search time, and results are ranked by cosine similarity.

Open reproductions such as OpenCLIP train CLIP-style models on public datasets; its ViT-bigG-14 trained on LAION-2B reports 80.1% zero-shot ImageNet accuracy in the project README.

CLIP ve Vizyon-Dil Modellerinin Geleceği

Several research directions grew directly out of CLIP's documented weaknesses. Data quality is one: the OpenCLIP project reports that the same architecture trained on different public datasets, for example LAION-2B versus DataComp-1B, reaches noticeably different zero-shot accuracy, so dataset curation has become a research topic of its own. Loss design is another: the 2023 SigLIP paper showed that a sigmoid loss decouples batch size from normalization and found little benefit beyond batches of about 32,000, shifting attention from raw scale to efficiency. The largest shift is in how the encoders are used. Since LLaVA's April 2023 release, a common recipe is to keep a contrastively trained image encoder and project its features into a large language model, so open questions now include how to preserve fine detail, text in images and spatial relations that a single global embedding discards. The weaknesses listed in the 2021 paper, such as counting, fine-grained categories and typographic attacks, remain useful test cases for any new vision-language model, and published evaluations rather than marketing claims are the reliable way to judge whether a newer system has closed them.

Uygulamaya koymak

Neden önemli?

  • Hız ve ölçek. Visual AI, inceleme, algılama ve etiketleme görevlerini geniş ölçekte otomatikleştirebilir.
  • Yapı seçimleri. Yaratıcı ekipler, daha az manuel revizyonla konseptleri daha hızlı prototipleyebilir.
  • Ekip ve iş akışı. Operasyonlar, daha önce işlenmesi zor olan görüntü ve video sinyallerini kullanabilir.

Dikkat edin

  • Kaynağın belirsiz olması durumunda görüntü hakları ve rıza yasal risk haline gelebilir.
  • Model performansı aydınlatma, demografik özellikler ve ortamlara göre değişiklik gösterebilir.
  • Güven eşikleri izlenmediği sürece yanlış pozitifler fark edilmeyebilir.

Sonraki adımlar

  1. Kesinlik, geri çağırma ve hata maliyetlerine ilişkin kabul kriterlerini tanımlayın.
  2. Gerçek üretim koşullarıyla eşleşen verilerle test edin.
  3. Düşük güvenirliğe sahip veya yüksek etkili tahminler için gerçek kişi tarafından yapılan incelemeyi ekleyin.
  4. Model kaymasını izleyin ve kamera veya veri kümesi değişikliklerinden sonra yeniden doğrulayın.

Kaynaklar ve ek okuma

  1. arXiv (OpenAI)Doğal Dil Denetiminden Aktarılabilir Görsel Modellerin Öğrenilmesi
  2. arXiv (Google)Sigmoid Loss for Language Image Pre-Training
  3. arXiv (NeurIPS 2023)Visual Instruction Tuning
  4. LLaVA project pageLLaVA: Large Language and Vision Assistant
  5. GitHub (mlfoundations)OpenCLIP: An open source implementation of CLIP
  6. DistillMultimodal Neurons in Artificial Neural Networks
  7. Hugging FaceCompVis/stable-diffusion-v1-4 model card

Keşfetmeye Devam Edin

Ücretsiz bülten

Günlük AI brifingini alın

Hafta içi her sabah sade İngilizce yazılmış, doğrulanmış üç yapay zeka hikayesi. Sonsuza kadar ücretsiz, reklam yok.

Hafta içi her gün bir e-posta. Tek tıklamayla aboneliğinizi iptal edin. Adresinizi asla satmayız veya paylaşmayız.

Kendinizi test edin

Take the CLIP and Vision-Language Models quiz

Her yanıtla ilgili anında geri bildirim ve bir kursu geçtiğinizde doğrulanabilir bir kimliğe sahip paylaşılabilir bir sertifika.

Testi başlat

Ücretsiz AI eğitimini destekleyin. AI Understanding, bir 501(c)(3) kâr amacı gütmeyen kuruluştur; hiçbir zaman reklam yoktur, ödeme duvarı yoktur. Bağış yap

Sık sorulan sorular

CLIP ve Vizyon-Dil Modelleri Nedir?

CLIP (Contrastive Language-Image Pre-training) is a 2021 OpenAI model that trains an image encoder and a text encoder to place matching pictures and captions close together in one shared vector space. That shared space lets software classify, search and filter images with plain-language descriptions, and CLIP-style encoders became the visual front end of many text-to-image and multimodal chat systems.

CLIP'in arkasındaki temel fikir nedir?

CLIP, hem görüntüleri hem de metni tek bir paylaşılan vektör uzayına eşler, böylece benzerlikleri doğrudan ölçülebilir.

CLIP hangi eğitim yaklaşımını kullanıyor?

CLIP karşılaştırmalı bir amaç kullanır: doğru resim yazısı çiftleri yakına çekilirken uyumsuz çiftler birbirinden uzaklaştırılır.

Orijinal CLIP aktarım kurulumunda sıfır atış sınıflandırması ne anlama geliyor?

CLIP'in önemli bir ön eğitimi vardır; Sıfır atış, hedef sınıflandırma değerlendirmesine tabidir.

CLIP bir görsel ile altyazının eşleşip eşleşmediğini nasıl ölçer?

CLIP her birini bir vektör halinde kodlar ve kosinüs benzerliğini hesaplar; Daha yüksek benzerlik, daha yakın bir anlamsal eşleşme anlamına gelir.

CLIP yaklaşık olarak ne kadar veri üzerinde eğitildi?

CLIP, internetten toplanan yaklaşık 400 milyon resim yazısı çiftinden bilgi edinerek ona geniş bir görsel dil bilgisi kazandırdı.