Update app/micro_distillv2.html
Browse files- app/micro_distillv2.html +108 -33
app/micro_distillv2.html
CHANGED
|
@@ -179,6 +179,7 @@ select {
|
|
| 179 |
select:focus { border-color: var(--border-focus); }
|
| 180 |
|
| 181 |
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
|
|
|
|
| 182 |
.metric {
|
| 183 |
padding: 10px 8px; background: var(--panel-2); border: 1px solid var(--border);
|
| 184 |
border-radius: 3px; text-align: center;
|
|
@@ -346,7 +347,7 @@ select:focus { border-color: var(--border-focus); }
|
|
| 346 |
<div class="brand">
|
| 347 |
<span class="brand-mark">mD</span>
|
| 348 |
<span class="brand-name">Micro Distillery</span>
|
| 349 |
-
<span class="brand-version">v3.1.
|
| 350 |
</div>
|
| 351 |
<div class="hdr-actions">
|
| 352 |
<button class="btn btn-ghost" id="btn-wizard">Setup Wizard</button>
|
|
@@ -428,11 +429,11 @@ select:focus { border-color: var(--border-focus); }
|
|
| 428 |
<input type="range" id="cfg-kl" min="0.01" max="0.5" step="0.01" value="0.1">
|
| 429 |
</div>
|
| 430 |
<div class="setting">
|
| 431 |
-
<div class="setting-label"><span>VAE Latent Dim</span><span class="setting-val" id="val-latent">32</span></div>
|
| 432 |
<input type="range" id="cfg-latent" min="8" max="128" step="8" value="32">
|
| 433 |
</div>
|
| 434 |
<div class="setting">
|
| 435 |
-
<div class="setting-label"><span>Filter Threshold</span><span class="setting-val" id="val-filter">0.70</span></div>
|
| 436 |
<input type="range" id="cfg-filter" min="0.1" max="0.9" step="0.05" value="0.7">
|
| 437 |
</div>
|
| 438 |
<div class="setting">
|
|
@@ -444,7 +445,7 @@ select:focus { border-color: var(--border-focus); }
|
|
| 444 |
<option value="olmo2-1b">OLMo-2-1B (AllenAI)</option>
|
| 445 |
<option value="tinyllama-11b">TinyLlama-1.1B (TinyLlama)</option>
|
| 446 |
</select>
|
| 447 |
-
<div class="small text-mute mt-8">Reference only — metadata used in export. Actual model is character-level bigram.</div>
|
| 448 |
</div>
|
| 449 |
</div>
|
| 450 |
</section>
|
|
@@ -508,7 +509,7 @@ select:focus { border-color: var(--border-focus); }
|
|
| 508 |
<span class="small text-mute" style="align-self:center;" id="osc-result"></span>
|
| 509 |
</div>
|
| 510 |
<div class="small text-mute mt-8">
|
| 511 |
-
Four incommensurate frequencies (1, phi, 2, pi).
|
| 512 |
</div>
|
| 513 |
</div>
|
| 514 |
</section>
|
|
@@ -593,6 +594,10 @@ select:focus { border-color: var(--border-focus); }
|
|
| 593 |
const $ = (id) => document.getElementById(id);
|
| 594 |
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
| 595 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
function factorial(n) {
|
| 597 |
if (n <= 1) return 1;
|
| 598 |
let r = 1;
|
|
@@ -724,11 +729,16 @@ class KnowledgeGraph {
|
|
| 724 |
constructor() { this.nodes = new Map(); this.edges = new Map(); }
|
| 725 |
clear() { this.nodes.clear(); this.edges.clear(); }
|
| 726 |
addNode(id, data = {}) {
|
| 727 |
-
if (!this.nodes.has(id))
|
| 728 |
-
|
|
|
|
|
|
|
|
|
|
| 729 |
const n = this.nodes.get(id);
|
| 730 |
-
|
|
|
|
| 731 |
Object.assign(n, data);
|
|
|
|
| 732 |
}
|
| 733 |
return this.nodes.get(id);
|
| 734 |
}
|
|
@@ -918,6 +928,9 @@ class Engine {
|
|
| 918 |
this.apiFanOut = new APIFanOut((m, c) => this.apiLog(m, c));
|
| 919 |
this.corpus = FALLBACK_NAMES.slice();
|
| 920 |
|
|
|
|
|
|
|
|
|
|
| 921 |
this.metrics = {
|
| 922 |
trainingSteps: 0,
|
| 923 |
finalLoss: 0,
|
|
@@ -934,6 +947,7 @@ class Engine {
|
|
| 934 |
}
|
| 935 |
|
| 936 |
log(msg, cls = "") {
|
|
|
|
| 937 |
const term = $("terminal");
|
| 938 |
if (!term) return;
|
| 939 |
const time = new Date().toLocaleTimeString("en-US", { hour12: false });
|
|
@@ -945,6 +959,7 @@ class Engine {
|
|
| 945 |
while (term.children.length > 300) term.removeChild(term.firstChild);
|
| 946 |
}
|
| 947 |
apiLog(msg, cls = "") {
|
|
|
|
| 948 |
const log = $("api-log");
|
| 949 |
if (!log) return;
|
| 950 |
const time = new Date().toLocaleTimeString("en-US", { hour12: false });
|
|
@@ -958,11 +973,21 @@ class Engine {
|
|
| 958 |
|
| 959 |
setProgress(pct, task) {
|
| 960 |
const p = Math.max(0, Math.min(100, pct));
|
| 961 |
-
$("progress-fill")
|
| 962 |
-
|
| 963 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 964 |
}
|
| 965 |
-
setProgressLabel(label) { $("progress-label").textContent = label; }
|
| 966 |
|
| 967 |
updateMetrics() {
|
| 968 |
$("m-steps").textContent = String(this.metrics.trainingSteps);
|
|
@@ -1262,16 +1287,20 @@ class Engine {
|
|
| 1262 |
}
|
| 1263 |
}
|
| 1264 |
|
|
|
|
|
|
|
| 1265 |
updateCache(trajectories) {
|
| 1266 |
const threshold = 0.9;
|
| 1267 |
-
const cache = new Map();
|
| 1268 |
const maxSize = 512;
|
| 1269 |
for (const tr of trajectories) {
|
| 1270 |
if (tr.reward > threshold) {
|
| 1271 |
const key = tr.text.substring(0, 20);
|
| 1272 |
-
if (!cache.has(key)) {
|
| 1273 |
-
cache.set(key, { text: tr.text, reward: tr.reward });
|
| 1274 |
-
if (cache.size > maxSize)
|
|
|
|
|
|
|
|
|
|
| 1275 |
this.metrics.cacheMisses++;
|
| 1276 |
} else {
|
| 1277 |
this.metrics.cacheHits++;
|
|
@@ -1375,6 +1404,8 @@ class Engine {
|
|
| 1375 |
this.updateOscDisplay();
|
| 1376 |
const msg = "osc " + m.oscillator + " E=" + m.energy.toFixed(3) + " x=" + m.x.toFixed(4);
|
| 1377 |
$("osc-result").textContent = msg;
|
|
|
|
|
|
|
| 1378 |
this.log("Quantum collapse: " + msg);
|
| 1379 |
return m;
|
| 1380 |
}
|
|
@@ -1397,7 +1428,7 @@ class Engine {
|
|
| 1397 |
|
| 1398 |
const modelJson = {
|
| 1399 |
format: "micro-distill-bigram-v1",
|
| 1400 |
-
version: "3.1.
|
| 1401 |
arch: policyArch,
|
| 1402 |
created: new Date().toISOString(),
|
| 1403 |
bos_token: this.bos,
|
|
@@ -1619,12 +1650,16 @@ class Engine {
|
|
| 1619 |
' prompts = []',
|
| 1620 |
' i = 0',
|
| 1621 |
' while i < len(args):',
|
| 1622 |
-
' if args[i] == "--temperature"
|
| 1623 |
-
'
|
| 1624 |
-
'
|
| 1625 |
-
'
|
| 1626 |
-
'
|
| 1627 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1628 |
' elif args[i] in ("--help", "-h"):',
|
| 1629 |
' print("Usage: python3 test.py [prompt...] [--temperature T]")',
|
| 1630 |
' sys.exit(0)',
|
|
@@ -1728,7 +1763,7 @@ class Engine {
|
|
| 1728 |
'',
|
| 1729 |
'```bash',
|
| 1730 |
'python3 test.py alice',
|
| 1731 |
-
'# =>
|
| 1732 |
'```',
|
| 1733 |
'',
|
| 1734 |
'### Custom temperature',
|
|
@@ -2082,6 +2117,8 @@ class Engine {
|
|
| 2082 |
if (files.length > 0) {
|
| 2083 |
if (this.selectedPreviewIndex >= files.length) this.selectedPreviewIndex = 0;
|
| 2084 |
this.renderPreview(files, this.selectedPreviewIndex);
|
|
|
|
|
|
|
| 2085 |
}
|
| 2086 |
}
|
| 2087 |
|
|
@@ -2139,7 +2176,13 @@ class Engine {
|
|
| 2139 |
this.kgSeed = 42;
|
| 2140 |
this.quantumMeasurements = [];
|
| 2141 |
this.corpus = FALLBACK_NAMES.slice();
|
|
|
|
| 2142 |
this.metrics = { trainingSteps: 0, finalLoss: 0, averageReward: 0, cacheHits: 0, cacheMisses: 0, filteredCount: 0, totalSamples: 0, vaeLoss: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2143 |
this.markStep("fetch", "active", "");
|
| 2144 |
this.markStep("train", "", "");
|
| 2145 |
this.markStep("export", "", "");
|
|
@@ -2149,6 +2192,8 @@ class Engine {
|
|
| 2149 |
this.setProgressLabel("idle");
|
| 2150 |
this.updateOscDisplay();
|
| 2151 |
$("osc-result").textContent = "";
|
|
|
|
|
|
|
| 2152 |
this.log("System reset.");
|
| 2153 |
}
|
| 2154 |
}
|
|
@@ -2253,7 +2298,7 @@ class Wizard {
|
|
| 2253 |
'<div class="wiz-info">',
|
| 2254 |
'<strong>Status:</strong> <span id="wiz-export-status">ready</span>',
|
| 2255 |
"</div>",
|
| 2256 |
-
'<button class="btn btn-primary btn-lg btn-block" id="wiz-run-export">
|
| 2257 |
],
|
| 2258 |
next: "Done",
|
| 2259 |
back: null
|
|
@@ -2292,7 +2337,12 @@ class Wizard {
|
|
| 2292 |
|
| 2293 |
if (id === "fetch") {
|
| 2294 |
const btn = $("wiz-run-fetch");
|
|
|
|
| 2295 |
if (btn) btn.addEventListener("click", async () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2296 |
btn.disabled = true;
|
| 2297 |
$("wiz-fetch-status").textContent = "fetching...";
|
| 2298 |
const ok = await this.engine.fetch();
|
|
@@ -2324,9 +2374,9 @@ class Wizard {
|
|
| 2324 |
}
|
| 2325 |
if (btn) btn.addEventListener("click", async () => {
|
| 2326 |
btn.disabled = true;
|
| 2327 |
-
$("wiz-export-status").textContent = "
|
| 2328 |
await this.engine.showExportModal();
|
| 2329 |
-
$("wiz-export-status").textContent = "ready -
|
| 2330 |
btn.disabled = false;
|
| 2331 |
});
|
| 2332 |
}
|
|
@@ -2398,6 +2448,20 @@ function setupCloseButtons() {
|
|
| 2398 |
});
|
| 2399 |
}
|
| 2400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2401 |
function setupButtons() {
|
| 2402 |
$("btn-fetch").addEventListener("click", async () => {
|
| 2403 |
$("btn-fetch").disabled = true;
|
|
@@ -2445,25 +2509,36 @@ function boot() {
|
|
| 2445 |
engine = new Engine();
|
| 2446 |
wizard = new Wizard(engine);
|
| 2447 |
|
| 2448 |
-
engine.log("Micro Distillery v3.1.
|
| 2449 |
-
engine.log("Data sources (2026): HuggingFace
|
| 2450 |
engine.log("Click Setup Wizard in the header, or use the pipeline.");
|
| 2451 |
engine.log("Ready.");
|
| 2452 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2453 |
setupTabs();
|
| 2454 |
setupSliders();
|
| 2455 |
setupCloseButtons();
|
|
|
|
| 2456 |
setupButtons();
|
| 2457 |
engine.updateMetrics();
|
| 2458 |
engine.updateOscDisplay();
|
| 2459 |
engine.renderGraph();
|
| 2460 |
engine.setProgress(0, "idle");
|
| 2461 |
|
| 2462 |
-
|
|
|
|
| 2463 |
if (!seen) {
|
| 2464 |
setTimeout(() => {
|
| 2465 |
-
wizard.open();
|
| 2466 |
-
localStorage.setItem("md_wizard_seen", "1");
|
| 2467 |
}, 400);
|
| 2468 |
}
|
| 2469 |
|
|
@@ -2476,7 +2551,7 @@ function boot() {
|
|
| 2476 |
window.addEventListener("resize", () => engine.renderGraph());
|
| 2477 |
|
| 2478 |
if ("serviceWorker" in navigator) {
|
| 2479 |
-
navigator.serviceWorker.register("sw.js").catch(() => { /*
|
| 2480 |
}
|
| 2481 |
}
|
| 2482 |
|
|
|
|
| 179 |
select:focus { border-color: var(--border-focus); }
|
| 180 |
|
| 181 |
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
|
| 182 |
+
#osc-display { grid-template-columns: repeat(4, 1fr); }
|
| 183 |
.metric {
|
| 184 |
padding: 10px 8px; background: var(--panel-2); border: 1px solid var(--border);
|
| 185 |
border-radius: 3px; text-align: center;
|
|
|
|
| 347 |
<div class="brand">
|
| 348 |
<span class="brand-mark">mD</span>
|
| 349 |
<span class="brand-name">Micro Distillery</span>
|
| 350 |
+
<span class="brand-version">v3.1.2</span>
|
| 351 |
</div>
|
| 352 |
<div class="hdr-actions">
|
| 353 |
<button class="btn btn-ghost" id="btn-wizard">Setup Wizard</button>
|
|
|
|
| 429 |
<input type="range" id="cfg-kl" min="0.01" max="0.5" step="0.01" value="0.1">
|
| 430 |
</div>
|
| 431 |
<div class="setting">
|
| 432 |
+
<div class="setting-label"><span>VAE Latent Dim (metadata)</span><span class="setting-val" id="val-latent">32</span></div>
|
| 433 |
<input type="range" id="cfg-latent" min="8" max="128" step="8" value="32">
|
| 434 |
</div>
|
| 435 |
<div class="setting">
|
| 436 |
+
<div class="setting-label"><span>Filter Threshold (metadata)</span><span class="setting-val" id="val-filter">0.70</span></div>
|
| 437 |
<input type="range" id="cfg-filter" min="0.1" max="0.9" step="0.05" value="0.7">
|
| 438 |
</div>
|
| 439 |
<div class="setting">
|
|
|
|
| 445 |
<option value="olmo2-1b">OLMo-2-1B (AllenAI)</option>
|
| 446 |
<option value="tinyllama-11b">TinyLlama-1.1B (TinyLlama)</option>
|
| 447 |
</select>
|
| 448 |
+
<div class="small text-mute mt-8">Reference only — metadata used in export. Actual model is character-level bigram. GRPO training uses group size and KL penalty; VAE fields are recorded in export metadata only.</div>
|
| 449 |
</div>
|
| 450 |
</div>
|
| 451 |
</section>
|
|
|
|
| 509 |
<span class="small text-mute" style="align-self:center;" id="osc-result"></span>
|
| 510 |
</div>
|
| 511 |
<div class="small text-mute mt-8">
|
| 512 |
+
Four incommensurate frequencies (1, phi, 2, pi). Coherent equal-weight superposition — |c_i|² is invariant under Hamiltonian evolution, so probabilities stay at 0.25 each. Measurement collapse drives the export seed.
|
| 513 |
</div>
|
| 514 |
</div>
|
| 515 |
</section>
|
|
|
|
| 594 |
const $ = (id) => document.getElementById(id);
|
| 595 |
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
| 596 |
|
| 597 |
+
// Production: suppress info/ok logs, keep warn + err visible in the Console / API panes.
|
| 598 |
+
// Success feedback is provided by step markers, progress bar, metrics, and status chips.
|
| 599 |
+
const LOG_ONLY_ERRORS = true;
|
| 600 |
+
|
| 601 |
function factorial(n) {
|
| 602 |
if (n <= 1) return 1;
|
| 603 |
let r = 1;
|
|
|
|
| 729 |
constructor() { this.nodes = new Map(); this.edges = new Map(); }
|
| 730 |
clear() { this.nodes.clear(); this.edges.clear(); }
|
| 731 |
addNode(id, data = {}) {
|
| 732 |
+
if (!this.nodes.has(id)) {
|
| 733 |
+
// New node: start with base weight 1; if data.weight provided, it replaces base.
|
| 734 |
+
this.nodes.set(id, Object.assign({ id, weight: 1 }, data));
|
| 735 |
+
} else {
|
| 736 |
+
// Existing node: accumulate weight from data onto current weight, then apply other fields.
|
| 737 |
const n = this.nodes.get(id);
|
| 738 |
+
const prevW = (typeof n.weight === "number" ? n.weight : 1);
|
| 739 |
+
const addW = (typeof data.weight === "number" ? data.weight : 0);
|
| 740 |
Object.assign(n, data);
|
| 741 |
+
n.weight = prevW + addW;
|
| 742 |
}
|
| 743 |
return this.nodes.get(id);
|
| 744 |
}
|
|
|
|
| 928 |
this.apiFanOut = new APIFanOut((m, c) => this.apiLog(m, c));
|
| 929 |
this.corpus = FALLBACK_NAMES.slice();
|
| 930 |
|
| 931 |
+
// Persistent trajectory cache for cache hit/miss accounting across training steps.
|
| 932 |
+
this.cache = new Map();
|
| 933 |
+
|
| 934 |
this.metrics = {
|
| 935 |
trainingSteps: 0,
|
| 936 |
finalLoss: 0,
|
|
|
|
| 947 |
}
|
| 948 |
|
| 949 |
log(msg, cls = "") {
|
| 950 |
+
if (LOG_ONLY_ERRORS && cls !== "warn" && cls !== "err") return;
|
| 951 |
const term = $("terminal");
|
| 952 |
if (!term) return;
|
| 953 |
const time = new Date().toLocaleTimeString("en-US", { hour12: false });
|
|
|
|
| 959 |
while (term.children.length > 300) term.removeChild(term.firstChild);
|
| 960 |
}
|
| 961 |
apiLog(msg, cls = "") {
|
| 962 |
+
if (LOG_ONLY_ERRORS && cls !== "err") return;
|
| 963 |
const log = $("api-log");
|
| 964 |
if (!log) return;
|
| 965 |
const time = new Date().toLocaleTimeString("en-US", { hour12: false });
|
|
|
|
| 973 |
|
| 974 |
setProgress(pct, task) {
|
| 975 |
const p = Math.max(0, Math.min(100, pct));
|
| 976 |
+
const fill = $("progress-fill");
|
| 977 |
+
if (fill) fill.style.width = p + "%";
|
| 978 |
+
const pctEl = $("progress-pct");
|
| 979 |
+
if (pctEl) pctEl.textContent = Math.round(p) + "%";
|
| 980 |
+
if (task !== undefined) {
|
| 981 |
+
const taskEl = $("progress-task");
|
| 982 |
+
if (taskEl) taskEl.textContent = task;
|
| 983 |
+
}
|
| 984 |
+
}
|
| 985 |
+
setProgressLabel(label) {
|
| 986 |
+
const p = $("progress-label");
|
| 987 |
+
if (p) p.textContent = label;
|
| 988 |
+
const ps = $("pipeline-status");
|
| 989 |
+
if (ps) ps.textContent = label;
|
| 990 |
}
|
|
|
|
| 991 |
|
| 992 |
updateMetrics() {
|
| 993 |
$("m-steps").textContent = String(this.metrics.trainingSteps);
|
|
|
|
| 1287 |
}
|
| 1288 |
}
|
| 1289 |
|
| 1290 |
+
// Uses persistent this.cache so cacheHits/cacheMisses accurately reflect
|
| 1291 |
+
// repeated high-reward trajectories across training steps.
|
| 1292 |
updateCache(trajectories) {
|
| 1293 |
const threshold = 0.9;
|
|
|
|
| 1294 |
const maxSize = 512;
|
| 1295 |
for (const tr of trajectories) {
|
| 1296 |
if (tr.reward > threshold) {
|
| 1297 |
const key = tr.text.substring(0, 20);
|
| 1298 |
+
if (!this.cache.has(key)) {
|
| 1299 |
+
this.cache.set(key, { text: tr.text, reward: tr.reward });
|
| 1300 |
+
if (this.cache.size > maxSize) {
|
| 1301 |
+
const oldest = this.cache.keys().next().value;
|
| 1302 |
+
if (oldest !== undefined) this.cache.delete(oldest);
|
| 1303 |
+
}
|
| 1304 |
this.metrics.cacheMisses++;
|
| 1305 |
} else {
|
| 1306 |
this.metrics.cacheHits++;
|
|
|
|
| 1404 |
this.updateOscDisplay();
|
| 1405 |
const msg = "osc " + m.oscillator + " E=" + m.energy.toFixed(3) + " x=" + m.x.toFixed(4);
|
| 1406 |
$("osc-result").textContent = msg;
|
| 1407 |
+
const os = $("osc-status");
|
| 1408 |
+
if (os) os.textContent = "superposition · " + this.quantumMeasurements.length + " measured";
|
| 1409 |
this.log("Quantum collapse: " + msg);
|
| 1410 |
return m;
|
| 1411 |
}
|
|
|
|
| 1428 |
|
| 1429 |
const modelJson = {
|
| 1430 |
format: "micro-distill-bigram-v1",
|
| 1431 |
+
version: "3.1.2",
|
| 1432 |
arch: policyArch,
|
| 1433 |
created: new Date().toISOString(),
|
| 1434 |
bos_token: this.bos,
|
|
|
|
| 1650 |
' prompts = []',
|
| 1651 |
' i = 0',
|
| 1652 |
' while i < len(args):',
|
| 1653 |
+
' if args[i] == "--temperature":',
|
| 1654 |
+
' if i + 1 < len(args):',
|
| 1655 |
+
' try:',
|
| 1656 |
+
' temperature = float(args[i + 1])',
|
| 1657 |
+
' except ValueError:',
|
| 1658 |
+
' print("Warning: invalid --temperature value, using 0.9", file=sys.stderr)',
|
| 1659 |
+
' i += 2',
|
| 1660 |
+
' else:',
|
| 1661 |
+
' print("Warning: --temperature requires a value, using 0.9", file=sys.stderr)',
|
| 1662 |
+
' i += 1',
|
| 1663 |
' elif args[i] in ("--help", "-h"):',
|
| 1664 |
' print("Usage: python3 test.py [prompt...] [--temperature T]")',
|
| 1665 |
' sys.exit(0)',
|
|
|
|
| 1763 |
'',
|
| 1764 |
'```bash',
|
| 1765 |
'python3 test.py alice',
|
| 1766 |
+
'# => alice… (seed-dependent continuation)',
|
| 1767 |
'```',
|
| 1768 |
'',
|
| 1769 |
'### Custom temperature',
|
|
|
|
| 2117 |
if (files.length > 0) {
|
| 2118 |
if (this.selectedPreviewIndex >= files.length) this.selectedPreviewIndex = 0;
|
| 2119 |
this.renderPreview(files, this.selectedPreviewIndex);
|
| 2120 |
+
} else {
|
| 2121 |
+
$("file-preview").textContent = "No files selected.";
|
| 2122 |
}
|
| 2123 |
}
|
| 2124 |
|
|
|
|
| 2176 |
this.kgSeed = 42;
|
| 2177 |
this.quantumMeasurements = [];
|
| 2178 |
this.corpus = FALLBACK_NAMES.slice();
|
| 2179 |
+
this.cache = new Map();
|
| 2180 |
this.metrics = { trainingSteps: 0, finalLoss: 0, averageReward: 0, cacheHits: 0, cacheMisses: 0, filteredCount: 0, totalSamples: 0, vaeLoss: 0 };
|
| 2181 |
+
this.superposition = new Superposition4(1337);
|
| 2182 |
+
this.apiFanOut = new APIFanOut((m, c) => this.apiLog(m, c));
|
| 2183 |
+
this.lastCollapse = null;
|
| 2184 |
+
this.selectedPreviewIndex = 0;
|
| 2185 |
+
this.modelFiles = [];
|
| 2186 |
this.markStep("fetch", "active", "");
|
| 2187 |
this.markStep("train", "", "");
|
| 2188 |
this.markStep("export", "", "");
|
|
|
|
| 2192 |
this.setProgressLabel("idle");
|
| 2193 |
this.updateOscDisplay();
|
| 2194 |
$("osc-result").textContent = "";
|
| 2195 |
+
const os = $("osc-status");
|
| 2196 |
+
if (os) os.textContent = "superposition";
|
| 2197 |
this.log("System reset.");
|
| 2198 |
}
|
| 2199 |
}
|
|
|
|
| 2298 |
'<div class="wiz-info">',
|
| 2299 |
'<strong>Status:</strong> <span id="wiz-export-status">ready</span>',
|
| 2300 |
"</div>",
|
| 2301 |
+
'<button class="btn btn-primary btn-lg btn-block" id="wiz-run-export">Open Export Panel</button>'
|
| 2302 |
],
|
| 2303 |
next: "Done",
|
| 2304 |
back: null
|
|
|
|
| 2337 |
|
| 2338 |
if (id === "fetch") {
|
| 2339 |
const btn = $("wiz-run-fetch");
|
| 2340 |
+
if (this.engine.fetching && btn) btn.disabled = true;
|
| 2341 |
if (btn) btn.addEventListener("click", async () => {
|
| 2342 |
+
if (this.engine.fetching) {
|
| 2343 |
+
$("wiz-fetch-status").textContent = "fetch already in progress";
|
| 2344 |
+
return;
|
| 2345 |
+
}
|
| 2346 |
btn.disabled = true;
|
| 2347 |
$("wiz-fetch-status").textContent = "fetching...";
|
| 2348 |
const ok = await this.engine.fetch();
|
|
|
|
| 2374 |
}
|
| 2375 |
if (btn) btn.addEventListener("click", async () => {
|
| 2376 |
btn.disabled = true;
|
| 2377 |
+
$("wiz-export-status").textContent = "opening export panel...";
|
| 2378 |
await this.engine.showExportModal();
|
| 2379 |
+
$("wiz-export-status").textContent = "ready - configure options in the export panel";
|
| 2380 |
btn.disabled = false;
|
| 2381 |
});
|
| 2382 |
}
|
|
|
|
| 2448 |
});
|
| 2449 |
}
|
| 2450 |
|
| 2451 |
+
function setupExportOptions() {
|
| 2452 |
+
// Keep the file list, preview, and total size in sync with checkbox state.
|
| 2453 |
+
// No-op when the bundle hasn't been built yet (modelFiles empty).
|
| 2454 |
+
const boxes = document.querySelectorAll(".opt input[type='checkbox']");
|
| 2455 |
+
boxes.forEach((cb) => {
|
| 2456 |
+
cb.addEventListener("change", () => {
|
| 2457 |
+
if (!engine || !engine.modelFiles || engine.modelFiles.length === 0) return;
|
| 2458 |
+
const filtered = engine.applyExportOptions();
|
| 2459 |
+
engine.renderFileList(filtered);
|
| 2460 |
+
engine.renderExportSize(filtered);
|
| 2461 |
+
});
|
| 2462 |
+
});
|
| 2463 |
+
}
|
| 2464 |
+
|
| 2465 |
function setupButtons() {
|
| 2466 |
$("btn-fetch").addEventListener("click", async () => {
|
| 2467 |
$("btn-fetch").disabled = true;
|
|
|
|
| 2509 |
engine = new Engine();
|
| 2510 |
wizard = new Wizard(engine);
|
| 2511 |
|
| 2512 |
+
engine.log("Micro Distillery v3.1.2 initialized.");
|
| 2513 |
+
engine.log("Data sources (2026): HuggingFace + GitHub");
|
| 2514 |
engine.log("Click Setup Wizard in the header, or use the pipeline.");
|
| 2515 |
engine.log("Ready.");
|
| 2516 |
|
| 2517 |
+
window.addEventListener("error", (e) => {
|
| 2518 |
+
try { engine.log("Unhandled: " + (e.message || e.error || e), "err"); } catch (_) {}
|
| 2519 |
+
});
|
| 2520 |
+
window.addEventListener("unhandledrejection", (e) => {
|
| 2521 |
+
const r = e && e.reason;
|
| 2522 |
+
const m = r && r.message ? r.message : String(r);
|
| 2523 |
+
try { engine.log("Unhandled rejection: " + m, "err"); } catch (_) {}
|
| 2524 |
+
});
|
| 2525 |
+
|
| 2526 |
setupTabs();
|
| 2527 |
setupSliders();
|
| 2528 |
setupCloseButtons();
|
| 2529 |
+
setupExportOptions();
|
| 2530 |
setupButtons();
|
| 2531 |
engine.updateMetrics();
|
| 2532 |
engine.updateOscDisplay();
|
| 2533 |
engine.renderGraph();
|
| 2534 |
engine.setProgress(0, "idle");
|
| 2535 |
|
| 2536 |
+
let seen = null;
|
| 2537 |
+
try { seen = localStorage.getItem("md_wizard_seen"); } catch (_) {}
|
| 2538 |
if (!seen) {
|
| 2539 |
setTimeout(() => {
|
| 2540 |
+
try { wizard.open(); } catch (_) {}
|
| 2541 |
+
try { localStorage.setItem("md_wizard_seen", "1"); } catch (_) {}
|
| 2542 |
}, 400);
|
| 2543 |
}
|
| 2544 |
|
|
|
|
| 2551 |
window.addEventListener("resize", () => engine.renderGraph());
|
| 2552 |
|
| 2553 |
if ("serviceWorker" in navigator) {
|
| 2554 |
+
navigator.serviceWorker.register("sw.js").catch(() => { /* expected when sw.js absent */ });
|
| 2555 |
}
|
| 2556 |
}
|
| 2557 |
|