← All models

image-text-to-text Β· vision-language Β· WebGPU Β· ~2.7 GB

Qwen2-VL β€” read a document, reason about a picture

Qwen2-VL is a heavier-hitting vision-language model with a reputation for reading: it transcribes text in photos, answers questions about screenshots, charts, forms and receipts, and reasons across what it sees. Give it an image and a prompt and the answer streams out token by token on your GPU β€” nothing uploaded.

At a glance

Modelonnx-community/Qwen2-VL-2B-Instruct (ONNX build of Qwen/Qwen2-VL-2B-Instruct)
Taskimage-text-to-text (vision β†’ text generation)
ArchitectureViT vision encoder (naive dynamic resolution) + Qwen2 text decoder
Params / dtype~2B Β· decoder q4f16, vision + embeddings fp16
BackendWebGPU (required β€” needs a GPU + shader-f16)
Download~2.7 GB, cached after first load
LicenseApache-2.0
Web APIsWebGPU, Web Workers, FileReader

Run it

An invoice with line items and totals A printed form with fields A photographed sign with text A busy street scene Two cats on a couch
…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 a block of vision tokens and slotted into a chat template alongside your words. Qwen2-VL wraps the turn in its ChatML format (<|im_start|> … <|im_end|>) with an <|vision_start|>…<|vision_end|> span standing in for the image patches. Below is the exact templated prompt the model receives, 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

Qwen2-VL is the "reading" VLM: it's tuned to pull structure and text out of images, not just caption them. Running that in a browser tab β€” privately, offline-capable, free per call β€” turns a lot of server-side document plumbing into a client-side primitive.

Use cases

Basics

Describe or ask about an image β€” the core "talk to a picture" loop.

Practical

Read a receipt, invoice, or screenshot and extract the answer β€” document Q&A and OCR reasoning.

Wild

Interrogate an image β€” keep asking follow-up questions in an open, multi-turn visual chat.

Multi-model

Qwen2-VL reads a document β†’ a summariser turns the extract into a one-line digest.

How the API works

Qwen2-VL in Transformers.js uses a dedicated model class. You build a chat message whose content mixes an image placeholder and text, template it, run the processor over the templated text plus the image, then generate β€” streaming tokens as they come:

import { AutoProcessor, Qwen2VLForConditionalGeneration, RawImage, TextStreamer }
  from "@huggingface/transformers";

const model_id = "onnx-community/Qwen2-VL-2B-Instruct";
const processor = await AutoProcessor.from_pretrained(model_id);
const model = await Qwen2VLForConditionalGeneration.from_pretrained(model_id, {
  dtype: { embed_tokens: "fp16", vision_encoder: "fp16", decoder_model_merged: "q4f16" },
  device: "webgpu",                        // WebGPU required
});

const image = await (await RawImage.read(imageURL)).resize(448, 448);
const conversation = [
  { role: "user", content: [{ type: "image" }, { type: "text", text: prompt }] },
];
const text = processor.apply_chat_template(conversation, { 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: 200, do_sample: false, 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. If the GPU backend itself crashes inside the model (a known ORT WebGPU issue with this ONNX build on some browser/GPU/driver combinations), the page says so plainly with what you can do next β€” the raw kernel text is demoted to a collapsed technical detail, never the headline.

References