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…
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.
| # | 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:
- Zero-server photo triage — sort hundreds of local photos into user-invented folders without uploading a pixel.
- Composable stage-2 attribute tagging — pair a fast object detector (11.33 MB) with TinyCLIP (24.28 MB) to query materials, styles, and states on every detected crop in 35.6 MB total.
- Instant mobile & edge moderation — score candidate safety or domain labels locally before a form submits.
- Transparent prompt sensitivity — inspect cosine margins and typographic attack vulnerabilities directly in the browser.
Use-case ladder
Basics: Prompt & Distractor Lab
Compare prompt templates, measure near vs far distractor dilution in bits, and switch q8/fp16/fp32 precision.
Practical: Album Tagger & Triage
Batch-tag multi-photo uploads against custom taxonomies with Stop/Cancel, category pills, and formula-safe CSV/JSON export.
Wild: Typographic Attack Lab
Stamp conflicting text ("iPod", "bicycle", custom stickers) or crops/blur onto images to watch CLIP flip live.
Multi-model: D-FINE 365 → TinyCLIP
Chain 11.33 MB object detection with 24.28 MB zero-shot crop classification (35.61 MB total) across materials & styles.
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 }, ...]