Multimodal Understanding

Foundation Models · M.Sc. AIS @ UniTN 2026

Paolo Rota, Jacopo Staiano, Federico Bartsch

{name.surname}@unitn.it

University of Trento

From LLMs to vision

Where we left off

Three ideas from the language block, and where each one comes back with images.

Idea In the language block With images
Free labels The text supervises itself: next token (GPT), masked words (BERT), corrupted spans (T5). Can images supervise themselves too? What is their free label? (Section 1)
Dense retrieval Encode queries and documents separately, rank by cosine, index with FAISS, score with Recall@K. A cross-encoder reranks the top \(K\). CLIP: the documents are images. Fusion encoders play the reranker. (Sections 2–3)
Question answering From extractive (a span of the passage, SQuAD) to generative answers. VQA: the passage is an image, and the answer is generated. (Section 3)

One warning we carry over

A high score does not prove the model read the passage.

  • In SQuAD 2.0, 85–89% of the training questions containing n’t or never are unanswerable: a model can learn the shortcut instead of the reading.
  • A model fine-tuned on SQuAD scores 75.6 F1 in-domain and 46.7 on TriviaQA.

With images the shortcut is to answer without looking. We will test it in the evaluation section.

So, back to the first row: what is the free label for pixels?

Sen, P. & Saffari, A. (2020). What do models learn from question answering datasets? EMNLP.

1. Vision foundation models (no language)

Why learn without labels?

Annotation does not scale.

  • Human labour to annotate and clean raw data: slow, expensive, error-prone.
  • Labels fix the vocabulary in advance: 1,000 ImageNet classes, and nothing else.

The data keeps moving. Distributions shift over time; you cannot relaunch an annotation campaign every year.

Solution: exploit the raw data itself. Self-supervised learning (SSL) builds a pretext task whose labels are generated automatically, and learns features by solving it.

Today’s question: does a vision encoder need language to learn to see, or can language be added afterwards? Section 1 uses no language at all, Section 2 adds it; we answer at the end.

What is a pretext task?

A task we do not care about, designed so that solving it requires understanding the data.

The recipe:

  1. Take a raw sample.
  2. Hide or transform part of it.
  3. Ask the model to recover what was hidden. The hidden part is the label, so it costs nothing.

You already know two pretext tasks:

Model What is hidden Free label
GPT the rest of the sentence the next token
BERT 15% of the words the masked words

After pretraining, the pretext task is thrown away: what we keep is the encoder and its features.

Activity: invent a pretext task

You have 1 billion unlabelled images and no annotators.

Apply the recipe to images: what would you hide or transform, and what would the model predict?

Your answers, mapped: rotate → predict the angle · grey → predict the colours · hide a region → paint it back · shrink → upscale · two crops of one image → “are they the same image?”

Pretext tasks

Solving the pretext task forces the model to learn features that transfer. The labels are generated automatically from the image.

Rotation (4-way classification)

Inpainting

Colorization

Super-resolution

How do we evaluate a representation?

The pretext task is thrown away, so we cannot judge it by its own loss. We judge the features it produced, and for that we need labels again: those of a downstream dataset, never used during pretraining.

Protocol What is trained Labels needed Cost The question it answers
Linear probe one linear layer to train the layer minutes is the information linearly available?
k-NN nothing as the stored reference set seconds per query batch are similar images close?
Fine-tuning everything for the target task (often few) hours to days, per task is it a good starting point?
Visualisation nothing only to colour the points seconds what does the space look like? (qualitative)

Linear probe

  • A single linear layer on top of the frozen encoder: \(\hat{y} = \text{softmax}(W f(x) + b)\).
  • How is it trained? With cross-entropy on a labelled set (e.g. the ImageNet training split). Only \(W, b\) receive gradients.
  • Because \(f\) never changes, compute \(f(x)\) once for the whole dataset: training is then plain logistic regression.
  • Report top-1 accuracy on the validation split.

k-NN classifier

  • No parameters to learn, but labels are still needed. You need:
    • the frozen encoder;
    • a labelled reference set (usually the same training split as the linear probe), whose features and labels you store;
    • a similarity (cosine, on L2-normalised features), a \(k\) and a voting rule. A common choice: \(k = 20\), votes weighted by similarity.
  • For a test image, find its \(k\) nearest neighbours in the reference set and let their labels vote.
  • Cheap enough to run during pretraining, as a progress monitor.
  • Measures local structure: are images of the same class neighbours? The linear probe measures global separability.

Fine-tuning and transfer

  • Start from the pretrained weights, add a head for the target task (classification, detection, segmentation), and train everything, with a smaller learning rate for the encoder.
  • Often reported with few labels (1% or 10% of ImageNet): that is where pretraining helps most.
  • Gives the best numbers, but mixes two things: how good the features are, and how well they adapt.

The protocols can disagree: an encoder can fine-tune very well and still do poorly on the linear probe. Report more than one.

Visualisation

  • Project the features of a labelled set to 2-D with PCA (linear) or t-SNE / UMAP (non-linear), then colour each point by its true class.
  • Classes that the encoder never saw during training should still form separate clusters.

Qualitative only: t-SNE distorts distances, so cluster sizes and the gaps between clusters mean little. Use it to spot problems; rank methods with the linear probe.

Contrastive learning

Learn an encoder \(f\) that scores positive pairs high and negative pairs low:

\[\text{score}(f(x), f(x^+)) \gg \text{score}(f(x), f(x^-))\]

  • \(x\): reference sample
  • \(x^+\): another view of the same image
  • \(x^-\): a different image

The InfoNCE loss

With one positive and \(N-1\) negatives:

\[ \mathcal{L}_{\text{InfoNCE}} = -\log \frac{e^{\,\text{sim}(f(x),\, f(x^+))/\tau}}{e^{\,\text{sim}(f(x),\, f(x^+))/\tau} + \sum_{i=1}^{N-1} e^{\,\text{sim}(f(x),\, f(x^-_i))/\tau}} \]

  • InfoNCE: a loss based on Noise-Contrastive Estimation (NCE): tell the true pair apart from “noise” samples. “Info” because it bounds the mutual information between the two views.
  • \(\text{sim}(\cdot,\cdot)\): cosine similarity · \(\tau\): temperature, divides the similarities before the softmax; small \(\tau\) makes the choice sharper (next slide).
  • It is a softmax classification: “which of these \(N\) samples is my positive?”

Remember this formula: it comes back, unchanged, when we add language.

van den Oord, A. et al. (2018). Representation learning with contrastive predictive coding. arXiv.

InfoNCE — a worked example

The same row of similarities, \((0.30, 0.25, 0.10)\), at three temperatures. Logits \(=\) similarity \(/\ \tau\), then softmax:

τ = 1

logits \((0.30, 0.25, 0.10)\)

\(p = (0.36, 0.34, 0.30)\)

loss \(= -\log 0.36 = \mathbf{1.02}\)

Almost a coin flip: a gap of 0.05 is invisible.

τ = 0.1

logits \((3.0, 2.5, 1.0)\)

\(p = (0.57, 0.35, 0.08)\)

loss \(= -\log 0.57 = \mathbf{0.56}\)

The positive starts to stand out.

τ = 0.01

logits \((30, 25, 10)\)

\(p = (0.993, 0.007, 0.000)\)

loss \(= -\log 0.993 = \mathbf{0.007}\)

A small gap becomes a sure choice.

Illustrative similarities. Loss from van den Oord, A. et al. (2018). Representation learning with contrastive predictive coding. arXiv.

SimCLR

  • Two augmentations of one image = a positive pair (crop, colour distortion, blur).
  • All other images in the batch = negatives.
  • Encoder \(f(\cdot)\) → projection head \(g(\cdot)\) → InfoNCE.
  • After pretraining, throw away the head, keep the encoder.

Chen, T. et al. (2020). A simple framework for contrastive learning of visual representations. ICML.

SimCLR — what makes it work

  • Strong augmentations — crop + colour jitter together; either alone is much weaker.
  • Large batches (4K–8K) — more negatives per step.
  • Non-linear projection head — the loss is applied in a space the encoder can afford to distort.

Projection head vs. linear probe accuracy

Chen, T. et al. (2020). A simple framework for contrastive learning of visual representations. ICML.

SimCLR — results

Protocol: pretrain on ImageNet without labels, freeze, train a linear classifier. Plot: number of parameters (x) vs top-1 accuracy (y); the grey cross is a supervised ResNet-50.

A 4× wider ResNet-50 matches a supervised ResNet-50, with about 16× the parameters.

Chen, T. et al. (2020). A simple framework for contrastive learning of visual representations. ICML.

Interlude: the Vision Transformer (ViT)

  • Cut the image into 16×16-pixel patches: a 224×224 image becomes 14×14 = 196 patches.
  • Flatten each patch and project it linearly: one token, exactly like a word embedding. Add position embeddings.
  • A standard transformer processes the sequence. An extra learnable [CLS] token gathers a summary of the whole image.

