zero-shot-image-classification vision-language 432.09 MB WASM q8 ViT-Large/14 Β· 304M Vision Β· 768-d MIT

CLIP ViT-Large/14 β€” Fine-Grained 768-d Zero-Shot Vision

OpenAI's flagship ViT-Large/14 vision transformer splits every 224Γ—224 frame into a dense 16Γ—16 grid of 256 fine 14Γ—14px patches and projects images and text into a shared 768-dimensional embedding space β€” running 100% locally in a Web Worker via CPU WebAssembly (432.09 MB q8, cached after first download).

At a glance

Upstream model openai/clip-vit-large-patch14 (MIT)
ONNX export Xenova/clip-vit-large-patch14 (onnx/model_quantized.onnx)
Task / pipeline zero-shot-image-classification (shared Transformers.js 3.7.5 via lib/webai.js)
Architecture CLIPModel β€” 24-layer ViT-Large/14 vision encoder (1024-d, 16 heads, 14Γ—14px patches, 256 spatial tokens, ~304M vision params) + 12-layer text encoder (768-d, 12 heads, max 77 tokens) β†’ 768-d shared projection
Quantisation & size q8 INT8 default (432.09 MB / 432,090,204 B Β· 412.07 MiB); optional q4 (400.74 MB) & q4f16 (297.84 MB)
Backend & memory WebAssembly (wasm) β€” ~432 MB download; mobile devices with tight RAM limits may take longer or prefer lighter sibling ViT-B/16
Web APIs Web Workers, Cache Storage, Canvas 2D, Clipboard, MediaDevices (all Baseline)

Run it β€” Live Open-Vocabulary Classifier

Loading curated starter photo…

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

See inside β€” 768-d Cosine Similarity Matrix & Logit Scale

ViT-Large/14 projects both the 256 spatial image patches (plus [CLS]) and each wrapped prompt into unit-normalized 768-d vectors. Below are the exact raw cosine similarities, logit_scale (learned β‰ˆ100.0Γ—) logits, softmax probabilities, and the pairwise text-to-text cosine similarity matrix from your run.

Embedding dim768-d
Prompt tokens–
Fitted logit scale–
Eff. choices (2^H)–
Image ↔ prompt 768-d cosines, scaled logits, and softmax probabilities
# Label Wrapped prompt 768-d cosine Scaled logit Softmax %
Run a classification above to inspect raw 768-d cosines and logits.
Pairwise 768-d prompt ↔ prompt cosine similarity matrix
Run a classification above to inspect the NΓ—N prompt cosine matrix.
Show the code β€” CLIP ViT-Large/14 worker coalesced load & epoch cancellation
Show the code β€” Zero-shot inference, 768-d cosines & pairwise matrix in worker.js
Show the code β€” analyzeZeroShotResult() NaN audit, entropy, and logit_scale fit

Why ViT-Large/14 matters

Smaller CLIP checkpoints (ViT-B/32 with 49 patches, or ViT-B/16 with 196 patches) compress images into 512 dimensions and miss subtle textures or small objects. ViT-Large/14 doubles depth to 24 layers and encodes 256 14Γ—14px tokens into 768-d space:

Use-case ladder

How the API works

CLIP ViT-Large/14 runs via the standard Transformers.js zero-shot-image-classification pipeline inside a module Web Worker:

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

const classifier = await pipeline(
  "zero-shot-image-classification",
  "Xenova/clip-vit-large-patch14",
  { device: "wasm", dtype: "q8" },
);

const scores = await classifier(image, ["a dog standing on grass", "a pizza on a plate"], {
  hypothesis_template: "a photo of {}",
});

References