AIToday

28.9M-parameter LLM runs on $8 ESP32-S3 microcontroller

Hacker News2h ago
28.9M-parameter LLM runs on $8 ESP32-S3 microcontroller

Key takeaway

A developer successfully deployed a 28.9 million parameter language model on an $8 ESP32-S3 microcontroller, generating text at about 9 tokens per second entirely on-device. This beats the previous record of 260 thousand parameters on the same hardware class by roughly 100 times, using Google's Per-Layer Embeddings technique to store most model parameters in slow flash memory while keeping only the active computation layers in fast RAM. The model generates short, coherent stories but lacks general reasoning and knowledge.

Summaries like this, in your inbox every morning.

Sign up free →

3 Key Points

  • What happened

    A developer successfully ran a 28.9 million parameter language model on an ESP32-S3 microcontroller (costing about $8), generating text at roughly 9 tokens per second entirely on-device with no server connection. The previous record for this chip class was 260 thousand parameters, making this model roughly 100 times larger.

  • Why it matters

    The breakthrough uses Google's Per-Layer Embeddings design from Gemma models, storing most parameters (25 million) in slow flash memory and loading only the rows needed for each token into fast RAM. This architectural shift demonstrates that large models can run on severely memory-constrained hardware, potentially enabling AI applications on edge devices without cloud dependency.

  • What to watch

    The full implementation, training code, and technical results are available in the project repository (firmware/esp32_llm/README.md, src/, and RESULTS.md). The model was trained on TinyStories and generates short coherent stories but does not answer questions, follow instructions, or provide factual knowledge.

In Depth

A developer created a 28.9 million parameter language model running on an ESP32-S3 microcontroller, a chip costing about $8. The model generates text directly on the device at roughly 9 tokens per second, with nothing sent to a server, and displays each word on a small wired screen. This represents roughly a hundred-fold increase in model size compared to the previous record on the same hardware class, which held only 260 thousand parameters.

The breakthrough relies on Google's Per-Layer Embeddings technique, originally designed for Gemma models. In standard language models, all parameters must be accessible from fast memory, but the ESP32-S3 has only 512KB of SRAM—a severe constraint. Per-Layer Embeddings solves this by recognizing that most language model parameters sit in embedding lookup tables that the model reads rather than computes. The developer keeps the 25 million row embedding table in the chip's 16MB flash memory (slow but large) and loads only the rows needed for each token, roughly 450 bytes at a time. The small part that does actual reasoning stays in fast memory, making the large model nearly cost-free to run because most of it is never loaded. The final model is 14.9MB at 4-bit quantization.

The model was trained on TinyStories, a dataset of short synthetic stories simple enough for small models to learn to write coherently. As a result, it generates short stories and maintains coherence but cannot answer questions, follow instructions, write code, or provide factual information. The developer emphasizes that the significance lies in the architecture and memory layout innovation rather than the model's capabilities. The firmware, wiring instructions, training code, ablations, and quantization code are available in the project repository, including the full method writeup in RESULTS.md. The developer deliberately preserved the commit history, including a bug in early parameter accounting and its correction, to show how the numbers moved and why. The work builds on Andrej Karpathy's llama2.c project, which established that small language models can be trained and run in plain C.

Context & Analysis

The achievement represents a shift in how language models can be deployed at the hardware extreme. Traditionally, fitting models onto microcontrollers required severe parameter reduction because the entire model had to fit into fast memory—the ESP32-S3's 512KB SRAM—which is why prior models on this chip class maxed out at 260 thousand parameters. By adopting Google's Per-Layer Embeddings architecture, the developer decoupled the model's lookup tables (embeddings) from its reasoning core, allowing 25 million of the 28.9 million parameters to live in the chip's slower 16MB flash memory. Only the active computation—the "thinking" part—needs to reside in fast memory, fundamentally changing the memory constraint equation.

The model achieves this while maintaining practical performance: 9 tokens per second is sufficient for real-time text generation on a screen, and coherent short-story generation on TinyStories proves the architectural trade-off does not destroy reasoning quality at scale. The deliberate choice to train on TinyStories acknowledges the model's limitations (no question-answering, instruction-following, or factual knowledge), anchoring expectations to what the architecture can actually deliver. This is explicitly about demonstrating that large models can run on tiny edge hardware, not about competing with general-purpose AI systems.

FAQ

How does such a large model fit on such a small chip?
The model uses Per-Layer Embeddings from Google's Gemma models, storing 25 million parameters in slow flash memory instead of fast RAM. Only the few rows needed for each token (about 450 bytes) are loaded into the fast 512KB SRAM at a time, while the small reasoning core stays in fast memory.
What can this model actually do?
It was trained on TinyStories and writes short, simple stories while keeping them mostly coherent. It cannot answer questions, follow instructions, write code, or provide factual knowledge.
How fast does it generate text?
The model generates text at roughly 9 tokens per second end-to-end (9.7 tokens per second of pure compute), running entirely on the ESP32-S3 with 512KB SRAM, 8MB PSRAM, and 16MB flash.

Get the latest Large Language Models news every morning

AI-summarized, only the topics you pick — one digest a day via Email, Slack, or Discord.

Free · takes 30 seconds · unsubscribe anytime

Discussion

No comments yet. Be the first to share your thoughts!

Log in to join the discussion

Related Articles

Stay ahead with AI news

Get curated AI news from 200+ sources delivered daily to your inbox. Free to use.

Get Started Free

Free · takes 30 seconds · unsubscribe anytime