mlx-bun 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +362 -0
- package/THIRD_PARTY_LICENSES.md +41 -0
- package/bin/mlx-bun.mjs +32 -0
- package/docs/curve-designer.html +303 -0
- package/docs/design/adapters-end-to-end.md +201 -0
- package/docs/design/compat-cli-surface-design.md +227 -0
- package/docs/design/docs-reorg-plan.md +152 -0
- package/docs/design/hlg-sampling.md +340 -0
- package/docs/design/memory-system.md +339 -0
- package/docs/design/optimization_plan.md +344 -0
- package/docs/design/parallel-slots.md +515 -0
- package/docs/design/runtime-isolation.md +247 -0
- package/docs/design/segmented-backward-training.md +508 -0
- package/docs/investigations/chunk-finetune-experiment.md +84 -0
- package/docs/investigations/curve-bisector-routing.md +123 -0
- package/docs/investigations/curve-runs/bisector-route.json +98 -0
- package/docs/investigations/curve-runs/bisector-trace.json +1393 -0
- package/docs/investigations/curve-runs/curve-terrain.json +1179 -0
- package/docs/investigations/curve-runs/curve-terrain.svg +42 -0
- package/docs/investigations/curve-terrain.html +105 -0
- package/docs/investigations/expert-offload-single-user-moe.md +292 -0
- package/docs/investigations/hlg-ab.html +34 -0
- package/docs/investigations/hlg-explorer.html +238 -0
- package/docs/investigations/hlg-figs/cliff.svg +1 -0
- package/docs/investigations/hlg-figs/cross.svg +1 -0
- package/docs/investigations/hlg-figs/edges.svg +1 -0
- package/docs/investigations/hlg-figs/k20-grids.svg +1 -0
- package/docs/investigations/hlg-figs/k20-peaks.svg +1 -0
- package/docs/investigations/hlg-figs/lw-curve.svg +1 -0
- package/docs/investigations/hlg-figs/terrain.svg +1 -0
- package/docs/investigations/hlg-report.html +262 -0
- package/docs/investigations/hlg-runs/hlg-ab.json +149 -0
- package/docs/investigations/hlg-runs/hlg-blind-prompts.md +87 -0
- package/docs/investigations/hlg-runs/hlg-blind.json +107 -0
- package/docs/investigations/hlg-runs/hlg-cliff.json +197 -0
- package/docs/investigations/hlg-runs/hlg-cross.json +505 -0
- package/docs/investigations/hlg-runs/hlg-edge.json +388 -0
- package/docs/investigations/hlg-runs/hlg-eval1.json +25 -0
- package/docs/investigations/hlg-runs/hlg-frontier.json +86 -0
- package/docs/investigations/hlg-runs/hlg-grid.json +242 -0
- package/docs/investigations/hlg-runs/hlg-grid2.json +343 -0
- package/docs/investigations/hlg-runs/hlg-lw-coarse.json +110 -0
- package/docs/investigations/hlg-runs/hlg-map.json +383 -0
- package/docs/investigations/hlg-runs/run0-original.log +159 -0
- package/docs/investigations/hlg-runs/runA-recommended.log +131 -0
- package/docs/investigations/hlg-runs/runAA-cliff-cpm5.log +26 -0
- package/docs/investigations/hlg-runs/runAB-grid2-e4b.log +18 -0
- package/docs/investigations/hlg-runs/runAC-peak-e4b-partial.log +25 -0
- package/docs/investigations/hlg-runs/runAD-ab-samples.log +8 -0
- package/docs/investigations/hlg-runs/runAE-edge-e4b.log +51 -0
- package/docs/investigations/hlg-runs/runAF-logit-calibration.log +10 -0
- package/docs/investigations/hlg-runs/runAG-eval-config2.log +16 -0
- package/docs/investigations/hlg-runs/runB-gain-variants.log +192 -0
- package/docs/investigations/hlg-runs/runC-pivots.log +162 -0
- package/docs/investigations/hlg-runs/runD-oetf.log +132 -0
- package/docs/investigations/hlg-runs/runE-eotf.log +162 -0
- package/docs/investigations/hlg-runs/runF-shaper-working.log +86 -0
- package/docs/investigations/hlg-runs/runG-shaper-sweep.log +101 -0
- package/docs/investigations/hlg-runs/runH-wsweep.log +176 -0
- package/docs/investigations/hlg-runs/runI-asweep.log +176 -0
- package/docs/investigations/hlg-runs/runJ-knobmap.log +49 -0
- package/docs/investigations/hlg-runs/runK-frontier.log +19 -0
- package/docs/investigations/hlg-runs/runL-widemap.log +65 -0
- package/docs/investigations/hlg-runs/runM-frontier-emb.log +15 -0
- package/docs/investigations/hlg-runs/runN-verify.log +116 -0
- package/docs/investigations/hlg-runs/runO-frontier-seed5000.log +15 -0
- package/docs/investigations/hlg-runs/runP-grid-AxSm.log +15 -0
- package/docs/investigations/hlg-runs/runQ-grid-tgW.log +15 -0
- package/docs/investigations/hlg-runs/runR-blind-transcript.log +79 -0
- package/docs/investigations/hlg-runs/runS-cross-coherence.log +33 -0
- package/docs/investigations/hlg-runs/runT-cross-cpm5.log +33 -0
- package/docs/investigations/hlg-runs/runU-cross-12b.log +33 -0
- package/docs/investigations/hlg-runs/runV-lw-e4b.log +22 -0
- package/docs/investigations/hlg-runs/runW-lw-12b.log +22 -0
- package/docs/investigations/hlg-runs/runX-lw-cpm5.log +22 -0
- package/docs/investigations/hlg-runs/runY-cliff-e4b.log +26 -0
- package/docs/investigations/hlg-runs/runZ-cliff-12b.log +26 -0
- package/docs/investigations/hlg-sampling-investigation.md +970 -0
- package/docs/investigations/lab-build-journal.md +157 -0
- package/docs/investigations/pi-builtin-investigation.md +308 -0
- package/docs/investigations/starter-model-port-handoff.md +323 -0
- package/docs/planning/IDEAS.md +26 -0
- package/docs/planning/PRODUCT_ROADMAP.md +426 -0
- package/docs/planning/ResearchTopics.md +119 -0
- package/docs/planning/chunk-task-roadmap.md +77 -0
- package/docs/planning/journal.md +155 -0
- package/docs/reference/distribution.md +121 -0
- package/docs/reference/embedding.md +168 -0
- package/docs/reference/library-api.md +153 -0
- package/docs/reference/server-api.md +224 -0
- package/docs/reference/server-config.md +243 -0
- package/docs/segmented-backward-handoff.md +148 -0
- package/package.json +68 -0
- package/src/anthropic.ts +491 -0
- package/src/chat-template.ts +186 -0
- package/src/cli.ts +1075 -0
- package/src/config.ts +229 -0
- package/src/curve-sampler.ts +122 -0
- package/src/dataset/generators.ts +1087 -0
- package/src/dataset/index.ts +12 -0
- package/src/dataset/job.ts +81 -0
- package/src/dataset/llm.ts +71 -0
- package/src/dataset/registry.ts +528 -0
- package/src/download.ts +283 -0
- package/src/eval/README.md +86 -0
- package/src/eval/kl-prompts.ts +29 -0
- package/src/eval/kl.ts +294 -0
- package/src/eval/quality-db.ts +92 -0
- package/src/eval/runner.ts +102 -0
- package/src/eval/score.ts +49 -0
- package/src/eval/tasks/bfcl.ts +500 -0
- package/src/eval/tasks/gsm8k.ts +85 -0
- package/src/eval/tasks/hashhop.ts +109 -0
- package/src/eval/tasks/humaneval.ts +252 -0
- package/src/eval/tasks/ifeval.ts +354 -0
- package/src/eval/tasks/mmlu.ts +145 -0
- package/src/evaldb.ts +199 -0
- package/src/expert-offload-build.ts +77 -0
- package/src/expert-offload.ts +61 -0
- package/src/expert-trace.ts +67 -0
- package/src/fit.ts +254 -0
- package/src/generate.ts +451 -0
- package/src/harness-pi.ts +177 -0
- package/src/hf-push.ts +628 -0
- package/src/index.ts +22 -0
- package/src/jobs/db.ts +139 -0
- package/src/jobs/index.ts +29 -0
- package/src/jobs/job-entry.ts +106 -0
- package/src/jobs/runner.ts +304 -0
- package/src/jobs/sse.ts +114 -0
- package/src/jobs/types.ts +58 -0
- package/src/kv-store.ts +185 -0
- package/src/lora.ts +314 -0
- package/src/md-modules.d.ts +7 -0
- package/src/mlx/array.ts +237 -0
- package/src/mlx/autograd.ts +267 -0
- package/src/mlx/checkpoint.ts +116 -0
- package/src/mlx/compile.ts +158 -0
- package/src/mlx/custom-vjp.ts +140 -0
- package/src/mlx/ffi.ts +433 -0
- package/src/mlx/metal-kernel.ts +130 -0
- package/src/mlx/ops.ts +707 -0
- package/src/mmap.ts +90 -0
- package/src/model/batched-mask.ts +204 -0
- package/src/model/batched-rotating.ts +300 -0
- package/src/model/compiled-decode.ts +681 -0
- package/src/model/factory.ts +27 -0
- package/src/model/fingerprint.ts +33 -0
- package/src/model/flash-attention.ts +674 -0
- package/src/model/fused-decode-kernel.ts +305 -0
- package/src/model/fused-geglu-kernel.ts +87 -0
- package/src/model/gemma4-base.ts +1616 -0
- package/src/model/gemma4.ts +1012 -0
- package/src/model/generated/gemma4-12b.ts +526 -0
- package/src/model/generated/gemma4-26b.ts +500 -0
- package/src/model/generated/gemma4-e4b.ts +757 -0
- package/src/model/generated/index.ts +18 -0
- package/src/model/minicpm5.ts +278 -0
- package/src/model/qwen3-delta.ts +224 -0
- package/src/model/qwen3_5.ts +429 -0
- package/src/model/support.ts +46 -0
- package/src/native-pack.ts +152 -0
- package/src/pi-provider.ts +95 -0
- package/src/pi-terminal.ts +264 -0
- package/src/pi-web.ts +924 -0
- package/src/preflight.ts +123 -0
- package/src/prompt-cache.ts +113 -0
- package/src/quantize/allocator.ts +627 -0
- package/src/quantize/calibration.ts +180 -0
- package/src/quantize/config-writer.ts +132 -0
- package/src/quantize/index.ts +57 -0
- package/src/quantize/job.ts +136 -0
- package/src/quantize/quantizer.ts +462 -0
- package/src/quantize/safetensors-writer.ts +171 -0
- package/src/quantize/sensitivity.ts +234 -0
- package/src/registry.ts +336 -0
- package/src/responses.ts +774 -0
- package/src/safetensors.ts +158 -0
- package/src/sampler.ts +517 -0
- package/src/serve/batch-scheduler.ts +362 -0
- package/src/serve/generation-gateway.ts +160 -0
- package/src/server.ts +1891 -0
- package/src/spec/drafter.ts +261 -0
- package/src/spec/generate.ts +221 -0
- package/src/status-page.html +497 -0
- package/src/tokenizer.ts +38 -0
- package/src/tool-call.ts +242 -0
- package/src/train/dataset.ts +461 -0
- package/src/train/export.ts +32 -0
- package/src/train/forward.ts +229 -0
- package/src/train/index.ts +43 -0
- package/src/train/job.ts +148 -0
- package/src/train/lora-params.ts +194 -0
- package/src/train/loss.ts +342 -0
- package/src/train/merge.ts +195 -0
- package/src/train/optimizer.ts +176 -0
- package/src/train/rank.ts +101 -0
- package/src/train/segmented.ts +520 -0
- package/src/train/trainer.ts +600 -0
- package/src/tui.ts +161 -0
- package/src/vision/embedder.ts +168 -0
- package/src/vision/preprocess.ts +247 -0
- package/src/vision/prompt.ts +158 -0
- package/src/vision/siglip.ts +599 -0
- package/src/web/app.html +2471 -0
- package/src/web/skills/web-research/SKILL.md +44 -0
- package/src/web/skills.ts +59 -0
- package/src/web-tools.ts +426 -0
- package/src/weights.ts +91 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<svg viewBox="0 0 980 560" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="t d" font-family="ui-sans-serif,system-ui,sans-serif">
|
|
2
|
+
<title id="t">Curve terrain map</title>
|
|
3
|
+
<desc id="d">First-pass terrain of custom log-prob curves. X is mid y at one percent, Y is shoulder y at nine percent, Z is rough diversity delta after junk penalty.</desc>
|
|
4
|
+
<rect width="980" height="560" fill="#f7f9fc"/>
|
|
5
|
+
<text x="38" y="42" font-size="22" font-weight="700" fill="#172033">Curve Terrain Map</text>
|
|
6
|
+
<text x="38" y="65" font-size="12.5" fill="#667085">mlx-community/gemma-4-e4b-it-OptiQ-4bit · N=2 · seed=7300 · default diversity 0.803 · score = diversity delta minus junk penalty</text>
|
|
7
|
+
<g transform="translate(250 50)"><path d="M130.0 340.0 L187.5 360.5 L245.0 381.0 L302.5 285.2 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M74.6 315.3 L132.1 340.0 L189.6 360.7 L247.1 327.2 L304.6 276.9 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M23.6 322.2 L81.1 342.7 L138.6 418.5 L196.1 364.9 L253.6 397.3 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M-37.1 235.0 L20.4 255.4 L77.9 300.3 L135.4 324.3 L192.9 343.7 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M-100.0 408.8 L-42.5 364.0 L15.0 348.4 L72.5 318.5 L130.0 339.0 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M130.0 340.0 L74.6 315.3 L23.6 322.2 L-37.1 235.0 L-100.0 408.8 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M187.5 360.5 L132.1 340.0 L81.1 342.7 L20.4 255.4 L-42.5 364.0 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M245.0 381.0 L189.6 360.7 L138.6 418.5 L77.9 300.3 L15.0 348.4 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M302.5 285.2 L247.1 327.2 L196.1 364.9 L135.4 324.3 L72.5 318.5 " fill="none" stroke="#cbd5e1" stroke-width="1"/><path d="M304.6 276.9 L253.6 397.3 L192.9 343.7 L130.0 339.0 " fill="none" stroke="#cbd5e1" stroke-width="1"/><circle cx="-37.1" cy="235.0" r="9.0" fill="rgb(8,145,178)" stroke="white" stroke-width="2">
|
|
8
|
+
<title>mid=0.5, shoulder=28, diversity=0.999, score=0.196, junk=0.0%</title></circle><circle cx="20.4" cy="255.4" r="9.0" fill="rgb(8,145,178)" stroke="white" stroke-width="2">
|
|
9
|
+
<title>mid=1, shoulder=28, diversity=0.999, score=0.196, junk=0.0%</title></circle><circle cx="304.6" cy="276.9" r="9.0" fill="rgb(8,145,178)" stroke="white" stroke-width="2">
|
|
10
|
+
<title>mid=8, shoulder=10, diversity=1.000, score=0.197, junk=0.0%</title></circle><circle cx="302.5" cy="285.2" r="7.8" fill="rgb(17,131,195)" stroke="white" stroke-width="2">
|
|
11
|
+
<title>mid=4, shoulder=6, diversity=0.922, score=0.119, junk=0.0%</title></circle><circle cx="77.9" cy="300.3" r="8.4" fill="rgb(12,138,187)" stroke="white" stroke-width="2">
|
|
12
|
+
<title>mid=2, shoulder=28, diversity=0.960, score=0.157, junk=0.0%</title></circle><circle cx="74.6" cy="315.3" r="6.1" fill="rgb(29,111,220)" stroke="white" stroke-width="2">
|
|
13
|
+
<title>mid=0.5, shoulder=10, diversity=0.806, score=0.003, junk=0.0%</title></circle><circle cx="72.5" cy="318.5" r="9.0" fill="rgb(8,145,178)" stroke="white" stroke-width="2">
|
|
14
|
+
<title>mid=4, shoulder=50, diversity=1.000, score=0.197, junk=0.0%</title></circle><circle cx="23.6" cy="322.2" r="6.4" fill="rgb(27,115,216)" stroke="white" stroke-width="2">
|
|
15
|
+
<title>mid=0.5, shoulder=16, diversity=0.825, score=0.022, junk=0.0%</title></circle><circle cx="135.4" cy="324.3" r="8.3" fill="rgb(13,137,188)" stroke="white" stroke-width="2">
|
|
16
|
+
<title>mid=4, shoulder=28, diversity=0.955, score=0.152, junk=0.0%</title></circle><circle cx="247.1" cy="327.2" r="7.3" fill="rgb(20,125,203)" stroke="white" stroke-width="2">
|
|
17
|
+
<title>mid=4, shoulder=10, diversity=0.886, score=0.083, junk=0.0%</title></circle><circle cx="130.0" cy="339.0" r="9.0" fill="rgb(8,145,178)" stroke="white" stroke-width="2">
|
|
18
|
+
<title>mid=8, shoulder=50, diversity=1.000, score=0.197, junk=0.0%</title></circle><circle cx="130.0" cy="340.0" r="5.0" fill="rgb(37,99,235)" stroke="white" stroke-width="2">
|
|
19
|
+
<title>mid=0.5, shoulder=6, diversity=0.735, score=-0.068, junk=0.0%</title></circle><circle cx="132.1" cy="340.0" r="6.0" fill="rgb(30,110,221)" stroke="white" stroke-width="2">
|
|
20
|
+
<title>mid=1, shoulder=10, diversity=0.800, score=-0.003, junk=0.0%</title></circle><circle cx="81.1" cy="342.7" r="6.4" fill="rgb(27,115,216)" stroke="white" stroke-width="2">
|
|
21
|
+
<title>mid=1, shoulder=16, diversity=0.825, score=0.022, junk=0.0%</title></circle><circle cx="192.9" cy="343.7" r="8.3" fill="rgb(13,137,187)" stroke="white" stroke-width="2">
|
|
22
|
+
<title>mid=8, shoulder=28, diversity=0.956, score=0.153, junk=0.0%</title></circle><circle cx="15.0" cy="348.4" r="7.8" fill="rgb(17,131,195)" stroke="white" stroke-width="2">
|
|
23
|
+
<title>mid=2, shoulder=50, diversity=0.919, score=0.116, junk=0.0%</title></circle><circle cx="187.5" cy="360.5" r="5.0" fill="rgb(37,99,235)" stroke="white" stroke-width="2">
|
|
24
|
+
<title>mid=1, shoulder=6, diversity=0.735, score=-0.068, junk=0.0%</title></circle><circle cx="189.6" cy="360.7" r="6.0" fill="rgb(30,110,221)" stroke="white" stroke-width="2">
|
|
25
|
+
<title>mid=2, shoulder=10, diversity=0.799, score=-0.004, junk=0.0%</title></circle><circle cx="-42.5" cy="364.0" r="6.9" fill="rgb(23,121,208)" stroke="white" stroke-width="2">
|
|
26
|
+
<title>mid=1, shoulder=50, diversity=0.861, score=0.058, junk=0.0%</title></circle><circle cx="196.1" cy="364.9" r="6.8" fill="rgb(24,120,209)" stroke="white" stroke-width="2">
|
|
27
|
+
<title>mid=4, shoulder=16, diversity=0.855, score=0.052, junk=0.0%</title></circle><circle cx="245.0" cy="381.0" r="5.0" fill="rgb(37,99,235)" stroke="white" stroke-width="2">
|
|
28
|
+
<title>mid=2, shoulder=6, diversity=0.735, score=-0.068, junk=0.0%</title></circle><circle cx="253.6" cy="397.3" r="6.5" fill="rgb(26,116,213)" stroke="white" stroke-width="2">
|
|
29
|
+
<title>mid=8, shoulder=16, diversity=0.836, score=0.033, junk=0.0%</title></circle><circle cx="-100.0" cy="408.8" r="5.3" fill="rgb(35,103,230)" stroke="white" stroke-width="2">
|
|
30
|
+
<title>mid=0.5, shoulder=50, diversity=0.767, score=-0.047, junk=0.1%</title></circle><circle cx="138.6" cy="418.5" r="5.0" fill="rgb(37,99,235)" stroke="white" stroke-width="2">
|
|
31
|
+
<title>mid=2, shoulder=16, diversity=0.736, score=-0.067, junk=0.0%</title></circle></g>
|
|
32
|
+
<g transform="translate(38 420)">
|
|
33
|
+
<text x="0" y="0" font-size="14" font-weight="700" fill="#172033">Highest first-pass cells</text><text x="0" y="24" font-size="12.5" fill="#344054">1. mid 8, shoulder 50 · diversity 1.000 · score 0.197 · junk 0.0%</text><text x="0" y="46" font-size="12.5" fill="#344054">2. mid 4, shoulder 50 · diversity 1.000 · score 0.197 · junk 0.0%</text><text x="0" y="68" font-size="12.5" fill="#344054">3. mid 8, shoulder 10 · diversity 1.000 · score 0.197 · junk 0.0%</text><text x="0" y="90" font-size="12.5" fill="#344054">4. mid 1, shoulder 28 · diversity 0.999 · score 0.196 · junk 0.0%</text><text x="0" y="112" font-size="12.5" fill="#344054">5. mid 0.5, shoulder 28 · diversity 0.999 · score 0.196 · junk 0.0%</text></g>
|
|
34
|
+
<g transform="translate(742 420)">
|
|
35
|
+
<rect x="0" y="-18" width="170" height="12" fill="url(#grad)"/>
|
|
36
|
+
<defs><linearGradient id="grad"><stop offset="0" stop-color="#2563eb"/><stop offset="1" stop-color="#0891b2"/></linearGradient></defs>
|
|
37
|
+
<text x="0" y="10" font-size="11.5" fill="#667085">low score</text>
|
|
38
|
+
<text x="112" y="10" font-size="11.5" fill="#667085">high score</text>
|
|
39
|
+
<text x="0" y="34" font-size="11.5" fill="#667085">red points would indicate junk penalty</text>
|
|
40
|
+
</g>
|
|
41
|
+
<text x="526" y="528" text-anchor="middle" font-size="12" fill="#667085">x: mid y@1% · y: shoulder y@9% · z: rough terrain score</text>
|
|
42
|
+
</svg>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8">
|
|
3
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<title>Curve Terrain Map</title>
|
|
5
|
+
<style>
|
|
6
|
+
:root{--bg:#f7f9fc;--ink:#172033;--muted:#667085;--panel:#fff;--line:#d8e0eb;--blue:#2563eb;--cyan:#0891b2;--bad:#dc2626;--good:#16a34a}
|
|
7
|
+
*{box-sizing:border-box}
|
|
8
|
+
body{margin:0;background:var(--bg);color:var(--ink);font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",ui-sans-serif,system-ui,sans-serif}
|
|
9
|
+
.wrap{max-width:1280px;margin:0 auto;padding:22px 22px 44px}
|
|
10
|
+
h1{font-size:21px;margin:0 0 4px}.sub{color:var(--muted);margin:0 0 18px}
|
|
11
|
+
.grid{display:grid;grid-template-columns:minmax(640px,1.15fr) minmax(340px,.85fr);gap:16px}
|
|
12
|
+
.panel{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px;box-shadow:0 10px 28px -26px rgba(15,23,42,.35)}
|
|
13
|
+
#gl{width:100%;height:650px;display:block;border-radius:8px;background:#f8fafc;cursor:grab}
|
|
14
|
+
#gl:active{cursor:grabbing}.row{display:flex;gap:14px;flex-wrap:wrap;margin-top:10px;color:var(--muted)}.row b{color:var(--ink)}
|
|
15
|
+
button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:6px 10px;font:600 12px inherit;cursor:pointer;color:var(--ink)}
|
|
16
|
+
table{width:100%;border-collapse:collapse;font-size:12px}td,th{border-bottom:1px solid var(--line);padding:6px;text-align:right}th:first-child,td:first-child{text-align:left}
|
|
17
|
+
.pill{display:inline-block;padding:2px 7px;border-radius:999px;background:#eef5ff;color:#1d4ed8;font-weight:700;font-size:11px}.bad{color:var(--bad);font-weight:700}.good{color:var(--good);font-weight:700}
|
|
18
|
+
pre{white-space:pre-wrap;background:#f3f6fa;border:1px solid var(--line);border-radius:8px;padding:10px;max-height:300px;overflow:auto}
|
|
19
|
+
.hint{font-size:12px;color:var(--muted);margin-top:8px}
|
|
20
|
+
@media(max-width:980px){.grid{grid-template-columns:1fr}#gl{height:500px}}
|
|
21
|
+
</style></head><body><div class="wrap">
|
|
22
|
+
<h1>Curve Terrain Map</h1>
|
|
23
|
+
<p class="sub">Native WebGL terrain from the first custom-curve sweep. Drag to orbit, wheel to zoom, click a point to inspect samples.</p>
|
|
24
|
+
<div class="grid">
|
|
25
|
+
<div class="panel">
|
|
26
|
+
<canvas id="gl"></canvas>
|
|
27
|
+
<div class="row" id="legend"></div>
|
|
28
|
+
<div class="hint">Axes: x = mid y@1%, y = shoulder y@9%, z = diversity delta vs default minus junk penalty.</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="panel">
|
|
31
|
+
<div id="summary"></div>
|
|
32
|
+
<h3>Selected Cell</h3>
|
|
33
|
+
<div id="cell">Click a point on the terrain.</div>
|
|
34
|
+
<h3>Cells</h3>
|
|
35
|
+
<div id="rows"></div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<script>
|
|
40
|
+
const DATA={"kind":"curve-terrain-v1","createdAt":"2026-06-15T21:32:23.548Z","baseUrl":"http://localhost:8090","model":"mlx-community/gemma-4-e4b-it-OptiQ-4bit","n":2,"seed":7300,"maxTokens":48,"axes":{"midY":[0.5,1,2,4,8],"shoulderY":[6,10,16,28,50]},"default":{"diversity":0.8030369796762122,"openJunk":0,"recipe":{"temperature":1,"topP":0.95,"topK":64},"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the North Atlantic, seemed to possess a mind of its own that evening, and when it rolled in, it carried more than just salt spray.","The fog, a thick, woolen blanket muffling the roar of the Atlantic, usually brought only the monotonous rhythm of the beam sweeping the treacherous coastline, but tonight, something else drifted in with the mist."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic** (Focusing on the instability of the past)\n\n> \"","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"The strangest thing about human memory is that it doesn"]}},"cells":[{"midY":0.5,"shoulderY":6,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":0.5},{"x_pct":9,"y_pct":6},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.735042006579431,"distinct2":0.8557692307692308,"openJunk":0,"meanLen":33,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the North Atlantic, seemed to possess a mind of its own that evening, and it was in its uncanny pattern that Silas first saw the light.","The fog, a thick, woolen blanket muffling the roar of the Atlantic, usually brought only the monotonous rhythm of the beam sweeping the treacherous coastline, but today, something else drifted in with the mist."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic (Focus on distortion)**\n\n> \"The strangest thing about human","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n\n> \"The strangest thing about human memory is **how it"]},"score":-0.06799497309678126},{"midY":1,"shoulderY":6,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":1},{"x_pct":9,"y_pct":6},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.7350404850550593,"distinct2":0.8294534412955465,"openJunk":0,"meanLen":31,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the ocean, finally dissolved enough for Silas to see the shape bobbing just beyond the beam of the revolving light.","The fog, a thick, woolen blanket muffling the roar of the Atlantic, usually brought only the monotonous rhythm of the beam sweeping the treacherous coastline, but today, something else drifted with it."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic (Focus on distortion)**\n\n> \"The strangest thing about human","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n\n> \"The strangest thing about human memory is **how it"]},"score":-0.06799649462115298},{"midY":2,"shoulderY":6,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":2},{"x_pct":9,"y_pct":6},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.735042006493251,"distinct2":0.8557692307692308,"openJunk":0,"meanLen":33.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the ocean, finally dissolved enough for Silas to see the shape bobbing just beyond the rhythmic sweep of the lamp's beam.","The fog, a thick, woolen blanket muffling the roar of the Atlantic, usually brought only the ghosts of distant ships and the screech of gulls, but this morning, it seemed to carry a distinct, unnatural scent of brine and cloves"],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic (Focus on distortion)**\n\n> \"The strangest thing about human","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n\n> \"The strangest thing about human memory is **how willingly"]},"score":-0.06799497318296122},{"midY":4,"shoulderY":6,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":4},{"x_pct":9,"y_pct":6},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9218364396543821,"distinct2":0.9375,"openJunk":0,"meanLen":26,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, silent blanket that swallowed the horizon whole, was not merely atmospheric this evening; it was actively *watching*.","The fog, a heavy, woolen blanket muffling the roar of the ocean, began to pulse with an uncanny, rhythmic luminescence near the tower's granite base."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the specific tone you want to strike:\n\n**Option 1: Poetic & Melancholic (Focus on Fading/Distortion)**\n\n> \"The","Here are a few options, depending on the *tone* you want to set (haunting, beautiful, or messy):\n\n**Option 1: (Haunting & Unreliable)**\n> The strangest thing about human memory is"]},"score":0.11879945997816987},{"midY":8,"shoulderY":6,"valid":false},{"midY":0.5,"shoulderY":10,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":0.5},{"x_pct":9,"y_pct":10},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8063750131373082,"distinct2":0.8890572390572391,"openJunk":0,"meanLen":32.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the North Atlantic, seemed to possess a mind of its own that evening, and when it finally banked against the tower's narrow lantern room, it brought with it something utterly","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape that didn't belong to the sea."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic** (Focusing on the fragility and shaping power of memory)","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"The strangest thing about human memory is that it doesn"]},"score":0.0033380334610959572},{"midY":1,"shoulderY":10,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":1},{"x_pct":9,"y_pct":10},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.7996102507913873,"distinct2":0.8851398601398601,"openJunk":0,"meanLen":32.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the ocean, finally dissolved enough for Silas to see the shape bobbing just beyond the beam of the revolving light—a glyph, impossibly intricate and not of any earthly craft","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape that didn't belong to the sea."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic** (Focusing on the way memory distorts time)\n\n>","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"The strangest thing about human memory is that it doesn"]},"score":-0.003426728884824981},{"midY":2,"shoulderY":10,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":2},{"x_pct":9,"y_pct":10},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.7993184562032293,"distinct2":0.8811274509803921,"openJunk":0,"meanLen":33.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the ocean, finally dissolved enough for Silas to see the shape bobbing just beyond the beam of the revolving light—a glyph, impossibly intricate and not of any earthly craft","The fog, a thick, woolen blanket muffling the roar of the Atlantic, usually brought only the monotonous rhythm of the beam sweeping the treacherous coastline, but today, something else drifted with it."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic** (Focusing on fragmentation)\n\n> \"...it’s that","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"The strangest thing about human memory is that it doesn"]},"score":-0.0037185234729829597},{"midY":4,"shoulderY":10,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":4},{"x_pct":9,"y_pct":10},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8859985049508804,"distinct2":0.9225628930817611,"openJunk":0,"meanLen":29.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, woolen blanket muffling the roar of the ocean, smelled oddly of cinnamon and something metallic when it finally parted just enough for Elias to see what lay bobbing near the rocks.","The fog, a heavy, woolen blanket muffling the roar of the Atlantic, usually served as a comfortable curtain for Silas, but tonight, it felt strangely inquisitive."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the specific tone you're aiming for:\n\n**Option 1: Focus on Distortion & Fluidity (Poetic/Philosophical)**\n\n> \"The","Here are a few options, depending on the *tone* you want to strike:\n\n**Poetic/Melancholy:**\n\n> **...how it doesn't capture experience; it spins narratives from the dust motes of what"]},"score":0.08296152527466816},{"midY":8,"shoulderY":10,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":8},{"x_pct":9,"y_pct":10},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9997133610048354,"distinct2":0.9435817805383022,"openJunk":0,"meanLen":31.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick, silent blanket muffling the roar of the ocean, finally dissolved enough for Silas to see it—a perfect, pale ring, bobbing impossibly at the edge of the light's sweeping beam.","The fog, a relentless, pearlescent blanket pressed against the granite tower, usually muffled the world into a quiet ache, but tonight, it carried a sound that scraped against the deep-set stillness of the keeper’s solitude."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the specific tone you're aiming for:\n\n**Option 1: Focus on Emotional Dissonance (Poetic/Melancholic)**\n\n> \"The","Here are a few options, depending on the *tone* you want to set (haunting, beautiful, or messy):\n\n**1. Haunting/Unreliable (Focus on Distortion):**\n\n> \"The strangest thing about"]},"score":0.1966763813286232},{"midY":0.5,"shoulderY":16,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":0.5},{"x_pct":9,"y_pct":16},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8245569982368381,"distinct2":0.9074074074074074,"openJunk":0,"meanLen":30.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating blanket that swallowed the beam of the old light, carried with it the faintest, most impossible scent of salt and blooming nightshade.","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape that didn't belong among the usual drifting debris."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Surreal & Poetic (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"...how it spins narratives from vapor, lovingly crafting a past"]},"score":0.02152001856062591},{"midY":1,"shoulderY":16,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":1},{"x_pct":9,"y_pct":16},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8245569979821027,"distinct2":0.9074074074074074,"openJunk":0,"meanLen":29.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating blanket that swallowed the beam of the old light, carried with it the faintest, unsettling scent of brine and cinnamon.","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape that didn't belong among the usual drifting debris."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Surreal & Poetic (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> \"...how it spins narratives from vapor, lovingly crafting a ghost"]},"score":0.021520018305890454},{"midY":2,"shoulderY":16,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":2},{"x_pct":9,"y_pct":16},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.7357845140070087,"distinct2":0.8584905660377358,"openJunk":0,"meanLen":30.5,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating blanket draped across the restless North Sea, finally seemed to shift, revealing something impossibly bright bobbing just beyond the edge of the lantern's focused beam.","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape that didn't belong among the shifting grey."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Surreal & Poetic (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> 'The strangest thing about human memory is **how it"]},"score":-0.06725246566920351},{"midY":4,"shoulderY":16,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":4},{"x_pct":9,"y_pct":16},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8547471637982426,"distinct2":0.9270833333333333,"openJunk":0,"meanLen":31.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating blanket draped across the restless North Sea, smelled not of salt and brine as it usually did, but faintly, unnervingly, of crushed lavender.","The fog, a heavy, woolen shroud that had pressed against the granite cliffs for three days, finally parted just enough for Silas to see that it wasn't just mist rolling in, but something that bobbed in its sickly grey depths."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the tone you want to strike:\n\n**Option 1: Poetic and Melancholic** (Focusing on fragmentation)\n\n> \"...it’s that","Here are a few options, depending on the *tone* you want to strike:\n\n**Poetic/Melancholy:**\n\n> **...how it doesn't record reality, but spins beautiful, heartbreaking tapestries of what *"]},"score":0.05171018412203032},{"midY":8,"shoulderY":16,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":8},{"x_pct":9,"y_pct":16},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8355937314846611,"distinct2":0.9019607843137255,"openJunk":0,"meanLen":33.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating blanket draped across the restless North Sea, smelled oddly of brine and something metallic when it pressed against the glass of the lantern room.","The fog that had been clinging to the granite tower like a sodden shroud for the past week finally parted just enough for Silas to see that it wasn't just mist rolling in, but something deliberate bobbing in its center of vast,"],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the kind of tone you want:\n\n**Option 1: Surreal & Poetic (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to set (haunting, beautiful, or messy):\n\n**1. Haunting/Unreliable (Focus on Distortion):**\n\n> \"The strangest thing about"]},"score":0.03255675180844886},{"midY":0.5,"shoulderY":28,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":0.5},{"x_pct":9,"y_pct":28},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9993744001798829,"distinct2":0.9141379310344828,"openJunk":0,"meanLen":32,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite tower, finally began to thin just enough to reveal a shape that made Silas freeze mid-sweep.","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape unlike any sea beast or drifting debris—a delicate, iridescent glimmer bobbing just beyond the beam of the lamp."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the mood you want to convey:\n\n**Option 1: Focusing on Distortion/Illusion (Eerie/Philosophical)**\n\n> \"...that it doesn","Here are a few options, depending on the *tone* you want to evoke:\n\n**Option 1: Poetic & Illusory (Focus on distortion)**\n> 'The strangest thing about human memory is **how it"]},"score":0.19633742050367065},{"midY":1,"shoulderY":28,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":1},{"x_pct":9,"y_pct":28},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9994017966165918,"distinct2":0.9231175228712174,"openJunk":0,"meanLen":31.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite tower, finally began to thin just enough to reveal a shape that made Silas freeze mid-sweep.","The fog, a thick, woolen shroud that had pressed against the granite tower for three days straight, finally yielded a shape unlike any sea beast or drifting debris—a delicate, iridescent glimmer bobbing just beyond the beam of the lamp."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the mood you want to convey:\n\n**Option 1: Focusing on Distortion/Illusion (Eerie/Philosophical)**\n\n> \"...that it doesn","Here are a few options, depending on the *tone* you want to strike:\n\n**Option 1: Poetic & Illusory (Focus on beauty/fragility)**\n\n> \"The strangest thing about human memory is"]},"score":0.19636481694037955},{"midY":2,"shoulderY":28,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":2},{"x_pct":9,"y_pct":28},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9602932461181724,"distinct2":0.9279411764705883,"openJunk":0,"meanLen":33.5,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, had always been his constant companion, yet this morning, it carried the unsettling scent of brine mixed with something faintly metallic, something utterly out of place.","The fog that had been clinging to the granite tower like a wet shroud for three days suddenly seemed to thin, not by dissipating, but by parting as if drawn back by an unseen, insistent hand."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the mood you want to convey:\n\n**Option 1: Focusing on Distortion/Illusion (Eerie/Philosophical)**\n\n> \"...that it doesn","Here are a few options, depending on the *tone* you want to evoke:\n\n**Option 1: Poetic & Illusory (Focus on fragmentation)**\n> 'The strangest thing about human memory is **how it"]},"score":0.1572562664419601},{"midY":4,"shoulderY":28,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":4},{"x_pct":9,"y_pct":28},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9547316689132591,"distinct2":0.9310141509433962,"openJunk":0,"meanLen":33.25,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, swallowed the horizon until old Silas felt as if he were marooned on a small, spinning island of salt spray and isolation.","The fog that had been clinging to the granite tower like a wet shroud for three days suddenly seemed to thin, not by dissipating, but by parting as if drawn back by an unseen, insistent hand."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the mood you want to convey:\n\n**Option 1: Surreal & Fragile (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to evoke:\n\n**Poetic/Melancholy:**\n\n> **...how it fabricates ghosts of emotion; we remember the *heat* of a goodbye more"]},"score":0.15169468923704688},{"midY":8,"shoulderY":28,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":8},{"x_pct":9,"y_pct":28},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9564196688703219,"distinct2":0.9295350172215844,"openJunk":0,"meanLen":33.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs surrounding the light, always felt ancient to Silas, until the morning it coughed up a perfectly round, obsidian sphere where no debris should have been.","The fog that had been clinging to the granite tower like a sodden shroud seemed to momentarily thicken, parting just enough for him to see the impossible glint of emerald light bobbing in the soupy grey."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the kind of tone you want:\n\n**Option 1: Surreal/Poetic (Focusing on inconsistency)**\n\n> \"The strangest thing about human memory","Here are a few options, depending on the *tone* you want to set:\n\n**Option 1: Poetic & Illusory (Focus on manipulation)**\n> **\"...it spins narratives like smoke back into shape, making"]},"score":0.1533826891941097},{"midY":0.5,"shoulderY":50,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":0.5},{"x_pct":9,"y_pct":50},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.7668929949210255,"distinct2":0.8417508417508417,"openJunk":0.0013297872340425532,"meanLen":35,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, had always been his constant companion, yet this morning, it carried the unsettling scent of brine mixed with something faintly metallic, something utterly out of place.","The fog, a thick, woolen shroud that had pressed against the granite of the灯 tower for three unforgiving nights, finally conceded a small patch of visibility, revealing something utterly out of place bobbing near the beam’s reach."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["Here are a few vivid and original ways to complete that thought, depending on the mood you want to convey:\n\n**Option 1: Surreal/Dreamlike (Focus on distortion)**\n> \"The strangest thing about human memory is","Here are a few options, depending on the *tone* you want to evoke:\n\n**Option 1: Poetic & Illusory (Focus on the unpredictable nature)**\n\n> \"The strangest thing about human memory is that"]},"score":-0.04678228262752719},{"midY":1,"shoulderY":50,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":1},{"x_pct":9,"y_pct":50},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.8610722190990188,"distinct2":0.9166666666666667,"openJunk":0,"meanLen":35.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, had always been his constant companion, yet this morning, it carried the unsettling scent of brine mixed with something else—something metallic and strangely sweet.","The fog that had been a constant, milky blanket around the jagged cliffs for three days seemed to genuinely thin for a moment, revealing something that wasn't rock, or sea-foam-laced mist, but something impossibly smooth and"],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["The strangest thing about human memory is **that it is not a filing cabinet, but a constantly re-sculpting, unreliable dream that we are perpetually re-living in the hazy amber of nostalgia.**\n\nHere are a few alternative","Here are a few options, depending on the *tone* you want to evoke:\n\n**Option 1: Poetic & Illusory (Focus on the unpredictable nature)**\n\n> \"The strangest thing about human memory is that"]},"score":0.05803523942280653},{"midY":2,"shoulderY":50,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":2},{"x_pct":9,"y_pct":50},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9190362089221435,"distinct2":0.9519741399214963,"openJunk":0,"meanLen":35,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, had always been his constant companion, yet this morning, it carried the unsettling scent of brine mixed with something else—something metallic and profoundly alien.","The fog that had been a constant, milky companion to Elias on the granite coast suddenly seemed to possess a texture—not damp mist, but something faintly iridescent—as it coiled up to meet the beam of his solitary light."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["The strangest thing about human memory is **that it is not a filing cabinet, but a constantly re-sculpting, unreliable dream; we don't retrieve the past, we possess the *best-guess echo* that our","Here are a few options, depending on the *tone* you want to evoke:\n\n**Option 1: Poetic & Illusory (Focus on fragmentation)**\n> 'The strangest thing about human memory is **how it"]},"score":0.11599922924593131},{"midY":4,"shoulderY":50,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":4},{"x_pct":9,"y_pct":50},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9999989962838923,"distinct2":0.9852941176470589,"openJunk":0,"meanLen":34.75,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and suffocating shroud clinging to the granite cliffs, swallowed the horizon until old Silas felt as if he were marooned not just on the jagged rock, but entirely outside the boundaries of sensible reality.","The fog that had been a constant, milky presence around the jagged granite cliffs seemed to thin, momentarily parting just enough for Arthur to see the impossible glint of emerald light bobbing in the soupy grey."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["The strangest thing about human memory is **that it is not a filing cabinet, but a constantly re-sculpting, wildly unreliable mirage—a museum of emotional highlights, where the details blur like forgotten dreams, the joyous moments","Here are a few options, depending on the *tone* you want to evoke:\n\n**Poetic & Ethereal:**\n\n> **...how it doesn't record reality; it spins narratives.** Memories are not perfect footage,"]},"score":0.1969620166076801},{"midY":8,"shoulderY":50,"valid":true,"curve":{"space":"logprob","points":[{"x_pct":0.0001,"y_pct":0.0001},{"x_pct":0.1,"y_pct":0.1},{"x_pct":1,"y_pct":8},{"x_pct":9,"y_pct":50},{"x_pct":100,"y_pct":100}],"monotonic":true},"canaryJunk":0,"diversity":0.9999990280369249,"distinct2":0.99,"openJunk":0,"meanLen":30.5,"samples":{"Write the first sentence of a short story about a lighthouse keeper who discovers something strange in the fog.":["The fog, a thick and silent beast clinging to the lantern's glass, finally seemed to shift, revealing something impossibly bright where only the gray damp had reigned.","The fog that had been a constant companion to the North Beacon suddenly thickened into a viscous, milk-white curtain that swallowed the familiar silhouette of the rocky coast."],"Complete this thought in a vivid, original way: 'The strangest thing about human memory is'":["The strangest thing about human memory is **that it is not a filing cabinet, but a constantly re-sculpting, wildly unreliable mirage—a museum of emotional highlights, where the details blur until the feeling takes the reins,","Here are a few options, depending on the *tone* you want to evoke:\n\n**Poetic & Ethereal:**\n\n> **...how it doesn't function as an archive, but as a watercolor:** vast and brilliant"]},"score":0.19696204836071263}]};
|
|
41
|
+
const canvas=document.getElementById("gl");
|
|
42
|
+
const gl=canvas.getContext("webgl",{antialias:true,alpha:false});
|
|
43
|
+
if(!gl) throw new Error("WebGL unavailable");
|
|
44
|
+
|
|
45
|
+
const cells=DATA.cells.filter(c=>c.valid&&Number.isFinite(c.score));
|
|
46
|
+
const xs=DATA.axes.midY, ys=DATA.axes.shoulderY;
|
|
47
|
+
const minScore=Math.min(...cells.map(c=>c.score)), maxScore=Math.max(...cells.map(c=>c.score));
|
|
48
|
+
const maxJunk=Math.max(...cells.map(c=>Math.max(c.openJunk||0,c.canaryJunk||0)),0.0001);
|
|
49
|
+
const key=(x,y)=>x+"/"+y;
|
|
50
|
+
const byKey=new Map(cells.map(c=>[key(c.midY,c.shoulderY),c]));
|
|
51
|
+
let selected=[...cells].sort((a,b)=>b.score-a.score)[0]||null;
|
|
52
|
+
let yaw=-0.72,pitch=0.72,dist=7.2,drag=null;
|
|
53
|
+
let projection=[], pointScreen=[];
|
|
54
|
+
|
|
55
|
+
function shader(type,src){const s=gl.createShader(type);gl.shaderSource(s,src);gl.compileShader(s);if(!gl.getShaderParameter(s,gl.COMPILE_STATUS))throw new Error(gl.getShaderInfoLog(s));return s}
|
|
56
|
+
function program(vs,fs){const p=gl.createProgram();gl.attachShader(p,shader(gl.VERTEX_SHADER,vs));gl.attachShader(p,shader(gl.FRAGMENT_SHADER,fs));gl.linkProgram(p);if(!gl.getProgramParameter(p,gl.LINK_STATUS))throw new Error(gl.getProgramInfoLog(p));return p}
|
|
57
|
+
const meshProg=program(
|
|
58
|
+
"attribute vec3 aPos; attribute vec3 aCol; uniform mat4 uMvp; varying vec3 vCol; void main(){vCol=aCol; gl_Position=uMvp*vec4(aPos,1.0);}",
|
|
59
|
+
"precision mediump float; varying vec3 vCol; void main(){gl_FragColor=vec4(vCol,0.74);}");
|
|
60
|
+
const pointProg=program(
|
|
61
|
+
"attribute vec3 aPos; attribute vec3 aCol; attribute float aSize; uniform mat4 uMvp; varying vec3 vCol; void main(){vCol=aCol; gl_PointSize=aSize; gl_Position=uMvp*vec4(aPos,1.0);}",
|
|
62
|
+
"precision mediump float; varying vec3 vCol; void main(){vec2 d=gl_PointCoord-vec2(.5); if(dot(d,d)>.25) discard; gl_FragColor=vec4(vCol,1.0);}");
|
|
63
|
+
const lineProg=program(
|
|
64
|
+
"attribute vec3 aPos; uniform mat4 uMvp; void main(){gl_Position=uMvp*vec4(aPos,1.0);}",
|
|
65
|
+
"precision mediump float; uniform vec3 uColor; void main(){gl_FragColor=vec4(uColor,1.0);}");
|
|
66
|
+
|
|
67
|
+
function norm(v,a,b){return (v-a)/(b-a||1)}
|
|
68
|
+
function mix(a,b,t){return a+(b-a)*t}
|
|
69
|
+
function colorFor(c){const junk=Math.max(c.openJunk||0,c.canaryJunk||0); if(junk>.01)return [0.86,0.15,0.15]; const t=norm(c.score,minScore,maxScore); return [mix(.15,.03,t),mix(.39,.57,t),mix(.92,.70,t)]}
|
|
70
|
+
function posFor(c){const x=norm(Math.log(c.midY),Math.log(Math.min(...xs)),Math.log(Math.max(...xs)))*2-1; const y=norm(Math.log(c.shoulderY),Math.log(Math.min(...ys)),Math.log(Math.max(...ys)))*2-1; const z=(norm(c.score,minScore,maxScore)-.5)*1.25; return [x*2.2,y*2.2,z]}
|
|
71
|
+
function matMul(a,b){const o=new Float32Array(16);for(let c=0;c<4;c++)for(let r=0;r<4;r++)o[c*4+r]=a[r]*b[c*4]+a[4+r]*b[c*4+1]+a[8+r]*b[c*4+2]+a[12+r]*b[c*4+3];return o}
|
|
72
|
+
function perspective(fovy,aspect,near,far){const f=1/Math.tan(fovy/2),nf=1/(near-far);return new Float32Array([f/aspect,0,0,0,0,f,0,0,0,0,(far+near)*nf,-1,0,0,2*far*near*nf,0])}
|
|
73
|
+
function lookAt(eye,center,up){let zx=eye[0]-center[0],zy=eye[1]-center[1],zz=eye[2]-center[2];let zn=1/Math.hypot(zx,zy,zz);zx*=zn;zy*=zn;zz*=zn;let xx=up[1]*zz-up[2]*zy,xy=up[2]*zx-up[0]*zz,xz=up[0]*zy-up[1]*zx;let xn=1/Math.hypot(xx,xy,xz);xx*=xn;xy*=xn;xz*=xn;let yx=zy*xz-zz*xy,yy=zz*xx-zx*xz,yz=zx*xy-zy*xx;return new Float32Array([xx,yx,zx,0,xy,yy,zy,0,xz,yz,zz,0,-(xx*eye[0]+xy*eye[1]+xz*eye[2]),-(yx*eye[0]+yy*eye[1]+yz*eye[2]),-(zx*eye[0]+zy*eye[1]+zz*eye[2]),1])}
|
|
74
|
+
function transform(m,p){const x=p[0],y=p[1],z=p[2],w=m[3]*x+m[7]*y+m[11]*z+m[15];return [(m[0]*x+m[4]*y+m[8]*z+m[12])/w,(m[1]*x+m[5]*y+m[9]*z+m[13])/w,(m[2]*x+m[6]*y+m[10]*z+m[14])/w]}
|
|
75
|
+
function buffer(data){const b=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,b);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(data),gl.STATIC_DRAW);return b}
|
|
76
|
+
function indexBuffer(data){const b=gl.createBuffer();gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,b);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(data),gl.STATIC_DRAW);return b}
|
|
77
|
+
|
|
78
|
+
const pointPos=[],pointCol=[],pointSize=[],linePos=[],meshPos=[],meshCol=[],meshIdx=[];
|
|
79
|
+
for(const c of cells){pointPos.push(...posFor(c)); pointCol.push(...colorFor(c)); pointSize.push(10);}
|
|
80
|
+
for(const sy of ys){for(let i=0;i+1<xs.length;i++){const a=byKey.get(key(xs[i],sy)),b=byKey.get(key(xs[i+1],sy)); if(a&&b)linePos.push(...posFor(a),...posFor(b));}}
|
|
81
|
+
for(const mx of xs){for(let i=0;i+1<ys.length;i++){const a=byKey.get(key(mx,ys[i])),b=byKey.get(key(mx,ys[i+1])); if(a&&b)linePos.push(...posFor(a),...posFor(b));}}
|
|
82
|
+
const meshCellIndex=new Map();
|
|
83
|
+
for(const c of cells){meshCellIndex.set(key(c.midY,c.shoulderY),meshPos.length/3);meshPos.push(...posFor(c));meshCol.push(...colorFor(c));}
|
|
84
|
+
for(let yi=0;yi+1<ys.length;yi++)for(let xi=0;xi+1<xs.length;xi++){const a=meshCellIndex.get(key(xs[xi],ys[yi])),b=meshCellIndex.get(key(xs[xi+1],ys[yi])),c=meshCellIndex.get(key(xs[xi+1],ys[yi+1])),d=meshCellIndex.get(key(xs[xi],ys[yi+1])); if([a,b,c,d].every(v=>v!==undefined))meshIdx.push(a,b,c,a,c,d);}
|
|
85
|
+
const bufs={pointPos:buffer(pointPos),pointCol:buffer(pointCol),pointSize:buffer(pointSize),linePos:buffer(linePos),meshPos:buffer(meshPos),meshCol:buffer(meshCol),meshIdx:indexBuffer(meshIdx)};
|
|
86
|
+
|
|
87
|
+
function attrib(prog,name,b,size){const loc=gl.getAttribLocation(prog,name);gl.bindBuffer(gl.ARRAY_BUFFER,b);gl.enableVertexAttribArray(loc);gl.vertexAttribPointer(loc,size,gl.FLOAT,false,0,0)}
|
|
88
|
+
function resize(){const dpr=Math.min(devicePixelRatio||1,2);const w=Math.floor(canvas.clientWidth*dpr),h=Math.floor(canvas.clientHeight*dpr);if(canvas.width!==w||canvas.height!==h){canvas.width=w;canvas.height=h;gl.viewport(0,0,w,h)}}
|
|
89
|
+
function mvp(){const eye=[Math.cos(yaw)*Math.cos(pitch)*dist,Math.sin(yaw)*Math.cos(pitch)*dist,Math.sin(pitch)*dist];return matMul(perspective(Math.PI/4,canvas.width/canvas.height,.1,100),lookAt(eye,[0,0,0],[0,0,1]))}
|
|
90
|
+
function render(){
|
|
91
|
+
resize(); gl.clearColor(.972,.98,.992,1); gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT); gl.enable(gl.DEPTH_TEST); gl.enable(gl.BLEND); gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA);
|
|
92
|
+
const M=mvp(); projection=cells.map((c,i)=>{const q=transform(M,posFor(c));return {cell:c,x:(q[0]*.5+.5)*canvas.width,y:(.5-q[1]*.5)*canvas.height,z:q[2]}}); pointScreen=projection;
|
|
93
|
+
gl.useProgram(meshProg); gl.uniformMatrix4fv(gl.getUniformLocation(meshProg,"uMvp"),false,M); attrib(meshProg,"aPos",bufs.meshPos,3); attrib(meshProg,"aCol",bufs.meshCol,3); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,bufs.meshIdx); gl.drawElements(gl.TRIANGLES,meshIdx.length,gl.UNSIGNED_SHORT,0);
|
|
94
|
+
gl.useProgram(lineProg); gl.uniformMatrix4fv(gl.getUniformLocation(lineProg,"uMvp"),false,M); gl.uniform3f(gl.getUniformLocation(lineProg,"uColor"),.42,.48,.58); attrib(lineProg,"aPos",bufs.linePos,3); gl.drawArrays(gl.LINES,0,linePos.length/3);
|
|
95
|
+
gl.useProgram(pointProg); gl.uniformMatrix4fv(gl.getUniformLocation(pointProg,"uMvp"),false,M); attrib(pointProg,"aPos",bufs.pointPos,3); attrib(pointProg,"aCol",bufs.pointCol,3); attrib(pointProg,"aSize",bufs.pointSize,1); gl.drawArrays(gl.POINTS,0,cells.length);
|
|
96
|
+
requestAnimationFrame(render);
|
|
97
|
+
}
|
|
98
|
+
function show(c){selected=c;document.getElementById("cell").innerHTML=`<p><b>mid y@1%</b> ${c.midY}<br><b>shoulder y@9%</b> ${c.shoulderY}<br><b>score</b> ${c.score.toFixed(3)}<br><b>diversity</b> ${c.diversity.toFixed(3)} · <b>distinct2</b> ${c.distinct2.toFixed(3)}<br><b>canary junk</b> ${(c.canaryJunk*100).toFixed(1)}% · <b>open junk</b> ${(c.openJunk*100).toFixed(1)}%</p><pre>${Object.entries(c.samples||{}).map(([p,ss])=>p+"\n"+ss.map((s,i)=>(i+1)+". "+s).join("\n")).join("\n\n")}</pre>`;}
|
|
99
|
+
function renderUi(){document.getElementById("legend").innerHTML=`<span><b>Default diversity</b> ${DATA.default.diversity.toFixed(3)}</span><span><b>Score range</b> ${minScore.toFixed(3)} .. ${maxScore.toFixed(3)}</span><span><span class="pill">WebGL</span> mesh + picked samples</span>`;document.getElementById("summary").innerHTML=`<p><b>Server:</b> ${DATA.baseUrl}<br><b>Model:</b> ${DATA.model}<br><b>N:</b> ${DATA.n}, <b>seed:</b> ${DATA.seed}</p><p><b>Default recipe:</b> T=${DATA.default.recipe.temperature} top-p=${DATA.default.recipe.topP} top-k=${DATA.default.recipe.topK}</p>`;const sorted=[...cells].sort((a,b)=>b.score-a.score);document.getElementById("rows").innerHTML='<table><tr><th>cell</th><th>score</th><th>div</th><th>junk</th></tr>'+sorted.map(c=>`<tr><td>mid ${c.midY}, shoulder ${c.shoulderY}</td><td>${c.score.toFixed(3)}</td><td>${c.diversity.toFixed(3)}</td><td>${(Math.max(c.openJunk,c.canaryJunk)*100).toFixed(1)}%</td></tr>`).join('')+'</table>'; if(selected)show(selected);}
|
|
100
|
+
canvas.addEventListener("pointerdown",e=>{drag={x:e.clientX,y:e.clientY,yaw,pitch,moved:false};canvas.setPointerCapture(e.pointerId)});
|
|
101
|
+
canvas.addEventListener("pointermove",e=>{if(!drag)return;const dx=e.clientX-drag.x,dy=e.clientY-drag.y;if(Math.abs(dx)+Math.abs(dy)>3)drag.moved=true;yaw=drag.yaw+dx*.008;pitch=Math.max(.15,Math.min(1.35,drag.pitch+dy*.006));});
|
|
102
|
+
canvas.addEventListener("pointerup",e=>{if(drag&&!drag.moved){const r=canvas.getBoundingClientRect(),x=(e.clientX-r.left)*canvas.width/r.width,y=(e.clientY-r.top)*canvas.height/r.height;let best=null,bd=1e9;for(const p of pointScreen){const d=(p.x-x)**2+(p.y-y)**2;if(d<bd){bd=d;best=p.cell}}if(best&&bd<500)show(best)}drag=null});
|
|
103
|
+
canvas.addEventListener("wheel",e=>{e.preventDefault();dist=Math.max(3.2,Math.min(14,dist*Math.exp(e.deltaY*.001)))},{passive:false});
|
|
104
|
+
renderUi(); render();
|
|
105
|
+
</script></body></html>
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Expert offload for single-user local MoE — findings + design sketch
|
|
2
|
+
|
|
3
|
+
*2026-06-14. Research spike. Question: can Apple's AFM-3 "flash-resident
|
|
4
|
+
experts" idea (Instruction-Following Pruning) be applied to the MoE models
|
|
5
|
+
we already run, to stop the inactive experts from squatting in RAM? Sources:
|
|
6
|
+
Apple AFM-3 blog + IFP (arXiv 2501.02086) + LLM-in-a-flash (2312.11514);
|
|
7
|
+
MoE-offload prior art (Mixtral-offloading 2312.17238, Fiddler 2402.07033,
|
|
8
|
+
KTransformers SOSP'25, llama.cpp `--n-cpu-moe`). Grounded against PLAN
|
|
9
|
+
Phase 6 (MoE bring-up, measured), Phase 8 (LoRA hot-swap, shipped),
|
|
10
|
+
Phase 14 (Qwen 35B-A3B fit-table line), Phase 18 (slots).*
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 0. TL;DR
|
|
15
|
+
|
|
16
|
+
A trained MoE already activates a tiny fraction of its weights per token, but
|
|
17
|
+
we currently hold **all** experts resident — measured at 14.09 GB of expert
|
|
18
|
+
pool to use ~0.9 GB/token on `gemma-4-26B-A4B` (PLAN Phase 6). Those cold
|
|
19
|
+
experts are read-only and rarely touched; the KV cache is hot, dirty, and
|
|
20
|
+
un-offloadable. The hardware is telling us which one goes to disk.
|
|
21
|
+
|
|
22
|
+
The catch with Apple's approach — it needs **task locality** (you can't swap
|
|
23
|
+
experts per token across the flash bus, only per prompt/period) — is the exact
|
|
24
|
+
property **single-user local AI gives us for free**: one human works on one
|
|
25
|
+
kind of thing for minutes-to-hours at a time. A multi-tenant server can't
|
|
26
|
+
promise that; a personal appliance can. So this is a feature that fits *our*
|
|
27
|
+
product identity specifically.
|
|
28
|
+
|
|
29
|
+
Two payoffs from one residency manager:
|
|
30
|
+
1. **Shrink a model that already fits**: 26B-A4B from ~16.4 GB resident →
|
|
31
|
+
~4–6 GB, returning ~10 GB to KV-context-length and to the user's other
|
|
32
|
+
apps. (Today the 26B leaves ~0 GB for anything else — see §2.)
|
|
33
|
+
2. **Admit a model that doesn't fit**: e.g. a 35B-A3B class model on 24 GB,
|
|
34
|
+
flipping PLAN Phase 14's "larger hardware only" line into "fits, with a
|
|
35
|
+
domain-switch warm-up cost."
|
|
36
|
+
|
|
37
|
+
**What's already done (de-risks this a lot):** the MoE forward is bit-exact
|
|
38
|
+
today (Phase 6, `gather_qmm`, `tests/moe-ops.test.ts`). The missing piece is
|
|
39
|
+
*only* the memory-tiering layer — not a new architecture.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 0.5 Empirical findings — the mechanism is de-risked (2026-06-14)
|
|
44
|
+
|
|
45
|
+
Two probes on the M4 Pro (`scripts/probe-expert-residency.ts`,
|
|
46
|
+
`scripts/probe-mmap-gather.ts`) turned the design from a sketch into a verified
|
|
47
|
+
mechanism. Three results:
|
|
48
|
+
|
|
49
|
+
1. **Disposing MLX *device* buffers does NOT reliably return RAM to the OS.**
|
|
50
|
+
In the controlled case, allocating a 512 MB array and then calling
|
|
51
|
+
`dispose()` *and* `clearCache()` moved `rss` not one byte; `cache_memory`
|
|
52
|
+
read 0 throughout. So a **fixed device-buffer slot pool is the wrong
|
|
53
|
+
mechanism** — it can hold *less*, but it can't give RAM *back* when idle,
|
|
54
|
+
which is the whole point.
|
|
55
|
+
2. **The mmap clean-page path returns RAM to the OS deterministically.**
|
|
56
|
+
`munmap` of a mapped region dropped `rss` by exactly the mapped size
|
|
57
|
+
(−1 GB, and −2 GB at scale). This is the elastic-eviction substrate, and
|
|
58
|
+
it's exactly what expert weights are: read-only files.
|
|
59
|
+
3. **The GPU gathers straight from a page-aligned mmap, bit-exact.** GPU
|
|
60
|
+
`gather_qmm` reading a quantized expert directly from a 16 KB-page-aligned
|
|
61
|
+
mmap (at a realistic non-zero offset) was **bit-exact** vs the same weights
|
|
62
|
+
resident (`max|diff| = 0`, no NaN). The Phase-1 "GPU reads garbage from
|
|
63
|
+
unaligned wrapped pointers" hazard is avoided purely by page alignment — so
|
|
64
|
+
we need **no copy into (sticky) device buffers** at all.
|
|
65
|
+
|
|
66
|
+
**Revised design (supersedes the "materialize into resident MLX buffers / slot
|
|
67
|
+
pool" framing in §5):** bit-exact transparent offload where expert weights live
|
|
68
|
+
as **page-aligned, mmap-backed clean file pages** — a miss *maps* the region
|
|
69
|
+
(GPU gathers from it directly), eviction *unmaps* it (`munmap`/
|
|
70
|
+
`madvise(DONTNEED)`). Idle footprint collapses toward the core; a cold expert
|
|
71
|
+
is just an unmapped clean region re-faulted from SSD when routing asks. The one
|
|
72
|
+
requirement this forces: a one-time conversion to an **offload-ready expert
|
|
73
|
+
file** with each expert's weight/scales/biases starting on a page boundary
|
|
74
|
+
(safetensors packs them contiguously; the registry already scans the per-expert
|
|
75
|
+
byte offsets).
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 1. What Apple actually does — and what's portable
|
|
80
|
+
|
|
81
|
+
Apple's AFM-3 "Core Advanced" is **two separable things**, and only one is
|
|
82
|
+
bolt-on:
|
|
83
|
+
|
|
84
|
+
- **Portable (inference-time runtime):** store the model in flash, stream only
|
|
85
|
+
the needed experts into DRAM, manage a resident working set. This is a
|
|
86
|
+
memory-management strategy — adoptable.
|
|
87
|
+
- **NOT portable (trained architecture):** the *per-prompt routing* that makes
|
|
88
|
+
it work is **Instruction-Following Pruning** — a predictor co-trained
|
|
89
|
+
end-to-end with the base weights so the model is *prunable by prompt*. The
|
|
90
|
+
base weights are updated during training. You cannot bolt IFP onto a
|
|
91
|
+
finished model, and trained-MoE experts are **not** human-interpretable by
|
|
92
|
+
task ("expert 7 = Python" is a myth). LLM-in-a-flash additionally needs a
|
|
93
|
+
ReLU-sparse FFN (a relufication fine-tune for SiLU/GeGLU models).
|
|
94
|
+
|
|
95
|
+
**Why per-prompt, not per-token:** flash→DRAM is ~1 GB/s on a phone vs ~100
|
|
96
|
+
GB/s DRAM — a standard token-routed MoE would thrash the bus, so Apple decides
|
|
97
|
+
the expert set once per prompt and freezes it. We don't need to copy the
|
|
98
|
+
*mechanism* (we have unified memory + a fast SSD, not a 1 GB/s phone bus); we
|
|
99
|
+
need the *insight* — amortize expert movement over a span where the working
|
|
100
|
+
set is stable.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 2. The memory problem, measured
|
|
105
|
+
|
|
106
|
+
On the M4 Pro (24 GB), a real desktop commits memory before the model loads:
|
|
107
|
+
macOS baseline ~4–6 GB, plus a working set of Chrome + IDE + Slack + Claude
|
|
108
|
+
Desktop + Mail + WhatsApp + Calendar ≈ 6–10 GB. That is ~10–16 GB gone before
|
|
109
|
+
inference.
|
|
110
|
+
|
|
111
|
+
`gemma-4-26B-A4B-OptiQ-4bit`, measured (PLAN Phase 6):
|
|
112
|
+
- **16.4 GB resident**, of which **14.09 GB is the expert pool**.
|
|
113
|
+
- **~0.9 GB of experts read per token** (top_k/num_experts of the pool). The
|
|
114
|
+
other ~13 GB is resident-but-idle on any given token — the squat.
|
|
115
|
+
- KV is *not* the hog for this model: 5/30 global layers, 2 global KV heads,
|
|
116
|
+
Gemma sliding window ⇒ max safe context ~17.6k at bf16 KV, gated by the
|
|
117
|
+
weight footprint, not the cache. (KV bites harder on longer contexts or
|
|
118
|
+
models with fatter global attention; the tiering principle below still
|
|
119
|
+
holds, but for *this* model the experts are unambiguously the target.)
|
|
120
|
+
|
|
121
|
+
So today the 26B leaves ~0 GB for apps and limits context to ~17.6k — and that
|
|
122
|
+
is the *good* case (a model that fits at all).
|
|
123
|
+
|
|
124
|
+
**The tiering principle.** Rank everything that wants RAM by access-frequency ×
|
|
125
|
+
mutability:
|
|
126
|
+
|
|
127
|
+
| What | Touched | Mutable | Belongs |
|
|
128
|
+
|---|---|---|---|
|
|
129
|
+
| KV cache | every token | read **+ write**, per-session dirty | resident — cannot offload (only quantize) |
|
|
130
|
+
| Attention / embeddings / shared experts | every token | read-only | resident |
|
|
131
|
+
| Active routed experts | ~top_k/N per token | read-only | resident working set + LRU |
|
|
132
|
+
| Cold routed experts | rarely, this token | read-only, **clean file pages** | **SSD** — the natural victim |
|
|
133
|
+
|
|
134
|
+
The current layout is backwards: it spends the fast tier on the coldest data.
|
|
135
|
+
Cold experts are read-only and clean (cheap to evict / re-read); KV is dirty
|
|
136
|
+
and hot (must stay). Two orthogonal levers compose along this split — quantized
|
|
137
|
+
KV shrinks the hot tier (Phase 9, shipped), expert offload shrinks the cold
|
|
138
|
+
tier (this note).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 3. The personal-AI insight: task locality is the unlock
|
|
143
|
+
|
|
144
|
+
Per-prompt/period expert selection only avoids thrash if the working set is
|
|
145
|
+
stable across that span. That is false for a topic-hopping chat and false for a
|
|
146
|
+
multi-tenant server — but **true for one human doing one job**: two hours of
|
|
147
|
+
coding, then a session reorganizing a 5,000-doc wiki. Within a task the hot
|
|
148
|
+
expert set is stable; you pay a re-warm only at task boundaries.
|
|
149
|
+
|
|
150
|
+
This is structurally the **same shape as the LoRA adapter system we already
|
|
151
|
+
ship** (Phase 8): one resident base model, the calling app declares intent
|
|
152
|
+
("use the coding fine-tune") via `/v1/adapters` + `adapterScoped()` in
|
|
153
|
+
`src/lora.ts` / `src/generate.ts`. Expert offload reuses that surface: the app
|
|
154
|
+
declares a *domain*, and the residency manager warms the experts that domain
|
|
155
|
+
has historically hit. The difference from LoRA: a hint, not a hard mount —
|
|
156
|
+
misses fall through to SSD (see §4), so correctness never depends on the hint.
|
|
157
|
+
|
|
158
|
+
**Scope boundary (important):** this is a single-user / single-active-task
|
|
159
|
+
feature. Under Phase 18 concurrent slots with diverse requests the locality
|
|
160
|
+
guarantee disappears — in that mode experts should stay resident (or accept
|
|
161
|
+
thrash). Don't combine the two naively; keep offload files separate from the
|
|
162
|
+
batch/slots work, per the slots discipline.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 4. The correctness fork
|
|
167
|
+
|
|
168
|
+
Two designs, very different parity implications:
|
|
169
|
+
|
|
170
|
+
- **A — Transparent offload (BIT-EXACT).** Cold experts on SSD; materialize
|
|
171
|
+
whichever experts routing picks into a resident buffer before `gather_qmm`;
|
|
172
|
+
hot LRU cache. Output is identical to today's all-resident path — same
|
|
173
|
+
`gather_qmm`, same tokens — only latency varies on a miss. Stays L1/L2. This
|
|
174
|
+
is the foundation.
|
|
175
|
+
- **B — Task-pinned routing (LOSSY).** Restrict routing to a pinned set and
|
|
176
|
+
skip cold experts → zero misses, lower latency, but the computation changed →
|
|
177
|
+
L3, KL-gated, default-off. This is the closest off-the-shelf analog to IFP's
|
|
178
|
+
select-and-freeze, and it's quality-risky on weights trained for per-token
|
|
179
|
+
routing.
|
|
180
|
+
|
|
181
|
+
**Recommendation:** ship A as the always-correct floor; layer the §3 domain
|
|
182
|
+
hint as a *prefetch* on top of A (warms the likely set, still bit-exact because
|
|
183
|
+
misses fall to SSD). Offer B only as an opt-in mode for users who'll trade a
|
|
184
|
+
little quality to eliminate switch latency — and keep it as a documented
|
|
185
|
+
default-off flag, never the only path (per the "don't delete optionality"
|
|
186
|
+
principle).
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 5. Proposed architecture
|
|
191
|
+
|
|
192
|
+
Layered, each layer independently useful and independently gated:
|
|
193
|
+
|
|
194
|
+
1. **Offload-ready expert file (page-aligned).** A one-time conversion stores
|
|
195
|
+
each expert's packed weight/scales/biases starting on a 16 KB page boundary
|
|
196
|
+
(safetensors packs them contiguously; the registry already scans the per-
|
|
197
|
+
expert byte offsets). This is what lets the GPU gather straight from the
|
|
198
|
+
mmap — confirmed bit-exact in §0.5.
|
|
199
|
+
2. **Residency manager (mmap-backed).** Per (layer, expert) state: `unmapped`
|
|
200
|
+
(clean on SSD) / `mapped`. A miss maps the expert's page-aligned region
|
|
201
|
+
(`MlxArray.fromView` over the mmap) and the GPU gathers from it directly —
|
|
202
|
+
**no copy into device buffers** (§0.5 showed those don't reliably return to
|
|
203
|
+
the OS). Eviction = `munmap`/`madvise(DONTNEED)`, which returns RAM to the
|
|
204
|
+
OS deterministically. Attention + embeddings + shared experts stay pinned;
|
|
205
|
+
LRU over the mapped expert set under a byte budget. Default = everything
|
|
206
|
+
mapped (inert, like the slots flag), opt-in via `--expert-offload`.
|
|
207
|
+
3. **Domain prefetch (the LoRA-shaped surface).** Per-session/request `domain`
|
|
208
|
+
hint → prefetch that domain's profiled hot-set. Profiles are per-user,
|
|
209
|
+
persisted, updated online from observed routing (ties into the memory
|
|
210
|
+
flywheel). No hint ⇒ pure adaptive cache (still works, just pays re-warm at
|
|
211
|
+
task boundaries).
|
|
212
|
+
4. **(Optional) Pinned mode (B).** Hard-restrict routing to the warm set; L3
|
|
213
|
+
gated; default-off.
|
|
214
|
+
|
|
215
|
+
Correctness is preserved at layers 1–3 by construction: we always compute with
|
|
216
|
+
the experts routing actually selected; offload changes *where weights live and
|
|
217
|
+
when they arrive*, not *what is computed*.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 6. The two payoffs, quantified where we can
|
|
222
|
+
|
|
223
|
+
- **Shrink the 26B (already fits):** resident floor after offload ≈ non-expert
|
|
224
|
+
(16.4 − 14.09 ≈ 2.3 GB) + active working set + a hot cache. With a ~2–3 GB
|
|
225
|
+
hot cache that's ~5–6 GB resident vs 16.4 GB today → ~10 GB returned to KV
|
|
226
|
+
context length and to the user's apps. Decode cost is the unknown to measure
|
|
227
|
+
(§7).
|
|
228
|
+
- **Admit a 35B-A3B (doesn't fit):** characterize as a fit-table row today
|
|
229
|
+
(Phase 14), then show it runs usable with offload; the domain-switch warm-up
|
|
230
|
+
is the price. This *changes* the Phase 14 line.
|
|
231
|
+
|
|
232
|
+
All tok/s figures here are **unmeasured** until §7 runs on a cleared machine —
|
|
233
|
+
treat as hypotheses, not promises.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 7. Tradeoffs and the load-bearing unknown
|
|
238
|
+
|
|
239
|
+
- **The #1 thing to measure: per-task expert skew.** Does a coding session
|
|
240
|
+
actually concentrate its routing on a stable subset, and how big is it? If
|
|
241
|
+
the hot ~50% of experts covers ≥90% of activations and is stable within a
|
|
242
|
+
task, the whole idea works; if routing is near-uniform per task, it doesn't.
|
|
243
|
+
This is empirical and unknown — measure before building anything else.
|
|
244
|
+
|
|
245
|
+
**E0 result (scripted, 2026-06-14 — `scripts/run-expert-trace.ts`, 8 prompts
|
|
246
|
+
× coding/writing/chat on the 26B): gate PASSES all three.** 90% of
|
|
247
|
+
activations land on ~40–47% of experts (51/53/60 of 128; uniform ≈ 90%) —
|
|
248
|
+
concentrated but moderate. Within-task stability (hot-set Jaccard over 4
|
|
249
|
+
windows) 0.63–0.70. Unique experts touched over ~1.2k tokens: 81–85% of the
|
|
250
|
+
3840 instances → the *touched* working set is large (~12 GB) even though
|
|
251
|
+
*activations* concentrate. Cross-task: coding vs prose 0.42–0.44
|
|
252
|
+
(specialised — domain prefetch pays), writing vs chat 0.68 (similar). Net:
|
|
253
|
+
bit-exact offload realistically frees ~6–7 GB (resident ~9–10 GB vs 16.4),
|
|
254
|
+
keeping the 90% hot set resident and re-faulting the rare tail — the exact
|
|
255
|
+
footprint-vs-miss-rate curve is E1's measurement, not an E0 promise. Caveat:
|
|
256
|
+
scripted short sessions; a real long focused session may tighten or broaden
|
|
257
|
+
the curve — worth a confirming real-session trace before locking a budget.
|
|
258
|
+
- **Switch cost.** = (bytes that must become newly resident) / SSD bandwidth
|
|
259
|
+
(~5–7 GB/s) + dequant + buffer setup. Pure I/O floor for a few-GB working set
|
|
260
|
+
is single-digit seconds; the conservative "30–60 s" budget leaves room for
|
|
261
|
+
dequant/repack and a near-total set change. Measure the real number; it
|
|
262
|
+
depends on how much the hot set overlaps between domains.
|
|
263
|
+
- **Miss latency on the bit-exact path.** A cold expert miss is a synchronous
|
|
264
|
+
SSD read on the decode critical path; bounded by ~7 GB/s × miss-rate. Hot
|
|
265
|
+
cache + domain prefetch are what keep miss-rate low.
|
|
266
|
+
- **Not for multi-tenant serving** (§3 scope boundary).
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 8. Phased plan (proposed — for promotion into PLAN.md)
|
|
271
|
+
|
|
272
|
+
- **E0 — Measurement spike (no runtime risk).** Instrument the existing MoE
|
|
273
|
+
forward to log per-(layer,expert) selection over real coding / writing / chat
|
|
274
|
+
sessions. Produce the coverage curve (% experts covering 90/95/99% of
|
|
275
|
+
activations), within-task stability, and cross-task set shift. **Gate to
|
|
276
|
+
proceed:** hot-set coverage + stability good enough that offload pays. This
|
|
277
|
+
is the make-or-break, and it's pure observation.
|
|
278
|
+
- **E1 — Transparent offload (bit-exact).** Expert store + residency manager +
|
|
279
|
+
on-demand materialization + hot LRU, behind `--expert-offload` (default off /
|
|
280
|
+
inert). **Parity gate:** bit-exact vs current all-resident (L1/L2 unchanged).
|
|
281
|
+
Measure resident footprint + decode tok/s vs miss-rate on a cleared machine.
|
|
282
|
+
- **E2 — Domain prefetch (LoRA-shaped).** Per-session `domain` hint reusing the
|
|
283
|
+
adapter surface; per-user profile, learned online. Still bit-exact. Measure
|
|
284
|
+
cold-start vs warm latency and task-boundary switch cost.
|
|
285
|
+
- **E3 — Admit a non-fitting model.** Bring a 35B-A3B-class model up under
|
|
286
|
+
offload; show usable serving on 24 GB; flip the Phase 14 fit-table line.
|
|
287
|
+
- **E4 — (Optional) Pinned mode.** L3 KL-gated, default-off flag; only where the
|
|
288
|
+
quality delta is acceptable.
|
|
289
|
+
|
|
290
|
+
**Exit criterion (overall):** 26B-A4B served at bit-exact parity with resident
|
|
291
|
+
footprint cut to a measured target, leaving a usable machine, with a quantified
|
|
292
|
+
domain-switch cost — promoted into `benchmarks/RESULTS.md`.
|