hckrnws
PenGPT: A Generative Transformer for Handwriting and Sketches
by smusamashah
by smusamashah
"The results are interesting and the project was a pleasure to work on. And yet there was no clever architectural idea behind it. About 80% of my effort went into building the biggest, cleanest datasets possible and doing lots of quality control on them."
I spend way too much time on trying to out-clever existing solutions, when a clean application of known approaches would serve best.
[1] http://www.incompleteideas.net/IncIdeas/BitterLesson.html
A whole lot of old ML algorithms (e.g. line detection algorithms in OCR) were really just clever heuristics.
This time I just put all my energy into data. Agentic workflows + good open weight vision models + cheap multimodal AI APIs make data quality filtering / caption generation really smooth
This is something that I've seen happen very often with machine learning practitioners. You cannot add more data to fix bad pre-processing. LLMs are limited by the BPE tokenisation (hence why early models couldn't count r-s in strawberry), diffusion models will produce illegible small text if their VAE isn't good enough, and audio classifiers will be bottlenecked no matter how much data you feed them if everything gets turned into a low resolution, single STFT window mel spectrogram.
Short of training a model on subatomic particles, you will always be injecting human knowledge into the model simply by choosing how you are preparing your data.
When I was a senior in college working on my eng thesis [1], some of his earlier posts (Scribe: Generating Realistic Handwriting with TensorFlow [2]) were helpful and inspiring to read.
[1]: https://johnlarkin1.github.io/pdfs/Handwriting-Synthesis-E90...
Looks a little bit like this: https://i.ibb.co/21Z4mWV7/AI-doodles.png (coffee-cup, "emai deliverabiliti was ..." etc.) Very fun! Thanks OP!
>Color is the source the pages came from.
No color key is provided
Using a less fine grid was huge for getting the compute time down (and thus the iteration / debugging time down - ultimately to about 5 minutes). This helped me try a lot of different things.
Finer grid -> quite a lot more tokens per stroke -> more longer context -> more compute (increasing nonlinearly).
So I pushed it to the coarsest grid I could get away with. Light post-processing can actually remove the grid artifacts pretty easily, so that can be added if needed. In the future I'll probably just train my FINAL model on a slightly finer grid.
Thanks for the feedback
The post text (except the conclusion) was written entirely by Claude.
All my other posts are handwritten. I wish I had written it by hand, and I apologize for doing it this way. I did put a lot of effort into the code/dataset/ablations/figures.
All I can say is that I HAD to get this post up in time. Won't do it that way in the future (and might go back and rewrite in my style over Christmas break) :)
It can do penguins, pelicans (kinda), and bicycles, but pelican on bike makes it generate bizarre semi-abstract art. Looks like it doesn't know how to combine things together.
That's so cool, and a lot of fun to play with.
That said I bet you could train on handwriting that only includes like 10,000 characters and it could extrapolate from there to all characters because of the stroke > radical > character chain.
For example, `!2/23\4/5.4;3;5l=3asfa913k391aslkf9a'a;s.":>"}+-=;.a`
Thank you for putting this first so I can close the browser tab and move on.
Yes I find it technically cool. I also find it horrifying that someone that smart just posts the code online.
[deleted]
[dead]
[dead]
[dead]
[dead]
Maybe they're better now... lol
I think it'd be neat to have personal GPT learned on own handwriting. How much effort/training would be needed for that?
I'm no ML researcher, but this kind of things is what I would love learning to make. I took a brief ML course a couple years ago, and best I did was a lame GAN that generated ugly "A"s from a bunch of fonts found in Google Fonts, and it was painful to build due to just using a CPU in a laptop.
Using Claude + being honest >>> using Claude + pretending you didn't at least (and FWIW I didn't find it too offensive here either)
I've just noticed this phenomenon and thought it's be a good point of conversation.
Hope you have a wonderful winter!
Another part of me thinks: everything is moving so fast right now, one just has to get one's projects OUT in time, and also - pessimistically - 90% of readers of the post will be other people's AI's looking to help them reproduce the results XD
Maybe I should start a blog with methods/technical details written by Claude and a (much shorter) human written section only with the most engaging prose - but much shorter.
“Here are the rows I found most interesting; the paper has the rest.”
“The drawing model blends but doesn’t bind.”
“Cut the data and everything gets worse. Drop augmentation and the drawing model stops following its prompts entirely”
(In Claudeland abstract concepts constantly "say" and "tell" things.)
I don't get how other people can stand it.
It truly is cringe inducing but a majority of people seem to not care much, given how widespread this is in blog posts/marketing copy/etc.
I did put a lot of effort into the code/dataset/ablations/figures. And for what it's worth, if you look at the rest of the work on my blog (including work from before LLMs existed) you will see that I have been competent at building these kinds of models for years.
Yes, LLM text may indicate that an author who didn’t take the time to do the writing also didnt put much effort into the project itself. But that is, if anything, a rule of thumb, and it is proven wrong here by the results.
In my view, it’s much better that you spent your limited time on the building rather than on the writing. If yiu had waited for Christmas, who knows if you had posted it at all, with life and new ideas getting in the way. It’s better that it exists than it be certified Claude free, in my view.
Thank you for the post!
Cringe to me are rather shallow dismissals of whole projects, while I never see anything amazingly humanly hand crafted from them (and given away for free).
[dead]
Why didn't we get GPT-2 in 2005?
Claude does it without selectivity or logic, just as a way to the end of a sentence.
Also I think it’s reasonable to say that personification is not in the gift of a machine; it’s our choice.