image-text-to-text Β· multi-image / video Β· WebGPU Β· ~250 MB
SmolVLM v1 talks to a single image. SmolVLM2 takes several images β or frames sampled from a video β in one turn, and reasons across them: what changed, how two scenes compare, what happened over time. Same tiny 256M footprint, all streaming token by token on your GPU, with nothing uploaded.
| Model | HuggingFaceTB/SmolVLM2-256M-Video-Instruct |
|---|---|
| Task | image-text-to-text (multi-image / video β text generation) |
| Architecture | SmolVLMForConditionalGeneration β SigLIP vision encoder + SmolLM2 decoder, trained for multi-image & video frames |
| 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, HTMLVideoElement + Canvas (frame sampling) |
Not the same demo as SmolVLM (v1): v1 is a single-image
model (idefics3); SmolVLM2 (smolvlm) adds native multi-image and
video-frame understanding.
Add a frame β click a sample, drop an image, or sample a video:
Optional webcam capture and uploaded videos stay on your device β nothing is uploaded.
A multi-frame VLM turns each image into hundreds of image tokens and interleaves them
with your words inside one chat template. Below is the exact prompt the model
receives (each <image> placeholder is expanded into patch tokens), the real
tensor shape going in (how many frames, at what resolution), and the live
token stream with the time each token arrived β so you can watch it read every
frame and reason across them.
| frames in this turn | β |
|---|---|
| pixel_values shape | β |
| prompt tokens (text + image) | β |
Run a generation to see the templated prompt.
Single-image VLMs answer "what's in this picture?". A multi-frame VLM answers "what happened?" β and it does it on-device, privately, for free. Once a model can hold several frames in one context, a new class of browser features opens up:
Describe one image β the plain "talk to a picture" loop, so you can see the model works.
Compare two images side by side β a before/after or A/B diff in plain language.
A moving scene β what changed: sample a live-animated sequence and ask the model what happened over time.
SmolVLM2 reads the frames β an on-device LLM narrates them into one flowing story.
SmolVLM2 uses the vision-to-text model classes. You build a chat message whose content mixes multiple image placeholders and text, template it, run the processor over the array of images, then generate β streaming tokens as they come:
import { AutoProcessor, AutoModelForVision2Seq, load_image, TextStreamer }
from "@huggingface/transformers";
const processor = await AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM2-256M-Video-Instruct");
const model = await AutoModelForVision2Seq.from_pretrained(
"HuggingFaceTB/SmolVLM2-256M-Video-Instruct",
{ dtype: "q4f16", device: "webgpu" }, // WebGPU required
);
const images = await Promise.all(frameURLs.map(load_image)); // several frames
const content = images.map(() => ({ type: "image" })); // one placeholder per frame
content.push({ type: "text", text: "What changed between these frames?" });
const messages = [{ role: "user", content }];
const text = processor.apply_chat_template(messages, { add_generation_prompt: true });
const inputs = await processor(text, images, { do_image_splitting: false });
// inputs.pixel_values.dims === [1, numFrames, 3, H, W] β the frames, batched
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: 160, 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.