Skip to content

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.

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.

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.