--- license: apache-2.0 language: - id - en library_name: transformers pipeline_tag: text-generation base_model: - Qwen/Qwen2.5-0.5B-Instruct tags: - indonesian - gguf - llama-cpp - minitron - knowledge-distillation - compact-llm - cpu-inference - cloud-escalation - artorialabs --- # MiniIndo (`artorialabs/MiniIndo`) **Created by:** **Nagisa Artoria** (`artorialabs`) **MiniIndo** is a compact, CPU-first Indonesian LLM family (`66M` – `376M` parameters) engineered to run **100% locally on low-power CPUs** (tested live on `Intel Core i5-5200U` @ ~1.5 GHz, dual-core, no GPU) as a **fast, privacy-preserving first-responder** before escalating heavy, out-of-context, or real-time queries to Cloud AI. --- ## 1. End-to-End Architecture & Training Flow ```mermaid flowchart TD A["Raw Sources (ID Corpus + Sanitized WA Exports)"] -->|"Strict Privacy Scrubbing\n(Phones, URLs, Emails, Names -> Pseudonyms;\nNoisy Groups Excluded)"| B["Clean Pretrain & 540 WA Windows\n(0 PII Verified)"] B -->|"Qwen3-4B-Instruct-2507 Synthesis\n+ Decontamination Filter"| C["Curated V3 SFT Dataset\n(14,234 samples, 0 Eval Leakage)"] D["Qwen/Qwen2.5-0.5B-Instruct\n(494M, 151k Vocab)"] -->|"20k ID/EN Closed Vocab Slice\n(id_map.pt: 136M -> 17.9M Embeds)"| E{"Model Sizing Strategy"} E -->|"Zero Weight Loss\n24L + FFN 4864 intact"| F1["MiniIndo-376M"] E -->|"24L Attention Intact\nMinitron FFN 4864 -> 2048"| F2["MiniIndo-194M (Recommended)"] E -->|"14/24 Strided Layers\nFFN 4864 -> 1536"| F3["MiniIndo-101M"] E -->|"8/24 Strided Layers\nFFN 4864 -> 1536"| F4["MiniIndo-66M"] F2 & F3 & F4 -->|"Stage 1: Top-64 Logit KL Healing\nTeacher: Qwen2.5-1.5B-Instruct\nseq 512 -> 1280"| G["Healed Backbones"] F1 & G -->|"Stage 2: Curated Indonesian + WA SFT\n(Label Smoothing 0.05, Bucketed Batching)"| H["FP16 Checkpoints"] H -->|"llama.cpp convert + quantize\n(Q4_K_M / Q3_K_M)"| I["GGUF Release Bundle\n(models/*.gguf)"] ``` --- ## 2. How MiniIndo Works at Runtime (Local-First -> Cloud Escalation) MiniIndo is designed as **Layer 1 (Local CPU)** in a hybrid **Local -> Cloud** routing pipeline: ```mermaid flowchart LR U["User / WhatsApp Message"] --> G{"Rule / Casual Gate\n(Exact Greetings / Shortcuts)"} G -->|"Hit"| R1["Instant Rule Reply (0ms)"] G -->|"Miss & Text/Context Eligible"| M["MiniIndo Local Server\n(127.0.0.1:8095, logprobs=true)"] M --> C{"Dual Escalation Check"} C -->|"Contains [ESKALASI_CLOUD]\nOR avg_logprob < threshold\nOR Timeout / Offline"| CL["Fallback to Cloud AI Agent\n(Full Tools / Web / Reasoning)"] C -->|"Confident Local Answer"| R2["Reply Directly from Local CPU\n(Zero Cloud Cost, High Privacy)"] ``` ### Dual Escalation Mechanism Instead of relying solely on a prompt or solely on confidence scores, MiniIndo combines **two independent signals**: 1. **Explicit `[ESKALASI_CLOUD]` Token Contract:** During SFT, the model is trained on both *in-context answerable* WhatsApp snippets and *out-of-context / impossible / real-time* traps (`[ESKALASI_CLOUD] ...`) so it explicitly admits when context is missing. 2. **Token `logprobs` Uncertainty Cutoff (`avg_lp`):** Whenever `llama-server` returns `logprobs: true`, the caller computes the mean per-token log-probability (`avg_lp`) of the generated response. If `avg_lp` falls below the calibrated threshold (`-0.95` for `194M`, `-0.78` for `376M`), hallucinations are caught automatically and routed to Cloud AI. --- ## 3. Training Methodology & Key Design Choices ### A. Privacy-First Data Curation (`0` PII, `0` Benchmark Contamination) - **Strict Sanitization:** Every chat export line was scrubbed to strip phone numbers, emails, URLs, `@mentions`, and real participant names (replaced deterministically with neutral pseudonyms). Noisy/spam chat groups were completely excluded. - **WA Q&A Synthesis:** `Qwen/Qwen3-4B-Instruct-2507` processed **538/540** sanitized chat windows to produce grounded Indonesian Q&A (`q_in`/`a_in`), concise group summaries (`a_sum`), and out-of-context escalation drills (`q_out`), alongside synthetic multi-speaker attribution drills so attention heads learn to read *who said what* rather than memorizing name priors. - **Clean Knowledge Mix (`14,234` rows):** Combined curated Indonesian Q&A, Python/tech explanations, multi-unit arithmetic word problems, casual Indonesian conversation, and long-context needle-in-a-haystack examples — with an automated blocklist preventing any evaluation probe leakage. ### B. Vocabulary Compression (`151,936 -> 20,000` Tokens) - `Qwen2.5-0.5B-Instruct` spends **136.1M parameters** (`~27%` of the entire model) on a 151k multilingual vocabulary full of CJK/Arabic/Cyrillic/rare tokens unused in Indonesian + English. - By extracting the **20,000 most relevant Indonesian/English/code BPE tokens** and remapping `embed_tokens` + `lm_head` 1:1 (`id_map.pt`), embedding size drops to **17.92M parameters** while keeping exact Qwen2.5 tokenization semantics. ### C. Why Attention-Intact Width Pruning (`194M`) Beat Aggressive Layer-Dropping (`66M`/`101M`) - Dropping `10–16` out of `24` layers in one shot breaks transformer residual-stream alignment and destroys factual weights, requiring billions of recovery tokens. - Keeping **all 24 attention layers untouched** and pruning only redundant SwiGLU FFN channels (`4864 -> 2048` via activation × weight L2 saliency) yielded **`MiniIndo-194M`**, which healed smoothly down to `KL = 0.42–0.67` in just 600 distillation steps against `Qwen/Qwen2.5-1.5B-Instruct` (Top-64 logits, `T=2.0`, `α=0.75`). - Removing noisy DPO and using **label-smoothed SFT (`label_smoothing=0.05`)** with length-bucketed batching eliminated repetitive token collapse while preserving fluency. --- ## 4. Variants & Live Benchmarks (`Intel Core i5-5200U` @ ~1.5 GHz, `-t 2`, `BelowNormal`) All speeds and RAM numbers below were **measured directly on a dual-core Windows CPU server (`i5-5200U`)** with background services (MetaTrader 5, PM2) running concurrently: | Model File | Architecture | Params | GGUF Size | `llama-bench` (`pp256` / `tg64`) | Live Server (`avg_prompt` / `avg_gen`) | Live RAM | Best Use Case | |---|---|---:|---:|---|---|---:|---| | **`mini194m-v3-sft-q4_k_m.gguf`** *(Default)* | 24L Attention intact, FFN `2048`, 20k vocab | `194.15 M` | `134.59 MiB` | `37.00` / `13.83` tok/s | `23.61` / `9.62` tok/s | `246.2 MB` | **Best speed/accuracy balance** (`3–9s` chat latency on `1.5 GHz`; `64.3 tok/s` on Ryzen laptop). Use `lpCutoff = -0.95`. | | **`mini194m-v3-sft-q8_0.gguf`** | 24L Attention intact, FFN `2048`, 20k vocab | `194.15 M` | `197.55 MiB` | — | — | `~290 MB` | Full 8-bit precision `MiniIndo-194M` for maximum stability. | | **`mini376m-v3-sft-q4_k_m.gguf`** | 24L + FFN `4864` intact, 20k vocab | `375.82 M` | `253.92 MiB` | `6.88` / `4.92` tok/s | `16.00` / `7.16` tok/s | `394.6 MB` | **Maximum accuracy** (best 4-speaker WA summary, Python, RAM/SSD, math). Slower on dual-core `1.5 GHz`. Use `lpCutoff = -0.78`. | | **`mini376m-v3-sft-q3_k_m.gguf`** | 24L + FFN `4864` intact, 20k vocab | `375.82 M` | `213.54 MiB` | `27.96` / `10.39` tok/s | — | `~340 MB` | Faster `Q3_K_M` option for `376M`. | | **`mini101m-v3-sft-q4_k_m.gguf`** / **`q8_0.gguf`** | 14/24 Strided layers, FFN `1536`, 20k vocab | `101.45 M` | `73.04` / `103.6 MiB` | `63.55` / `26.85` tok/s | `47.78` / `21.62` tok/s | `155.3 MB` | **Ultra-fast escalation router** (`9/9` routing accuracy at `21.6 tok/s`). | | **`mini66m-v3-sft-q4_k_m.gguf`** / **`q8_0.gguf`** | 8/24 Strided layers, FFN `1536`, 20k vocab | `65.65 M` | `49.74` / `66.6 MiB` | `124.43` / `43.64` tok/s | — | `~120 MB` | Ultra-light `>=64M` speed baseline (`43.6 tok/s`!). | | `smol135-v3-sft-q4_k_m.gguf` / `q8_0.gguf` | `SmolLM2-135M-Instruct` trained on V3 corpus | `134.52 M` | `98.87` / `138.1 MiB` | `47.82` / `19.48` tok/s | — | `~190 MB` | External open-weights baseline comparator. | --- ## 5. Quick Start (`llama.cpp`) ### System Prompt ```text Lu adalah MiniIndo, asisten AI lokal berbahasa Indonesia yang santai, akurat, dan jujur. Jawab jelas dari pengetahuan atau potongan chat yang diberikan. Kalau info tidak ada di konteks atau pertanyaan terlalu berat/di luar kemampuanmu, wajib jawab diawali [ESKALASI_CLOUD]. ``` ### Run OpenAI-Compatible Server (Windows / Linux) ```bash llama-server -m models/mini194m-v3-sft-q4_k_m.gguf --host 127.0.0.1 --port 8095 --threads 2 --ctx-size 4096 -ngl 0 ``` Once running, open **`http://127.0.0.1:8095`** in any browser for the built-in Chat UI. ### Node.js API Call with `logprobs` Escalation Gate ```js const SYS_PROMPT = 'Lu adalah MiniIndo, asisten AI lokal berbahasa Indonesia yang santai, akurat, dan jujur. ' + 'Jawab jelas dari pengetahuan atau potongan chat yang diberikan. ' + 'Kalau info tidak ada di konteks atau pertanyaan terlalu berat/di luar kemampuanmu, wajib jawab diawali [ESKALASI_CLOUD].'; const res = await fetch('http://127.0.0.1:8095/v1/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ messages: [ { role: 'system', content: SYS_PROMPT }, { role: 'user', content: 'gw pesen 3 martabak manis satunya 32rb, total bayarnya berapa?' }, ], temperature: 0.25, top_p: 0.9, repeat_penalty: 1.08, max_tokens: 180, logprobs: true, }), }); const data = await res.json(); const reply = (data.choices?.[0]?.message?.content || '').trim(); const lps = (data.choices?.[0]?.logprobs?.content || []).map(x => x.logprob).filter(Number.isFinite); const avgLp = lps.length ? lps.reduce((a, b) => a + b, 0) / lps.length : -99; // Escalate to Cloud AI when explicitly tagged or uncertain const shouldEscalate = !reply || reply.includes('[ESKALASI_CLOUD]') || avgLp < -0.95; ``` --- ## 6. Operational Recommendations for Compact Models (`194M`) - **Prefer single-turn / focused context:** Passing a concise chat snippet + single question gives sharper results than accumulating long multi-topic conversation histories. - **Always keep Cloud Fallback enabled:** MiniIndo is built to absorb high-frequency casual chat, short WA Q&A, and basic facts locally (`0` API cost) while failing safely to Cloud AI on multi-step reasoning, real-time prices/news, or complex coding. --- ## 7. Repository Contents - `models/*.gguf` — All 10 quantized V3 models (`66M Q4/Q8`, `101M Q4/Q8`, `135M Q4/Q8`, `194M Q4/Q8`, `376M Q3_K_M/Q4_K_M`). --- ## Author & Attribution Created, trained, and benchmarked by **Nagisa Artoria** for **artorialabs**.