B.14.1 What the System Does After Pass 12
After Pass 12 the system sees and hears. Images and audio become arrays the way the reference processors make them, vision encoders turn images into embeddings and align them with text, Whisper transcribes speech with logits that match Hugging Face, and transcripts and image answers are scored with every number backed by consent records. All of it is Python, on the course’s own autograd and numpy. The text system from Pass 11 is unchanged, and everything from earlier passes keeps working. This page says what the finished solution does, which solution files do it, and why each piece is needed.
Concepts from other sections (23)
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.
- logits: unnormalized log-scores that softmax turns into probabilities; here the table stores . Read more: 6.1 Byte bigram: counts, logits, safetensors v0
- 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 - Cross-correlation: sliding a kernel over a signal and taking a dot product at each position, with no flip; what deep learning calls convolution. Read more: 18.1 Convolution as a linear map in Mathematics
- Lanczos3: the windowed sinc on . Read more: 18.3 Resampling and interpolation in Mathematics
- DFT: multiplication by , writing samples as coefficients of complex sinusoids. Read more: 18.4 DFT and FFT in Mathematics
- 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
- pixel budget: the configured maximum
width*height, checked from the header before decompression. Read more: 14.6 Image preprocessing to the specification - EXIF orientation: a tag (1 to 8) saying how stored pixels must be flipped or rotated for display. Read more: 14.6 Image preprocessing to the specification
- 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
- 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
- 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
- dual encoder: two towers, one per modality, projecting into a shared embedding space. Read more: 14.5 Contrastive image-text: CLIP and SigLIP
- Contrastive training: fine-tuning an embedder by pulling matching pairs together and pushing negatives apart. Read more: 16.3 Embeddings, small models, and platforms
- cross-attention: attention with queries from one sequence and keys and values from another. Read more: 11.3 Multi-head attention
- 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
- 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
- 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
- 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
The preprocessing rests on the signals-and-images chapter of Mathematics, from convolution as a linear map to mel filterbanks and its problem set, with image preprocessing to the specification and the audio frontend. The vision encoders are the Vision foundations chapter, and Whisper is Speech recognition. Scoring is the multimodal eval metrics and consent and biometric evidence.
Images and audio become arrays the way the reference processors make them
Section titled “Images and audio become arrays the way the reference processors make them”The mathematics sections are the numpy reference semantics for everything after them. sig/conv.py writes convolution as a cross-correlation and as one matrix (im2col, col2im, conv_matrix); image/layout.py converts uint8 HWC decoder output to float32 CHW and cuts patches; sig/resample.py resizes with nearest, bilinear, bicubic, and Lanczos3 kernels and resamples audio; sig/fft.py, sig/stft.py, and sig/mel.py compute the DFT, a mixed-radix FFT, Hann-windowed STFT frames, and mel filterbanks.
On top of them, vision/preprocess.py decodes an image within a pixel budget, applies its EXIF orientation, resizes, crops, and normalizes it to the processor’s written config, and hashes the raw bytes (media_hash). io/wav.py parses WAV from the RIFF bytes up, and speech/frontend.py turns it into Whisper’s input: mono 16 kHz, padded or trimmed to 30 s, and a log-mel picture of 80 bands by 3000 frames.
Why this matters: a model sees only the tensor its training processor produced. A one-pixel shift in resizing or a different mel normalization changes every logit downstream, so preprocessing is checked on its own, before any model.
Vision encoders turn images into embeddings and align them with text
Section titled “Vision encoders turn images into embeddings and align them with text”vision/conv.py runs Conv2d, Conv1d, and pooling on the course’s autograd through im2col. vision/rope2d.py generalizes Pass 5’s RoPE to patch rows and columns and to Qwen2-VL’s M-RoPE. vision/vit.py is the ViT encoder: a stride-p PatchEmbed, position tables that interpolate to new grids, and transformer blocks. vision/tiling.py chooses a resolution and tiles large images (any-resolution and Idefics3 splits) and trades spatial size for channels with pixel_shuffle. vision/contrastive.py trains a dual encoder with the CLIP and SigLIP losses and classifies zero-shot from text prompts; a tiny dual encoder learns zero-shot classification of 24 color-shape classes.
Why this matters: a language model reads tokens, so an image must become a sequence of vectors in the same space as text. Patches make the sequence, 2D positions keep the geometry, tiling keeps fine detail in large images, and contrastive training is what puts image and text embeddings in one space.
Whisper transcribes speech with logits that match Hugging Face
Section titled “Whisper transcribes speech with logits that match Hugging Face”speech/encoder.py turns the 30 s log-mel picture into 1500 vectors with a convolutional stem and transformer blocks. speech/decoder.py is the causal decoder with cached cross-attention (CrossKV) and the complete Whisper model, and io/hf_whisper.py maps a published checkpoint into it, so its logits match HF’s within 1e-5. speech/decode.py and speech/tokenizer.py build the start-of-transcript sequence, detect the language, apply the timestamp rules, and decode a window greedily or with beam search, falling back to higher temperatures when a segment fails its quality checks.
Why this matters: the encoder and decoder are Pass 5’s encoder-decoder transformer at a new input, and matching a published checkpoint is what proves every layer and every weight mapping is right. Decoding is where Whisper’s special tokens and fallbacks turn logits into a usable transcript.
Transcripts and image answers are scored, and every number is backed by consent records
Section titled “Transcripts and image answers are scored, and every number is backed by consent records”eval/mm.py computes WER and CER from edit operations after normalization, VQA accuracy, caption scores, zero-shot accuracy, and bootstrap confidence intervals. The consent-and-evidence solution in primers/ethics.08 keeps license and consent as separate records for every source, regenerates the model card’s numbers from runnable evidence, and refuses a card whose numbers or groups do not match that evidence.
Why this matters: a speech or vision model is judged by numbers, and those numbers are only meaningful with an interval and a record of where the media came from. Voices and faces are biometric data, 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 the course yet; this is where the course’s thirteen passes end.