A from-scratch PyTorch implementation of Google DeepMind's PaliGemma vision-language model (google/paligemma-3b-pt-224), checked against Hugging Face transformers: bit-exact logits in bf16 and identical greedy generation, with and without a KV cache. The handbook explains every part with interactive figures: SigLIP patches and encoder, the linear projector and prefix-LM mask, Gemma's residual stream, √d scaling, RMSNorm, GeGLU, RoPE, multi-query attention and the KV cache.
The handbook needs JavaScript. Source code: github.com/mlihgenel/paligemma-from-scratch