Why now: the next methods work on patches. MAE hides patches, DINO’s attention maps show where [CLS] looks, and later a VLM feeds patch tokens straight into an LLM.

Dosovitskiy, A. et al. (2021). An image is worth 16x16 words: transformers for image recognition at scale. ICLR.

Masked autoencoders (MAE)

BERT for images: mask patches, reconstruct them.

  • Mask 75% of patches: images are spatially redundant, text is not, so the task must be much harder than BERT’s 15%.
  • The encoder sees only visible patches → ~3× faster pretraining; the light decoder does the pixel work and is discarded.

He, K. et al. (2022). Masked autoencoders are scalable vision learners. CVPR.

MAE — masking and scaling

Reconstructions under different masks

Longer training keeps helping

Fine-tuning is excellent; the linear probe is weaker than contrastive methods. Masked features are good raw material, less “ready to use”.

This is the disagreement from the fine-tuning slide: judged by fine-tuning, MAE is one of the best encoders; judged by linear probe, it is not.

He, K. et al. (2022). Masked autoencoders are scalable vision learners. CVPR.

DINO — the question

So far, two ways to pretrain without labels, and neither gives features that are ready to use:

  • SimCLR: invariance between two views, but on a convnet, and it needs many negatives.
  • MAE: a ViT, but rebuilding pixels gives features that shine only after fine-tuning; the linear probe lags.

Question: can a ViT learn without labels features that work frozen, with a k-NN or a linear layer? And does it learn anything a convnet does not?

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV.

DINO — what they found

  1. Segmentation for free. The attention of the [CLS] token in the last layer contains the scene layout and the object boundaries. It does not emerge as clearly with supervised ViTs, nor with convnets.
  2. Features that work as they are. A plain k-NN classifier on the frozen features reaches 78.3% top-1 on ImageNet with a small ViT: no fine-tuning, no linear layer.
  3. What makes it work. A momentum teacher, multi-crop training, and small patches (8×8 instead of 16×16).
  4. A simpler method: DINO, self-distillation with no labels. No negatives, no contrastive loss, no predictor; 80.1% linear-probe accuracy with a ViT-B/8.

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV.

DINO — objects segment themselves

Self-attention of the [CLS] token in the last layer of a ViT-S/8 trained with no labels. Each pair: the input image and where [CLS] looks.

No labels, no masks, no text, and the attention finds the objects.

The vision counterpart of “emergent” capabilities in LLMs.

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV. Fig. 1.

DINO — self-distillation with no labels

Redrawn from Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV. Fig. 2.

DINO — the ingredients

  • Knowledge distillation trains a student to match the soft outputs of a teacher. Normally the teacher is a large pretrained model and there are labels. Here there are neither.
  • The teacher is built from the student: an exponential moving average of its past weights. Only the student is trained by SGD.
  • Two views of the same image. The student must reproduce, from its view, the teacher’s output distribution over \(K\) = 65,536 dimensions.
  • Multi-crop: the student sees 2 global crops (224²) and several local ones (96²); the teacher sees only global crops. From a patch of fur, predict what the whole image looks like: local-to-global.

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV.

DINO — why doesn’t it collapse?

Collapse: student and teacher agree perfectly by outputting the same thing for every image. The loss is minimal and the features are useless. SimCLR avoided it with negatives; DINO has none. Two operations on the teacher’s output pull in opposite directions:

It needs a momentum teacher: slow-moving targets, and better than the student throughout training.

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV. Sec. 3.1 and 5.3.

DINO in a few lines

gt.params = gs.params                        # teacher starts as a copy of the student
for x in loader:
    x1, x2 = augment(x), augment(x)           # two random views
    s1, s2 = gs(x1), gs(x2)                   # student outputs, n × K
    t1, t2 = gt(x1), gt(x2)                   # teacher outputs, n × K
    loss = H(t1, s2) / 2 + H(t2, s1) / 2      # each view predicts the other
    loss.backward(); update(gs)               # SGD on the student only
    gt.params = l * gt.params + (1 - l) * gs.params     # EMA teacher
    C = m * C + (1 - m) * cat([t1, t2]).mean(dim=0)     # running centre

def H(t, s):
    t = t.detach()                            # stop-gradient
    s = softmax(s / tps, dim=1)
    t = softmax((t - C) / tpt, dim=1)         # centre + sharpen
    return -(t * log(s)).sum(dim=1).mean()

Legend. gs, gt: student and teacher networks · tps, tpt: student and teacher temperatures (the teacher’s is lower: sharpening) · C: running centre of the teacher outputs · l, m: momentum rates of the EMA teacher and of the centre.

Adapted from Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV. Algorithm 1 (without multi-crop).

DINO — the evidence

Masks from thresholded [CLS] attention, ViT-S/8

Overlap with the true masks (Jaccard, PASCAL VOC12): random 22.0 · supervised 27.3 · DINO 45.9 (ViT-S/16).

ImageNet top-1, ViT-S, frozen features:

Method Linear k-NN
Supervised 79.8 79.8
BYOL 71.4 66.6
MoCo v2 72.7 64.4
SwAV 73.5 66.3
DINO 77.0 74.5

Other self-supervised methods lose 5–8 points going from linear probe to k-NN; DINO loses 2.5. Its features are organised so that neighbours share a class.

Caron, M. et al. (2021). Emerging properties in self-supervised vision transformers. ICCV. Fig. 4 and Table 2.

DINOv2 — a vision foundation model

  • Combines self-distillation (DINO) with masked prediction (iBOT): the two ideas of this section in one loss.
  • Curated data: LVD-142M, retrieved from 1.2B web images by similarity to curated datasets.
  • ViT-g (1.1B parameters), distilled into smaller models.
  • Frozen features + a linear head: classification, depth, segmentation, retrieval.

First appearance of this lecture’s recurring lesson: the data curation matters as much as the method.

Oquab, M. et al. (2024). DINOv2: learning robust visual features without supervision. TMLR.

Zhou, J. et al. (2022). iBOT: image BERT pre-training with online tokenizer. ICLR.

DINOv2 — the same parts, across images

PCA of the patch features of images in the same column; the first 3 components are shown as RGB, the background is removed by thresholding the first one. The same colour lands on the same part (wings, heads, wheels) across poses, styles and even different objects: an eagle and a plane, a real horse and a drawing.

Oquab, M. et al. (2024). DINOv2: learning robust visual features without supervision. TMLR. Fig. 1.

The vision foundation model zoo

Model Pretraining What you get
DINOv2 / v3 self-distillation + masking, curated web images general frozen features, dense and global
Sapiens2 masking + self-distillation, 1B curated human images one backbone for human-centric tasks (pose, segmentation, normals, pointmaps)
SAM MAE encoder + supervised data engine (1.1B masks) promptable segmentation with points and boxes

Most SSL methods are available in one library: solo-learn (SimCLR, MoCo, BYOL, SwAV, DINO, MAE, VICReg, …).

da Costa, V. G. T. et al. (2022). solo-learn: a library of self-supervised methods for visual representation learning. JMLR.

Kirillov, A. et al. (2023). Segment anything. ICCV.

Khirodkar, R. et al. (2026). Sapiens2. ICLR.

What is still missing?

Every protocol we used ends the same way: to recognise a class, you need labelled images of that class.

  • Look at the linear probe: \(W\) has one row per class, a vector that stands for “cat”, learned from labelled cat images.
  • A new class (“capybara”) means new labelled images and a new row.

Question: could we write the row for “capybara” from the word itself, instead of learning it from examples?

We would need images and words in the same space. And the web pairs them for free: alt-text, captions, titles, billions of them.

The free label for pixels, from the first slide: the text that comes with them.

Keep SimCLR’s contrastive machinery; make the positive of an image its caption.

2. Adding language: contrastive image–text pretraining

Natural-language supervision

Instead of class labels, supervise vision with the text that came with the image on the web.

Align matching image–text pairs, push the rest apart. The label space is now all of language.

Dual encoders at scale

At ICML 2021, two papers scaled this idea. The architectures differ, but the key difference is data curation:

  • CLIP (OpenAI): 400M curated image–text pairs.
  • ALIGN (Google): 1.8B noisy alt-text pairs, minimal filtering.

Both work. Scale can compensate for noise, and curation can compensate for scale.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML.

Jia, C. et al. (2021). Scaling up visual and vision-language representation learning with noisy text supervision. ICML. Sec. 3.

CLIP — the contrastive objective

\[ L_{v2t} = -\log \frac{e^{\,f_v(I)\cdot f_t(T)/\tau}}{\sum_{T'} e^{\,f_v(I)\cdot f_t(T')/\tau}} \] \[ L_{t2v} = -\log \frac{e^{\,f_t(T)\cdot f_v(I)/\tau}}{\sum_{I'} e^{\,f_t(T)\cdot f_v(I')/\tau}} \] \[ L = \tfrac{1}{2}(L_{v2t}+L_{t2v}) \]

  • Text encoder: GPT-2-style transformer (63M, 12 layers).
  • Image encoder: ViT-B/32, B/16, L/14 (and ResNets).

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML.

