CLIP found the weekend timetable. The photo says “First train 06:10, last train 22:40”; the caption just says “Weekend service has changed.” When does the last train leave? To answer 22:40, the model has to read the digits and associate them with the last train. A single score for the whole photo doesn't give you that answer.

We follow ViT + projector + decoder-only LLM, not a universal VLM architecture. Read CLIP and Decoder-only first if needed.

An image need not become one vector

In one lineVisual vectors can stay a sequence; the projector only maps them to the LLM width. A plain linear layer or MLP keeps the token count.

ViT divides an image into patches, flattens and projects them, adds position information, and applies a Transformer.

The tensor shapes are worked out in ViT: a $224\times224$ RGB image cut into $16\times16$ patches gives 196 patches of 768 raw values each. What matters here is that the 196 projected vectors can remain a sequence rather than immediately becoming one global vector. Original ViT classification adds a class token, so include one extra position when counting that sequence.

flowchart TD
    A["Image"] --> B["Patches + positions"]
    B --> C["Vision encoder: P visual features"]
    C --> D["Projector: vision width → LLM width"]
    D --> E["Visual vectors + question embeddings"]
    E --> F["Decoder-only LLM"]
    F --> G["Generate answer tokens"]

Visual inputs are often continuous features, not discrete vocabulary IDs. A projector changes feature width; an ordinary tokenwise linear layer or MLP does not automatically reduce token count. Length compression needs pooling, a resampler, or another explicit mechanism.

Matching dimensions is not matching meaning

In one lineMatching widths only makes the matrices fit; the LLM must still learn what the vectors mean. LLaVA trains the projector first, then the LLM too.

Mapping $d_v$ to $d_{LM}$ makes the matrices compatible. It does not, by itself, teach the LLM what the visual features mean.

The original LLaVA training recipe gives a concrete example:

Stage Updated parameters Purpose
Image–text alignment Projector; vision encoder and LLM frozen Make visual features usable as language-model conditioning
Visual instruction tuning Projector and LLM; vision encoder frozen Learn to answer using the image and question

This is one paper's recipe, not a rule that all VLMs freeze vision. Check each alternative against its data, trainable modules, and compute constraints.

Which positions receive loss

In one lineOnly answer positions are scored: in the example, 2 of 208. The loss mask picks scored predictions; the attention mask picks readable inputs.

In this answer-generation teaching setup, the input contains the image, question, and true answer prefix. The objective predicts the next answer token. Visual and question positions do not directly contribute to answer-only loss, but they remain valid context: they influence answers and can carry gradients to trainable modules.

Count one made-up sample: the image becomes 196 visual positions, the question “Is the red square left of the circle?” is assumed to take 8 tokens, the answer “Yes” plus an end marker takes 2 tokens, and 2 padding positions fill out the batch.

Position Count Scored as a prediction target? Can answer positions read it through attention?
Visual positions 196 No Yes
Question tokens 8 No Yes
Answer and end marker 2 Yes They read themselves and earlier positions
Padding 2 No No

Only 2 of the 208 positions are scored, so the denominator below is $M=2$, not 208, and not the 206 left after removing padding. For per-position labels, see the VLM fine-tuning mask example.

Padding is different. It fills out the batch shape and should be excluded from both the loss and the context attended to by valid answer positions. The loss mask chooses which predictions are scored; the attention mask chooses which inputs can be read. Neither replaces the other. Properly masked padding input positions should not provide information or gradient paths to the answer. This is a statement about those input positions, not a claim that shared embedding / output parameters never receive gradients from elsewhere. PyTorch padding-mask documentation

$$L=-\frac{1}{M}\sum_{t\in\mathcal A}\log p_\theta(a_t\mid I,q,a_{<t}),\qquad M=|\mathcal A|.$$

$\mathcal A$ contains scored answer positions. This differs from the contrastive objective of matching images with captions. To check shifting and masks, revisit one language-model training step.

Three design trade-offs worth asking about

In one lineMore resolution means more tokens; freezing saves gradients but not the forward pass; a fluent caption can miss the evidence a question needs.

  • Detail versus length: with fixed-size patches and one image scale, doubling both image dimensions gives four times as many patches. The dense attention score matrix over those tokens has sixteen times as many entries (worked in ViT). End-to-end cost also depends on text length, implementation, and compression; this does not imply a sixteen-fold runtime increase.
  • Freezing versus adaptation: training fewer modules can reduce their gradient and optimizer-state costs, but forward computation and some activation costs remain. Measure the effect on domain adaptation rather than assuming it.
  • Descriptions versus evidence: a fluent caption may omit small text, spatial relations, or details needed by the question. OCR or higher resolution should address a specific information gap, not be added automatically.

Test more than a plausible answer

In one lineUse paired synthetic images: swap only the shapes and the answer should change. Mismatched images and unseeable details test blind guessing.

Make a second copy of the timetable and edit just the last departure, from 22:40 to 23:10. Ask about the last train on both copies: the answer should change. Ask about the first train instead: both answers should still be 06:10. A model that answers 23:10 to both questions on the new photo may have picked up the new digits without reading the row. This tells you more than a single correct answer, though not whether it can read other layouts.

Try the same check with shapes. For “Is the red square left of the circle?”, swap only the shapes' positions; the answer should change. Hold the prompt and decoding settings fixed and compare.

The multimodal overview's comparison table explains what four tests can and cannot show: removing the image, changing one piece of evidence, masking the key region, and introducing an image–text conflict. For spatial questions, add two more tests. Supply a mismatched image and check whether the model blindly follows the question's suggestion. Ask about an attribute that cannot be seen and check whether it acknowledges the missing information rather than giving a longer explanation.

These are proposed teaching experiments, not measured claims about a model. Track small text, counting, and spatial relations separately rather than relying only on aggregate accuracy.

Connect these checks to controlled comparisons and slices before deciding whether more training is necessary. Robot VLA models use the same vision encoder, connector and LLM, but output actions instead of text; see Robot learning: VLA.