Sketch Charades
You get a secret word. Draw it! A real AI model called CLIP looks at your drawing and shouts its guesses. Can you make it say your word before the clock runs out?
I'm great at charades, but first I need my picture-and-words brain. Press Wake up the model, then Start game!
Challenges
What just happened?
- Robo never saw your drawing before, and nobody taught it "this squiggle is a cat". It still guessed!
- CLIP learned from 400 million pictures with captions found online. It learned which pictures go with which words.
- Every half second or so, Robo turned your drawing into a list of 512 numbers and compared it with the numbers for all 32 secret words.
- More strokes changed the numbers, so the guesses jumped around. Big, clear shapes are easiest for it.
How it works
Learn the words
Once, at the start, the "word brain" turns every secret word into 512 numbers, like "a simple black and white drawing of a cat".
You draw
A little after each stroke, Robo takes a snapshot of your drawing.
Picture numbers
The "picture brain" chops the snapshot into 49 squares and squeezes it into its own 512 numbers.
Compare
The picture's numbers are compared with every word's numbers. The closest words become Robo's guesses.
Score!
If your secret word is high enough on the list before time runs out, you win points. Faster = more.
For grown-ups: what's really going on
This is zero-shot image classification with OpenAI's CLIP ViT-B/32, running entirely on-device via Transformers.js and ONNX Runtime WebAssembly. Model: Xenova/clip-vit-base-patch32, 8-bit quantised text encoder (~65 MB) and vision encoder (~89 MB), the same files as the Words ↔ Pictures lesson, so the browser cache is shared. Drawings never leave the device.
- Contrastive training: an image encoder and a text encoder were trained together on ~400M (image, caption) pairs with a symmetric InfoNCE loss: within each batch the true pairs must have higher cosine similarity than every mismatched pair. The result is a shared 512-d embedding space.
- Zero-shot: no drawing data or fine-tuning. Each word is wrapped in a prompt template (default
"a simple black and white drawing of a {}"), encoded once and cached. Each snapshot is resized to 224×224, split into 7×7 patches of 32 px, encoded, L2-normalised, and scored withp = softmax(100 · cos(image, text))over all words. Try the other templates: wording alone shifts accuracy noticeably, which is why the CLIP paper averages many templates ("prompt ensembling"). - Equivalent pipeline: this is what
pipeline("zero-shot-image-classification")does, but split into its two encoders so the text side runs once instead of on every snapshot. - Throttling: the image encoder runs at most once per ~600 ms and never overlaps itself; a new snapshot is taken only if the drawing changed. On a laptop CPU one pass takes roughly 0.1 to 0.5 s.
- Failure modes: CLIP saw mostly photos, so sketches are out of distribution. It is biased toward words that look "drawing-like", can be swayed by written text in the image (typographic attacks), and confuses similar silhouettes (sun/flower, cat/dog). The softmax always picks something, even for a blank page, so probabilities are not calibrated confidence.
Further reading: Radford et al., Learning Transferable Visual Models From Natural Language Supervision (2021) · Quick, Draw! (a classifier trained on sketches).