Live demo · Multimodality
A vision-language model does one surprising thing: it turns a picture and a sentence into the same kind of object - a single sequence of vectors - then reasons over both at once. Step through the pipeline below to watch it happen.
Everything here runs in your browser and is derived from the real pixels and the text you type. The exact numbers are illustrative - a trained model learns them from data - but the shapes and steps are how real models like CLIP, LLaVA and GPT-4o actually work.
One image, one sentence - two completely different kinds of data.
Raw text
Text splits into tokens. The image splits into a grid of patches.
Text → tokens
Image → patches
CLIP ViT-L/14 uses 14px patches, giving 256 patches for a 224px image. Each patch is flattened and treated as its own "visual word."
Every token and every patch becomes a vector - and they all line up together.
d_model, e.g. 4096 in LLaMA-7B), and a positional encoding (learned, sinusoidal, or RoPE) is added so order is preserved.
In a VLM this alignment is done by a small adapter: LLaVA uses a 2-layer MLP projector, BLIP-2 a Q-Former, Flamingo a Perceiver Resampler.
From here on, the model doesn't care which row came from pixels and which from letters - it's all just vectors.
The transformer lets a word look at the pixels - then fires neurons.
Cross-modal attention - pick a word, watch the image light up
Top attended patches
Mixture-of-Experts routing - a gate sends the token to 2 of 4 experts
Feed-forward activations (GELU) - which neurons fire for this token
softmax(QKᵀ/√d)·V, run in parallel multi-heads) lets every position pull information from every other -
including a text token reading the image patches it cares about (that's the heatmap, a form of cross-attention).
In a Mixture-of-Experts layer a router sends each token to its top-2 of N experts (as in Mixtral 8×7B);
the feed-forward net then fires activations through GELU or SwiGLU. Stack this block ~30-80× (LLaMA-7B: 32, GPT-3: 96), with RMSNorm and residuals between.
All that computation collapses into one probability distribution.
P(next token | image + text)