CLIP — a worked example

A batch of 3 pairs, \(\tau = 0.05\). The same InfoNCE, once per row and once per column:

Rows: image → text (\(L_{v2t}\))

dog photo: logits \((6, 5, 2)\), \(p(\text{"a dog"}) = 0.72\), loss \(0.33\)

cat photo: \(p(\text{"a cat"}) = 0.67\), loss \(0.40\)

car photo: \(p(\text{"a car"}) = 0.96\), loss \(0.05\)

\(L_{v2t} = (0.33 + 0.40 + 0.05)/3 = \mathbf{0.26}\)

Columns: text → image (\(L_{t2v}\))

“a dog”: \(p(\text{dog photo}) = 0.76\), loss \(0.28\)

“a cat”: \(p(\text{cat photo}) = 0.63\), loss \(0.47\)

“a car”: \(p(\text{car photo}) = 0.96\), loss \(0.04\)

\(L_{t2v} = \mathbf{0.26}\), and \(L = \tfrac{1}{2}(0.26 + 0.26) = \mathbf{0.26}\)

Dog and cat confuse each other (0.25, 0.24): their losses are the largest, so the gradient pushes them apart. The car is already easy.

Illustrative similarities. Loss from Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML.

CLIP — a strikingly simple algorithm

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML. Fig. 3.

CLIP — zero-shot classification

  1. Turn each class label into a sentence: “a photo of a {class}”.
  2. Encode all sentences with the text encoder.
  3. Encode the image; pick the most similar sentence.

This is the linear probe’s \(W\) with every row written by the text encoder: no labelled images, no training. That is what zero-shot means.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML.

CLIP — it actually works

Zero-shot CLIP vs. a supervised ResNet-50 linear probe. Each bar: CLIP’s accuracy minus the probe’s, one dataset.

Linear probe on CLIP features vs. EfficientNet-L2 (Noisy Student), same bar reading.

Left: with no labels at all, CLIP beats a fully supervised linear probe on 16 of 27 datasets. It loses on specialised or abstract tasks: satellite images, tumours, counting, distances. Right: give CLIP’s features a linear probe too, and they beat the best ImageNet model of the time on 21 of 27 datasets.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML. Fig. 5, 11.

CLIP — robust under distribution shift

A ResNet-101 trained on ImageNet vs. zero-shot CLIP (ViT-L/14), which never saw an ImageNet label. Same ImageNet accuracy (76.2%), very different behaviour off ImageNet: the ResNet collapses on sketches, renditions and hard natural images (2.7% on ImageNet-A), while CLIP holds at 60–89%.

How it’s measured. Top-1 accuracy on ImageNet classes, on new test sets: ImageNetV2 (new photos collected the same way), Sketch (drawings), ImageNet-R (renditions: art, cartoons, toys), ObjectNet (objects in unusual poses and places), ImageNet-A (natural photos that fool ResNets). CLIP on ImageNet-A: 77.1%.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML. Fig. 13.

The secret sauce is the data

  • Existing datasets were too small → a new 400M pair dataset from the web.
  • 500K queries (words occurring ≥100× in English Wikipedia), up to 20K pairs per query.
  • Open replications: LAION-400M / 5B (web pairs filtered with CLIP itself, used to train OpenCLIP), then DataComp, a benchmark where the model is fixed and only the data varies.

Back to robustness. Fang et al. retrained CLIP-style models changing one factor at a time: dataset size, the loss, language supervision, the training distribution. Only the training distribution moved the robustness under shift; dataset size, the loss and language supervision did not. CLIP is robust mostly because of what it saw.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML.

Schuhmann, C. et al. (2022). LAION-5B: an open large-scale dataset for training next generation image-text models. NeurIPS.

Gadre, S. Y. et al. (2023). DataComp: in search of the next generation of multimodal datasets. NeurIPS.

Fang, A. et al. (2022). Data determines distributional robustness in contrastive language image pre-training (CLIP). ICML.

MetaCLIP — CLIP’s curation, rebuilt

OpenAI released the model, not the data nor the curation code. MetaCLIP rebuilt the curation from the few lines in the CLIP paper:

  1. Concepts: 500K entries from WordNet and Wikipedia (words, bigrams, article titles).
  2. Match: keep an image–text pair from the web only if its text contains at least one of the 500K concepts (e.g. the alt-text “my golden retriever at the beach” matches golden retriever and beach). About half of the English pairs survive.
  3. Balance: cap every concept at 20K pairs. Before the cap, 16K frequent concepts account for 94.5% of all matches.

Result: 400M pairs from CommonCrawl, same model and training as CLIP: 70.8% zero-shot on ImageNet (ViT-B/16) vs 68.3% for OpenAI’s CLIP. Only the data changed.

Xu, H. et al. (2024). Demystifying CLIP data. ICLR. Sec. 3, Table 4.

Meta CLIP 2 — the rest of the web

  • CLIP data is English-only, so most of the web is thrown away. Meta CLIP 2 applies the same recipe to the worldwide, multilingual web.
  • The curse of multilinguality (left): at ViT-L, adding non-English data lowers English accuracy on ImageNet. At ViT-H, the worldwide model beats the English-only one: a large enough model has room for both.
  • It also sets new results on multilingual benchmarks: Babel-ImageNet 50.2% (ImageNet zero-shot with classes translated into 280 languages), CVQA 57.4% (multiple-choice VQA answered in the local language).

Chuang, Y.-S. et al. (2025). Meta CLIP 2: a worldwide scaling recipe. arXiv. Fig. 1, Table 1.

SigLIP — why the softmax is the problem

CLIP’s loss asks, for each image, “which of these \(|B|\) captions is mine?” The answer is normalised over the whole batch: the full \(|B| \times |B|\) similarity matrix, gathered across every GPU.

SigLIP asks \(|B|^2\) independent questions, “does image \(i\) go with caption \(j\)?”, each a binary logistic loss:

\[ \mathcal{L} = -\frac{1}{|B|}\sum_{i}\sum_{j} \log \sigma\big(z_{ij}\,(t\, \mathbf{x}_i \cdot \mathbf{y}_j + b)\big), \qquad z_{ij} = \pm 1 \]

Zhai, X. et al. (2023). Sigmoid loss for language image pre-training. ICCV.

SigLIP — a worked example

Same matrix, scale \(t = 100\) and bias \(b = -25\). Each cell on its own: logit \(= t \cdot \text{sim} + b\), loss \(= -\log \sigma(z \cdot \text{logit})\).

Positive (dog photo, “a dog”), \(z = +1\)

logit \(= 100 \times 0.30 - 25 = 5\)

P(match) \(= \sigma(5) = 0.993\)

loss \(= -\log \sigma(5) = \mathbf{0.007}\)

A confident, correct “yes”: tiny gradient.

Hard negative (dog photo, “a cat”), \(z = -1\)

logit \(= 100 \times 0.25 - 25 = 0\)

P(match) \(= \sigma(0) = 0.5\)

loss \(= -\log \sigma(0) = \mathbf{0.69}\)

Undecided: most of the gradient is here.

Easy negative (dog photo, “a car”), \(z = -1\)

logit \(= 100 \times 0.10 - 25 = -15\)

P(match) \(= \sigma(-15) \approx 0\)

loss \(= -\log \sigma(15) \approx \mathbf{0}\)

A confident, correct “no”: no gradient.

No softmax over a row: each GPU can score its own block of the matrix without seeing the rest of the batch.

SigLIP — smaller batches are enough

  • Small batches: below 16K, sigmoid clearly beats softmax (left: SigLiT, i.e. a frozen pretrained image tower with only the text tower trained; right: SigLIP, both towers from scratch).
  • Big batches do not help: both saturate around 32K. They pushed to 1M: no further gain, and very large batches hurt.
  • Cheaper: no full matrix in memory, only each device’s own block. On 4 TPU-v4 chips, SigLIP-Base fits a batch of 4,096 vs 2,048 for CLIP.
  • Frugal: a SigLiT model reaches 84.5% zero-shot on ImageNet with those 4 chips in two days.

Simpler loss, less hardware, same or better accuracy: SigLIP (and SigLIP 2) became the default vision encoder of many open VLMs (e.g. PaliGemma, Google’s open VLM).

Zhai, X. et al. (2023). Sigmoid loss for language image pre-training. ICCV. Fig. 2.

Activity: be CLIP (1/2)

Image 1

Image 2

(A) some plants surrounding a lightbulb   ·   (B) a lightbulb surrounding some plants

Vote: match each caption to an image.

cosine similarity caption (A) caption (B)
Image 1 0.326 0.332
Image 2 0.322 0.325

