Unit 9 of 9 · about 2 hours · explain

Audio and video tokenization and native multimodal generation objectives

This optional unit is a vocabulary bridge, not a second implementation project. It makes clear which parts of the image-text contract generalize to time and which require a decoder for the output modality.

You'll be able to

  • Explain video frame or tube tokens and audio codec tokens with explicit temporal alignment and rate budgets.
  • Distinguish codec reconstruction, next-code prediction and conditional text generation objectives.
  • Explain what an autoregressive mixed-modal model needs to generate images rather than only describe them.

Covers

Audio and video tokenization and temporal-alignment vocabularyImage or audio generation objectives
1

Read

In this order, only the parts listed

0 of 4 done

  1. Qwen2-VL, arXiv:2409.12191v1: video inputsQwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution (Wang et al., 2024)

    Section 2.1, Model Architecture: the M-RoPE paragraph and Figure 3 (temporal coordinates) and the Unified Image and Video Understanding paragraph (3D convolutions with a depth of two)

  2. EnCodec, arXiv:2210.13438v1High Fidelity Neural Audio Compression (EnCodec)

    Sections 3.1 to 3.4 and Figure 1: encoder stride, residual vector quantization, code language model and training objectives

    Stop before the experiments. No audio download, codec training or listening panel is required.

  3. Chameleon, arXiv:2405.09818v1Chameleon: Mixed-Modal Early-Fusion Foundation Models (Chameleon Team, 2024)

    Section 2 and Sections 2.1 to 2.3: autoregressive mixed-modal sequences, image tokenizer, pretraining data and stability

    Read the representation and objective, not the full training recipe. Image generation does not require diffusion: this model predicts discrete image codes and decodes them.

  4. CS336 Spring 2026 Lecture 17: multimodal modelsCS336 2026 - Alignment and Multimodality

    The chameleon block: discrete image tokens, training mixture and stability summary

2

Focus on

  • Video needs time as well as frame-local position. Frame sampling, timestamps, temporal stride and dropped frames change the evidence; an average of frame embeddings can erase event order.
  • Audio sample rate, latent frame rate and code-id rate are different. In the stated EnCodec encoder, strides 2, 4, 5 and 8 give total stride 320, hence 75 latent frames per second at 24 kHz. Each residual codebook adds another id per frame.
  • The codec reconstructs waveforms with time-domain, spectral, adversarial and commitment losses. A separate language model predicts code distributions; codec reconstruction alone does not teach text-conditioned audio generation.
  • Chameleon predicts categorical tokens in mixed text-image order. Its tokenizer maps a 512 by 512 image to 1024 codes from 8192 entries. Token count, codebook cardinality and output-decoding cost are separate quantities; the tokenizer's lost detail limits downstream reconstruction.
Common mistakes · 3
  • Calling a spectrogram frame or a continuous visual embedding a discrete vocabulary entry. Continuous features need a different prediction or output-decoding contract.
  • Interpreting codec codebook size as sequence length. More codebooks or a longer recording add code ids without changing the number of entries per codebook.
  • Comparing image and audio token likelihoods as if they shared a unit. Tokenization, codebook structure and loss weighting differ.
3

Try it yourself

Closed-book, before checking anything

Without code or notes, budget a two-second, 24 kHz clip with encoder stride 320 and four 1024-entry codebooks: 150 latent frames, 600 code ids and 6000 fixed-width bits, or 3 kbps before framing and entropy coding. Contrast this with two image frames encoded by Chameleon's stated tokenizer: 2048 image codes, excluding separators. Explain why neither count alone specifies autoregressive latency: codebooks may be predicted in parallel rather than flattened into sequential steps.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Does adding four residual codebooks make the latent frame rate four times higher?Answer

    No. The frame rate is unchanged; four code ids describe each frame. A flattened serialization would have four times as many ids as latent frames.

  2. 2.What is missing from a CLIP encoder plus a text decoder if the task is to output an image?Answer

    An image-output representation, a model objective for predicting it and a decoder that turns it into pixels. Describing an image in words does not supply those.

  3. 3.Why are equal numbers of video frames not necessarily equal temporal evidence?Answer

    Sampling rate and timestamps determine coverage and order. Sparse or irregular frames can miss short events even when the frame count matches.

5

