zero-shot-image-classification vision-language 24.28 MB WASM q8 · ~69 ms warm 8M Vision + 3M Text MIT

TinyCLIP ViT-8M/16 — 24 MB Open-Vocabulary Vision

Distilled via Affinity Mimicking + Weight Inheritance on YFCC-15M, TinyCLIP shrinks CLIP to an 8M-parameter ViT-8M/16 vision tower and a 3M-parameter 3-layer text tower — fitting in just 24.28 MB (q8 WASM) and classifying any image against custom prompts in under 80 ms on CPU.

At a glance

Upstream model wkcn/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M (MIT)
ONNX export onnx-community/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M-ONNX (onnx/model_quantized.onnx)
Task / pipeline zero-shot-image-classification (shared Transformers.js 3.7.5 via lib/webai.js)
Architecture CLIPModel — 10-layer ViT-8M/16 vision encoder (256d, 4 heads, 224×224) + 3-layer 3M text encoder (256d, 4 heads, max 77 tokens) → 512-d projection
Quantisation & size q8 INT8 default (24.28 MB / 24,281,512 B); optional fp16 (47.18 MB) & fp32 (94.07 MB)
Backend WebAssembly (wasm) — runs on any laptop or phone CPU without WebGPU
Web APIs Web Workers, Cache Storage, Canvas 2D, Clipboard, MediaDevices (all Baseline)

Run it — Live Open-Vocabulary Classifier

Loading starter photo…

Latency–
Top-1 & margin–
Entropy–
NaN count–
RuntimeWASM q8 · 24.28 MB

See inside TinyCLIP ViT-8M/16

Instead of training a tiny CLIP from scratch, Microsoft's Affinity Mimicking distills pairwise image-text similarity matrices from a large CLIP teacher, while Weight Inheritance initializes the 8M vision / 3M text student directly from the teacher's most salient channels. Below are the exact 512-d normalized embedding cosines, raw scaled logits (logit_scale · cos), and softmax probabilities from your last run.

Embedding dim512-d
Prompt tokens–
Est. logit scale–
Eff. choices (2^H)–
Per-candidate prompt scores, cosine similarity, and raw logits
# Label Wrapped prompt Cosine sim Raw logit Softmax %
Run a classification above to inspect raw logits and cosines.
Show the code — TinyCLIP worker coalesced load & epoch cancellation
Show the code — Zero-shot inference, cosine & logit extraction in worker.js
Show the code — Real NaN audit, entropy, and logit_scale fit in tinyclip-core.mjs

Why TinyCLIP-ViT-8M/16 matters

Standard CLIP ViT-B/32 (~151 MB) and SigLIP (~420 MB) are too heavy for instant cold loads on mobile connections or tight per-frame budgets. At 24.28 MB and ~69 ms warm latency on CPU WASM, TinyCLIP unlocks open-vocabulary vision anywhere a tiny classifier can run:

Use-case ladder

How the API works

TinyCLIP loads via the standard Transformers.js zero-shot-image-classification pipeline in a dedicated Web Worker:

import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.5";

const classifier = await pipeline(
  "zero-shot-image-classification",
  "onnx-community/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M-ONNX",
  { device: "wasm", dtype: "q8" },
);

const scores = await classifier(image, ["a dog on grass", "a pizza on a plate"], {
  hypothesis_template: "a photo of {}",
});
// → [{ label: "a dog on grass", score: 0.98 }, ...]

References