---
title: "nanoVLM: The simplest repository to train your VLM in pure PyTorch"
description: "nanoVLM is a minimal, readable pure-PyTorch toolkit for training small Vision Language Models, inspired by nanoGPT and runnable on a free Colab notebook."
url: "https://swe.quest/articles/nanovlm-the-simplest-repository-to-train-your-vlm-in-pure-pytorch-58371792838c4fd0"
canonical: "https://huggingface.co/blog/nanovlm"
source: "Hugging Face"
published: "2025-05-21"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["model-training","computer-vision","llms","python"]
---

# nanoVLM: The simplest repository to train your VLM in pure PyTorch

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-05-21, 9 min read, How-to. Original: [https://huggingface.co/blog/nanovlm](https://huggingface.co/blog/nanovlm)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch basics
- transformer architecture ([easy posts on System design](https://swe.quest/tags/system-design.md?difficulty=easy))
- Hugging Face Hub

## Keywords

nanoVLM, PyTorch, SigLIP, SmolLM2, nanoGPT, MMStar, Hugging Face

## Related posts

- [SmolVLM - small yet mighty Vision Language Model](https://swe.quest/articles/smolvlm-small-yet-mighty-vision-language-model-c85d5a6cd246b728.md): Hugging Face · 2024-11-26 · Hard · 12 min read · Computer vision, Model training, Inference & serving, LLMs, Evaluation
  SmolVLM is a 2B-parameter open vision language model built on the Idefics3 architecture with a SmolLM2 1.7B backbone.
- [SmolVLM Grows Smaller – Introducing the 256M & 500M Models!](https://swe.quest/articles/smolvlm-grows-smaller-introducing-the-256m-500m-models-4ba2af378f1bbdc6.md): Hugging Face · 2025-01-23 · Easy · 8 min read · Computer vision, LLMs, Model training, Inference & serving
  SmolVLM-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.
- [Vision Language Models Explained](https://swe.quest/articles/vision-language-models-explained-92cc71897cd36570.md): Hugging Face · 2024-04-11 · Medium · 8 min read · Computer vision, LLMs, Model training, Evaluation, Python
  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.
- [PaliGemma – Google's Cutting-Edge Open Vision Language Model](https://swe.quest/articles/paligemma-google-s-cutting-edge-open-vision-language-model-eb2d13e0b9bcd3ec.md): Hugging Face · 2024-05-14 · Medium · 11 min read · Computer vision, LLMs, Model training, Inference & serving, Python
  PaliGemma 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.
- [SmolVLM2: Bringing Video Understanding to Every Device](https://swe.quest/articles/smolvlm2-bringing-video-understanding-to-every-device-60d6aeac72462756.md): Hugging Face · 2025-02-20 · Medium · 8 min read · Computer vision, Inference & serving, LLMs, Python, Swift
  SmolVLM2 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