CLIP’s answer: ✗ both captions pick Image 1, by 0.004 and 0.007. The two captions are 0.96 similar to each other: for CLIP they are almost the same point. It sees a lightbulb and plants; who surrounds whom is lost.

Thrush, T. et al. (2022). Winoground: probing vision and language models for visio-linguistic compositionality. CVPR. Images © Getty Images, licensed for research.

Activity: be CLIP (2/2)

Image 1

Image 2

(A) it’s a fire truck   ·   (B) it’s a truck fire

Vote: match each caption to an image.

cosine similarity caption (A) caption (B)
Image 1 0.277 0.242
Image 2 0.219 0.264

CLIP’s answer: ✓ each caption picks its own image, by 0.06 and 0.02, far wider margins than for the lightbulb. “Fire truck” is a fixed phrase seen countless times on the web: it behaves like a single word.

Thrush, T. et al. (2022). Winoground: probing vision and language models for visio-linguistic compositionality. CVPR. Images © Getty Images, licensed for research.

CLIP — why it fails where it fails

CLIP’s limits are not random: each one follows from how it was built.

Cause What breaks Evidence
The objective. Picking the right caption among random ones never needs word order, so CLIP learns a bag of concepts binding, word order, relations: “a red ball and a blue cube” = “a blue ball and a red cube” the lightbulb pair (captions 0.96 similar). On all 400 Winoground pairs, CLIP ViT-B/32 gets 8% fully right (both images and both captions matched), below random guessing (16.7%)
The data. Web captions rarely state counts or distances, or mention what is absent counting, distances, negation (“not a yellow coat”) the zero-shot plot (“CLIP — it actually works”): CLEVRCounts −18, KITTI Distance (how far is the nearest car) −34. Negation, our run: on the fire-truck photo, “a photo of a dog” 0.92 vs “a photo with no dog” 0.08
The interface. It only outputs a similarity score; the text encoder stops at 77 tokens questions, explanations, long descriptions every activity so far: CLIP can only rank captions we wrote

CLIP knows what is in an image but little about how it is arranged, and it can only score captions we write.

The third row is what the next section fixes: connect the vision encoder to a model that generates language.

Radford, A. et al. (2021). Learning transferable visual models from natural language supervision. ICML. Fig. 5, Sec. 2.4.

Yuksekgonul, M. et al. (2023). When and why vision-language models behave like bags-of-words, and what to do about it? ICLR.

Thrush, T. et al. (2022). Winoground: probing vision and language models for visio-linguistic compositionality. CVPR. Table 3.

Red circle — the question

CLIP gives one score for the whole image. Many questions are about one region of it:

  • Referring expressions: which box is “the person taking a picture of the dog”?
  • Keypoints: where is the bird’s beak?
  • The usual trick: crop. Cut out each candidate region and score the crop against the text. But the crop throws away the context, and the relation (of the dog) lives in the context.
  • Prompts are engineered on the text side (“a photo of a {label}”). The image is an input too, and nobody had tried to engineer it.

Question: can we tell CLIP where to look by editing the pixels, keeping the whole image, with no training?

Shtedritski, A., Rupprecht, C. & Vedaldi, A. (2023). What does CLIP know about a red circle? Visual prompt engineering for VLMs. ICCV.

Red circle — the idea

Mark, don’t crop: draw a thin red ellipse around each candidate region, score every marked image against the query, keep the best. No training, no new parameters, and the context stays in the image.

Shtedritski, A., Rupprecht, C. & Vedaldi, A. (2023). What does CLIP know about a red circle? Visual prompt engineering for VLMs. ICCV. Our example: CLIP ViT-L/14 on one photo, illustrative.

Red circle — the evidence

Referring expressions, zero-shot (accuracy, %)

Method RefCOCO RefCOCO+ RefCOCOg
CPT (colour the box) 32.2 31.9 36.7
ReCLIP, crops 42.0 47.4 57.8
ReCLIP, crops + relation rules 45.8 47.9 59.3
Red circle 49.8 55.3 59.4
  • It comes from the data. Human-drawn markers on web photos are rare: in 6M YFCC15M images the authors found about 70 (~0.001%). And on keypoints, red circles beat arrows, squares, crosses and other colours: what people actually draw.
  • It appears only at scale. Naming keypoints on birds: ViT-B/32 19.1% → ViT-L/14 at 336 px 58.2%. From the smallest to the largest CLIP, keypoints gain ~250%, zero-shot ImageNet only ~20%.

How it’s measured. RefCOCO / RefCOCO+ / RefCOCOg: COCO photos, each with a sentence that names one object; RefCOCO+ forbids location words (“left”), RefCOCOg has longer sentences. A prediction counts if the chosen box overlaps the true one enough (intersection over union ≥ 0.5, Section 6); validation splits, higher is better. Naming keypoints (CUB-200 birds): given the keypoint positions and their names, % of names matched to the right position.

The data also teaches what circles mean. News sites circle missing people and suspects. Circling a person in a COCO photo raises how often CLIP picks a criminal label (“criminal”, “thief”, “suspicious person”) from 29.8% to 47.9% (ViT-L/14 at 336 px).

Shtedritski, A., Rupprecht, C. & Vedaldi, A. (2023). What does CLIP know about a red circle? Visual prompt engineering for VLMs. ICCV. Tables 2, 3, 5, 6, Fig. 6, Sec. 4.1.

Demo: CLIP zero-shot, locally

from PIL import Image
from transformers import CLIPModel, CLIPProcessor

name = "openai/clip-vit-base-patch32"
model, proc = CLIPModel.from_pretrained(name), CLIPProcessor.from_pretrained(name)

labels = ["cat", "dog", "car"]
inputs = proc(text=[f"a photo of a {l}" for l in labels],
              images=Image.open("pet.jpg"), return_tensors="pt", padding=True)

probs = model(**inputs).logits_per_image.softmax(dim=-1)
print(dict(zip(labels, probs[0].tolist())))

Live: change the prompt template, add a distractor label, try a binding pair, draw a red circle.

The modality gap

CLIP’s shared space is not really shared: images and captions sit in two separate regions, and each pair is joined across the gap. The same happens in other contrastive models (video, medical images, proteins), and even with random weights (bottom row): the gap is there before training, and the contrastive loss keeps it.

How to read it. UMAP (a 2-D projection that keeps neighbours close) of paired embeddings: red = images (or video, medical images, proteins), blue = text, a grey line joins each pair. Top: trained models. Bottom: the same architectures with random weights.

Liang, W. et al. (2022). Mind the gap: understanding the modality gap in multi-modal contrastive representation learning. NeurIPS. Fig. 1.

3. From alignment to conversation

Before LLMs: fusion encoders — FLAVA

FLAVA’s goal: a true vision-and-language foundation model should be good at vision, at language, and at vision-language, all at the same time. Before it, each family was good at one side:

  • Dual encoders (CLIP): strong visual features and retrieval, but the towers never read image and text together: weak at VQA.
  • Fusion encoders (ViLBERT, UNITER, …): good at VQA, but trained only on paired data: weaker unimodal quality.

One model, three encoders (image, text, multimodal), trained with unimodal losses (masked image / text modelling, also on unpaired data) and multimodal ones (contrastive, image–text matching). 70M public pairs.

ViT-B/16 VQAv2 CoLA (text) ImageNet linear
CLIP 55.3 25.4 80.2
FLAVA 72.8 50.7 75.5

How it’s measured. VQAv2: answer accuracy on visual questions. CoLA: classify whether an English sentence is grammatical (Matthews correlation, a text-only task). ImageNet linear: linear-probe top-1 on frozen image features.

A step towards one model for everything, but still an encoder: it classifies and retrieves, it does not generate language.

Singh, A. et al. (2022). FLAVA: a foundational language and vision alignment model. CVPR. Table 5.

Anatomy of a modern VLM

Four design choices, each with its own literature:

  1. Vision encoder — usually contrastive (CLIP, SigLIP), sometimes SSL (DINOv2) or both.
  2. Connector — how visual features enter the LLM.
  3. LLM — the language backbone; one of the biggest factors in the final quality (Idefics2, later in this lecture).
  4. Data — alignment pairs, interleaved documents, instruction data.

Activity: design the connector

Blue = frozen vision encoder, green = frozen LLM, purple = the part you design. The bar is the LLM’s 4K-token context: a text prompt takes a few tokens, and the image takes as many as your connector gives it.

You have a frozen vision encoder that outputs 576 tokens × 1024 dims (a 24×24 patch grid) and a frozen LLM with 4096-dim embeddings and a 4K-token context. How do you get the image into the LLM?

3 minutes in pairs.

576 tokens × 4096 dims in the input · or fewer tokens first · or new layers that look at the image from inside the LLM: the three families, next slide.

Three common ways in

The three families that most open VLMs fall into. The question each one answers: where do the image features meet the text, and how many tokens do they cost?

