← All news

PenGPT: a generative transformer for handwriting and sketches

Sam Greydanus

PenGPT is a generative transformer model for producing handwriting and sketches, shared on a personal blog and discussed on Hacker News.

Source: greydanus.github.io ↗ · By CapyLaunch

AuthorSam Greydanus, personal blog
Handwriting model6M parameters, writes print and cursive
Drawing model54M parameters, draws from text prompt
Handwriting data495,590 words by 1,255 writers, from scans
Drawing data477,670 sketches from ten public datasets
ResourcesPaper, code and weights linked from the post

PenGPT is a generative transformer for producing handwriting and sketches as pen strokes. It has two models: a 6M-parameter model that writes print and cursive and can continue the handwriting of a writer it has never seen, and a 54M-parameter model that draws from a text prompt. The work is shared on a personal blog with a paper, code and downloadable weights.

Pen points snap to a grid, so a word becomes a walk in eight directions plus pen-down and pen-up moves. Byte-pair encoding merges common runs of moves into tokens, which shortens sequences by about 3.2x. A plain decoder transformer then cross-attends to the text for handwriting or to a SigLIP 2 vector for drawings.

The author says most of the gain came from data (80%), with speed (15%) and architecture (5%) making up the rest. For builders working on handwriting or sketch generation, the post shows how to represent pen input as grid-snapped moves tokenized with byte-pair encoding, and it lists which design choices changed results and which did not.

For builders: If your product involves handwriting or sketch generation, PenGPT is a generative transformer approach you can study for stroke-based output.

For: Developers and researchers building products that involve handwriting or sketch generation as stroke-based output.

Try:

https://greydanus.github.io/2026/11/12/pengpt/

What does the handwriting model do with a new writer?

It reads one to three real words from a writer held out of training and carries on in that writer's hand. The post reports this on 21 held-out writers.

Are the training datasets released?

The author says the datasets are not being released, but the paper's appendix explains how to build them.

Did the author find that bigger or more complex designs helped?

Not in the handwriting results shown. Doubling the model changed nothing, a vocabulary sixty times larger changed nothing, and telling the model where its pen is did nothing for handwriting.

Is a transformer required?

Not strictly. An LSTM on the same tokens is a bit behind on handwriting and still picks up new hands, but on drawings, where sequences are several times longer, it falls well behind.

All 16 Research stories →

Spotted a mistake? Email hello@capylaunch.com and we will correct it. How we make CapyLaunch TLDR News.