KryonAI-Text-4M: High-Intelligence 4M Parameter LLM for KryonOS
KryonAI-Text-4M is a highly optimized, lightweight 4.01-million parameter autoregressive transformer designed specifically for on-device inference on resource-constrained microcontrollers, such as the ESP32-S3 (N16R8) running KryonOS.
It features INT8 weights with float32 scaling factor parameters, structured as an all-in-one .krai format with a 16-byte SIMD alignment compatible with ESP32 ESP-NN accelerated matrix kernels.
Model Details
- Developed by: KryonOS
- Model Type: Decoder-only Transformer (GPT-style)
- Parameters: 4,010,000 (4M)
- Context Length: 128 tokens
- Vocabulary Size: 4,096 BPE subwords (trained on Whitespace pre-tokenizer)
- Quantization Format: INT8 Weights + FP32 Scales (Custom SIMD-aligned
.krailayout) - Target Hardware: ESP32-S3, ESP32-S3 N16R8 with Octal PSRAM (using 8MB PSRAM configurations)
Architecture Specifications
| Parameter | Value |
|---|---|
Hidden Dimension (dim) |
192 |
Intermediate FFN Dimension (hidden_dim) |
768 (4 * dim) |
Layers (n_layers) |
6 |
Attention Heads (n_heads) |
6 (Head Dimension = 32) |
| Positional Embeddings | Learned Position Embeddings (wpe) |
| Normalization | LayerNorm |
| Activation | GELU |
Training & Dataset Curation
The model was trained with Mixed Precision (bfloat16) on a Google Colab NVIDIA L4 GPU for 7,500 steps (approximately 245.76 Million tokens processed) using a cosine annealing learning rate scheduler.
Datasets Used
- KryonOS Identity & Custom General Chat Anchors: Hand-crafted prompt/completions (oversampled) targeting system questions, capabilities, and basic UI actions.
- Synthetic Arithmetic Curriculum: 16,000 clean arithmetic samples (additions, subtractions, multiplications, divisions) to suppress mathematical hallucinations.
- HuggingFaceTB/smol-smoltalk: High-signal instruction-following conversational interactions.
- OpenAssistant/oasst2: Top-ranked conversational samples.
- microsoft/orca-math-word-problems-200k: Naturally concise word problems filtered to fit within the 128-token window.
Optimization
- Quantization-Aware Training (QAT): Straight-Through Estimators (STE) were activated for the final 15% of the training phase (starting at step 6,375) to pre-adapt weights to standard INT8 limitations.
- Label Smoothing: 0.03 label smoothing was applied to discourage overconfident text generation loops common in sub-10M parameter models.
Binary .krai Format Spec
The model is packaged into an all-in-one executable weights format consisting of:
- 64-Byte Header: Contains parameters like hidden dimensions, attention heads, and offsets for quick lookup directly in microcontroller flash memory.
- Null-Terminated UTF-8 Vocabulary Table: Exactly 4,096 entries mapped back to text indices.
- SIMD-Aligned Weights Payload: Padded to 16-byte boundaries so the ESP32 vector processing instructions can run at max efficiency directly from PSRAM.
How to Use
Follow these steps to run the AI model locally on your KryonOS device.
Download the Model: Download the latest KryonAI-Text-4M model file (
.krai) using the direct download link: Download KryonAI-Text-4M.Transfer the Model: Open your KryonOS device and copy the downloaded
.kraifile to either the internal storage or your SD card.Install the Local AI Chat App:
- Open the App Store on your KryonOS device.
- Navigate to the AI category.
- Find and download Local AI Chat.
Load the Model:
- Open the Local AI Chat app.
- Tap Pick to select the
.kraifile you downloaded. - Once selected, the app will mount the AI model on your KryonOS device.
Start Chatting:
- Tap the prompt input field to open the on-screen keyboard.
- Enter a prompt, such as
Hi!. - Press OK to confirm your prompt.
- Tap Send to submit it.
Get the Response: The AI model will process your prompt locally and display its generated response on your device.
Requirements
- Your KryonOS device must have PSRAM to run local AI models.
- Make sure the
.kraimodel file is fully copied to your device before loading it.
Build Your Own AI Applications
You are not limited to using the Local AI Chat app. You can also develop your own custom JavaScript applications for KryonOS and integrate this on-device AI model into your applications.
For development documentation, visit the KryonOS Documentation.
Train Your Own AI Models
You can also train your own custom AI models for on-device inference with KryonOS.
To learn how to train and prepare your own text-generation models, visit the On-Device AI: Text Models Documentation.