Demo · runs in your browser

Sketch autocomplete

Draw a shape. The dashed shape is the model's guess at what you will draw next. Press Tab to take it.

Code on GitHub ↗

Loading the model…

Draw

Next shape guesses

Draw something to get a guess.

Tab take it · ← → or 1 2 3 switch · Esc stop drawing

Click to start a shape and the guesses change to finish it for you.

Start from

Results

Tested on 5,000 sketches the model never saw.

Bar chart: top guess exactly right 43%, right shape in the top three 54%, right kind of shape 74%
Line chart: error on training sketches and on unseen sketches fall together over 60,000 steps
Error on training and unseen sketches fell together: learning, not memorising.
Eight test sketches with the model's guess for the next shape drawn dashed; seven matched what the person drew
Nine test sketches picked at random from the times the model was at least 50% sure; it is right on 77% of those. Each pair: the model's guess (dashed blue), then what the person really drew.

The system design

Top row: what happens each time you draw. Bottom row: how the model was made.

WHEN YOU DRAW · in your browser, no serverYou drawa line, circle, arcor pointThis pageturns your shapesinto numbersThe modelruns in your browser0.13 secondsThree guessesbest first, shownas dashed shapesYou decideTab takes a guess,or keep drawingBEFOREHAND · once, on a rented GPUPublic sketches9.2 millionCleaningdrop copies, keepthe test honestTraining rows2.5 millionTrainingguess, correct,nudge the weightsSaved copiescloud storageExportsame answers onGPU and in browserScoringunseen sketches:precision and recallthe trained model, a 9 MB filenot built yet: learn from the guesses people take or ignore

The model design

Built the same way as chat AIs, only tiny. A shape is a few numbers: its kind, then where it sits.

THE MODEL · 4.8 million weights · a 9 MB fileShapes so fara row of numbers,up to 128 longLook-up tableeach number and itsplace → 256 valuesREPEATED 6 TIMESAttentioneach number looks back atearlier ones · 4 headsSmall networkreworks each one256 → 1,024 → 256Scoresone for each of the75 possible numbersNext numberbest ones keptadded to the row, then again, until the shape is complete

How this was made

1

Free drawings

9.2 million sketches

Real sketches people drew in a design tool, collected by Princeton researchers (SketchGraphs). Each one lists its shapes in the order they were drawn.

No hand labelling: the shape a person drew next is the right answer.

2

Drawings become numbers

line 12 16 52 16

A model only reads numbers. Each shape becomes its kind (line, circle, arc, point) plus its positions on a 64 × 64 grid. A sketch becomes a sentence, and the job becomes guessing the next word.

3

Cleaning

9.2 → 2.5 million

Most sketches were copies of each other, so only one of each was kept. Over a third of the test sketches also sat in the training pile and were taken out of the test.

Why: a test the model has already seen flatters the score.

4

The model

4.8 million weights

A small model built the same way as chat AIs like ChatGPT, written from scratch. They guess the next word from the words so far; this one guesses the next shape from the shapes so far.

5

Training

72 minutes · $1.64

On one rented GPU the model guesses, gets corrected, and its weights are nudged, 60,000 times. Weight decay keeps the weights small, and the copy that does best on unseen sketches is the one kept.

Watched throughout: the gap between seen and unseen sketches, the sign of memorising.

6

Scoring

43% exactly right

Tested on 5,000 sketches it never saw, hiding the next shape 31,859 times. The top guess is exactly the shape the person drew 43% of the time, the right shape is in the top three 54% of the time, and it is the right kind of shape 74% of the time.

Showing only confident guesses: when the model is at least 50% sure, 77% of its guesses are exactly right (precision), and it speaks up on 39% of steps.

7

Into the browser

0.13 seconds a guess

The model was rewritten in plain JavaScript so it runs on this page with no server. It was checked against the GPU version and gives the same guesses.

⚙

The settings used

Learning rate 0.001 (eased in over the first 1,000 steps, then slowly lowered) · 1,024 sketches per step · weight decay 0.05 · no dropout · 60,000 steps, about 24 passes over the data · 6 layers, 256 wide, 4 heads.

Note: these were first picks and nothing has been tuned. Both error lines were still falling when training stopped, so a longer run or a bigger model should score higher.

!

What did not work at first

Guesses ran to the page edge. The training sketches were all stretched to fill the page, and the first model learned to expect that. On sketches that do not fill the page its top guess was right only 26% of the time. Training was restarted with sketches shrunk and shifted at random: 31% after the same amount of training, 34% when finished.

Too many helpers. The cleaning step ran 96 helper programs on a machine with about 18 processors. They tripped over each other and it looked frozen. With 16 it took two minutes.

A silent wait. That first run printed nothing, so there was no telling stuck from slow. It was restarted with progress messages.

Missing tools. The rented machine lacked the file-copy tool and parts of the data reader; each was installed by hand.

Since then: every long job reports its progress.

Not done yet

It guesses shapes only, not the rules between them (parallel, equal, mirrored), which the data also holds. It handles up to 16 shapes on a 64 × 64 grid. It does not yet learn from which guesses people take.