How SketchNN works
One transformer draws all 345 Quick, Draw! categories, guesses what you are drawing, finishes your sketch and morphs one doodle into another. It is a single 27.6 MB file that runs on your own device, and every section below ends with a way to try it.
- Categories
- 345
- Parameters
- 21.0M
- Layers × heads
- 8 × 6
- Pen grid
- 128 × 128
- Training steps
- 170k
- Model file (int8)
- 27.6 MB
- A drawing as tokens
- One model, 345 categories
- Guessing
- Finishing your sketch
- Morphing
- Sampling without trailing off
- Running in the browser
- Training
- Limitations
- Questions
1. A drawing as tokens
The model sees a drawing as a sentence. Each pen point is snapped to a 128 × 128 grid and becomes one token, y × 128 + x, so there are 16,384 point tokens. UP lifts the pen, EOS ends the drawing, and BOS starts it:
BOS p p p UP p p UP … EOS
The positions are absolute, not offsets from the last point, so a small error never drifts the rest of the drawing. Here is a cat the model drew: 84 points in 14 strokes, 100 tokens with BOS and EOS. Step through it to see each token add a point.
BOS 3760 3621 3996 4883 6156 7177 8968 10380 11281 12057 12451 12588 12472 12099 10960 9813 8151 6870 5457 4555 3907 3388 3253 3369 UP 5770 4999 3718 1927 10 141 913 2968 UP 3911 3401 2513 1630 1381 1382 1765 5333 UP 7200 7201 UP 6841 6970 UP 8360 8873 9133 8625 8242 UP 9255 10407 10787 10783 10526 UP 9258 10026 10413 10545 10295 9914 9402 UP 7332 7457 7585 7716 UP 7098 7223 UP 5785 6042 5915 UP 5696 5825 5826 5697 5823 UP 12315 12565 13834 16256 UP 11086 11220 12254 13541 14952 UP EOS
2. One model, 345 categories
The category is not a token. It is a vector added to the input at every position, computed as cls_w @ cls_emb: cls_emb holds one learned vector per category, and cls_w says how much of each to use. For one category, cls_w is all zeros with a single 1. It has one entry more than there are categories, and that last entry means "no category": draw anything.
This is the difference from SketchRNN, the usual reference for an AI that draws doodles. Magenta published SketchRNN as one model per category, 131 categories at 3 to 8 MB each. SketchNN is one 21.0M-parameter decoder-only transformer (8 layers, 6 heads, width 384) and one 27.6 MB file for all 345.
3. Guessing
A second, small output head reads the drawing so far and scores every category. It is trained on drawings given the "no category" entry, so it has to work out the category from the strokes alone, and the app asks it the same way. It is trained to guess at every position of a drawing, not only at the end, so a half-finished drawing is exactly what it learned to read, and the guess can update after every stroke you make.
- after 1 stroke
- after 2 strokes
- after 5 strokes
- after 14 strokes
The drawing above, stroke by stroke. In training, the guess head is asked for the category after every pen point of a drawing, so each of these stages is the kind of input it learned from.
Play: can the AI guess your doodle? → · Draw on the pad and watch the guesses →
4. Finishing your sketch
Dataset drawings fill the canvas. Yours may not: a small doodle in a corner is fine. During training, half of the drawings are shrunk and moved around the canvas and start with a second start token, BOS_FREE, instead of BOS. To finish your sketch, the app writes BOS_FREE, then your strokes as tokens, and lets the model carry on from there, at whatever size and place you drew.
BOS_FREE your points … UP your points … UP the model's points … UP … EOS5. Morphing
Because the category is just a weight vector, it can be between two categories. Morph draws eight frames with the same random choices and slides cls_w from the first category to the second, so each frame is a little further along.

6. Sampling without trailing off
At each step the model gives a probability to every point, UP and EOS, 16,386 outputs in all. Lowering the temperature of the whole distribution, as language models usually do, makes neat points but starves the rare UP and EOS tokens: the pen rarely lifts at the right moment, and the drawing trails off into dozens of tiny strokes.
So sampling is split in two. Whether the next token is a point, a pen lift or the end is sampled at temperature 1, as the model learned it. The temperature (the "wildness" slider) then only shapes where the next point goes.
1. point, UP or EOS? at temperature 1
2. if a point: which? at the chosen temperature, top-pTwo guards back this up, in the same grammar as the Python sampler: at most 4 one-point strokes (eyes and nostrils; after that a stroke needs two points), and past 120 tokens ending the drawing is nudged up at every pen lift. A drawing can be at most 256 tokens long.
7. Running in the browser
The model is exported to ONNX with a key-value cache, so each new pen point is one small step through the network rather than a rerun of the whole drawing, then quantized to int8. ONNX Runtime Web runs it in WebAssembly. The site sends cross-origin isolation headers, which let the WebAssembly run on several threads: about 7 ms per pen point on a desktop.
- Download
- 27.6 MB, once; the browser caches it
- Runtime
- onnxruntime-web, WebAssembly, multi-threaded
- Server
- static files only: no inference API
Nothing leaves the device: what you draw, the guesses and the results all stay in your browser.
8. Training
- 75k recognised drawings per category from the Quick, Draw! dataset, for each of the 345 categories.
- Half of them shrunk and moved around the canvas (the
BOS_FREEdrawings), and some given "no category", for finishing and guessing. - bf16 mixed precision, 170k steps.
- The output layer has 16,386 entries, so the full logits for a batch do not fit in 8 GB of VRAM. The loss is computed in chunks, and each chunk is recomputed in the backward pass (checkpointing) instead of kept in memory.
9. Limitations
- Some categories draw poorly: the model is small, and a few of them often come out as a vague shape. The drawings on the guides were picked from several seeds for that reason.
- Share links replay from the category, temperature and seed. They name no model version, so after a model update an old link may draw something different.
- Embedded in another site, the pad is not cross-origin isolated, so the WebAssembly runs on a single thread and guesses take longer.
- It only knows the 345 Quick, Draw! categories, and it draws in their style: quick doodles, not illustrations.
Questions
Is this SketchRNN?
No. SketchRNN (Ha & Eck, 2017) is a recurrent network that writes pen offsets, and Magenta published one model per category, 131 of them, at 3 to 8 MB each. SketchNN is a different model: one 21.0M-parameter transformer that writes absolute pen positions as tokens and draws all 345 Quick, Draw! categories from a single 27.6 MB file. Both learned from the same dataset.
Does my drawing get uploaded?
No. The model runs on your device, so what you draw is never sent to a server. A share link carries the drawing in the part of the address after #, which browsers do not send to the server either. The site counts page visits, nothing else.
Which dataset and licence?
The Quick, Draw! dataset by Google Creative Lab, under CC BY 4.0: 75k recognised drawings per category were used for training. The browser runs the model with ONNX Runtime Web (MIT licence).
Can I embed it?
Yes. Embed the drawing pad on your own page with one iframe: your readers draw, and the model guesses in their browser. It is free and needs no key.
Trained on the Quick, Draw! dataset by Google Creative Lab (CC BY 4.0). Runs with ONNX Runtime Web (MIT). SketchRNN: David Ha and Douglas Eck, A Neural Representation of Sketch Drawings, 2017.
Open the drawing companion · Play the guessing game · Morph · Step-by-step guides · Embed the pad