PenGPT: A Tiny AI Model That Copies Your Handwriting From Just a Few Words

Researcher Sam Greydanus has built two small transformer models that draw handwriting and sketches stroke by stroke. The 6-million-parameter model picks up a stranger's handwriting from just a few example words. And the project ends with an uncomfortable finding: almost all of the performance comes from the data, and hardly any from clever ideas.

Research Nov 25, 2026 9 min read Source: Hacker News
Illustrative image, AI-generated

What it's about

Sam Greydanus, a researcher with a physics background, has released PenGPT: two small AI models that write and draw with a virtual pen. They don't produce finished pixel images. Instead, they lay down one stroke after another, the way a person moves a pen. The handwriting model has 6 million parameters. It writes any text in print or cursive and can imitate the handwriting of someone it has never seen. The drawing model has 54 million parameters and turns text descriptions into sketches.

Greydanus describes the project on his blog at greydanus.github.io/2026/11/12/pengpt, and a detailed paper is also available. According to a report by ecosistemastartup.com, both models are in the public GitHub repository "greydanus/pengpt", where the weights can be downloaded as a release. The handwriting model is 6 MB and the drawing model 50 MB. Both run from a NumPy file on an ordinary laptop. Greydanus hasn't published the training datasets, but the paper's appendix explains how to rebuild them.

A note on transparency: Greydanus says Claude wrote the blog post, except for the conclusion. He plans to rewrite it in his own words over the Thanksgiving holiday.

PenGPT builds on an earlier project. The year before, Greydanus and Zach Wimpee trained a tiny GPT called the "Cursive Transformer". It learned cursive from just 3,500 words Greydanus had written himself on a trackpad, so it only knew one person's handwriting.

How the model writes

At its core, PenGPT works like a language model. A language model outputs one word after another. PenGPT outputs one pen movement after another. To do this, a tokenizer (which breaks input into small building blocks) translates strokes into just ten symbols: the eight compass directions on a grid, plus "pen down" (DOWN) and "pen up" (UP). The system merges common combinations of these symbols using BPE, a method that fuses frequently occurring sequences into new, longer tokens. That's it for handwriting- or drawing-specific tricks. The same tokenizer handles both tasks.

The handwriting model receives the text it's supposed to write. The drawing model receives a vector from SigLIP 2, a model that maps images and text into the same mathematical space, so a typed sentence can stand in for an image. According to the repository, the decoder is built in the style of nanochat. It uses rotary position embeddings and cross-attention, a mechanism that lets the model keep "looking" back at the prompt while it draws.

80 percent data work

Hardly anyone records pen movements digitally. So Greydanus extracted his handwriting data from scans: 495,590 words from 1,255 writers. According to ecosistemastartup.com, they come from seven sources. These include two research collections (CSAFE and the CEDAR letter), letters and diaries from the Internet Archive and the Library of Congress, public notes from GitHub, and the trackpad words from the earlier project.

The processing ran in several steps:

  • A vision-language model (an AI that understands and describes images) picks out legible pages and transcribes them.
  • The pages are cut into individual words.
  • The InkSight tool reconstructs the likely pen strokes from each word image.
  • Automated checks weed out bad reconstructions.

Only a third to a half of the words survive this filter.

For the drawings, Greydanus used 477,670 sketches from ten public datasets, the largest being Quick, Draw!, Sketchy and TU-Berlin. Of the 50 million drawings in Google's Quick, Draw!, he kept only the best 0.5 percent. According to ecosistemastartup.com, each sketch was described with up to 17 different phrasings. These descriptions later form the model's text interface.

By his own account, Greydanus put about 80 percent of his effort into the data and 15 percent into fast training. Only 5 percent went into the architecture. On a machine with eight A100 GPUs, the handwriting model trains in 8 minutes and the drawing model in about 35 minutes. The Cursive Transformer had needed more than 10 hours on a single A100.

What actually matters: the ablation study

Greydanus investigated where the performance comes from. He changed one thing at a time and retrained. This kind of experiment series is called an ablation. In the tables, the PenGPT row shows the absolute score. The variants show the difference from it, and a positive value means a worse result. "Style rank" measures how well the model matches an unfamiliar handwriting; lower is better.

Handwriting Score change Style rank Legible
LSTM à la Graves, same tokens +0.029 2.2 49%
ScribeTokens BPE, 60x vocabulary −0.001 1.9 53%
PenGPT 0.716 1.9 54%
One tenth of the data +0.050 3.0 47%
No augmentation +0.028 2.0 52%
One word per sequence +0.009 6.0 52%
No pen position +0.001 1.9 52%
No BPE merges −0.010 – 55%
Double the parameters −0.004 1.9 55%
Real handwriting 66%
Drawings Score change Matches label Matches description
LSTM à la sketch-rnn, same tokens +0.049 40% 20%
Trained on Quick, Draw! only +0.002 74% 37%
PenGPT 0.591 76% 43%
No augmentation +0.013 4% 6%
No pen position +0.008 74% 40%
Half the layers, half the width +0.022 62% 31%