Three common ways in — side by side

Family Example How visual features enter Visual tokens Trained
Projection LLaVA linear / MLP maps patch features into the LLM input sequence all patches (256 in LLaVA, 576 in LLaVA-1.5, more with high resolution) projector, then LLM
Learned queries BLIP-2, Qwen-VL a small transformer with \(K\) learned queries compresses the image fixed \(K\) (32–256) Q-Former / resampler
Cross-attention Flamingo, Llama 3.2-V new gated cross-attention layers inside the LLM attend to image features none in the sequence new layers (Llama 3.2-V also tunes the image encoder)

Not the only routes. Encoder-free models skip the vision encoder and feed raw patches straight into the LLM (Fuyu). Early-fusion models turn images into discrete tokens and train one transformer on both from scratch (Chameleon). Unified models that also generate images, for example with a diffusion head (Transfusion), are beyond this lecture.

Bavishi, R. et al. (2023). Fuyu-8B: a multimodal architecture for AI agents. Adept AI blog.

Chameleon Team (2024). Chameleon: mixed-modal early-fusion foundation models. arXiv.

Zhou, C. et al. (2025). Transfusion: predict the next token and diffuse images with one multi-modal model. ICLR.

How we got here: Frozen, the first step (2021)

The three families in the order they appeared: Frozen (2021) → Flamingo (2022) → BLIP-2 (2023) → LLaVA (2023).

  • Train an image encoder so its output works as a prefix of word embeddings.
  • The LLM stays frozen; gradients flow through it into the vision side.
  • Few-shot by prepending image–caption examples, like in-context learning.

The root of family (a): images become “foreign words” in the LLM’s input.

Tsimpoukelli, M. et al. (2021). Multimodal few-shot learning with frozen language models. NeurIPS.

Flamingo, family (c) cross-attention

  • Frozen vision encoder + frozen 70B LLM (Chinchilla, DeepMind’s language model).
  • Perceiver Resampler: a small transformer with 64 learned queries (the idea of family (b)) turns any number of image features into 64 visual tokens.
  • Gated cross-attention layers between frozen LLM blocks; a \(\tanh\) gate initialised at 0, so at the start the model is the original LLM.
  • Trained on interleaved web pages (text with images in between), plus image–text and video–text pairs. The interleaved pages are what make few-shot prompting with images work.

Alayrac, J.-B. et al. (2022). Flamingo: a visual language model for few-shot learning. NeurIPS. Fig. 3.

Focus: gating in Flamingo

How do you add new layers to a frozen LLM without breaking it?

Each new layer (a cross-attention, then an MLP, the transformer’s feed-forward block) is a residual branch scaled by a learnable gate:

\[ y = x + \tanh(\alpha_1)\,\text{XAttn}(x, V) \] \[ y \leftarrow y + \tanh(\alpha_2)\,\text{MLP}(y) \]

  • \(\alpha\) is one scalar per layer, initialised at 0. At step 0 the new layers add nothing: the network is the pretrained LLM, with its language ability intact.
  • Training opens the gates gradually, so visual information flows in without wrecking the LLM on the first updates.

Alayrac, J.-B. et al. (2022). Flamingo: a visual language model for few-shot learning. NeurIPS. Sec. 2.2.

Gating elsewhere

Zero-init gates: start as the identity, then learn the change. A new module begins silent, so a pretrained (or very deep) network is not disturbed.

Model What starts at zero What it is for
Flamingo (2022) \(\tanh(\alpha)\) on new cross-attention and MLP layers add vision to a frozen LLM
LoRA (2022, next lecture) \(B = 0\), so the update \(\Delta W = BA\) is 0 fine-tune a frozen LLM cheaply
ControlNet (2023, generation lecture) “zero convolutions” around a trainable copy of the encoder add spatial control to a frozen diffusion model
ReZero (2021) every residual branch scaled by \(\alpha = 0\) train very deep networks fast

Routing gates are a different idea: an input-dependent value multiplies the signal at every step, to decide what passes. A sigmoid in \([0, 1]\) in LSTM, GRU and GLU; a Swish in the SwiGLU MLPs of today’s LLMs (e.g. LLaMA).

Hu, E. J. et al. (2022). LoRA: low-rank adaptation of large language models. ICLR. · Zhang, L. et al. (2023). Adding conditional control to text-to-image diffusion models. ICCV.

Bachlechner, T. et al. (2021). ReZero is all you need: fast convergence at large depth. UAI. · Shazeer, N. (2020). GLU variants improve Transformer. arXiv.

Hochreiter, S. & Schmidhuber, J. (1997). Long short-term memory. Neural Computation.

BLIP-2, family (b) — the question

By 2023, end-to-end vision-language pretraining had become prohibitively expensive. Meanwhile, excellent unimodal models were free to download: CLIP-style image encoders and LLMs.

  • Reuse both, frozen: cheap, and the LLM’s language skills stay intact.
  • The catch: a frozen LLM has never seen an image. Frozen and Flamingo bridge the gap with a single language-modelling loss, and BLIP-2 argues that is not enough.

Question: how do you align a frozen image encoder with a frozen LLM, training only a small module in between?

Li, J. et al. (2023). BLIP-2: bootstrapping language-image pre-training with frozen image encoders and large language models. ICML.

BLIP-2 — stage 1: what to look at

  • Trained: the Q-Former, i.e. its 32 learned queries and its transformer (188M parameters, initialised from BERT-base; the cross-attention layers are new).
  • Frozen: the image encoder (CLIP ViT-L/14 or EVA-CLIP ViT-g/14).
  • Not used: the LLM.
  • Data: image–caption pairs (129M images).
  • Losses, same queries, a different attention mask for each:
    • ITC (image–text contrastive): the best-matching query output vs the caption embedding, CLIP-style. Queries and text cannot see each other.
    • ITM (image–text matching): is this the right caption? A yes/no classifier. Queries and text see each other.
    • ITG (image-grounded text generation): write the caption. Each word sees the queries and the previous words only.

The queries learn to pull out of the image what a caption would describe.

Li, J. et al. (2023). BLIP-2: bootstrapping language-image pre-training with frozen image encoders and large language models. ICML. Redrawn from Fig. 1–2; Sec. 3.1, 3.2, 3.4.

BLIP-2 — stage 2: let the LLM talk

  • Trained: the Q-Former, continuing from stage 1 (it is not frozen), plus a new linear layer that maps each 768-dim query output to the LLM’s embedding size. About 103–108M trainable parameters, depending on the LLM.
  • Frozen: the image encoder and the LLM (OPT or FlanT5).
  • Not used: the Q-Former’s text branch. Only the 32 query outputs go on.
  • Loss: language modelling. The 32 projected outputs are prepended to the text as soft visual prompts, and the frozen LLM must generate the caption. For FlanT5 (encoder–decoder), the first part of the caption goes into the encoder with the image and the decoder writes the rest (prefix LM).

Only the small module between the two frozen models learns to speak the LLM’s language.

Li, J. et al. (2023). BLIP-2: bootstrapping language-image pre-training with frozen image encoders and large language models. ICML. Redrawn from Fig. 3; Sec. 3.3, Table 2.

BLIP-2 — the Q-Former bottleneck

  • Intuition: 32 learned queries are 32 questions the model learns to ask the image. They cross-attend to the frozen image features and return a fixed-size digest (32 × 768) that keeps only what text needs: a bottleneck on purpose.
  • Stage 1, no LLM yet: the Q-Former has its own small text branch (initialised from BERT-base). It trains the queries with three losses, contrastive (ITC), matching (ITM) and captioning (ITG), each with a different attention mask between queries and text.
  • Stage 2: one linear layer turns the 32 outputs into soft visual prompts for the frozen LLM. Only the Q-Former (188M parameters) and this layer are trained.

Why not stop after stage 1? The Q-Former’s text branch is small and knows only captions: no world knowledge, no reasoning, no instructions. Stage 1 teaches the queries what to look at; the LLM does the talking. Without stage 1, the LLM fails (zero-shot VQA drops sharply, next slide). When nothing must be generated, the Q-Former is enough: for image–text retrieval, BLIP-2 fine-tunes the stage-1 model and uses no LLM at all.

Li, J. et al. (2023). BLIP-2: bootstrapping language-image pre-training with frozen image encoders and large language models. ICML. Fig. 1 and Sec. 4.4.

BLIP-2 — the evidence

Zero-shot VQAv2 during stage 2, with and without stage 1
  • Stage 1 is what makes it work. Without it (blue), zero-shot VQA is much lower, and with OPT it even degrades as training goes on.
  • Cheap and strong: +8.7 points over Flamingo-80B on zero-shot VQAv2, with 54× fewer trainable parameters.
  • Generic: swap in a better image encoder or a better LLM, and BLIP-2 gets better.

