B.14 Pass 12: Multimodal
This pass extends the text system to images and audio. A language model reads tokens, so an image or a clip of speech must become a sequence of vectors in the same space as text, and the model sees only the tensor its training processor produced. The pass builds that path from first principles: the signal and image mathematics (convolution as a matrix, layouts, resampling, the FFT, the STFT, and mel filterbanks), the vision models (conv layers, 2D RoPE and M-RoPE, a ViT encoder, dynamic resolution and tiling, image preprocessing to a written specification, and CLIP and SigLIP), and the speech models (Whisper’s log-mel frontend, encoder, decoder, and decoding).
Concepts from other sections (21)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- STFT: the DFT of overlapping windowed frames, giving a spectrum per time step. Read more: 18.5 Sampling, Nyquist, windows, and the STFT in Mathematics
- Mel filterbank: a matrix of triangular filters on mel-spaced edges that pools an rfft power spectrum into bands. Read more: 18.6 Mel scale and filterbanks in Mathematics
- RoPE: rotary position embedding, which rotates queries and keys by position to encode relative position. Read more: 5.3 Model landscape and lifecycle
- M-RoPE: Qwen2-VL’s multimodal RoPE, giving each token three position ids . Read more: 14.2 2D RoPE and M-RoPE
- Log-mel: Whisper’s features, of the mel spectrogram with a floor, an 8-unit clip, and the map . Read more: 18.6 Mel scale and filterbanks in Mathematics
- Biometric data: media that can identify a person by body or voice; voice is always treated as biometric here. Read more: 34.2 Consent and biometric evidence in model cards
- Linear map: a function between vector spaces with ; once bases are chosen, every linear map is a matrix. Read more: Chapter 9: Linear Algebra in Mathematics
- Contrastive training: fine-tuning an embedder by pulling matching pairs together and pushing negatives apart. Read more: 16.3 Embeddings, small models, and platforms
- Special token: an id with a role (
unk,bos,eos,pad) that enters a sequence only throughadd_special, never by matching input text. Read more: 7.1 The tokenizer protocol and the char tokenizer - word error rate (WER): pooled substitutions, deletions and insertions divided by the total reference word count. Read more: 15.5 Multimodal eval metrics: WER, CER, VQA, captions, zero-shot
- character error rate (CER): the same rate computed over the characters of the stripped strings, spaces included. Read more: 15.5 Multimodal eval metrics: WER, CER, VQA, captions, zero-shot
- Confidence interval: a procedure that, over repeated samples, produces intervals covering the fixed true parameter at the stated rate. Read more: 13.11 Probability problem set, part c: limit theorems and confidence intervals in Mathematics
- DFT: multiplication by , writing samples as coefficients of complex sinusoids. Read more: 18.4 DFT and FFT in Mathematics
- Mel scale: a perceptual pitch scale; Slaney’s is linear below 1000 Hz and logarithmic above, HTK’s is . Read more: 18.6 Mel scale and filterbanks in Mathematics
- im2col: the linear map that copies each receptive field of an image into a column, so a convolution becomes a matmul. Read more: 14.1 Conv layers and pooling on autograd
- pixel shuffle: a permutation that moves an block of tokens into the channels of one token. Read more: 14.4 Dynamic resolution and tiling
- conv stem: the two width-3
Conv1dlayers with GELU that precede attention; the second’s stride 2 halves the sequence length. Read more: 15.2 Whisper encoder: conv stem, sinusoids, pre-LN blocks - beam search: keeping the best prefixes by summed log-probability, ranking all extensions together at each step. Read more: 10.4 Beam search, generic over a step function
- temperature fallback: retrying a window at hotter temperatures when output is repetitive or low-confidence. Read more: 15.4 Whisper decoding and long-form transcription
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card
- Consent record: the ledger fields (
consent,biometric,prohibited_uses,attribution,modality) that state whether people agreed to their media being used, separate from the license. Read more: 34.2 Consent and biometric evidence in model cards
Every piece is a Python reference on the course’s own autograd and numpy, built on the attention, RoPE, tokenizers, and checkpoints of earlier passes. The pass ends with the metrics that score transcripts and image answers, and with the consent and evidence rules for biometric data: voices and faces are biometric, so consent, not just access, decides what may be measured and published. Serving the multimodal models in the Rust engine and gateway is not part of this pass yet; the text system from Pass 11 keeps working unchanged.
Learning objectives
- Explain convolution as a linear map, image layouts, resampling kernels, the FFT, the STFT, and mel filterbanks.
- Explain how a ViT embeds patches, how 2D positions and tiling preserve geometry and detail, and how contrastive training aligns images with text.
- Explain how Whisper turns audio into log-mel frames, encodes them, and decodes a transcript with special tokens and fallbacks.
- Compute WER, CER, and the other multimodal metrics with confidence intervals, and explain why each needs consent-backed evidence.
Before you begin
Section titled “Before you begin”This pass needs Pass 11. It leans most on the encoder-decoder transformer and RoPE from Pass 5.
In this pass
Section titled “In this pass”- Convolution as a linear map. Afterwards you can explain why convolution is a linear map and how it is written as a matrix.
- Image tensors and layouts. Afterwards you can explain image tensor layouts (HWC, CHW) and how to convert between them.
- Resampling and interpolation. Afterwards you can explain how resampling and interpolation (nearest, bilinear, bicubic, antialiasing) compute output pixels.
- DFT and FFT. Afterwards you can explain the DFT as a matrix and how the FFT computes it in O(n log n).
- Sampling, Nyquist, windows, and the STFT. Afterwards you can explain the Nyquist limit, why windows reduce leakage, and how the STFT frames a signal.
- Mel scale and filterbanks. Afterwards you can explain the mel scale and how a mel filterbank is built from triangular filters.
- Signals and images problem set. Afterwards you can work every problem in the set and explain each answer.
- Conv layers and pooling. Afterwards you can explain how conv layers run through im2col and how pooling reduces resolution.
- 2D RoPE and M-RoPE. Afterwards you can explain how 2D RoPE and M-RoPE extend rotary position to images.
- Vision transformer encoder. Afterwards you can explain how the ViT encoder embeds patches and runs transformer blocks over them.
- Dynamic resolution and tiling. Afterwards you can explain how dynamic resolution tiles an image and how pixel shuffle reduces tokens.
- Image preprocessing. Afterwards you can explain each step of image preprocessing to the written spec.
- Contrastive image-text. Afterwards you can explain how CLIP and SigLIP train image-text alignment with contrastive losses.
- Audio frontend. Afterwards you can explain how the audio frontend parses WAV and computes Whisper’s log-mel features.
- Whisper encoder. Afterwards you can explain how the Whisper encoder’s conv stem and transformer blocks process log-mel frames.
- Whisper decoder and weights. Afterwards you can explain how the Whisper decoder cross-attends to the encoder and how its weights are loaded.
- Whisper decoding and transcription. Afterwards you can explain how Whisper decoding uses special tokens, timestamps, beam search, and temperature fallback.
- Multimodal eval metrics. Afterwards you can explain how WER, CER, and the other multimodal eval metrics are computed.
- Consent and biometric evidence. Afterwards you can explain why the model card’s numbers must match runnable evidence and why every source needs valid consent records.
- What the System Does After Pass 12. Afterwards you can explain how the system sees and hears: images and audio flow through preprocessing, encoders, and decoders that match their reference models.
The stages are also in this pass’s manifest, path.tsv. After this pass the system sees and hears, and the text system is unchanged.
Stages
Section titled “Stages”Generated from path.tsv.
| Stage | Read | Done when |
|---|---|---|
| 1 | Multimodal pass plan B.14 Pass 12: Multimodal | You can explain the image, speech, and evaluation work in Pass 12 and how it builds on the text system. |
| 2 | Convolution as a linear map 18.1 Convolution as a linear map | You can explain why convolution is a linear map and how it is written as a matrix (M12.1). |
| 3 | Image tensors and layouts 18.2 Image tensors and layouts | You can explain image tensor layouts (HWC, CHW) and how to convert between them (M12.2). |
| 4 | Resampling and interpolation 18.3 Resampling and interpolation | You can explain how resampling and interpolation (nearest, bilinear, bicubic, antialiasing) compute output pixels (M12.3). |
| 5 | DFT and FFT 18.4 DFT and FFT | You can explain the DFT as a matrix and how the FFT computes it in O(n log n) (M12.4). |
| 6 | Sampling, Nyquist, windows, and the STFT 18.5 Sampling, Nyquist, windows, and the STFT | You can explain the Nyquist limit, why windows reduce leakage, and how the STFT frames a signal (M12.5). |
| 7 | Mel scale and filterbanks 18.6 Mel scale and filterbanks | You can explain the mel scale and how a mel filterbank is built from triangular filters (M12.6). |
| 8 | Signals and images problem set 18.7 Signals and images problem set: convolution, sampling, Fourier, mel, contrastive losses, and WER | You can work every S-M12 problem and explain each answer. |
| 9 | Conv layers and pooling 14.1 Conv layers and pooling on autograd | You can explain how conv layers run through im2col and how pooling reduces resolution (L13.1). |
| 10 | 2D RoPE and M-RoPE 14.2 2D RoPE and M-RoPE | You can explain how 2D RoPE and M-RoPE extend rotary position to images (L13.2). |
| 11 | Vision transformer encoder 14.3 Vision transformer encoder | You can explain how the ViT encoder embeds patches and runs transformer blocks over them (L13.3). |
| 12 | Dynamic resolution and tiling 14.4 Dynamic resolution and tiling | You can explain how dynamic resolution tiles an image and how pixel shuffle reduces tokens (L13.4). |
| 13 | Image preprocessing 14.6 Image preprocessing to the specification | You can explain each step of image preprocessing to the written spec (L13.6). |
| 14 | Contrastive image-text 14.5 Contrastive image-text: CLIP and SigLIP | You can explain how CLIP and SigLIP train image-text alignment with contrastive losses (L13.5). |
| 15 | Audio frontend 15.1 Audio frontend: WAV parsing and Whisper’s log-mel | You can explain how the audio frontend parses WAV and computes Whisper’s log-mel features (L14.1). |
| 16 | Whisper encoder 15.2 Whisper encoder: conv stem, sinusoids, pre-LN blocks | You can explain how the Whisper encoder’s conv stem and transformer blocks process log-mel frames (L14.2). |
| 17 | Whisper decoder and weights 15.3 Whisper decoder and checkpoint weights | You can explain how the Whisper decoder cross-attends to the encoder and how its weights are loaded (L14.3). |
| 18 | Whisper decoding and transcription 15.4 Whisper decoding and long-form transcription | You can explain how Whisper decoding uses special tokens, timestamps, beam search, and temperature fallback (L14.4). |
| 19 | Multimodal eval metrics 15.5 Multimodal eval metrics: WER, CER, VQA, captions, zero-shot | You can explain how WER, CER, and the other multimodal eval metrics are computed (L14.5). |
| 20 | Consent and biometric evidence 34.2 Consent and biometric evidence in model cards | You can explain why the model card’s numbers must match runnable evidence and why every source needs valid consent records (ethics.08). |
| 21 | What the system does after Pass 12 B.14.1 What the System Does After Pass 12 | You can explain how the system sees and hears: images and audio flow through preprocessing, encoders, and decoders that match their reference models. |