Spaces:
Running
Running
deploy(hf): sync szl-holdings/a11oy@main derived COPY set
Browse filesReusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy main.
Files: 1007 Pruned: 0
Derived from Dockerfile COPY sources (NO hand-maintained allowlist).
Signed-off-by: SZL Holdings <noreply@szlholdings.ai>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
static/3d/holographic.html
CHANGED
|
@@ -316,6 +316,7 @@ const SURFACES = [
|
|
| 316 |
{ id: "flowbrain", cat: "brain", flag: true, title: "FlowBrain · continuous belief-flow lens · tiers as thresholds crossed on x_t∈[0,1] + 1D-time⊗1D-node axis-factorization (STRUCTURAL-ONLY; borrows B[FM]² continuous-flow principle, NO EEG)", mod: "/static/3d/surfaces/flowbrain.js" },
|
| 317 |
{ id: "blocksparse", cat: "attention", title: "Learned Blockwise Top-k KV Sparse Attention · selection (MODELED)", mod: "/static/3d/surfaces/blocksparse.js" },
|
| 318 |
{ id: "confattest", cat: "governance", title: "Confidential-Compute Attestation + Action Gate · SIMULATED enclave quote → receipt · govern ACTIONS not reasoning (MODELED)", mod: "/static/3d/surfaces/confattest.js" },
|
|
|
|
| 319 |
];
|
| 320 |
|
| 321 |
const stageEl = document.getElementById("stage");
|
|
|
|
| 316 |
{ id: "flowbrain", cat: "brain", flag: true, title: "FlowBrain · continuous belief-flow lens · tiers as thresholds crossed on x_t∈[0,1] + 1D-time⊗1D-node axis-factorization (STRUCTURAL-ONLY; borrows B[FM]² continuous-flow principle, NO EEG)", mod: "/static/3d/surfaces/flowbrain.js" },
|
| 317 |
{ id: "blocksparse", cat: "attention", title: "Learned Blockwise Top-k KV Sparse Attention · selection (MODELED)", mod: "/static/3d/surfaces/blocksparse.js" },
|
| 318 |
{ id: "confattest", cat: "governance", title: "Confidential-Compute Attestation + Action Gate · SIMULATED enclave quote → receipt · govern ACTIONS not reasoning (MODELED)", mod: "/static/3d/surfaces/confattest.js" },
|
| 319 |
+
{ id: "retrievalattn", cat: "attention", title: "Retrieval-Modulated Long-Context Attention · needle recall (MODELED)", mod: "/static/3d/surfaces/retrievalattn.js" },
|
| 320 |
];
|
| 321 |
|
| 322 |
const stageEl = document.getElementById("stage");
|
static/3d/surfaces/retrievalattn.js
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/retrievalattn.js — RETRIEVAL-MODULATED LONG-CONTEXT ATTENTION organ for
|
| 5 |
+
// the holographic frontier ring. Renders a long token stream as a row of nodes: the
|
| 6 |
+
// last W tokens are the LOCAL window (kept for free), and planted "needle" facts glow
|
| 7 |
+
// by whether each read policy recalls them. A plain sparse window is structurally
|
| 8 |
+
// blind to any needle beyond the window; the MATCH retrieval step re-injects the
|
| 9 |
+
// long-range needles it drops — chosen by CONTENT similarity to the query — so they
|
| 10 |
+
// re-light proof-teal. An exponentially-decaying-memory baseline only rescues the
|
| 11 |
+
// recent tail. A HUD shows long-range recall per policy, the recovery the retrieval
|
| 12 |
+
// step adds over a plain sparse window, and the sub-dense attend fraction it pays,
|
| 13 |
+
// from /api/a11oy/v1/retrievalattn/recall. Honesty label "MODELED" is read VERBATIM
|
| 14 |
+
// from the JSON and displayed as-is; it is never upgraded.
|
| 15 |
+
//
|
| 16 |
+
// Surface export shape (mirrors gateddelta.js / kvcache.js exactly):
|
| 17 |
+
// export default { id, title, endpoints, mount(ctx), unmount() }
|
| 18 |
+
// ctx = { stage, container, live, label, THREE, szl3d }
|
| 19 |
+
//
|
| 20 |
+
// DATA SHOWN (all from the live endpoint):
|
| 21 |
+
// seq_len, window, n_needles, retrieval_k, dim, decay,
|
| 22 |
+
// full_long_range_recall, sparse_long_range_recall, edm_long_range_recall,
|
| 23 |
+
// retrieval_long_range_recall, long_range_recall_recovery, retrieval_vs_edm_gain,
|
| 24 |
+
// attend_frac_sparse/retrieval/full, n_long_range_needles, n_window_needles,
|
| 25 |
+
// per_needle[] {pos,in_window,sim,retrieved,edm_weight,recalled_*}
|
| 26 |
+
//
|
| 27 |
+
// LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own; arXiv ids VERIFIED):
|
| 28 |
+
// MATCH: Modulating Attention via In-Context Retrieval — Ma et al. 2026, arXiv:2606.29844
|
| 29 |
+
// Augmenting Attention with Exponentially Decaying Memory — Wei & Gulcehre 2026, arXiv:2605.28640
|
| 30 |
+
//
|
| 31 |
+
// HONESTY LABELS: MODELED (deterministic simulation of full / sparse-window /
|
| 32 |
+
// decaying-memory / retrieval-augmented read policies over a synthetic needle task;
|
| 33 |
+
// NOT a real trained model, corpus, or GPU). Read verbatim from JSON; never upgraded.
|
| 34 |
+
// COLOURS: proof-teal 0x3af4c8 (retrieval-recovered / HUD accent), lattice-blue
|
| 35 |
+
// 0x5b8dee (local window), amber 0xf5b23a (decaying-memory tail), greys (dropped /
|
| 36 |
+
// degraded). Purple BANNED.
|
| 37 |
+
// 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
|
| 38 |
+
// DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
|
| 39 |
+
// Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
|
| 40 |
+
|
| 41 |
+
import { createShowcase } from "./_showcase.js";
|
| 42 |
+
|
| 43 |
+
const ID = "retrievalattn";
|
| 44 |
+
const TITLE = "Retrieval-Modulated Long-Context Attention · needle recall (live)";
|
| 45 |
+
|
| 46 |
+
// PRIMARY endpoint is the a11oy-NATIVE self-hosted twin (same-origin, szl_retrieval_attn.py):
|
| 47 |
+
// real full / sparse / decaying-memory / retrieval read policies over a seeded needle
|
| 48 |
+
// task (label MODELED, read verbatim). No cross-origin dependency.
|
| 49 |
+
const EP = "/api/a11oy/v1/retrievalattn/recall?seed=42&seq_len=512&window=64&n_needles=12&retrieval_k=16&dim=16&decay=0.08";
|
| 50 |
+
|
| 51 |
+
// data-viz hues — purple BANNED
|
| 52 |
+
const C_RETR = 0x3af4c8; // proof-teal (retrieval-recovered needle / HUD accent)
|
| 53 |
+
const C_WIN = 0x5b8dee; // lattice-blue (local window)
|
| 54 |
+
const C_EDM = 0xf5b23a; // amber (decaying-memory tail)
|
| 55 |
+
const C_DROP = 0x5a6570; // grey (dropped long-range needle)
|
| 56 |
+
const C_DIM = 0x42505d; // grey (degraded / no-live-data)
|
| 57 |
+
const C_GRID = 0x1b3a44; // floor / link colour
|
| 58 |
+
|
| 59 |
+
// token-stream layout geometry
|
| 60 |
+
const STREAM_LEN = 15.0; // world-units the whole sequence spans along X
|
| 61 |
+
const MAX_NEEDLES = 24; // cap on needle nodes rendered (backend clamps n_needles)
|
| 62 |
+
const BASE_Y = 0.4; // resting height of a needle node
|
| 63 |
+
|
| 64 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _show = null;
|
| 65 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null;
|
| 66 |
+
|
| 67 |
+
// geometry handles
|
| 68 |
+
let _spine = null; // THREE.Line — the token-stream spine
|
| 69 |
+
let _winMesh = null; // THREE.Mesh — the local-window slab (last W tokens)
|
| 70 |
+
let _query = null; // THREE.Mesh — the query marker at the stream head
|
| 71 |
+
let _needle = []; // Array<THREE.Mesh> — one node per planted needle
|
| 72 |
+
|
| 73 |
+
// live state
|
| 74 |
+
const S = {
|
| 75 |
+
label: null,
|
| 76 |
+
seqLen: null,
|
| 77 |
+
window: null,
|
| 78 |
+
nNeedles: null,
|
| 79 |
+
retrievalK: null,
|
| 80 |
+
dim: null,
|
| 81 |
+
decay: null,
|
| 82 |
+
nLongRange: null,
|
| 83 |
+
nWindow: null,
|
| 84 |
+
fullLR: null, // full_long_range_recall
|
| 85 |
+
sparseLR: null, // sparse_long_range_recall
|
| 86 |
+
edmLR: null, // edm_long_range_recall
|
| 87 |
+
retrLR: null, // retrieval_long_range_recall
|
| 88 |
+
recovery: null, // long_range_recall_recovery
|
| 89 |
+
vsEdm: null, // retrieval_vs_edm_gain
|
| 90 |
+
attendSparse: null,
|
| 91 |
+
attendRetr: null,
|
| 92 |
+
perNeedle: null, // per_needle[]
|
| 93 |
+
state: "init",
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
// =============================================================================
|
| 97 |
+
// mount(ctx)
|
| 98 |
+
// =============================================================================
|
| 99 |
+
export function mount(ctx) {
|
| 100 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 101 |
+
_group = new _THREE.Group();
|
| 102 |
+
_stage.scene.add(_group);
|
| 103 |
+
_stage.camera.position.set(0, 6, 18);
|
| 104 |
+
try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1, 0); _stage.controls.update(); } } catch (_) {}
|
| 105 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 106 |
+
|
| 107 |
+
_buildFloor();
|
| 108 |
+
_buildStream();
|
| 109 |
+
_buildNeedles();
|
| 110 |
+
_buildQuery();
|
| 111 |
+
|
| 112 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 113 |
+
|
| 114 |
+
_badge = ctx.live.createBadge();
|
| 115 |
+
_polls.push(ctx.live.poll(EP, 5000, _onRecall, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
|
| 116 |
+
|
| 117 |
+
_buildOverlay();
|
| 118 |
+
return { id: ID, started: true };
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// =============================================================================
|
| 122 |
+
// builders
|
| 123 |
+
// =============================================================================
|
| 124 |
+
function _buildFloor() {
|
| 125 |
+
const THREE = _THREE;
|
| 126 |
+
const grid = new THREE.GridHelper(36, 36, C_GRID, 0x0f2027);
|
| 127 |
+
grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
|
| 128 |
+
_group.add(grid);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
function _buildStream() {
|
| 132 |
+
const THREE = _THREE;
|
| 133 |
+
const half = STREAM_LEN / 2;
|
| 134 |
+
// token-stream spine along X (index 0 at -half, last token at +half == query head)
|
| 135 |
+
{
|
| 136 |
+
const pts = [new THREE.Vector3(-half, 0, 0), new THREE.Vector3(half, 0, 0)];
|
| 137 |
+
const geo = new THREE.BufferGeometry().setFromPoints(pts);
|
| 138 |
+
const mat = new THREE.LineBasicMaterial({ color: C_WIN, transparent: true, opacity: 0.4 });
|
| 139 |
+
_spine = new THREE.Line(geo, mat);
|
| 140 |
+
_group.add(_spine);
|
| 141 |
+
}
|
| 142 |
+
// local-window slab — a translucent box hugging the last W tokens near the head.
|
| 143 |
+
// width is set from live data in _updateStream; starts hidden.
|
| 144 |
+
_winMesh = new THREE.Mesh(
|
| 145 |
+
new THREE.BoxGeometry(1.0, 1.2, 2.4),
|
| 146 |
+
new THREE.MeshStandardMaterial({ color: C_WIN, emissive: C_WIN, emissiveIntensity: 0.22, transparent: true, opacity: 0.0 }),
|
| 147 |
+
);
|
| 148 |
+
_winMesh.position.set(half, 0.6, 0);
|
| 149 |
+
_winMesh.visible = false;
|
| 150 |
+
_group.add(_winMesh);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
// Pre-allocate a fixed pool of needle nodes; toggled in-place as live data arrives
|
| 154 |
+
// (no per-poll geometry churn).
|
| 155 |
+
function _buildNeedles() {
|
| 156 |
+
const THREE = _THREE;
|
| 157 |
+
const geo = new THREE.IcosahedronGeometry(0.24, 0);
|
| 158 |
+
for (let n = 0; n < MAX_NEEDLES; n++) {
|
| 159 |
+
const node = new THREE.Mesh(
|
| 160 |
+
geo,
|
| 161 |
+
new THREE.MeshStandardMaterial({ color: C_DROP, emissive: C_DROP, emissiveIntensity: 0.2, transparent: true, opacity: 0.0 }),
|
| 162 |
+
);
|
| 163 |
+
node.position.set(0, BASE_Y, 0);
|
| 164 |
+
node.visible = false;
|
| 165 |
+
_group.add(node);
|
| 166 |
+
_needle.push(node);
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function _buildQuery() {
|
| 171 |
+
const THREE = _THREE;
|
| 172 |
+
_query = new THREE.Mesh(
|
| 173 |
+
new THREE.ConeGeometry(0.34, 0.9, 4),
|
| 174 |
+
new THREE.MeshStandardMaterial({ color: C_RETR, emissive: C_RETR, emissiveIntensity: 0.5, wireframe: true, transparent: true, opacity: 0.85 }),
|
| 175 |
+
);
|
| 176 |
+
_query.position.set(STREAM_LEN / 2, 1.4, 0);
|
| 177 |
+
_query.rotation.z = Math.PI; // point down at the stream head
|
| 178 |
+
_group.add(_query);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
// =============================================================================
|
| 182 |
+
// live data handler
|
| 183 |
+
// =============================================================================
|
| 184 |
+
function _onRecall(j) {
|
| 185 |
+
// read honesty label VERBATIM — never upgrade
|
| 186 |
+
S.label = (j.label || "MODELED").toUpperCase();
|
| 187 |
+
S.seqLen = typeof j.seq_len === "number" ? j.seq_len : null;
|
| 188 |
+
S.window = typeof j.window === "number" ? j.window : null;
|
| 189 |
+
S.nNeedles = typeof j.n_needles === "number" ? j.n_needles : null;
|
| 190 |
+
S.retrievalK = typeof j.retrieval_k === "number" ? j.retrieval_k : null;
|
| 191 |
+
S.dim = typeof j.dim === "number" ? j.dim : null;
|
| 192 |
+
S.decay = typeof j.decay === "number" ? j.decay : null;
|
| 193 |
+
S.nLongRange = typeof j.n_long_range_needles === "number" ? j.n_long_range_needles : null;
|
| 194 |
+
S.nWindow = typeof j.n_window_needles === "number" ? j.n_window_needles : null;
|
| 195 |
+
S.fullLR = typeof j.full_long_range_recall === "number" ? j.full_long_range_recall : null;
|
| 196 |
+
S.sparseLR = typeof j.sparse_long_range_recall === "number" ? j.sparse_long_range_recall : null;
|
| 197 |
+
S.edmLR = typeof j.edm_long_range_recall === "number" ? j.edm_long_range_recall : null;
|
| 198 |
+
S.retrLR = typeof j.retrieval_long_range_recall === "number" ? j.retrieval_long_range_recall : null;
|
| 199 |
+
S.recovery = typeof j.long_range_recall_recovery === "number" ? j.long_range_recall_recovery : null;
|
| 200 |
+
S.vsEdm = typeof j.retrieval_vs_edm_gain === "number" ? j.retrieval_vs_edm_gain : null;
|
| 201 |
+
S.attendSparse = typeof j.attend_frac_sparse === "number" ? j.attend_frac_sparse : null;
|
| 202 |
+
S.attendRetr = typeof j.attend_frac_retrieval === "number" ? j.attend_frac_retrieval : null;
|
| 203 |
+
S.perNeedle = Array.isArray(j.per_needle) ? j.per_needle : null;
|
| 204 |
+
|
| 205 |
+
_updateStream();
|
| 206 |
+
_paintOverlay();
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
// =============================================================================
|
| 210 |
+
// geometry updater — drives the token stream from live data
|
| 211 |
+
// =============================================================================
|
| 212 |
+
function _updateStream() {
|
| 213 |
+
const live = S.state === "live";
|
| 214 |
+
const half = STREAM_LEN / 2;
|
| 215 |
+
const needles = live && S.perNeedle && S.perNeedle.length ? S.perNeedle.slice(0, MAX_NEEDLES) : [];
|
| 216 |
+
const seq = S.seqLen || 1;
|
| 217 |
+
|
| 218 |
+
// local-window slab: cover [seq-W, seq) mapped onto the stream near the head.
|
| 219 |
+
if (_winMesh) {
|
| 220 |
+
if (live && S.window != null && seq > 0) {
|
| 221 |
+
const wFrac = Math.max(0.02, Math.min(1.0, S.window / seq));
|
| 222 |
+
const w = wFrac * STREAM_LEN;
|
| 223 |
+
_winMesh.scale.x = Math.max(0.02, w);
|
| 224 |
+
_winMesh.position.x = half - w / 2;
|
| 225 |
+
_winMesh.material.color.setHex(C_WIN);
|
| 226 |
+
_winMesh.material.emissive.setHex(C_WIN);
|
| 227 |
+
_winMesh.material.opacity = 0.16;
|
| 228 |
+
_winMesh.visible = true;
|
| 229 |
+
} else {
|
| 230 |
+
_winMesh.visible = false;
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
for (let n = 0; n < MAX_NEEDLES; n++) {
|
| 235 |
+
const node = _needle[n];
|
| 236 |
+
if (!live || n >= needles.length) { node.visible = false; continue; }
|
| 237 |
+
node.visible = true;
|
| 238 |
+
const rec = needles[n];
|
| 239 |
+
const pos = typeof rec.pos === "number" ? rec.pos : 0;
|
| 240 |
+
const x = -half + (pos / Math.max(1, seq - 1)) * STREAM_LEN;
|
| 241 |
+
|
| 242 |
+
// classify colour by which policy recalls this needle:
|
| 243 |
+
// in-window -> lattice-blue (kept for free)
|
| 244 |
+
// retrieval-only -> proof-teal (MATCH recovered it)
|
| 245 |
+
// edm-only tail -> amber (decay rescued the recent tail)
|
| 246 |
+
// dropped -> grey (no policy short of dense reaches it)
|
| 247 |
+
let col = C_DROP, glow = 0.15, y = BASE_Y;
|
| 248 |
+
const sim = typeof rec.sim === "number" ? rec.sim : 0;
|
| 249 |
+
if (rec.in_window) {
|
| 250 |
+
col = C_WIN; glow = 0.4; y = BASE_Y + 0.5;
|
| 251 |
+
} else if (rec.recalled_retrieval) {
|
| 252 |
+
col = C_RETR; glow = 0.35 + 0.5 * Math.max(0, Math.min(1, sim)); y = BASE_Y + 0.4 + 0.8 * Math.max(0, sim);
|
| 253 |
+
} else if (rec.recalled_edm) {
|
| 254 |
+
col = C_EDM; glow = 0.3; y = BASE_Y + 0.3;
|
| 255 |
+
} else {
|
| 256 |
+
col = C_DROP; glow = 0.12; y = BASE_Y;
|
| 257 |
+
}
|
| 258 |
+
node.position.set(x, y, 0);
|
| 259 |
+
node.material.color.setHex(col);
|
| 260 |
+
node.material.emissive.setHex(col);
|
| 261 |
+
node.material.emissiveIntensity = glow;
|
| 262 |
+
node.material.opacity = rec.in_window ? 0.95 : (rec.recalled_retrieval ? 0.95 : 0.6);
|
| 263 |
+
// retrieved long-range needles read a touch larger (re-injected into the read set)
|
| 264 |
+
node.scale.setScalar(rec.retrieved && !rec.in_window ? 1.25 : 1.0);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// spine + query degrade to grey when not live
|
| 268 |
+
if (_spine) {
|
| 269 |
+
_spine.material.color.setHex(live ? C_WIN : C_DIM);
|
| 270 |
+
_spine.material.opacity = live ? 0.4 : 0.15;
|
| 271 |
+
}
|
| 272 |
+
if (_query) {
|
| 273 |
+
const c = live ? C_RETR : C_DIM;
|
| 274 |
+
_query.material.color.setHex(c);
|
| 275 |
+
_query.material.emissive.setHex(c);
|
| 276 |
+
_query.material.opacity = live ? 0.85 : 0.3;
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
// =============================================================================
|
| 281 |
+
// per-frame animation
|
| 282 |
+
// =============================================================================
|
| 283 |
+
function _onFrame() {
|
| 284 |
+
const t = performance.now();
|
| 285 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00009) * 0.10;
|
| 286 |
+
if (_query) {
|
| 287 |
+
_query.rotation.y += 0.03;
|
| 288 |
+
const pulse = 1.0 + 0.12 * Math.sin(t * 0.004);
|
| 289 |
+
_query.scale.setScalar(pulse);
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// =============================================================================
|
| 294 |
+
// overlay
|
| 295 |
+
// =============================================================================
|
| 296 |
+
function _buildOverlay() {
|
| 297 |
+
const ctx = _ctx;
|
| 298 |
+
_show = createShowcase(ctx, {
|
| 299 |
+
id: ID, title: TITLE, accent: "#3af4c8",
|
| 300 |
+
badge: _badge,
|
| 301 |
+
chips: [{ label: "MODELED", text: "long-range recall", name: "ra" }],
|
| 302 |
+
legend: ["MODELED", "SAMPLE"],
|
| 303 |
+
description:
|
| 304 |
+
'A cheap <b>sparse / local attention window</b> only reads the last W tokens, so any ' +
|
| 305 |
+
'fact planted further back — a long-context <b>needle</b> — is structurally dropped and ' +
|
| 306 |
+
'no recency weighting brings it back. <b>MATCH</b> modulates that window with an ' +
|
| 307 |
+
'in-context <b>retrieval</b> step: it scores the dropped tokens by CONTENT similarity to ' +
|
| 308 |
+
'the query and re-injects the Top-k, recovering the long-range needles the window missed. ' +
|
| 309 |
+
'For contrast an <b>exponentially-decaying-memory</b> baseline only rescues the recent ' +
|
| 310 |
+
'tail (position, not content). The HUD reports long-range recall for each policy, the ' +
|
| 311 |
+
'recovery retrieval adds over a plain sparse window, and the still-sub-dense attend ' +
|
| 312 |
+
'fraction it pays. Honesty label <b>MODELED</b> (deterministic simulation on a synthetic ' +
|
| 313 |
+
'needle task; NOT a real trained model, corpus, or GPU). 0 runtime CDN.',
|
| 314 |
+
citations:
|
| 315 |
+
"MATCH — Ma et al. arXiv:2606.29844 (ACL 2026) · Exponentially-Decaying-Memory attention " +
|
| 316 |
+
"— Wei & Gulcehre arXiv:2605.28640. MODELED · not claimed-as.",
|
| 317 |
+
plain: { html: _plainHtml },
|
| 318 |
+
});
|
| 319 |
+
|
| 320 |
+
_el["ra-seqwin"] = _show.addField("seq_len · window W");
|
| 321 |
+
_el["ra-needles"] = _show.addField("needles (long-range / in-window)");
|
| 322 |
+
_el["ra-fullLR"] = _show.addField("full-dense long-range recall (oracle)");
|
| 323 |
+
_el["ra-sparse"] = _show.addField("sparse-window long-range recall");
|
| 324 |
+
_el["ra-edm"] = _show.addField("decaying-memory long-range recall");
|
| 325 |
+
_el["ra-retr"] = _show.addField("retrieval long-range recall — MODELED");
|
| 326 |
+
_el["ra-recov"] = _show.addField("recovery vs plain sparse window");
|
| 327 |
+
_el["ra-vsedm"] = _show.addField("retrieval vs decaying-memory gain");
|
| 328 |
+
_el["ra-attend"] = _show.addField("attend fraction (sparse / retrieval)");
|
| 329 |
+
_el["ra-k"] = _show.addField("retrieval Top-k re-injected");
|
| 330 |
+
_el["ra-label"] = _show.addField("honesty label");
|
| 331 |
+
|
| 332 |
+
_paintOverlay();
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
function _plainHtml() {
|
| 336 |
+
const sp = S.sparseLR != null ? (S.sparseLR * 100).toFixed(0) + "%" : "loading…";
|
| 337 |
+
const rt = S.retrLR != null ? (S.retrLR * 100).toFixed(0) + "%" : "loading…";
|
| 338 |
+
const rc = S.recovery != null ? (S.recovery * 100).toFixed(0) + " points" : "loading…";
|
| 339 |
+
return (
|
| 340 |
+
"<b>What this means:</b> Picture reading a very long book but only being allowed to look at " +
|
| 341 |
+
"the last few pages. If an important fact was mentioned early on, you simply cannot see it — " +
|
| 342 |
+
"that is a sparse window, and here it recalls <b>" + sp + "</b> of the far-back facts. The " +
|
| 343 |
+
"<b>retrieval</b> trick lets the model glance back and PULL IN the few early sentences that " +
|
| 344 |
+
"best match the question, no matter how far back they are — so it now recalls <b>" + rt + "</b> " +
|
| 345 |
+
"of those far facts, a recovery of about <b>" + rc + "</b>. It does this while still reading far " +
|
| 346 |
+
"fewer tokens than looking at the whole book. This view is a <b>MODELED</b> deterministic " +
|
| 347 |
+
"simulation of those read rules on a synthetic needle task, not a run of a real trained model.");
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
function _tok(s) {
|
| 351 |
+
if (s === "live") return null;
|
| 352 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 353 |
+
if (s === "degraded") return "DEGRADED";
|
| 354 |
+
if (s === "error") return "OFFLINE";
|
| 355 |
+
return "…";
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
function pct(v) { return typeof v === "number" ? (v * 100).toFixed(1) + "%" : "—"; }
|
| 359 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 360 |
+
|
| 361 |
+
function _paintOverlay() {
|
| 362 |
+
const t = _tok(S.state);
|
| 363 |
+
_set("ra-seqwin", t || ((S.seqLen != null && S.window != null) ? (S.seqLen + " · " + S.window) : "—"));
|
| 364 |
+
_set("ra-needles", t || ((S.nLongRange != null && S.nWindow != null) ? (S.nLongRange + " / " + S.nWindow) : "—"));
|
| 365 |
+
_set("ra-fullLR", t || pct(S.fullLR));
|
| 366 |
+
_set("ra-sparse", t || pct(S.sparseLR));
|
| 367 |
+
_set("ra-edm", t || pct(S.edmLR));
|
| 368 |
+
_set("ra-retr", t || pct(S.retrLR));
|
| 369 |
+
_set("ra-recov", t || (S.recovery != null ? "+" + pct(S.recovery) : "—"));
|
| 370 |
+
_set("ra-vsedm", t || (S.vsEdm != null ? "+" + pct(S.vsEdm) : "—"));
|
| 371 |
+
_set("ra-attend", t || ((S.attendSparse != null && S.attendRetr != null) ? (pct(S.attendSparse) + " / " + pct(S.attendRetr)) : "—"));
|
| 372 |
+
_set("ra-k", t || (S.retrievalK != null ? String(S.retrievalK) : "—"));
|
| 373 |
+
// honesty label verbatim — never upgraded
|
| 374 |
+
_set("ra-label", t || (S.label || "MODELED"));
|
| 375 |
+
if (_show) { _show.setChip("ra", S.label || "MODELED", { text: "long-range recall" }); _show.refreshPlain(); }
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
// =============================================================================
|
| 379 |
+
// unmount — clean up everything; must not affect other organs
|
| 380 |
+
// =============================================================================
|
| 381 |
+
export function unmount() {
|
| 382 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 383 |
+
try { if (_show) _show.destroy(); } catch (_) {}
|
| 384 |
+
try {
|
| 385 |
+
if (_group && _stage) {
|
| 386 |
+
_group.traverse((o) => {
|
| 387 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 388 |
+
if (o.material) {
|
| 389 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 390 |
+
ms.forEach((m) => { if (m.dispose) m.dispose(); });
|
| 391 |
+
}
|
| 392 |
+
});
|
| 393 |
+
_stage.scene.remove(_group);
|
| 394 |
+
}
|
| 395 |
+
} catch (_) {}
|
| 396 |
+
_group = _show = null;
|
| 397 |
+
_spine = null; _winMesh = null; _query = null; _needle = [];
|
| 398 |
+
_el = {}; _badge = null; _frameReg = false;
|
| 399 |
+
_stage = _THREE = _ctx = null;
|
| 400 |
+
S.label = S.seqLen = S.window = S.nNeedles = S.retrievalK = S.dim = S.decay = null;
|
| 401 |
+
S.nLongRange = S.nWindow = null;
|
| 402 |
+
S.fullLR = S.sparseLR = S.edmLR = S.retrLR = S.recovery = S.vsEdm = null;
|
| 403 |
+
S.attendSparse = S.attendRetr = S.perNeedle = null;
|
| 404 |
+
S.state = "init";
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|