|
Download README.md from KryonOS/KryonAI-Text-4M: direct link, hf CLI and curl.
- Browser
- Download file 5.31 kB
-
https://huggingface.co/KryonOS/KryonAI-Text-4M/resolve/main/README.md
- Command line
-
hf download hf://KryonOS/KryonAI-Text-4M/README.md
-
curl -L -o README.md https://huggingface.co/KryonOS/KryonAI-Text-4M/resolve/main/README.md
5.31 kB
| language: | |
| - en | |
| license: apache-2.0 | |
| datasets: | |
| - HuggingFaceTB/smol-smoltalk | |
| - OpenAssistant/oasst2 | |
| - microsoft/orca-math-word-problems-200k | |
| library_name: pytorch | |
| tags: | |
| - microcontrollers | |
| - esp32 | |
| - text-generation | |
| - quantized | |
| - edge-ai | |
| model_type: custom | |
| pipeline_tag: text-generation | |
| # 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 `.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 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 | |
| 1. **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 Spec | |
| The 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. | |
| ## How to Use | |
| Follow these steps to run the AI model locally on your KryonOS device. | |
| 1. **Download the Model:** Download the latest KryonAI-Text-4M model file (`.krai`) using the direct download link: [Download KryonAI-Text-4M](https://huggingface.co/KryonOS/KryonAI-Text-4M/resolve/main/kryonai-text-4m.krai). | |
| 2. **Transfer the Model:** Open your KryonOS device and copy the downloaded `.krai` file to either the internal storage or your SD card. | |
| 3. **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**. | |
| 4. **Load the Model:** | |
| - Open the Local AI Chat app. | |
| - Tap **Pick** to select the `.krai` file you downloaded. | |
| - Once selected, the app will mount the AI model on your KryonOS device. | |
| 5. **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. | |
| 6. **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 `.krai` model 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](https://kryonos.harislab.tech/docs). | |
| ### 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](https://kryonos.harislab.tech/docs/on-device-ai/text-models). |