Skip to content

Visual chat models: LLaVA, IDEFICS2, PaliGemma and Qwen-VL

How language models learned to answer questions about images — projected visual tokens, visual instruction tuning, resampled and high-resolution inputs, prefix attention and boxes as text — and how to check what they say before using it.

Advanced ~16 min10 steps

What runs in CodeSplash

You will be able to

  • Describe how LLaVA turns image features into language-model tokens
  • Explain visual instruction tuning and where its answers came from
  • Compare resampled, prefix-attention and dynamic-resolution designs
  • Check a vision-language model's answers with image-swap and blank-image controls

Read first

01

A language model that reads images

Read

A vision-language modelVision-language modelA language model that also reads images: it can answer a question about a picture or pick a label for it. feeds an image encoder's output into a language model as extra tokens and answers in text. The designs below differ in three choices: how image features become tokens, how many tokens an image gets, and how the model was taught to follow requests about images.

They are powerful and fluent, which is the danger: a fluent answer about an image is not evidence that the model looked.

02

LLaVA: project and instruct

Read
Reference · MM013 · Explained hereLLaVA: image-based visual instruction tuningConnects a pretrained vision encoder to a language model and trains on visual instruction examples. It illustrates how alignment pretraining and instruction tuning can produce an image-grounded assistant with a…

LLaVA takes a CLIP image encoder's patch features and maps each, with a small projection, to the language model's embedding width; the projected features are placed before the question like ordinary tokens. In the program two features of width 2 become a 2 × 3 block in the language model's width.

Then visual instruction tuningVisual instruction tuningFine-tuning a vision-language model on image + question + answer examples so it follows requests about images.: first train only the projection on captions, then fine-tune projection and language model on image–question–answer examples. LLaVA's answers were written by a text-only model from captions and boxes, so that model's errors became training data.

03

IDEFICS2: fixed tokens, any resolution

Read
Reference · MM014 · Explained hereIDEFICS2Builds an open multimodal foundation model through systematic choices about backbones, visual processing, data and training.

IDEFICS2 reads images at their own resolution and aspect ratio with a SigLIP encoder, splits large images into tiles, and then pools each image's many patch features into a fixed number of tokens with learned queries, like BLIP-2's Q-Former. In the program, images of 3 and 6 patches both become 2 output tokens.

Its weights and training data are open, which makes it a common baseline. Fixed pooling caps cost; tiling keeps small text readable.

04

PaliGemma: the prompt sees everything

Read
Reference · MM015 · Explained herePaliGemmaCombines a SigLIP visual encoder with a Gemma language model to provide a transferable vision-language base. It supports many task-specific adaptations, including structured visual outputs, rather than being defined…

PaliGemma joins a SigLIP encoder to a Gemma language model with a prefix language modelPrefix language modelThe image and prompt (the prefix) attend to each other freely; the answer is generated left to right after it. mask: the image tokens and the prompt (the prefix) attend to each other in both directions, while the answer is generated left to right. In the program's 5-token mask the first three tokens see one another, and each answer token sees everything before it.

It was built for transfer: fine-tune it per task (captioning, question answering, detection written as text, segmentation codes) rather than chat with it.

05

Qwen-VL: tokens that scale with the image

Read
Reference · MM016 · Explained hereQwen-VL family: selected Qwen-VL, Qwen2-VL and Qwen2.5-VL designsDevelops visual-language systems for understanding, text reading and localization. Selected later designs introduce dynamic visual resolution, multimodal position encoding and stronger document/video interfaces.

The Qwen-VL family reads images at native resolution, so the visual token budgetVisual token budgetHow many tokens an image becomes. More tokens keep small text and details but cost memory and time. grows with image size: a 640 × 480 image in 16-pixel patches is 1,200 patches before merging. It also writes boxes as text coordinates; the program converts a normalized box to pixels (64, 96, 384, 336).

More tokens keep fine print and small objects, at a cost in memory and time. A box in an answer is a claim to check, not a measurement.

06

A blank picture

Predict

Predict first

You ask a vision-language model "What brand is the laptop?" about a plain gray image. What can happen?

It says it can't see anythingIt may answer confidently anywayIt returns an error
Reveal

It may answer confidently anyway. Language priors fill the gap: laptops in photos are often a few common brands. That's why CodeSplash's pilot asks the same question about a blank image; a confident answer there means the model isn't judging the image.

07

Checking what they say

Read

Before using a vision-language model's labels or extracted values, check them:

  • Image swap: ask about the wrong image; the answer should change.
  • Blank image: a blank-image checkBlank-image checkThe pilot asks the same question about a blank gray image; a confident answer means the model isn't judging the image.; the answer should be "unknown".
  • Known labels: score a hand-labeled sample, per label, including counts, negation, small text and rare objects.
  • Text in images is data: a sign saying "ignore your instructions" must not steer the model.
08

Images with Label with AI

In the app

CodeSplash doesn't ship these models. Label with AI and the LLM classifier can label image columnsImage labeling with AIA local vision model looks at each image of a column and picks one of your labels; a pilot scores it first. or extract named fields through a vision model you run on this Mac in Ollama or LM Studio. Images go only to that local modelLocal vision onlyImages go only to a model on this Mac (Ollama or LM Studio at a localhost address); cloud providers aren't used for images., never to a cloud provider; the pilot scores the model on your known labels and runs the blank-image check first.

09

Check: visual chat models

Checkpoint

Check yourself

How does LLaVA give its language model access to an image?

Show the answer

Answer: a

Projected features act as extra input tokens. Flamingo's gated cross-attention is the alternative design.

Check yourself

LLaVA's instruction answers were generated by a text-only model from captions and box lists. What follows?

Show the answer

Answer: a

Generated answers are supervision with their own error. Evaluate the model on human-checked questions.

Check yourself

IDEFICS2 pools every image to a fixed number of visual tokens. What does that buy, and what does tiling add?

Show the answer

Answer: a

Learned queries compress any patch count to a fixed size; splitting into tiles gives the encoder more pixels per region.

Check yourself

Why is IDEFICS2 often used as a research baseline?

Show the answer

Answer: a

Openness makes it possible to check training data overlap and rerun experiments.

Check yourself

In PaliGemma's prefix-LM mask, which tokens attend to each other in both directions?

Show the answer

Answer: a

The prefix is fully visible to itself; generated tokens see the prefix and earlier answer tokens only.

Check yourself

PaliGemma was designed mainly to be used how?

Show the answer

Answer: b

It is a transfer model: a strong starting point that each task adapts.

Check yourself

A model reads images at native resolution in 16 × 16 pixel patches. How many patches does a 320 × 240 image make, before any merging?

Show the answer

Answer: 300

320 / 16 = 20 and 240 / 16 = 15, so 20 × 15 = 300. Doubling both sides would give four times as many.

Check yourself

A Qwen-VL answer includes a box around "the crack in the weld". How should you treat it?

Show the answer

Answer: b

Boxes written as text come from the same generator as the words. Check grounding separately from fluency.

10

Recap

Recap
  • Vision-language models feed image tokens to a language model; designs differ in projection, token budget and instruction data.
  • LLaVA projects patches and tunes on generated instructions; IDEFICS2 pools to fixed tokens; PaliGemma uses a prefix mask; Qwen-VL scales tokens with resolution and writes boxes as text.
  • Fluent isn't grounded: use image-swap, blank-image and known-label checks.
  • In CodeSplash, Label with AI reads images only through a local vision model, with a pilot first.

Concepts in this lesson