KryonAI-Text-4M: A 4 million parameter language model for ESP32 microcontrollers
2 min readupdated
KryonAI-Text-4M is an ultracompact language model (autoregressive transformer) built specifically to run directly on microcontrollers like the ESP32-S3 running the KryonOS operating system. The model contains just 4.01 million parameters, uses INT8 quantization (weight compression to save memory), and comes in a single optimized .krai file format. It is designed for resource-constrained devices that require local text generation without an internet connection.
Key features
- Transformer architecture: A decoder with 6 layers, a hidden dimension of 192, and 6 attention heads.
- .krai format: A custom structure featuring a 64-byte header, a token table, and weights with 16-byte SIMD alignment to accelerate performance on ESP32 chips.
- QAT training: Quantization-Aware Training applied during the training process to adapt weights for INT8 constraints.
- Context and vocabulary: A 128-token context window and a vocabulary of 4,096 BPE subwords.
What you can do
- Run on hardware: Install the model on a device running KryonOS and an ESP32-S3 with PSRAM, and chat using the Local AI Chat app.
- Build an app: Develop your own JavaScript application for KryonOS by integrating the local language model.
- Train your own model: Use the KryonOS documentation to create and prepare custom text models for microcontrollers.
Example
The model does not run via Python scripts; instead, it runs directly on the microcontroller through the system application Local AI Chat on KryonOS. Example interaction on the device:
Prompt: Hi!
Result: A local model response generated directly on the ESP32 chip.
Read more
DetailsBenchmarks and training: Trained on Google Colab (NVIDIA L4) for 7,500 steps (about 245.76 million tokens) on a dataset mix (SmolTalk, OASST2, Orca Math, and synthetic arithmetic).
Hardware requirements: The device running KryonOS must have PSRAM (an ESP32-S3 N16R8 with 8 MB of PSRAM is recommended).
Limitations: The context length is 128 tokens.










Comments