9 Multimodal
  1. In this chapter
  2. Multimodal LLMs
  3. Diffusion Models and Flow Matching
  4. World models and planning
All chapters →

Part 3 · Deploy and apply Chapter 9

Multimodal

How vision and language are aligned, and how images are generated: from CLIP, LLaVA and the token cost of an image to how diffusion and flow matching build images, robot actions and text from noise, the core structures and limits of multimodal models.

3 pages about 1.5 h Chapter labs on GitHub ↗ Intermediate → Advanced Updated

After this chapter you will be able to

  • Explain how a vision encoder, a projector and a language model turn an image into tokens and align it with text.
  • Estimate how many visual tokens an image takes and what that does to the KV cache and the latency.
  • Explain why resolution decides whether the model can read small text, and choose image preprocessing accordingly.
  • Write the training objective and sampling procedure of diffusion models and flow matching, and explain the trade-offs between step count, guidance strength and sample quality.
  • Tell vision-language models that read images from diffusion and flow-matching models that draw them, and name the components they share (ViT, Transformers, text encoders).

The basic idea of a multimodal LLM is to use a vision encoder to turn an image into vectors, and a projector to “translate” them into tokens the language model can read. After that, everything the earlier chapters say about attention, the KV cache and serving applies to images unchanged; the sequence just contains a batch of visual tokens.

This chapter has two pages, one for reading images and one for drawing them. The first focuses on vision-language models that describe and answer questions about images, and works through the engineering questions: how an image becomes tokens, what it costs, and whether small text can be read. The second covers diffusion models and flow matching: it implements them from scratch on 2-D data, measures how steps and guidance strength trade off against sample quality, and then extends to latent diffusion, DiT, and the generation of robot actions and text. Audio and video will be added later.

Related paper explainers: CLIP, LLaVA, DDPM and Flow Matching.

World models and planning connects visual representations to control through predictive dynamics, planning, and feedback.

Chapter roadmap

  1. 9.1

    Multimodal LLMs: How an Image Becomes Tokens

    A vision-language model cuts an image into patches, turns them into visual tokens with a vision encoder and a projector, and feeds them to a language model. Measured here are CLIP's contrastive loss, LLaVA's two training stages, token and KV cache costs, and how resolution affects small text.

    Intermediate 42 min read

    Prerequisites3.2Attention Basics2.5Tokenizers and Embeddings7.3KV Cache and Inference Performance

  2. 9.2

    Diffusion Models and Flow Matching: Generating Images, Actions and Text from Noise

    Diffusion models turn data into Gaussian noise with a known process and train a network to undo it step by step; flow matching regresses a velocity field instead, so sampling is an ODE solve. This page builds DDPM, DDIM, flow matching and reflow on 2-D data and measures steps against quality.

    Advanced 43 min read

    Prerequisites2.3Neural Network Basics3.2Attention Basics9.1Multimodal LLMs

  3. 9.3

    World models and planning: from prediction to closed-loop control

    A world model predicts how actions change state. A planner compares candidate sequences and corrects its plan with observations. This tutorial explains latent dynamics and verifies replanning after a map error with a grid simulator.

    Intermediate 11 min read

    Prerequisites9.1Multimodal LLMs6.4Reinforcement Learning Basics