← All models

image-text-to-text Β· multi-image / video Β· WebGPU Β· ~250 MB

SmolVLM2 β€” reason across frames, not just one picture

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.

At a glance

ModelHuggingFaceTB/SmolVLM2-256M-Video-Instruct
Taskimage-text-to-text (multi-image / video β†’ text generation)
ArchitectureSmolVLMForConditionalGeneration β€” SigLIP vision encoder + SmolLM2 decoder, trained for multi-image & video frames
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, 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.

Run it

Frames the model will see

Add a frame β€” click a sample, drop an image, or sample a video:

A riverside at golden hour with a swan Two cats on a couch A cozy bedroom
Drop / choose an image

Optional webcam capture and uploaded videos stay on your device β€” nothing is uploaded.

The model's answer will stream here.

See inside

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)–

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

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:

Use cases

Basics

Describe one image β€” the plain "talk to a picture" loop, so you can see the model works.

Practical

Compare two images side by side β€” a before/after or A/B diff in plain language.

Wild

A moving scene β†’ what changed: sample a live-animated sequence and ask the model what happened over time.

Multi-model

SmolVLM2 reads the frames β†’ an on-device LLM narrates them into one flowing story.

How the API works

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.

References