Update README.md
Browse files123---license: apache-2.0---1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768---language:- enlicense: apache-2.0datasets:- HuggingFaceTB/smol-smoltalk- OpenAssistant/oasst2- microsoft/orca-math-word-problems-200klibrary_name: pytorchtags:- microcontrollers- esp32- text-generation- quantized- edge-aimodel_type: custompipeline_tag: text-generation---# KryonAI-4M: High-Intelligence 4M Parameter LLM for KryonOS**KryonAI-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 Team / KryonAI- **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 `.krai` layout)- **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 CurationThe 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 Used1. **KryonOS Identity & Custom General Chat Anchors:** Hand-crafted prompt/completions (oversampled) targeting system questions, capabilities, and basic UI actions.2. **Synthetic Arithmetic Curriculum:** 16,000 clean arithmetic samples (additions, subtractions, multiplications, divisions) to suppress mathematical hallucinations.3. **HuggingFaceTB/smol-smoltalk:** High-signal instruction-following conversational interactions.4. **OpenAssistant/oasst2:** Top-ranked conversational samples.5. **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 SpecThe model is packaged into an all-in-one executable weights format consisting of:1. **64-Byte Header:** Contains parameters like hidden dimensions, attention heads, and offsets for quick lookup directly in microcontroller flash memory.2. **Null-Terminated UTF-8 Vocabulary Table:** Exactly 4,096 entries mapped back to text indices.3. **SIMD-Aligned Weights Payload:** Padded to 16-byte boundaries so the ESP32 vector processing instructions can run at max efficiency directly from PSRAM.
README.md+65