nanoVLM: The simplest repository to train your VLM in pure PyTorch
nanoVLM is a minimal, readable pure-PyTorch toolkit for training small Vision Language Models, inspired by nanoGPT and runnable on a free Colab notebook. It pairs a SigLIP vision encoder with a Llama 3-style SmolLM2 decoder, joined by a modality projector made of a pixel shuffle and a linear layer, which cuts the number of image tokens. Training uses two learning rates (a higher one for the freshly initialized projector, a lower one for the pretrained backbones), mixed precision, and cosine decay with warmup, and evaluates on MMStar. A reference model trained for about 6 hours on one H100 with roughly 1.7M Cauldron samples is published for inference via generate.py.
Related posts
- SmolVLM - small yet mighty Vision Language Model
Hugging Face hardMasterSmolVLM is a 2B-parameter open vision language model built on the Idefics3 architecture with a SmolLM2 1.7B backbone. It uses 9x pixel-shuffle compression so each 384x384 patch becomes just 81 tokens. A test prompt plus image encodes to 1.2k tokens versus 16k for Qwen2-VL, giving 5 GB minimum GPU RAM, 3.3-4.5x faster prefill and 7.5-16x faster generation, at modestly lower benchmark scores. Training details cover extending context to 16k by raising the RoPE base to 273k, choosing checkpoints with a weighted benchmark metric, and fine-tuning with QLoRA on a ~16 GB L4 or DPO via TRL.
- SmolVLM Grows Smaller – Introducing the 256M & 500M Models!
Hugging Face easyNoviceSmolVLM-256M and SmolVLM-500M are new vision language models, with the 256M model billed as the smallest VLM released and reported to outperform the 17-month-old Idefics 80B. Key design changes from SmolVLM 2B: a 93M SigLIP base patch-16/512 encoder in place of SigLIP 400M SO, because the larger encoder gave only marginal gains; higher image resolution; a data mix weighted toward document understanding (41%) and captioning (14%); and more aggressive pixel shuffle at 4096 pixels per token. Sub-image separator strings such as <row_1_col_1> are now single special tokens instead of 7 tokens, which improved training stability and result quality. Base and instruct checkpoints ship for transformers, MLX and ONNX/WebGPU, alongside ColSmolVLM retrieval variants.
- Vision Language Models Explained
Hugging Face mediumAdeptVision language models combine an image encoder, a projector that aligns image features with text embeddings, and a text decoder that generates text from both inputs. LLaVA trains in two stages: first only the projector with the encoder and decoder frozen, then the projector together with an unfrozen decoder. KOSMOS-2 instead trains end to end, and Fuyu-8B skips the image encoder entirely. The guide compares open VLMs by license, size and resolution, explains model selection via Vision Arena, the Open VLM Leaderboard and benchmarks like MMMU and MMBench, then shows inference with transformers' LlavaNext and supervised fine-tuning of Llava 1.5 using TRL's new experimental VLM support in SFTTrainer.
- PaliGemma – Google's Cutting-Edge Open Vision Language Model
Hugging Face mediumAdeptPaliGemma is Google's open vision-language model family that pairs a SigLIP-So400m image encoder with a Gemma-2B text decoder through a linear projector. It ships as pretrained, mix and task-specific fine-tuned checkpoints at 224, 448 and 896 resolutions. Behaviour is steered with task prefixes such as "detect" and "segment", and detections come back as <loc> tokens normalized to 1024. Images become 256 to 4096 prefix tokens with full attention over the image and prompt, so higher resolutions cost much more memory while helping mainly fine-grained tasks like OCR. The post includes transformers code for inference, 4-bit loading, and fine-tuning the decoder with full training or QLoRA, plus big_vision transfer configs.
- SmolVLM2: Bringing Video Understanding to Every Device
Hugging Face mediumAdeptSmolVLM2 is a family of small vision-language models (2.2B, 500M and 256M parameters) that handle video and multi-image understanding, with the 500M and 256M variants being the smallest video language models released so far. The 2.2B model beats other 2B models on Video-MME and improves on its predecessor in math-with-images, OCR, diagrams and scientific visual QA. The 500M model comes close to the 2.2B on video at under a quarter of the size. Inference examples cover Transformers, MLX in Python and Swift MLX. Demos include an on-device iPhone app, a VLC integration and a highlight generator, and the 500M model is best fine-tuned fully rather than with LoRA/QLoRA.