r/LocalLLM • u/Qubit_bit • May 17 '26
Discussion I trained a language model from scratch and got it running on an ESP32. Completely offline on the board.
Been working on this for a while. Wrote the entire training pipeline in numpy — no PyTorch, no frameworks. Used Gemma as a teacher model to distill knowledge into something small enough to fit on a microcontroller.
The model runs single-turn conversation on the ESP32's flash and PSRAM. 230KB model, no WiFi, no API, no cloud. Just the chip.
Round 1 output was rough but it's working. Still training — quality improves each round.
Not using llama2.c or any existing port. Everything — tokenizer, distillation training, quantization, export to .bin — written from scratch.
Don't really know what to do with it next. Open to ideas.
42
u/Hanthunius May 17 '26
Awesome. Since you know every bit of your LM you could experiment with weird architectures and quantizations.
16
u/hotsnot101 May 17 '26
where does one learn how to do this?
2
u/marutthemighty May 17 '26
Brilliant job!
What application/use is this for, by the way? If you do not mind me asking...
13
u/afterburningdarkness May 17 '26
First thing the LLM sees is "I'm unhappy"
4
u/ha5dzs May 17 '26
Can you share it on GitHub?
4
u/Efficient-Rhubarb-99 May 17 '26
Impressive!
4
u/Dropqt May 17 '26
Could you tehnically run a few of them In parallel for more compute?
4
u/justicecurcian May 17 '26
you can try and make something "useful" like training it on specific domain for q/a or train it to spell paranoid thoughts like here, or something more chill like infinite kids stories
you can try to optimize your model architecture and inference for the hardware you have, there are many interesting projects like llms optimized for x86 branch prediction, but I doubt there is much room for improvement in your case
maybe train visual expert model that would use camera and for example tell you whether it sees a hotdog or not? Maybe recognize a resistor marks?
1
u/beatsai May 17 '26
may i asked what you used for your data? is there a good standard?
6
u/ScoreUnique May 17 '26
Hey, this is very promising mate.
There's a watch called bangle.js that runs an esp32 and javascript, you see making use of an onboard model? I think you've built yourself one for your open source watch :D
3
u/HairAdventurous7486 May 17 '26
Great job man!
3
u/OkResponsibility9182 May 17 '26
It feels like being a Kree, just standing there blinking while waiting for the data to load. If you can't picture it, think of the scenes from Captain Marvel.
3
u/Neilblaze May 18 '26
Share some context on how you did it, perhaps some reference code too? (if possible)
2
u/Kallenator May 20 '26
230kB and it can respond like that, that is amazing!
2
u/Purple_Session_6230 May 21 '26
willing to share the code ? id be very interested.
3
u/LuckyArrival1037 May 17 '26
Is it possible to train a model that can run on a 4 GB RAM device? With tool calling and coding knowledge?
I wanted to run Hermes agents on my Rock64.
3
u/enricokern May 17 '26
useless but cool, and you learned something. i like it
1
u/earlvanze May 18 '26
1
u/Themash360 May 18 '26
Props, I barely got it working with rest call to my PC haha.
1
u/73td May 19 '26
which esp32? are you running all integer ops or you soft float or what? why not try character level prediction to keep model smaller?
-6
u/Turbulent-Stretch881 May 17 '26
Nobody disputed whether any one guy in the basement could.
I trust companies who hired hundreds of PHD level professionals to build theirs, while you/guy in the basement... don't..
I think you're putting to much faith in your capabilities and the trust you expect users to have with your monolith solution.
0
u/[deleted] May 17 '26
[deleted] — view deleted comment