Limit: it describes images well, but it is not an assistant. Trained on single image–caption pairs, it gains nothing from in-context examples, and it was never tuned on multimodal instructions. That is the gap LLaVA targets.

How it’s measured. Zero-shot VQAv2: open-ended questions on images, no VQA training; VQA accuracy (an answer counts if at least 3 of 10 annotators gave it). BLIP-2 65.0 vs Flamingo-80B 56.3.

Li, J. et al. (2023). BLIP-2: bootstrapping language-image pre-training with frozen image encoders and large language models. ICML. Fig. 5, Table 2, Sec. 5.

LLaVA, family (a) — the question

  • Vision models had a fixed interface: one model per task, and language only describes the image.
  • LLMs had shown something else: language as a universal interface. You state the task in words and the model does it. Instruction tuning made this work (ChatGPT; in the open, Alpaca and Vicuna, tuned on instructions written by GPT).
  • Multimodal models so far (Flamingo, BLIP-2) were trained on image–caption pairs, not tuned to follow instructions.

Question: can instruction tuning be carried over to images, to build a general-purpose visual assistant? The obstacle: almost no multimodal instruction data exists.

Liu, H. et al. (2023). Visual instruction tuning. NeurIPS.

LLaVA — the data trick

Intuition: GPT-4 (text-only in 2023) cannot see, so describe the image to it in words. Give it the COCO captions and the object boxes, a symbolic version of the image, and ask it to write conversations as if it were looking at the photo.

Three kinds of answers:

  • 58K conversations (what, where, how many),
  • 23K detailed descriptions,
  • 77K complex reasoning questions.

158K samples, generated almost for free.

Liu, H. et al. (2023). Visual instruction tuning. NeurIPS. Table 1.

LLaVA — keep the model simple

  • CLIP ViT-L/14 → one linear layer \(W\) → Vicuna (an open LLaMA model fine-tuned on ChatGPT conversations). The authors mention Flamingo’s cross-attention and BLIP-2’s Q-Former, and choose the simplest option on purpose: it lets them iterate quickly on data.
  • Stage 1: a visual tokenizer. Train only \(W\) on 595K image–caption pairs (filtered from CC3M, Conceptual Captions: web images with their alt-text), so that CLIP features become “words” the frozen LLM can read.
  • Stage 2: instruction tuning. Train \(W\) and the LLM on the 158K generated conversations; CLIP stays frozen.

The bet: the connector matters less than the data. It paid off: LLaVA became a common starting point for open VLMs.

Liu, H. et al. (2023). Visual instruction tuning. NeurIPS.

LLaVA — the evidence

  • It holds a conversation about an image it has never seen: explains, reasons, follows the instruction. On the same image, BLIP-2 answers “a man is sitting on the back of a yellow cab”: it describes, but misses what is unusual.
  • LLaVA-Bench: 85.1% of GPT-4’s score on the generated instruction-following test set (GPT-4 as the judge).
  • ScienceQA: 90.92% alone; 92.53% when text-only GPT-4 acts as the judge (if the two disagree, GPT-4 sees both answers and decides), a new state of the art.
  • Open: data, code and weights released.

How it’s measured. LLaVA-Bench (COCO): 90 questions on 30 COCO images; text-only GPT-4 rates LLaVA’s answer and its own reference answer (written from the captions) from 1 to 10; score = LLaVA’s rating as a % of GPT-4’s. ScienceQA: ~21K multiple-choice science questions, many with an image; accuracy.

Liu, H. et al. (2023). Visual instruction tuning. NeurIPS. Tables 4, 7.

After LLaVA: resolution becomes the bottleneck

  • LLaVA-1.5 — a 2-layer MLP projector, 336px input, academic VQA data mixed in. Became a standard baseline.
  • LLaVA-NeXT (AnyRes) — tile a high-resolution image into 336px crops + a thumbnail. Better OCR and documents, many more tokens.
  • Native dynamic resolution (e.g. Qwen2-VL) — feed the image at its own size; the number of visual tokens varies with it.

Every gain in resolution is paid in visual tokens. Keep that in mind for video.

Liu, H. et al. (2024). Improved baselines with visual instruction tuning (LLaVA-1.5). CVPR.

Liu, H. et al. (2024). LLaVA-NeXT: improved reasoning, OCR, and world knowledge. Blog post.

Wang, P. et al. (2024). Qwen2-VL: enhancing vision-language model’s perception of the world at any resolution. arXiv.

The Qwen way: don’t resize the world

Most VLMs squeeze every image into the encoder’s fixed input: resize to 336px, or cut it into fixed tiles (LLaVA-NeXT). Qwen’s bet across three releases: feed the input at its own size and duration, and give the model positions that know space and time.

Release Connector The new idea
Qwen-VL (2023) learned queries, family (b): 256 queries, one cross-attention layer fixed 448px input
Qwen2-VL (2024) projection, family (a): an MLP merges 2×2 neighbouring patches native dynamic resolution: any image size, a variable number of tokens; M-RoPE positions in time, height, width
Qwen2.5-VL (2025) same MLP merger a ViT trained from scratch with window attention; time positions in seconds; data from 1.2T to 4.1T tokens

Qwen moved from family (b) to family (a): images of any size need a variable number of tokens, which a fixed set of learned queries cannot give.

Bai, J. et al. (2023). Qwen-VL: a versatile vision-language model for understanding, localization, text reading, and beyond. arXiv.

Wang, P. et al. (2024). Qwen2-VL: enhancing vision-language model’s perception of the world at any resolution. arXiv.

Bai, S. et al. (2025). Qwen2.5-VL technical report. arXiv.

Qwen2.5-VL — the architecture

  • Vision encoder, native resolution: image sides are rounded to multiples of 28 and cut into 14px patches, so a small and a large image give few and many tokens. To keep that affordable, 28 of 32 layers use window attention (8×8-patch windows) and only 4 use full attention: cost grows linearly with the number of patches. RMSNorm (LayerNorm without subtracting the mean) and SwiGLU (a gated MLP), as in the LLM.
  • Merger: 2×2 neighbouring patches are concatenated and projected by a 2-layer MLP, 4× fewer tokens for the LLM.
  • LLM: Qwen2.5 (3B / 7B / 72B), with its 1D positions replaced by M-RoPE (next slide).

Bai, S. et al. (2025). Qwen2.5-VL technical report. arXiv. Fig. 1, Sec. 2.1.

Qwen2.5-VL — space and time as positions

M-RoPE: RoPE (rotary position embedding) encodes a token’s position by rotating its query and key vectors; M-RoPE gives every token three position ids, (time, height, width), instead of one.

  • Text: the three ids are equal, so it is ordinary 1D RoPE.
  • Image: time is constant; height and width follow each token’s place in the grid.
  • Video: time grows frame by frame. New in 2.5: the time id follows absolute seconds, so “2 seconds later” means the same at 1 or at 4 fps. Frames are sampled at a dynamic rate, and two consecutive frames are merged into one token group.

The same idea for outputs: boxes and points are written in the image’s real pixel coordinates (earlier models rescaled them to [0, 1]). The model sees the true size of objects, which helps its grounding (detect, point, count).

Bai, S. et al. (2025). Qwen2.5-VL technical report. arXiv. Sec. 2.1.2–2.1.3.

Wang, P. et al. (2024). Qwen2-VL: enhancing vision-language model’s perception of the world at any resolution. arXiv. (M-RoPE figure)

Qwen2.5-VL — where the results come from

Data, 1.2T → 4.1T tokens. Captions, OCR, visual knowledge (landmarks, species, celebrities), documents parsed into HTML, grounding in absolute coordinates, video, agent interactions. Interleaved web pages are scored for image–text relevance and complementarity, and only the good ones are kept.

Stage Trained Data Tokens Context
Pre-training 1 ViT only captions, knowledge, OCR 1.5T 8K
Pre-training 2 ViT + LLM + interleaved, VQA, video, grounding, agent, pure text 2T 8K
Pre-training 3 ViT + LLM + long video, long documents, long agent traces 0.6T 32K
Post-training LLM (ViT frozen) SFT on ~2M samples (half text-only), then DPO (preference tuning, next lecture)
  • Half of the SFT data is text-only, so the model does not lose the LLM’s language skills.
  • Rejection sampling: an intermediate model answers questions with known solutions; only reasoning traces that reach the right answer are kept as training data.

Bai, S. et al. (2025). Qwen2.5-VL technical report. arXiv. Sec. 2.2–2.3, Table 2.

What actually matters? The four choices, tested

Most VLM papers change the encoder, the connector, the LLM and the data all at once, so it is hard to tell which choice made the difference. Three papers isolate them with controlled experiments:

Design choice (anatomy slide) Paper Its question
③ LLM and ② connector Idefics2 (2024) which component matters most? which way in?
① Vision encoder Cambrian-1 (2024) which encoder, and does it need language?
④ Data Molmo / PixMo (2025) can we get there without copying a closed model?

