How a 28.9M-Parameter LLM Lives in Eight Dollars of Silicon

A memory trick borrowed from Google's Gemma models lets a language model one hundred times larger than previous microcontroller efforts run locally, revealing where the real bottleneck on tiny hardware lives.
The Hype Is the Ratio
The ESP32-S3 is an $8 microcontroller built around a 240MHz dual-core Xtensa LX6 CPU, offering 512KB of on-chip SRAM, 8MB of external PSRAM, and 16MB of flash. In the taxonomy of AI hardware, it sits firmly at the bottom: powerful enough to sample sensors and manage a Wi-Fi stack, but traditionally excluded from the conversation around generative models. The standard literature on ESP32 AI, from maker blogs to industrial guides, repeats the same boundary: it can run lightweight classifiers, wake-word detectors, and anomaly monitors, or it can act as a thin client streaming data to cloud APIs. A project like the ESP32-AI Home Assistant takes exactly that latter path, using the chip to record audio and forward it to Google Speech-to-Text and OpenAI, because local inference of a conversational model is assumed impossible.

Against that backdrop, the claim of running a 28.9-million-parameter language model entirely on the device—with no network connection, no external accelerator, and no cloud round-trip—reads like a typo. The previous public benchmark for a self-contained generative model on this class of chip was roughly 260,000 parameters. The new figure is two orders of magnitude larger. At roughly 9.5 tokens per second, it generates text onto a small screen wired to the chip in real time. The hype is not about utility; it is about the collapse of an assumed hard limit.
The Memory Wall
The reason that limit existed is not storage capacity but memory hierarchy. The ESP32-S3 has 16MB of flash and 8MB of PSRAM, yet only 512KB of SRAM tightly coupled to the CPU for fast access. In a conventional inference pipeline, model weights are loaded into RAM before execution. Even with 4-bit quantization, a 28.9M-parameter model produces a 14.9MB weight file. That is thirty times the available SRAM. PSRAM, while larger, is slower and still too small to comfortably host the entire working set of a generative transformer without aggressive paging that would stall the CPU.
This constraint has shaped the TinyML ecosystem. Edge Impulse deployments, environmental sensor networks, and wildfire detection systems all use models measured in tens or hundreds of kilobytes, carefully pruned to fit within the SRAM envelope. Flash memory, despite its spaciousness, has been treated as a cold archive for firmware and static assets, not as a live weight store. Its access latency and block-oriented read characteristics make it seem ill-suited to the fine-grained, unpredictable memory access patterns of neural inference.
The Flash Loophole
The escape route is an idea called Per-Layer Embeddings, introduced in Google’s Gemma 3n and Gemma 4 models to fit large models onto phones and other memory-constrained devices. The author of this repository appears to be the first to adapt it to a microcontroller’s severe memory layout, at least as far as the public record indicates.
To understand why it works, consider where the parameters actually live. In most transformer language models, the overwhelming majority of weights—here, 25 million out of 28.9 million—are not in the attention heads or the feed-forward layers. They are in the embedding and unembedding tables: vast, shallow lookup dictionaries that map integer token IDs to dense vectors. These tables are read-mostly. During a single forward pass, the model does not need the entire table. It needs only the rows corresponding to the current token and a tiny handful of others. That working slice is minuscule: about six rows, or roughly 450 bytes.
The author exploited this sparsity by leaving the 25-million-row table in flash. At each generation step, the firmware pulls only the necessary 450 bytes into SRAM. The actual compute core—the transformer blocks that perform attention, projection, and activation—remains small enough to reside permanently in fast memory. PSRAM is used as a secondary staging area for the output head and intermediate buffers. The result is a three-tier architecture that mirrors the hardware’s economics: SRAM holds the active thinking circuit, PSRAM holds the scratchpad, and flash serves as a near-line lookup archive for the model’s long tail of rarely-touched parameters.
Because the generation rate is only 9.5 tokens per second, the flash can sustain the read load despite its slowness. The model is vast in parameter count but tiny in active working set. It is the difference between owning a library and carrying one book at a time.
Capability and Honesty
The model was trained on TinyStories, the Microsoft Research dataset of short, synthetically simple narratives designed to be learnable by small transformers. It writes coherent, child-level stories. It does not answer questions, follow instructions, write code, or recall factual knowledge. The author is explicit about this: the achievement is architectural, not conversational.
That honesty is important because it clarifies a common confusion in edge AI. Memory tricks can scale parameter count, but they do not scale reasoning ability. The transformer layers that attend, project, and activate still have to fit inside 512KB of SRAM. They are the bottleneck for capability, even as the embedding table balloons. This repository demonstrates that you can carry a vast vocabulary and token geometry on a keychain, but the keychain still thinks with a very small brain. The parameter count is 28.9 million; the active reasoning graph is a fraction of that.
A History Left Intact
The repository retains its full commit history, including a bug the author discovered in their own parameter accounting that had initially inflated the model size. They corrected the numbers and left the error visible. In an ecosystem that often sanitizes launch narratives into polished marketing, this transparency is unusual. It lends credibility to the figures in RESULTS.md and signals that the 28.9M count is the audited, corrected one, not a press-release rounding. The lineage also acknowledges Andrej Karpathy’s llama2.c as the spiritual ancestor that proved tiny models could run in plain C at all.
Against the Landscape
Most ESP32 AI projects occupy one of two poles. At one end are cloud-reliant assistants—voice gadgets that use the chip as an I/O and networking layer for Google and OpenAI APIs. At the other end are classic TinyML classifiers: gas-sensing electronic noses, wildfire detection monitors, and object-recognition cameras, usually trained through platforms like Edge Impulse and constrained to the chip’s native SRAM. This repository sits in a narrow, newly opened middle ground: a generative, self-contained language model that requires no network and no subscription. It is not a classifier, and it is not a cloud client. It is a local LLM, however narrow, running on hardware that costs less than a lunch.
The Outlook
The immediate implication is that flash memory on microcontrollers has been systematically undervalued as an inference resource. If a model’s access pattern is sparse and predictable—as it is for embedding lookups—you can trade flash capacity for parameter count without paying the SRAM price. This redefines what “fits” on a microcontroller. The privacy benefits are real, too: a device that never connects to a server never leaks its prompts or its sensor context.
The next question is whether similar sparsity tricks can apply to other model components, or whether the 512KB SRAM ceiling will harden into an absolute wall. For now, the project stands as a boundary marker. It shows that the gap between datacenter LLMs and microcontroller inference is not merely a waiting game for Moore’s Law. It is an architecture problem. You do not always need a smaller model. Sometimes you need a model whose memory footprint matches the shape of the hardware beneath it. The $8 chip did not get faster. It just got a model that finally understood how it remembers.
Sources
- [DIY Project] Building a Real-Time AI Voice Assistant on an ESP32 with ...
- Computer Vision with TinyML (Edge AI + CNNs) | Deploy Machine ...
- Can ESP32 Run AI? Exploring Edge AI on Microcontrollers - DigitalMonk
- ESP32 AI Home Assistant
- What is your experience with edge AI and tinyML? Where did you use it?
- 6 Popular ESP32 AI Applications Using TinyML in 2024
- I Built an AI Desk Buddy with ESP32 (Xiaozhi + Custom Face UI)
- Need Advice on Deep Edge AI / Embedded ML Capstone Ideas (STM32, TinyML, Optimization)
- Adding AI to your ESP32 is Easier than You Think!
- ESP32 Edge AI Camera : 15 Steps (with Pictures)
- Train AI Models with an ESP32 Camera and Edge Impulse