Skip to content
HN On Hacker News ↗

GitHub - Carloscodix/qapla: A char-level transformer trained from scratch on an $8 ESP32-S3. Not inference: the chip runs the full training loop, with backprop written by hand in C.

▲ 67 points 20 comments by pavelai 3w ago HN discussion ↗

Pangram verdict · v3.3

We believe that this text is a mix of AI and human-written content.

71 %

AI likelihood · overall

Mixed
21% human-written 79% AI-generated
SEGMENTS · HUMAN 3 of 7
SEGMENTS · AI 0 of 7
WORD COUNT 781
PEAK AI % 68% · §2
Analyzed
Aug 5
backend: pangram/v3.3
Segments scanned
7 windows
avg 112 words each
Distribution
21 / 79%
human / AI fraction
Verdict
Mixed
Pangram v3.3

Article text · 781 words · 7 segments analyzed

Human AI-generated
§1 Human · 17%

This text was written with the assistance of an AI. Careful: assistance doesn't mean the AI wrote it. It means it corrected, reviewed and filled in some parts, but the author is human (or so I believe). Léeme en español Qapla' Project This is how you train a transformer from scratch on an eight-buck ESP32-S3. The (Klingon) GPT nobody asked for but everybody needed. And why did we need it? Because we take for granted that training a model requires a GPU or a datacenter. Not always: sometimes something as small and as cheap as an eight-buck micro is enough to train one from scratch. Read that again: train. From scratch. Not run a pre-cooked model. Train. Forward pass, backprop and weight updates, inside the chip. What is Qapla'? Edge AI is nothing new. TinyML has been doing inference on microcontrollers for years, community ports of llama2.c — Andrej Karpathy's minimalist project — put ~260K-parameter transformers on an ESP32, and just recently a brilliant project got a model of almost 29 million parameters running on an $8 ESP32-S3. They're excellent pieces of work, and although they happen to have overlapped in time with this experiment, they weren't the model we were following. The esp32-ai project by Slava S. (slvDev), and others like it, all share one thing: they are inference.

§2 Mixed · 68%

The model is born somewhere else — a GPU, a datacenter — trained on its data, quantized, and only then loaded onto the chip so it can run it. The brain is cooked outside and served on-chip. We asked ourselves a different question: what happens when the model can't be born outside? What happens when it can't come pre-trained — because the data it needs to learn doesn't exist until the device is in place — can't carry that data with it, and has no internet to download it?

§3 Human · 18%

We know what you're thinking: "Fine, but… why would anyone need to train a transformer on an ESP32?" And it's a fair question. Maybe the answer is "no reason at all".

§4 Mixed · 58%

But… if we're going to get creative, picture this: a sensor bolted to a piece of farm machinery in the middle of a field, which has to learn the normal vibration of that specific machine (different from any other machine in the world) to spot when something's going wrong and schedule maintenance before it breaks (and no, you won't catch me out: I said there's no internet, but… LoRa? ;). Or picture a sensor in a plot of land that learns how that particular soil dries out — its earth, its sun, its drainage — and predicts when it'll need watering, before the plants suffer. In those cases (and others we can think of) the data didn't exist until the device was installed: nobody could have pre-trained it. The chip has to learn on the fly, alone, right where it stands.

§5 Mixed · 38%

We don't have a piece of farm machinery lying around to experiment with. So, to put the real learning ability of an ESP32 to the test, we designed the experiment around the only thing we did have: language.

§6 Mixed · 66%

How far can an eight-buck chip get, learning a language from scratch, with nobody's help? What does training on a micro actually mean? Training inside an eight-buck micro imposes rules of the game a datacenter doesn't have. And those rules dictate everything else: Once again, memory rules. An ESP32-S3 has a few MB of RAM/PSRAM, not gigabytes. That caps the size of the model: we're talking hundreds of thousands of parameters here, not millions. A model that "fits" and trains on the chip is, by necessity, small. The small model rules the task. A model this size can learn the structure of a language (how words are built, its phonotactics, some grammar), but not the deep semantics of an entire tongue. The task has to be cut to the model's size. And the corpus rules the result. With a small model you don't need gigabytes of text. You need a corpus that is compact, clean and structured. And, if you're going to publish it, you need it free of copyright headaches. Put the three constraints together — small model, narrow task, clean and compact corpus — and the question becomes concrete: which language ticks all of those at once?

§7 Human · 7%

I could tell you we ran a brainstorming session to decide which language to experiment with in this first phase, but sometimes it's better to stick to the old "the first idea is usually the good one"… and in this particular case, the first language that came to mind… was Klingon. The Klingon language Yes, Klingon. The language of the Star Trek warriors.