Laurençon, H. et al. (2024). What matters when building vision-language models? NeurIPS.

Tong, S. et al. (2024). Cambrian-1: a fully open, vision-centric exploration of multimodal LLMs. NeurIPS.

Deitke, M. et al. (2025). Molmo and PixMo: open weights and open data for state-of-the-art vision-language models. CVPR.

Idefics2 — the LLM and the connector

Controlled ablations, one change at a time, same data and compute.

  • The LLM matters more than the vision encoder. At a fixed parameter budget, upgrading the language backbone (LLaMA-1-7B → Mistral-7B: +5.1) helps more than upgrading the vision backbone (CLIP-H → SigLIP: +3.3).
  • Tokens in the sequence beat cross-attention. With frozen backbones, cross-attention (c) is better. Once the backbones are trained, feeding visual tokens into the sequence is better, even with fewer parameters. Training them fully can diverge, and LoRA (small trainable add-ons instead of the full weights, next lecture) keeps it stable.
  • Fewer tokens are fine. Learned queries pooling down to 64 tokens per image are cheaper and score higher.
  • Keep the aspect ratio. Adapting the encoder to native aspect ratio and resolution costs nothing and speeds up training: the same bet as Qwen.

Laurençon, H. et al. (2024). What matters when building vision-language models? NeurIPS. Findings 1–5.

Cambrian-1 — the vision encoder

The same VLM recipe with 20+ vision encoders swapped in: the LLM is used as a probe for the encoder.

  • Benchmarks barely test vision. With the image switched off, VLMs lose less than 5 points on several popular benchmarks (MMMU, MathVista, AI2D, ScienceQA). Cambrian builds CV-Bench (counting, spatial relations, depth, distance) to measure vision itself.
  • Language-supervised encoders still win (CLIP, SigLIP)…
  • …but SSL closes the gap. DINOv2 sits between the two; with enough data and proper tuning, self-supervised encoders come close.
  • Combining encoders helps, especially on vision-centric tasks: language-supervised and SSL features are complementary.

Back to the opening question: language is the best supervision so far, but not the only one.

How it’s measured. MMMU: college-level exam questions with images. MathVista: math on charts and figures. AI2D: science diagrams. CV-Bench: 2,638 hand-checked questions on counting, spatial relations, depth order and distance.

Tong, S. et al. (2024). Cambrian-1: a fully open, vision-centric exploration of multimodal LLMs. NeurIPS. Findings 1, 6, 7.

Molmo / PixMo — the data

The problem: open models had become distillations of closed ones. LLaVA’s data was written by GPT-4; later datasets use GPT-4V captions (ShareGPT4V). The weights are open, but nobody knows how to build a strong VLM from scratch.

The answer: collect the data from people, without any external VLM.

  • Dense captions by speech. Annotators talk about an image for 60–90 seconds instead of typing: longer, more detailed descriptions (712K images), and the audio proves a human made them.
  • Pointing. 2.3M annotations of “point to …”: much faster to collect than boxes or masks. The model learns to point to its evidence and to count by pointing.

Result: fully open data, and the 72B model ranks second by human preference, just behind GPT-4o (Elo 1077 vs 1079).

How it’s measured. Human preference: ~870 annotators compared the answers of two anonymous models on the same image and prompt (325K comparisons); an Elo score is fitted from the wins, as in Chatbot Arena.

Deitke, M. et al. (2025). Molmo and PixMo: open weights and open data for state-of-the-art vision-language models. CVPR. Sec. 3, Table 1.

Demo: ask the served VLM

vLLM serves a model on a GPU machine behind the same HTTP API as OpenAI’s: any OpenAI client works, you only change the address. Images travel inside the message, encoded as text (base64).

import base64, os
from openai import OpenAI

client = OpenAI(base_url=os.environ.get("VLLM_BASE_URL", "http://LAB-HOST:8000/v1"),   # the lab server
                api_key=os.environ.get("VLLM_API_KEY", "EMPTY"))
MODEL = "Qwen/Qwen2.5-VL-7B-Instruct"          # whatever the lab serves

def as_data_url(path):                          # image file -> text the API can carry
    return "data:image/jpeg;base64," + base64.b64encode(open(path, "rb").read()).decode()

resp = client.chat.completions.create(model=MODEL, max_tokens=200, messages=[
    {"role": "user", "content": [               # one user turn: text + image together
        {"type": "text", "text": "What is unusual about this image?"},
        {"type": "image_url", "image_url": {"url": as_data_url("scene.jpg")}}]}])
print(resp.choices[0].message.content)          # the generated answer

On the lab box: vllm serve Qwen/Qwen2.5-VL-7B-Instruct. Export VLLM_BASE_URL to point your client at it.

4. Video understanding

Activity: how many tokens is a video?

A 10-minute video, sampled at 1 frame per second, 256 visual tokens per frame.

How many tokens? How would you fit it into the LLM?

1 minute to compute, 2 minutes for fixes.

\(600 \times 256 = \mathbf{153{,}600}\) tokens, before any text: 37× a 4K context.

Video = images over time

Most video VLMs reuse the image encoder frame by frame, so the token count explodes. Every design is a way to cut the budget without losing when things happen.

At the extreme, LLaMA-VID keeps 2 tokens per frame. Qwen2.5-VL uses all four: dynamic frame sampling, the 2×2 merger, two consecutive frames per patch, time ids in seconds.

Li, Y. et al. (2024). LLaMA-VID: an image is worth 2 tokens in large language models. ECCV.

Bai, S. et al. (2025). Qwen2.5-VL technical report. arXiv. Sec. 2.1.

From video retrieval to video chat

Video did not need a new recipe: at each step it reused what had just worked for images.

So the real question is not the architecture: does a model built on image features actually use time? Next slides.

Luo, H. et al. (2022). CLIP4Clip: an empirical study of CLIP for end to end video clip retrieval. Neurocomputing. · Lin, B. et al. (2024). Video-LLaVA: learning united visual representation by alignment before projection. EMNLP.

Li, K. et al. (2023). VideoChat: chat-centric video understanding. arXiv. · Zhang, Y. et al. (2024). Video instruction tuning with synthetic data (LLaVA-Video). arXiv.

Is it really video understanding?

A single well-chosen frame matches many video-language models on standard benchmarks.

MSR-VTT-MC NExT-QA NExT-QA, hard subset
one frame picked by ATP (CLIP features) 93.2 49.2 20.2
best video model 92.1 (VideoCLIP) 49.7 (HGA) 44.1 (HGA)

Much of “video QA” is image QA in disguise.

Quick check: one frame of a benchmark question. Hands up: can you answer it?

How it’s measured. Multiple-choice accuracy (%), 5 options per question, so chance = 20%. MSR-VTT-MC: pick the caption that matches the video. NExT-QA: answer a descriptive, temporal or causal question. Hard subset: the NExT-QA questions that ATP models cannot answer.

Buch, S. et al. (2022). Revisiting the “video” in video-language understanding. CVPR. Tables 1, 3.

Apollo — the question

Video LMMs are built with many design choices that are never justified. Studying them properly is too expensive:

Obstacle Why
Training is costly a video is thousands of tokens
Evaluation is costly 184 GPU-hours to evaluate one 3B model
Benchmarks mislead many questions are answered from text or one frame

Question: how do you explore the video design space cheaply, and measure what really needs video?

Zohar, O. et al. (2025). Apollo: an exploration of video understanding in large multimodal models. CVPR.

Apollo — two tools for the study

① ApolloBench: test only what needs video. Ask open-source models every multiple-choice question three times: with the video, with only the centre frame, with only the text. Drop the questions that more than half of the models get right without the video. Keep the 400 that best separate models, and check them by hand. 41× faster to run, and it still ranks models like the full benchmarks.

② Scaling Consistency: explore small, then scale. Design choices that win on a ~2–4B model also win on 7B (R² > 0.9: the scores of 21 design variants at the small size predict their scores at 7B). Below that size, they do not transfer.

How well design choices made on a model of each size predict those on 7B (red curve)

Zohar, O. et al. (2025). Apollo: an exploration of video understanding in large multimodal models. CVPR. Sec. 2–3, Fig. 3.

Activity: predict before you see

You have 16 frames’ worth of budget for every video, short or long.

Would you sample 16 frames per video, or a fixed number of frames per second?

And how many tokens per frame would you keep?

1 minute, then vote.

Apollo — what matters (1/2): sampling and tokens

Black: model trained with fps sampling. Bars: trained with a fixed number of frames, tested the same way (left) or with fps (right)
  • Sample at a fixed frame rate. A fixed number of frames plays long videos fast and short ones slow; sampling at a fixed fps keeps time consistent, and beats every frame count, in training and at test time.
  • 8–32 tokens per frame is the sweet spot between more frames and more detail per frame, and a Perceiver resampler compresses best.

