← All models

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

nanoLLaVA β€” a pocket-sized LLaVA that talks about images

nanoLLaVA is a ~1B-parameter LLaVA-style vision-language model: a SigLIP vision encoder bolted onto a small Qwen1.5 language model. Give it an image, a system persona, and a question β€” and it answers in a chat format, streaming token by token on your GPU with nothing uploaded.

At a glance

ModelXenova/nanoLLaVA (ONNX build of qnguyen3/nanoLLaVA)
Taskimage-text-to-text (vision β†’ text generation)
ArchitectureSigLIP-400M vision encoder + Qwen1.5-0.5B decoder (LLaVA-style projector)
Params / dtype~1B Β· decoder q4f16, vision + embeddings fp16
BackendWebGPU (required β€” needs a GPU + shader-f16)
Download~1 GB, 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 A cafΓ© receipt with items and a total
…or drop / choose your own image
Selected image
The model's answer will stream here.

See inside

nanoLLaVA follows the LLaVA recipe: your image is encoded to a grid of visual tokens that replace the <image> placeholder inside a ChatML template, alongside a system persona and your question. Below is the exact templated prompt the tokenizer receives, and the live token stream with the time each token arrived β€” so you can watch it reason and see where the latency goes.

Constructed ChatML prompt

Run a generation to see the templated prompt.

Token stream (value Β· ms since start)

Tokens appear here as they're generated.

Why it matters

nanoLLaVA brings the well-known LLaVA architecture down to a browser-friendly size. The system persona makes it steerable β€” the same image and question can produce a terse label, a marketing caption, or a careful accessibility description, just by changing the persona.

Use cases

Basics

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

Practical

Read a screenshot or receipt and answer questions β€” visual Q&A over documents.

Wild

Swap the system persona to change the voice β€” same image, many personalities.

Multi-model

nanoLLaVA captions β†’ an OPUS-MT translator makes multilingual alt-text.

How the API works

nanoLLaVA uses the LLaVA model class. You build a ChatML message list with a system line and a user turn that embeds the <image> placeholder, template it, tokenize, run the image through the processor, then generate β€” streaming tokens as they come:

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

const model_id = "Xenova/nanoLLaVA";
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const processor = await AutoProcessor.from_pretrained(model_id);
const model = await LlavaForConditionalGeneration.from_pretrained(model_id, {
  dtype: { embed_tokens: "fp16", vision_encoder: "fp16", decoder_model_merged: "q4f16" },
  device: "webgpu",                        // WebGPU required
});

const messages = [
  { role: "system", content: "Answer the question." },
  { role: "user", content: `<image>\n${prompt}` },
];
const text = tokenizer.apply_chat_template(messages, { tokenize: false, add_generation_prompt: true });
const text_inputs = tokenizer(text);
const image = await RawImage.fromURL(imageURL);
const vision_inputs = await processor(image);

const streamer = new TextStreamer(tokenizer,
  { skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });
await model.generate({ ...text_inputs, ...vision_inputs, do_sample: false, 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