CiEL7 commited on
Commit
8810586
·
verified ·
1 Parent(s): 78a3415

Release MiniIndo V3 (66M, 101M, 135M, 194M, 376M GGUF) + README & integration guide

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ models/mini101m-v3-sft-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
37
+ models/mini194m-v3-sft-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
38
+ models/mini376m-v3-sft-q3_k_m.gguf filter=lfs diff=lfs merge=lfs -text
39
+ models/mini376m-v3-sft-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
40
+ models/mini66m-v3-sft-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
41
+ models/smol135-v3-sft-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - id
5
+ - en
6
+ library_name: transformers
7
+ pipeline_tag: text-generation
8
+ base_model:
9
+ - Qwen/Qwen2.5-0.5B-Instruct
10
+ tags:
11
+ - indonesian
12
+ - gguf
13
+ - llama-cpp
14
+ - minitron
15
+ - knowledge-distillation
16
+ - compact-llm
17
+ - cpu-inference
18
+ - cloud-escalation
19
+ - artorialabs
20
+ ---
21
+
22
+ # MiniIndo (`artorialabs/MiniIndo`)
23
+
24
+ **Created by:** **Nagisa Artoria** (`artorialabs`)
25
+
26
+ **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.
27
+
28
+ ---
29
+
30
+ ## 1. End-to-End Architecture & Training Flow
31
+
32
+ ```mermaid
33
+ flowchart TD
34
+ 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)"]
35
+ B -->|"Qwen3-4B-Instruct-2507 Synthesis\n+ Decontamination Filter"| C["Curated V3 SFT Dataset\n(14,234 samples, 0 Eval Leakage)"]
36
+
37
+ 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"}
38
+
39
+ E -->|"Zero Weight Loss\n24L + FFN 4864 intact"| F1["MiniIndo-376M"]
40
+ E -->|"24L Attention Intact\nMinitron FFN 4864 -> 2048"| F2["MiniIndo-194M (Recommended)"]
41
+ E -->|"14/24 Strided Layers\nFFN 4864 -> 1536"| F3["MiniIndo-101M"]
42
+ E -->|"8/24 Strided Layers\nFFN 4864 -> 1536"| F4["MiniIndo-66M"]
43
+
44
+ F2 & F3 & F4 -->|"Stage 1: Top-64 Logit KL Healing\nTeacher: Qwen2.5-1.5B-Instruct\nseq 512 -> 1280"| G["Healed Backbones"]
45
+ F1 & G -->|"Stage 2: Curated Indonesian + WA SFT\n(Label Smoothing 0.05, Bucketed Batching)"| H["FP16 Checkpoints"]
46
+ H -->|"llama.cpp convert + quantize\n(Q4_K_M / Q3_K_M)"| I["GGUF Release Bundle\n(models/*.gguf)"]
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 2. How MiniIndo Works at Runtime (Local-First -> Cloud Escalation)
52
+
53
+ MiniIndo is designed as **Layer 1 (Local CPU)** in a hybrid **Local -> Cloud** routing pipeline:
54
+
55
+ ```mermaid
56
+ flowchart LR
57
+ U["User / WhatsApp Message"] --> G{"Rule / Casual Gate\n(Exact Greetings / Shortcuts)"}
58
+ G -->|"Hit"| R1["Instant Rule Reply (0ms)"]
59
+ G -->|"Miss & Text/Context Eligible"| M["MiniIndo Local Server\n(127.0.0.1:8095, logprobs=true)"]
60
+
61
+ M --> C{"Dual Escalation Check"}
62
+ C -->|"Contains [ESKALASI_CLOUD]\nOR avg_logprob < threshold\nOR Timeout / Offline"| CL["Fallback to Cloud AI Agent\n(Full Tools / Web / Reasoning)"]
63
+ C -->|"Confident Local Answer"| R2["Reply Directly from Local CPU\n(Zero Cloud Cost, High Privacy)"]
64
+ ```
65
+
66
+ ### Dual Escalation Mechanism
67
+ Instead of relying solely on a prompt or solely on confidence scores, MiniIndo combines **two independent signals**:
68
+ 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.
69
+ 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.
70
+
71
+ ---
72
+
73
+ ## 3. Training Methodology & Key Design Choices
74
+
75
+ ### A. Privacy-First Data Curation (`0` PII, `0` Benchmark Contamination)
76
+ - **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.
77
+ - **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.
78
+ - **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.
79
+
80
+ ### B. Vocabulary Compression (`151,936 -> 20,000` Tokens)
81
+ - `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.
82
+ - 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.
83
+
84
+ ### C. Why Attention-Intact Width Pruning (`194M`) Beat Aggressive Layer-Dropping (`66M`/`101M`)
85
+ - Dropping `10–16` out of `24` layers in one shot breaks transformer residual-stream alignment and destroys factual weights, requiring billions of recovery tokens.
86
+ - 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`).
87
+ - Removing noisy DPO and using **label-smoothed SFT (`label_smoothing=0.05`)** with length-bucketed batching eliminated repetitive token collapse while preserving fluency.
88
+
89
+ ---
90
+
91
+ ## 4. Variants & Live Benchmarks (`Intel Core i5-5200U` @ ~1.5 GHz, `-t 2`, `BelowNormal`)
92
+
93
+ 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:
94
+
95
+ | Model File | Architecture | Params | GGUF Size | `llama-bench` (`pp256` / `tg64`) | Live Server (`avg_prompt` / `avg_gen`) | Live RAM | Best Use Case |
96
+ |---|---|---:|---:|---|---|---:|---|
97
+ | **`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). Accurate WA QA, math, casual ID, & `[ESKALASI_CLOUD]`. Use `lpCutoff = -0.95`. |
98
+ | **`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`. |
99
+ | **`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`. |
100
+ | **`mini101m-v3-sft-q4_k_m.gguf`** | 14/24 Strided layers, FFN `1536`, 20k vocab | `101.45 M` | `73.04 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`). |
101
+ | **`mini66m-v3-sft-q4_k_m.gguf`** | 8/24 Strided layers, FFN `1536`, 20k vocab | `65.65 M` | `49.74 MiB` | `124.43` / `43.64` tok/s | — | `~120 MB` | Ultra-light `>=64M` speed baseline (`43.6 tok/s`!). |
102
+ | `smol135-v3-sft-q4_k_m.gguf` | `SmolLM2-135M-Instruct` trained on V3 corpus | `134.52 M` | `98.87 MiB` | `47.82` / `19.48` tok/s | — | `~190 MB` | External open-weights baseline comparator. |
103
+
104
+ ---
105
+
106
+ ## 5. Quick Start (`llama.cpp`)
107
+
108
+ ### System Prompt
109
+ ```text
110
+ 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].
111
+ ```
112
+
113
+ ### Run OpenAI-Compatible Server (Windows / Linux)
114
+ ```bash
115
+ 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
116
+ ```
117
+ Or on Windows with the included launcher (`BelowNormal` priority):
118
+ ```bat
119
+ start_miniindo.bat
120
+ :: Or switch variant:
121
+ start_miniindo.bat mini376m-v3-sft-q4_k_m.gguf
122
+ ```
123
+ Once running, open **`http://127.0.0.1:8095`** in any browser for the built-in Chat UI, or run `node test_escalation_bench.mjs` to test escalation routing.
124
+
125
+ ### Node.js API Call with `logprobs` Escalation Gate
126
+ ```js
127
+ const SYS_PROMPT =
128
+ 'Lu adalah MiniIndo, asisten AI lokal berbahasa Indonesia yang santai, akurat, dan jujur. ' +
129
+ 'Jawab jelas dari pengetahuan atau potongan chat yang diberikan. ' +
130
+ 'Kalau info tidak ada di konteks atau pertanyaan terlalu berat/di luar kemampuanmu, wajib jawab diawali [ESKALASI_CLOUD].';
131
+
132
+ const res = await fetch('http://127.0.0.1:8095/v1/chat/completions', {
133
+ method: 'POST',
134
+ headers: { 'Content-Type': 'application/json' },
135
+ body: JSON.stringify({
136
+ messages: [
137
+ { role: 'system', content: SYS_PROMPT },
138
+ { role: 'user', content: 'gw pesen 3 martabak manis satunya 32rb, total bayarnya berapa?' },
139
+ ],
140
+ temperature: 0.25,
141
+ top_p: 0.9,
142
+ repeat_penalty: 1.08,
143
+ max_tokens: 180,
144
+ logprobs: true,
145
+ }),
146
+ });
147
+
148
+ const data = await res.json();
149
+ const reply = (data.choices?.[0]?.message?.content || '').trim();
150
+ const lps = (data.choices?.[0]?.logprobs?.content || []).map(x => x.logprob).filter(Number.isFinite);
151
+ const avgLp = lps.length ? lps.reduce((a, b) => a + b, 0) / lps.length : -99;
152
+
153
+ // Escalate to Cloud AI when explicitly tagged or uncertain
154
+ const shouldEscalate = !reply || reply.includes('[ESKALASI_CLOUD]') || avgLp < -0.95;
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 6. Operational Recommendations for Compact Models (`194M`)
160
+ - **Prefer single-turn / focused context:** Passing a concise chat snippet + single question gives sharper results than accumulating long multi-topic conversation histories.
161
+ - **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.
162
+
163
+ ---
164
+
165
+ ## 7. Repository Contents
166
+ - `models/*.gguf` — All 6 quantized V3 models (`66M`, `101M`, `135M`, `194M`, `376M Q3_K_M`, `376M Q4_K_M`).
167
+ - `start_miniindo.bat` — Windows CPU launcher (`127.0.0.1:8095`, `BelowNormal` priority).
168
+ - `test_escalation_bench.mjs` — 9-probe latency, `avg_lp`, and escalation routing benchmark script.
169
+ - `instruction.md` — Integration guide for connecting a Node.js WhatsApp bot to MiniIndo.
170
+
171
+ ---
172
+
173
+ ## Author & Attribution
174
+ Created, trained, and benchmarked by **Nagisa Artoria** for **artorialabs**.
instruction.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MiniIndo-LLM Integration Guide (`botwa` Local-First -> Cloud Escalation)
2
+
3
+ > **Target Folder:** `C:\Users\XinooXS\Documents\PROJEK GEDE\MiniIndo-LLM` (alias `Z:\Documents\PROJEK GEDE\MiniIndo-LLM`)
4
+ > **Target Bot Repo (jangan ubah tanpa mengikuti panduan ini):** `C:\Users\XinooXS\Documents\PROJEK GEDE\botwa` (`Z:\Documents\PROJEK GEDE\botwa`)
5
+
6
+ Dokumen ini ditujukan untuk **AI Agent / Developer `botwa`** agar dapat menghubungkan `botwa` ke **MiniIndo-LLM** (server `llama.cpp` lokal di `http://127.0.0.1:8095/v1/chat/completions`) sebagai **Layer AI Lokal Pertama** sebelum melakukan eskalasi ke Cloud AI.
7
+
8
+ ---
9
+
10
+ ## 1. Pilihan Model yang Tersedia di `models\` (Terukur di CPU `rielcomputer` i5-5200U, `-t 2`, `BelowNormal`)
11
+
12
+ | Model File | Ukuran | RAM Live | Kecepatan (`llama-bench` / Live) | Rekomendasi Pemakaian |
13
+ |---|---:|---:|---|---|
14
+ | `mini194m-v3-sft-q4_k_m.gguf` **(Default)** | `134.59 MiB` | `246.2 MB` | `pp256: 37.0 tok/s`, `tg64: 13.8 tok/s` | **Default seimbang:** cepat + akurat untuk QA konteks chat WA, matematika dasar, sapaan santai, & `[ESKALASI_CLOUD]`. Gunakan `LP_CUTOFF = -0.95`. |
15
+ | `mini376m-v3-sft-q4_k_m.gguf` | `253.92 MiB` | `394.6 MB` | `pp256: 6.9 tok/s`, `tg64: 4.9 tok/s` (Live avg `7.2 tok/s`) | **Akurasi maksimal:** rangkuman grup & pengetahuan umum paling kuat (24L + 4864 FFN utuh). Gunakan `LP_CUTOFF = -0.78`. |
16
+ | `mini376m-v3-sft-q3_k_m.gguf` | `213.54 MiB` | `~340 MB` | `pp256: 28.0 tok/s`, `tg64: 10.4 tok/s` | Alternatif `376M` lebih ringan & responsif. |
17
+ | `mini101m-v3-sft-q4_k_m.gguf` | `73.04 MiB` | `155.3 MB` | `pp256: 63.6 tok/s`, `tg64: 26.9 tok/s` (Live `21.6 tok/s`) | **Ultra-ringan / Triage:** `9/9` routing eskalasi, cocok jika CPU sangat sibuk. |
18
+ | `mini66m-v3-sft-q4_k_m.gguf` | `49.74 MiB` | `~120 MB` | `pp256: 124.4 tok/s`, `tg64: 43.6 tok/s` | Baseline ultra-cepat `65.65M` parameter. |
19
+ | `smol135-v3-sft-q4_k_m.gguf` | `98.87 MiB` | `~190 MB` | `pp256: 47.8 tok/s`, `tg64: 19.5 tok/s` | Pembanding eksternal (`SmolLM2-135M`). |
20
+
21
+ Menjalankan server lokal secara aman (prioritas `BelowNormal` agar `MetaTrader 5 / terminal64.exe` dan `pm2` tidak terganggu):
22
+ ```bat
23
+ cd /d "C:\Users\XinooXS\Documents\PROJEK GEDE\MiniIndo-LLM"
24
+ start_miniindo.bat
25
+ ```
26
+ Atau ganti model: `start_miniindo.bat mini376m-v3-sft-q4_k_m.gguf`.
27
+
28
+ ---
29
+
30
+ ## 2. Arsitektur Integrasi di `botwa`
31
+
32
+ Jangan hapus sistem lama (`lib/casual-gate.js` dan `lib/localmodel.js`). Sisipkan `MiniIndo` sebagai **layer opsional dengan feature flag** (`process.env.USE_MINIINDO_LOCAL === '1'`) di `lib/riel.js`:
33
+
34
+ 1. **Pertahankan `think(...)` (`lib/localmodel.js`) & `evaluateCasualGate(...)` (`lib/casual-gate.js`)** pada `lib/riel.js` (~L675 & L1045–1078).
35
+ 2. **Tepat setelah `evaluateCasualGate(...)` miss** (sekitar `lib/riel.js` L1078, sebelum masuk loop Cloud Agent `while (!agentFinished && iteration < maxIterations)` di L1087):
36
+ - Jalankan MiniIndo **HANYA jika**:
37
+ - `process.env.USE_MINIINDO_LOCAL === '1'`
38
+ - `!isDumpMode && !mediaIntentDirective && !imageUrl && !audioData && !hasQuotedImg && !documentContext`
39
+ - Tidak membutuhkan tool/MCP eksternal (`(filteredToolsInfo?.mcpCount ?? 0) === 0`)
40
+ 3. **Buat modul baru `lib/miniindo.js`**:
41
+ - Panggil `POST http://127.0.0.1:8095/v1/chat/completions` (`AbortSignal.timeout(12000)` untuk `194M`, atau `25000` untuk `376M`).
42
+ - Wajib sertakan `logprobs: true`, `temperature: 0.25`, `top_p: 0.9`, `repeat_penalty: 1.08`, `max_tokens: 180`.
43
+ - **System Prompt Wajib:**
44
+ ```text
45
+ 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].
46
+ ```
47
+ - Jika `quotedContextBlock` atau `groupContextBlock` tersedia di `lib/riel.js`, gabungkan sebagai konteks sebelum pertanyaan user:
48
+ ```text
49
+ Berdasarkan potongan chat WhatsApp ini:
50
+ <isi groupContextBlock / quotedContextBlock>
51
+
52
+ Pertanyaan: <question>
53
+ ```
54
+
55
+ ---
56
+
57
+ ## 3. Aturan Eskalasi ke Cloud AI (Fail-Safe)
58
+
59
+ `queryMiniIndo(...)` di `lib/miniindo.js` harus mengembalikan `{ hit: boolean, reply?: string, reason?: string }` dan **WAJIB fallback (`hit: false`) ke loop Cloud Agent `lib/riel.js` L1087** jika salah satu kondisi berikut terpenuhi:
60
+
61
+ 1. Server `127.0.0.1:8095` mati, timeout, atau HTTP status bukan `200`.
62
+ 2. Output kosong atau mengandung tag **`[ESKALASI_CLOUD]`** (case-insensitive).
63
+ 3. Rata-rata `logprob` token respons (`avgLp`) berada di bawah ambang batas kepercayaan:
64
+ - **`avgLp < -0.95`** (untuk `mini194m-v3-sft-q4_k_m.gguf`)
65
+ - **`avgLp < -0.78`** (untuk `mini376m-v3-sft-q4_k_m.gguf`)
66
+ 4. Jawaban terlihat repetitif/terputus tidak wajar (`reply.length < 3`).
67
+
68
+ Jika `hit: true`, kirim `res.reply` ke user, panggil `saveHistory(...)` dan `finishAndDump(...)` sama seperti pola `evaluateCasualGate` hit di `lib/riel.js`, lalu `return`.
69
+
70
+ ---
71
+
72
+ ## 4. Privasi & Keamanan
73
+
74
+ - Seluruh model `MiniIndo` di folder `models\` hanya dilatih pada korpus terkurasi bebas PII (`Karasuno`, `Sistem Informasi 012`, `Kabinet Memajukan Indonesia` yang sudah di-anonymize; grup `CEREEEEE` diblokir permanen).
75
+ - `llama-server.exe` hanya bind ke loopback **`127.0.0.1:8095`** (tidak terbuka ke LAN/internet).
76
+ - Jangan pernah mengirim data sensitif ke endpoint publik saat memakai mode lokal; eskalasi ke Cloud AI hanya terjadi ketika kondisi fallback di Bagian 3 terpicu.
models/mini101m-v3-sft-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f53d92b45a050592dba720f7ae57ed71f94e11ed13d6829426fead524163351
3
+ size 77235872
models/mini194m-v3-sft-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ca2d173541ef995c57037ebc2fd16561427a919b942e401fb82aeab91467324
3
+ size 141779328
models/mini376m-v3-sft-q3_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80210205a4082708b461f58917686a524a2cc06fe3db2486a8535363f9b71c1a
3
+ size 224569728
models/mini376m-v3-sft-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2f535bb32303e3831b94bbfa372fc02cbfb7b820fe9d9ffc9489e1ff3d1ce32
3
+ size 266911104
models/mini66m-v3-sft-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c94a156f1f5c69b4795847865f4b19f5a2f87cba5d2f19108e590ff3939c4692
3
+ size 52797056
models/smol135-v3-sft-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0f36b57a2f0f75c734c3bc77479fb1d1a3961226b379c8f009659b5bfba898b
3
+ size 105454016
start_miniindo.bat ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ setlocal
3
+ cd /d "%~dp0"
4
+
5
+ set MODEL=mini194m-v3-sft-q4_k_m.gguf
6
+ if not "%~1"=="" set MODEL=%~1
7
+
8
+ set PORT=8095
9
+ if not "%~2"=="" set PORT=%~2
10
+
11
+ echo Starting %MODEL% on http://127.0.0.1:%PORT% ^(threads=2, ctx=4096, Priority=BelowNormal^)...
12
+ start "MiniIndo-LLM" /BELOWNORMAL "%~dp0bin\llama-server.exe" ^
13
+ -m "%~dp0models\%MODEL%" ^
14
+ --host 127.0.0.1 ^
15
+ --port %PORT% ^
16
+ --threads 2 ^
17
+ --threads-batch 4 ^
18
+ --ctx-size 4096 ^
19
+ --n-gpu-layers 0 ^
20
+ --parallel 1 ^
21
+ --no-warmup
test_escalation_bench.mjs ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Benchmark & Cloud-Escalation Test Harness untuk MiniIndo-LLM (llama-server.exe /v1/chat/completions)
3
+ * Jalan dengan Node.js >=18 atau Bun di Windows Server rielcomputer.
4
+ */
5
+
6
+ const URL = process.env.MINIINDO_URL || 'http://127.0.0.1:8095/v1/chat/completions';
7
+ const LABEL = process.env.MODEL_LABEL || process.argv[2] || 'miniindo-model';
8
+ const LP_CUTOFF = Number(process.env.LP_CUTOFF ?? '-0.95');
9
+ const MAX_TOKENS = Number(process.env.MAX_TOKENS ?? '128');
10
+ const SYS_PROMPT =
11
+ 'Lu adalah MiniIndo, asisten AI lokal berbahasa Indonesia yang santai, akurat, dan jujur. ' +
12
+ 'Jawab jelas dari pengetahuan atau potongan chat yang diberikan. ' +
13
+ 'Kalau info tidak ada di konteks atau pertanyaan terlalu berat/di luar kemampuanmu, wajib jawab diawali [ESKALASI_CLOUD].';
14
+
15
+ const SAMPLE_KARASUNO = [
16
+ '[21:50] Raka: ges mo nanya dong, ada yang pernah ke sawarna ga? kira2 pantai yang bagus namanya apa dan jalannya nanjak2 ngga ya',
17
+ '[21:51] Dika: Ancol',
18
+ '[21:51] Raka: gweh mau ke bali tahun depan skalian nyari kenalan disana',
19
+ '[21:52] Tama: btw tadi botnya sempat off lagi perbaikan kata Bima',
20
+ '[21:56] Bot_Riel: Halo! Ada yang bisa dibantu hari ini?',
21
+ ].join('\n');
22
+
23
+ const TESTS = [
24
+ {
25
+ name: '1. WA Context QA (Sawarna/Bali)',
26
+ expectEscalate: false,
27
+ prompt: `Berdasarkan potongan chat WhatsApp ini:\n${SAMPLE_KARASUNO}\n\nPertanyaan: siapa yang pengen ke Bali tahun depan dan apa alasannya?`
28
+ },
29
+ {
30
+ name: '2. WA Context Summary',
31
+ expectEscalate: false,
32
+ prompt: `rangkumin inti obrolan grup di bawah ini secara singkat:\n${SAMPLE_KARASUNO}`
33
+ },
34
+ {
35
+ name: '3. WA Out-of-Context -> Must Escalate',
36
+ expectEscalate: true,
37
+ prompt: `Berdasarkan potongan chat WhatsApp ini:\n${SAMPLE_KARASUNO}\n\nPertanyaan: berapa harga tiket masuk pantai Sawarna per orang saat akhir pekan?`
38
+ },
39
+ {
40
+ name: '4. Core Knowledge (Python List)',
41
+ expectEscalate: false,
42
+ prompt: 'di Python, bedanya metode append sama extend di list apa ya?'
43
+ },
44
+ {
45
+ name: '5. Core Knowledge (Gunung Berapi ID)',
46
+ expectEscalate: false,
47
+ prompt: 'sebutin 3 nama gunung berapi aktif terkenal di Indonesia!'
48
+ },
49
+ {
50
+ name: '6. Math Dasar (Martabak)',
51
+ expectEscalate: false,
52
+ prompt: 'gw pesen 3 martabak manis satunya 32rb, total bayarnya berapa?'
53
+ },
54
+ {
55
+ name: '7. Sapaan Santai',
56
+ expectEscalate: false,
57
+ prompt: 'wkwk asli males bgt besok udah senin lagi nih'
58
+ },
59
+ {
60
+ name: '8. Open-World Trap (Antartika) -> Must Escalate',
61
+ expectEscalate: true,
62
+ prompt: 'siapa nama presiden benua antartika tahun 2026?'
63
+ },
64
+ {
65
+ name: '9. Realtime/Heavy Task -> Must Escalate',
66
+ expectEscalate: true,
67
+ prompt: 'berapa harga saham bbca dan ihsg hari ini real-time?'
68
+ },
69
+ ];
70
+
71
+ async function queryModel(prompt) {
72
+ const t0 = performance.now();
73
+ const res = await fetch(URL, {
74
+ method: 'POST',
75
+ headers: { 'Content-Type': 'application/json' },
76
+ body: JSON.stringify({
77
+ messages: [
78
+ { role: 'system', content: SYS_PROMPT },
79
+ { role: 'user', content: prompt },
80
+ ],
81
+ temperature: 0.25,
82
+ top_p: 0.9,
83
+ repeat_penalty: 1.08,
84
+ max_tokens: MAX_TOKENS,
85
+ logprobs: true,
86
+ stream: false,
87
+ }),
88
+ });
89
+ const wallMs = performance.now() - t0;
90
+ if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
91
+ const data = await res.json();
92
+ const choice = data.choices?.[0];
93
+ const text = (choice?.message?.content || '').trim();
94
+ const lpList = (choice?.logprobs?.content || []).map(x => x.logprob).filter(Number.isFinite);
95
+ const avgLp = lpList.length ? lpList.reduce((a, b) => a + b, 0) / lpList.length : null;
96
+ const minLp = lpList.length ? Math.min(...lpList) : null;
97
+ const predTok = data.timings?.predicted_n ?? data.usage?.completion_tokens ?? lpList.length;
98
+ const promptTok = data.timings?.prompt_n ?? data.usage?.prompt_tokens ?? 0;
99
+ const timings = data.timings || {};
100
+ const genTps = timings.predicted_per_second || (predTok / Math.max(wallMs / 1000, 0.01));
101
+ const promptTps = timings.prompt_per_second || 0;
102
+ const explicitEsc = text.includes('[ESKALASI_CLOUD]');
103
+ const lpEsc = avgLp !== null && avgLp < LP_CUTOFF;
104
+ const escalated = explicitEsc || lpEsc;
105
+ return { text, escalated, explicitEsc, lpEsc, avgLp, minLp, predTok, promptTok, genTps, promptTps, wallMs };
106
+ }
107
+
108
+ async function main() {
109
+ console.log(`=== BENCH: ${LABEL} @ ${URL} (lpCutoff=${LP_CUTOFF}, maxTok=${MAX_TOKENS}) ===`);
110
+ const results = [];
111
+ for (const t of TESTS) {
112
+ const r = await queryModel(t.prompt);
113
+ results.push({ ...t, ...r });
114
+ const lpStr = r.avgLp === null ? 'n/a' : r.avgLp.toFixed(3);
115
+ const routeOk = r.escalated === t.expectEscalate ? 'ROUTE_OK' : 'ROUTE_MISS';
116
+ console.log(
117
+ `\n[${t.name}] ${routeOk} esc=${r.escalated}(exp=${t.expectEscalate}, tag=${r.explicitEsc}, lp=${r.lpEsc}) ` +
118
+ `| avg_lp=${lpStr} | prompt=${r.promptTok}t@${r.promptTps.toFixed(1)}t/s | gen=${r.predTok}t@${r.genTps.toFixed(1)}t/s | ${r.wallMs.toFixed(0)}ms`
119
+ );
120
+ console.log(` -> ${r.text.replace(/\n+/g, ' ')}`);
121
+ }
122
+ const avgGen = results.reduce((s, r) => s + r.genTps, 0) / results.length;
123
+ const avgPrompt = results.reduce((s, r) => s + r.promptTps, 0) / results.length;
124
+ const routeHits = results.filter(r => r.escalated === r.expectEscalate).length;
125
+ console.log(`\n=== SUMMARY [${LABEL}]: route=${routeHits}/${results.length} | avg_prompt=${avgPrompt.toFixed(2)} tok/s | avg_gen=${avgGen.toFixed(2)} tok/s ===`);
126
+ }
127
+
128
+ main().catch(err => {
129
+ console.error(err);
130
+ process.exit(1);
131
+ });