Zohar, O. et al. (2025). Apollo: an exploration of video understanding in large multimodal models. CVPR. Findings 2, 3, 6; Fig. 4.

Apollo — what matters (2/2): the recipe

  • Two encoders beat one: SigLIP is the best single encoder, and adding a video encoder (InternVideo2) helps. Same lesson as Cambrian-1.
  • Unfreeze step by step, train the encoders on video only, and keep ~10–14% text-only data: the LLM must not forget language (Qwen does something similar).

Zohar, O. et al. (2025). Apollo: an exploration of video understanding in large multimodal models. CVPR. Findings 4, 5, 7–9.

Apollo — the result

Apollo-3B beats most 7B video models (55.1 on LongVideoBench).

Apollo-7B leads its size class (70.9 on MLVU, 63.3 on Video-MME with subtitles), close to 30B models.

The message: a careful study on small models, with a benchmark that really needs video, beats scaling up blindly.

How it’s measured. All multiple-choice accuracy on long videos. LongVideoBench: 3.8K web videos up to an hour, questions that refer to a specific moment. MLVU: 1.7K videos of 3 min to 2 h, 9 tasks. Video-MME: 900 videos from 11 s to 1 h, 2,700 expert questions, with or without subtitles.

Zohar, O. et al. (2025). Apollo: an exploration of video understanding in large multimodal models. CVPR. Table 4.

5. Segment: beyond vision, Omni

ImageBind — one space, six modalities

  • Images as the hub: each new modality is trained only against images, with CLIP’s contrastive loss; the image and text encoders are taken from OpenCLIP (the open reimplementation of CLIP) and kept frozen.
  • Emergent alignment: audio lands near the text that describes it, so audio → text retrieval and zero-shot audio classification work with no audio–text data.

Girdhar, R. et al. (2023). ImageBind: one embedding space to bind them all. CVPR.

Omni models — hear, see, speak

  • GPT-4o (2024) — one model end-to-end across text, vision and audio, with real-time speech in and out.
  • Qwen2.5-Omni (2025) — open weights; a Thinker (the LLM, produces text) and a Talker (turns its states into streaming speech). TMRoPE interleaves audio and video on a shared time axis.

Same recipe as for images and video: encoders per modality, a connector, an LLM, aligned in time.

Xu, J. et al. (2025). Qwen2.5-Omni technical report. arXiv. Redrawn from Fig. 2.

6. Evaluation: how we measure understanding

Task metrics

Task Metric: what it measures Typical benchmarks
Retrieval (image ↔︎ text) Recall@K: is the right match among the top \(K\)? COCO, Flickr30k → coming up
Zero-shot classification top-1 accuracy with class names as prompts ImageNet; shifted: -R, -A, Sketch ✓ seen, Section 2
Representations linear probe, k-NN accuracy on frozen features ImageNet, transfer suites ✓ seen, Section 1
VQA answer accuracy: agreement with several human answers VQAv2, GQA → coming up
Captioning CIDEr, BLEU-4, SPICE: overlap with reference captions COCO Captions, NoCaps → coming up
Grounding accuracy at IoU ≥ 0.5 on the box (spatial) or time span (temporal) RefCOCO / + / g; temporal: Charades-STA → coming up

Retrieval — Recall@K

Each query has one true match among thousands of candidates. R@1 asks for a perfect ranking; R@5 and R@10 forgive near misses, which matters when the other top images also fit the text.

VQA — answer accuracy

Open-ended answers are compared by exact string match after normalisation (case, articles, number words), so “2 cats” and “two” depend on the normaliser. Multiple-choice benchmarks (MMMU, MMBench) avoid this, but they only test whether the model picks the right option.

Antol, S. et al. (2015). VQA: visual question answering. ICCV.

Goyal, Y. et al. (2017). Making the V in VQA matter: elevating the role of image understanding in visual question answering (VQAv2). CVPR.

VQA — scoring by likelihood

  • Instead of generating and string-matching, score each candidate answer by the model’s probability and sum over its spellings: no parsing, no normaliser.
  • The price: a candidate list (open-ended becomes closed: the model only has to recognise the answer), access to the logits, and a length normalisation that can change the ranking.

Holtzman, A. et al. (2021). Surface form competition: why the highest probability answer isn’t always right. EMNLP.

Captioning — overlap is not meaning

  • BLEU-4: precision of shared 1–4-grams. CIDEr: shared n-grams weighted by how rare they are across the dataset. SPICE: compares objects, attributes and relations parsed from the captions.
  • Learned metrics compare meaning: BERTScore, BLEURT (vs. references); CLIPScore (vs. the image, no references, but CLIP’s blind spots). Then LLM judges, with their own biases.

Papineni, K. et al. (2002). BLEU: a method for automatic evaluation of machine translation. ACL. · Vedantam, R. et al. (2015). CIDEr: consensus-based image description evaluation. CVPR.

Anderson, P. et al. (2016). SPICE: semantic propositional image caption evaluation. ECCV.

Zhang, T. et al. (2020). BERTScore: evaluating text generation with BERT. ICLR.

Sellam, T. et al. (2020). BLEURT: learning robust metrics for text generation. ACL.

Hessel, J. et al. (2021). CLIPScore: a reference-free evaluation metric for image captioning. EMNLP.

Grounding — IoU

Spatial: phrase → box (RefCOCO). Temporal: phrase → time span in a video (Charades-STA). Correct if IoU ≥ 0.5; video papers report R@1 at IoU 0.5 and 0.7.

Yu, L. et al. (2016). Modeling context in referring expressions. ECCV.

Gao, J. et al. (2017). TALL: temporal activity localization via language query. ICCV.

VLM benchmarks and hallucination

Broad suites: MMMU (11.5K college-exam questions, 30 subjects), MMBench (3.2K multiple-choice, 20 abilities, options rotated), MME (yes/no questions, scored in points), SEED-Bench (multiple-choice over images and video). Hallucination: two ways to catch objects that are not there.

Yue, X. et al. (2024). MMMU: a massive multi-discipline multimodal understanding and reasoning benchmark for expert AGI. CVPR. · Liu, Y. et al. (2024). MMBench: is your multi-modal model an all-around player? ECCV.

Fu, C. et al. (2025). MME: a comprehensive evaluation benchmark for multimodal large language models. NeurIPS D&B. · Li, B. et al. (2024). SEED-Bench: benchmarking multimodal large language models. CVPR.

Rohrbach, A. et al. (2018). Object hallucination in image captioning. EMNLP.

Li, Y. et al. (2023). Evaluating object hallucination in large vision-language models. EMNLP.

Activity: the blind benchmark

Hands up: who can answer anyway?

Questions from Chen, L. et al. (2024). Are we on the right way for evaluating large vision-language models? NeurIPS. Fig. 1.

Benchmarks leak (1/2): MMStar

  • Many questions are answerable without the image: (a) world knowledge, (b) the answer is in the question, (c, d) the item leaked into the training data of LLMs or VLMs.
  • MMStar keeps 1,500 samples, checked by hand, that really need vision.

Chen, L. et al. (2024). Are we on the right way for evaluating large vision-language models? NeurIPS. Fig. 1.

Benchmarks mislead (2/2): MMVP

  • CLIP-blind pairs: images CLIP embeds as nearly identical (0.95) but DINOv2 tells apart (0.58). A pair scores only if both answers are right.
  • VLMs built on CLIP fail them; mixing in DINOv2 features helps.

Report several metrics, run a blind (text-only) baseline, and keep qualitative probing in the loop.

Tong, S. et al. (2024). Eyes wide shut? Exploring the visual shortcomings of multimodal LLMs. CVPR. Fig. 2.

Closing: do we need language?

Back to the opening question

  • For the interface, yes. Language gives open vocabulary, zero-shot and conversation (Sections 2–3). It can be added afterwards: connector + LLM trained on image–text data.
  • For the encoder, not obviously.
    • MMVP: CLIP features miss visual details that DINOv2 captures.
    • Cambrian-1: language-supervised encoders still win, but SSL narrows the gap, and combining the two helps.
    • Web-SSL: a language-free encoder (7B, 2B web images), frozen inside the same VLM, matches CLIP on VQA; OCR & Chart catch up with more images or text-rich data.

Average VQA accuracy; bubble size = parameters (1B and 7B). On the same 2B web images, Web-SSL gains +4.6 from 1B to 7B, CLIP +0.7.

Language: necessary for the interface. For the encoder: so far an efficient shortcut, with no proof that it is necessary.

Fan, D. et al. (2025). Scaling language-free visual representation learning. arXiv. Fig. 1.

Discussion questions

  1. CLIP aligns but cannot generate. What exactly does the connector add, and what does it cost?
  2. DINOv2 and CLIP both show that data curation beats architecture at scale. When would that stop being true?
  3. Give a prompt where you expect a VLM’s binding to fail. Why?

Exit ticket: one thing CLIP can’t do, and which architecture fixes it.

Questions?