Patch Embedding and ViT Input
Turn a raw image tensor into a sequence of patch embeddings with a class token and learnable position embeddings.
Build a ViT encoder, multimodal projector, causal decoder, training loop, and caption generation from raw tensor operations.
Every source step is its own lesson with intuition, concepts, correctly rendered MathJax mathematics, implementation, tests, mistakes, and a checkpoint.
Turn a raw image tensor into a sequence of patch embeddings with a class token and learnable position embeddings.
Implement scaled dot-product attention from primitives and assemble it into a full multi-head self-attention module.
Build the position-wise MLP, layer normalization, pre-norm residual sublayers, and stack them into a vision encoder.
Extract patch features and project them into the language model's embedding dimension with a two-layer MLP.
Build the tokenizer, embed text tokens, locate the image placeholder, and splice projected image tokens into the multimodal embedding sequence.
Build the masked transformer decoder, language modeling head, and wire up the full vision-language model forward pass.
Compute next-token cross-entropy loss with masking, then implement temperature, top-k, and sampling-based autoregressive generation.
Initialize parameters, run training steps with autograd, perform gradient descent updates, and execute a full training loop.