Vision Language Models Explained
Vision 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.
Related posts
- A Dive into Vision-Language Models
Hugging Face hardMasterVision-language models pair an image encoder and a text encoder with a strategy for fusing the two, and the pre-training objective determines which downstream tasks they handle well. The main families are contrastive learning (CLIP, ALIGN, LiT), PrefixLM and frozen PrefixLM (SimVLM, Frozen, ClipCap, Flamingo), cross-attention fusion into language model layers (VisualGPT, FIBER), combined masked-language modeling and image-text matching (VisualBERT, FLAVA), and training-free methods (MaGiC, ASIF). Frozen-backbone approaches let teams train with limited aligned image-text data, while PrefixLM-only models are mostly limited to captioning and VQA. The post also surveys common pre-training datasets and shows how to experiment with these models in 🤗 Transformers.
- 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.
- Vision Language Models (Better, faster, stronger)
Hugging Face easyNoviceVision language models shifted over the past year toward smaller yet stronger models, any-to-any architectures, multimodal reasoning, Mixture-of-Experts decoders and vision-language-action models for robotics. Specialized capabilities matured: detection, segmentation and counting via localization tokens (PaliGemma, Molmo, Qwen2.5-VL), multimodal safety filters (ShieldGemma 2, Llama Guard 4), and multimodal RAG that skips brittle PDF parsing using DSE or ColBERT-style retrievers such as ColPali. Small models like SmolVLM and gemma-3-4b-it can run locally through MLX and llama.cpp with one-line commands, and MoE decoders trade higher memory for faster inference.
- nanoVLM: The simplest repository to train your VLM in pure PyTorch
Hugging Face mediumAdeptnanoVLM 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.
- Preference Optimization for Vision Language Models
Hugging Face hardMasterTRL now supports direct preference optimization (DPO) for vision language models, trained on chosen/rejected answer pairs rather than fixed labels. A walkthrough fine-tunes Idefics2-8b on the RLAIF-V dataset, formatting image-plus-question prompts with the processor's chat template. Full float32 DPO training would need about 160 GB (policy, reference model, gradients, AdamW states), but bfloat16 plus LoRA cuts trainable parameters to 55M and memory to roughly 32 GB. Batch size 2 with 32 gradient accumulation steps and gradient checkpointing fits activations, and training is judged by rising accuracy and reward margin.