The big effects come from the data and from how it's presented to the model. Less data makes everything worse. Without data augmentation, meaning artificially altered copies of training examples (slightly rotated or stretched, for instance), the drawing model practically stops following its prompts. The hit rate drops from 76 to 4 percent. If the model only sees one word per sequence during training, it can no longer pick up an unfamiliar handwriting, and the style rank falls from 1.9 to 6.0.

The clever details, on the other hand, barely matter. Telling the model where its pen currently is doesn't improve the handwriting. The BPE merges Greydanus was proud of actually make the score slightly worse. Their only benefit is speed, since sequences get 3.2x shorter. A 60x larger vocabulary and a model twice the size don't change anything either. Even the transformer is only partly necessary. An LSTM, an older type of neural network for sequences, trails only slightly on handwriting. On the longer drawing sequences, though, it falls well behind.

Someone else's handwriting from a few words

According to Greydanus, the trick here is "almost embarrassingly simple". Each training sequence contains up to four words from the same person. That teaches the model that later words look like earlier ones. To imitate someone, you just feed it a few real words, and it keeps writing in the same style. No dedicated style encoder or fine-tuning (additional training) is needed. That's how the 21 sample handwritings in the blog post were created.

A photo works as a template, too. A photo contains no strokes, so InkSight first reconstructs a few words from it. Then a single new "writer vector" is fitted to those strokes while the rest of the model stays frozen. Looking inside the model, Greydanus also found an attention head in layer 4 that puts 81 percent of its attention on the letter currently being written. There are no heads that specialize in cursive or print.

Captions are non-negotiable

The image descriptions are the most expensive part of the drawing data. So Greydanus tested whether it's enough to train only on SigLIP image vectors and still type in text at the end. It isn't. That model had the best likelihood, meaning the best score on the training metric, but it only produced scribbles. The reason is geometric: SigLIP's vectors for sketches sit in a narrow cone, almost at right angles to the vectors for text. A model that only knows that cone has no idea what to do with a sentence. Short labels are enough to draw single concepts (78 percent). Full phrases only work if descriptions were in the training data: 43 percent versus 10 percent.

Limitations

The drawing model can blend ideas but can't bind them cleanly. A teapot with a face works. Which of two figures is wearing the hat doesn't. "Facing left" and "facing right" produce the same drawing, because the two descriptions have a cosine similarity of 0.999. In practice, the vector behaves almost like an unordered bag of words. The generated handwriting is less legible than the real thing (54 versus 66 percent). And since most of the training strokes were reconstructed from scans, the stroke order is a model's guess, not an actual recording.

What you need to try it

The requirements are minimal. According to ecosistemastartup.com, both models run from a NumPy file on a laptop, no GPU required. The downloads are 6 MB and 50 MB. You need Python with NumPy and the code from the GitHub repository "greydanus/pengpt". According to the sources, PenGPT isn't available through Ollama or Hugging Face. If you want to retrain the models yourself, you'll need the unpublished datasets, which you'll have to rebuild following the paper's appendix, plus serious compute: Greydanus used eight A100 GPUs.

The bigger picture

PenGPT isn't competing with big image generators. It's a small, well-documented research project you can learn a lot from. Greydanus explicitly references Rich Sutton's essay "The Bitter Lesson", which argues that in the long run, general methods with more data and compute beat clever specialized ideas. The ablations confirm this on a small scale: data quantity, data quality and how the data is presented make the difference. Architectural finesse hardly matters.

"The bitter lesson kills or displaces a lot of beautiful research ideas. It's like gravity: it constrains you, and most of the time it's a very bad idea to fight it."

If you train your own models, the caption finding is an important warning. A better training metric can go hand in hand with a useless result. That's why you have to evaluate the actual task, not just the loss. There are caveats: all the numbers come from the author himself. According to ecosistemastartup.com, legibility was judged by eye. The datasets remain unpublished, and the handwriting stroke order is reconstructed, not recorded. The ability to imitate someone's handwriting from a few words or a photo also raises obvious questions about forgery. The sources don't address them.

Sources

#handwriting#sketches#transformer#bitter lesson#data quality#open weights
Read the original source

Ask the AI assistant

Questions about this article, installation or background? Our assistant knows this page and runs on our own machine, not in someone else's cloud.

Connecting …

The Assistant is an AI (Gemma 4) and can make mistakes – please check important details against the source. Questions are used only to generate an answer and are deleted after one hour. Please don't enter any personal data.

Comments

What do you think? Already tried it? Write it here, no sign-up needed.

  1. Loading comments …

Comments are public. Links aren't allowed, and we delete abusive posts. You can delete your own comment at any time in this browser. Learn more in the Privacy Policy.