Toy Multimodal Dataset
Generate tiny grayscale images and pair each with a text label to form the multimodal training data.
Train a VQ-VAE image tokenizer and an autoregressive text-conditioned transformer with guided sampling.
Every source step is its own lesson with intuition, concepts, correctly rendered MathJax mathematics, implementation, tests, mistakes, and a checkpoint.
Generate tiny grayscale images and pair each with a text label to form the multimodal training data.
Normalize images, split them into patches, and build the linear encoder/decoder that maps patches to latent vectors and back.
Create the codebook, quantize latents with nearest-neighbor lookup and the straight-through estimator, assemble the VQ-VAE losses, train it, and tokenize images.
Build a character vocabulary, encode labels, prepend text tokens to image tokens, and add token plus positional embeddings.
Implement causal masking, layer norm, multi-head self-attention, the feed-forward MLP, the stacked blocks, and the output logit projection.
Compute the next-token cross entropy over image positions and apply optax updates to the transformer parameters.
Add classifier-free guidance dropout, combine conditional and unconditional logits, apply temperature and top-k sampling, and autoregressively decode tokens into an image.
Measure accuracy, reconstruction error, and generation quality, then run the full VQ-VAE and transformer training and end-to-end conditional generation.