image-text-to-text · vision-language · WebGPU · ~250 MB
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.
| Model | HuggingFaceTB/SmolVLM-256M-Instruct |
|---|---|
| Task | image-text-to-text (vision → text generation) |
| Architecture | SigLIP vision encoder + SmolLM2 text decoder (Idefics3-style) |
| Params / dtype | 256M · q4f16 (4-bit weights, fp16 compute) |
| Backend | WebGPU (required — needs a GPU + shader-f16) |
| Download | ~250 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebGPU, Web Workers, FileReader |
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.
Run a generation to see the templated prompt.
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.
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.