Practice

  • TensorTonic: Assign Multimodal RoPE Coordinates, Strided video grid case

    The public Strided video grid case and its two-frame example with frame_stride=2

    Reuse your coordinate builder. Explain the temporal coordinates and the next-segment offset when frame stride changes while the number of frames stays fixed. This is a coordinate exercise, not video understanding or audio generation; no second model training run is required.

You're done when

You reproduce the rate budget and strided-video coordinates, and can state the representation, prediction target and output decoder for text-conditioned image or audio generation without proposing a large training run.

Only when you can do this without notes.

Leads to

Notes

Resources · 4 for this unit, 11 more in the section

Also in this section

  • CLIP Paper and Official CodeOpenAI · required

    Read Section 2.2 and the Figure 3 pseudocode (normalized embeddings, logits scaled by a learned temperature, the symmetric cross-entropy), then Section 2.3. Check preprocessing and tokenization in the official code (clip/clip.py _transform and tokenize, https://github.com/openai/CLIP). The README says logits are "times 100", but the model learns the scale.

  • Sigmoid Loss for Language Image Pre-Training (Zhai et al., 2023)Google DeepMind · required

    Read Sections 3.1 and 3.2 and Algorithm 1: a pairwise sigmoid loss with a learned temperature and bias instead of a softmax over the batch. Negatives still matter; keep the reduction convention explicit.

  • LLaVA - Visual Instruction TuningLLaVA Team · required

    Read Section 3 (GPT-assisted instruction data built from captions and boxes) and Sections 4.1 and 4.2 (a linear projection, then two-stage training). LLaVA-1.5 (https://arxiv.org/abs/2310.03744) swaps in a two-layer MLP; see build_vision_projector in the code. Build only a tiny frozen-encoder plus projector path and compare it with text-only and shuffled-pair controls.

  • POPE: Evaluating Object Hallucination in Large Vision-Language ModelsRenmin University · required

    Read Sections 5.1 and 5.2 of the paper (https://aclanthology.org/2023.emnlp-main.20.pdf), then evaluate one negative-sampling slice (random, popular or adversarial) with accuracy, F1 and the yes ratio. Join answers by question id, not row order, and keep the original files apart from POPEv2.

  • Modern LLM Notebook - Vision-Language ModelsWalking Labs · support

    Complete notebooks-en/part4-frontiers/29-vlm.ipynb through the minimal VLM. Add missing-image, conflicting-caption, resolution and serialization tests that the walkthrough does not supply.

  • smol-course Unit 3 - Vision Language ModelsHugging Face · support

    Work through Unit 3 for a runnable VLM fine-tuning path on SmolVLM2. Check its memory notes against your GPU and shrink the model, image resolution or batch before running.

  • COCO Captions SubsetCOCO Consortium · support

    Select 50 to 200 image ids from one annotation split with all their captions, record each image's license, and keep every caption of an evaluation image out of training. The annotations are CC BY 4.0; the images keep their own terms.

  • Flamingo: a Visual Language Model for Few-Shot Learning (Alayrac et al., 2022)DeepMind · support

    Read Sections 2.1 to 2.3 (details in Appendix A.1.1 to A.1.3): the Perceiver Resampler, gated cross-attention with tanh gates starting at zero, and multi-image masking. It is the cross-attention contrast to LLaVA's token concatenation.

  • TensorTonic - Alignment and Multimodality SetTensorTonic · support

    Solve Patchify a Batch of Images (cs336-l17-vision-transformer-patchify), Implement Symmetric CLIP Contrastive Loss (cs336-l17-symmetric-clip-loss), Implement the SigLIP Pairwise Loss (cs336-l17-siglip-pairwise-loss) and Assign Multimodal RoPE Coordinates (cs336-l17-multimodal-rope-coordinates). Its SigLIP loss averages over all B squared pairs while OpenCLIP divides the sum by B, so multiply by B before comparing. Public test cases check the listed edge cases, not gradients or the hidden grader, so keep your own tests beside each solution.

  • OpenCLIPML Foundations · reference

    Use release 3.3.0 for one small comparison: ClipLoss and SigLipLoss in src/open_clip/loss.py as oracles for your losses, and the zero-shot classifier. OpenAI RN50 weights need force_quick_gelu=True. The main branch has a refactored training stack; do not adopt the distributed trainer.

  • LLM Post-Training Laboratory - Multimodal ModuleRoadmap-Final · support

    Use the optional multimodal evidence module for versioned aligned data, projector or fusion tests, retrieval and generation evaluation, and modality-specific safety checks.