← All models

image-text-to-text · vision-language · WebGPU · ~250 MB

SmolVLM — talk to a picture, on your device

SmolVLM is a tiny vision-language model: give it an image and a question, and it writes an answer. Describe a scene, read the text in a sign, count the cats, reason about what's happening — all streaming token by token on your GPU, with nothing uploaded.

At a glance

ModelHuggingFaceTB/SmolVLM-256M-Instruct
Taskimage-text-to-text (vision → text generation)
ArchitectureSigLIP vision encoder + SmolLM2 text decoder (Idefics3-style)
Params / dtype256M · q4f16 (4-bit weights, fp16 compute)
BackendWebGPU (required — needs a GPU + shader-f16)
Download~250 MB, cached after first load
LicenseApache-2.0
Web APIsWebGPU, Web Workers, FileReader

Run it

A riverside at golden hour with a swan Two cats on a couch A cozy bedroom
…or drop / choose your own image
Selected image
The model's answer will stream here.

See inside

A VLM doesn't "see" — it reads a sequence of tokens where your image has been turned into hundreds of image tokens and slotted into a chat template alongside your words. Below is the exact prompt the model receives (the <image> placeholder is expanded into patch tokens during processing), and the live token stream with the time each token arrived — so you can watch it think and see where the latency goes.

Constructed chat template

Run a generation to see the templated prompt.

Token stream (value · ms since start)

Tokens appear here as they're generated.

Why it matters

A 256M-parameter model that understands images used to be unthinkable in a browser tab. SmolVLM makes visual understanding a client-side primitive — private, offline-capable, and free to run.

Use cases

Basics

Describe an image — the core "talk to a picture" loop.

Practical

Generate accessible alt-text you can copy straight into your HTML.

Wild

Ask the image anything — an open-ended visual chat.

How the API works

SmolVLM uses the vision-to-text model classes. You build a chat message whose content mixes an image placeholder and text, template it, run the processor, then generate — streaming tokens as they come:

import { AutoProcessor, AutoModelForVision2Seq, load_image, TextStreamer }
  from "@huggingface/transformers";

const processor = await AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM-256M-Instruct");
const model = await AutoModelForVision2Seq.from_pretrained(
  "HuggingFaceTB/SmolVLM-256M-Instruct",
  { dtype: "q4f16", device: "webgpu" },   // WebGPU required
);

const image = await load_image(imageURL);
const messages = [{ role: "user", content: [{ type: "image" }, { type: "text", text: prompt }] }];
const text = processor.apply_chat_template(messages, { add_generation_prompt: true });
const inputs = await processor(text, [image]);

const streamer = new TextStreamer(processor.tokenizer,
  { skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });
await model.generate({ ...inputs, max_new_tokens: 150, streamer });

This page runs exactly that, in a Web Worker, and gates on a real WebGPU adapter first — if none exists it shows a labelled needs-WebGPU state instead of a fake answer.

References