Ex0bit commited on
Commit
de8a1e5
·
verified ·
1 Parent(s): 216c745

fix: HTML entities in textContent, finally blocks on all buttons, caption cleanup

Browse files
experiments/demo_server.py CHANGED
@@ -117,7 +117,7 @@ def run_cost(sizes: list) -> list:
117
  @torch.no_grad()
118
  def run_custom(doc_text: str, pairs: list, seed: int) -> dict:
119
  """Stream the USER's own text with the USER's own named key->value pairs,
120
- some changed mid-stream mid-stream, then query. Names map deterministically into
121
  the model's token space (shown in the response); the model only ever sees
122
  ids -- exactly the MQAR regime it was trained on."""
123
  from mulattice.protocol import logits_at
@@ -342,7 +342,7 @@ PAGE = r"""<!doctype html>
342
  <section>
343
  <div class="sn"><span class="n">01</span><h2 class="serif">Stream your own document</h2></div>
344
  <p class="lead">Paste any text. Define facts as <em>name &rarr; value</em> pairs. Mark any to be
345
- <strong>changed mid-stream mid-stream</strong>. The model reads the stream, stores the facts,
346
  and returns the <em>latest</em> value for each.</p>
347
  <div class="fig">
348
  <div class="grid2">
@@ -452,7 +452,7 @@ function prow(n,v,nv){const d=document.createElement("div");d.className="prow";
452
  d.querySelector(".del").onclick=()=>d.remove();return d}
453
  DEF.forEach(x=>$("pairs").appendChild(prow(...x)));
454
  $("addp").onclick=()=>$("pairs").appendChild(prow("","",""));
455
- $("runc").onclick=async()=>{$("runc").disabled=true;$("runc").textContent="reading your stream&hellip;";
456
  try{
457
  const pairs=[...document.querySelectorAll("#pairs .prow")].map(r=>{
458
  const i=r.querySelectorAll("input");return{name:i[0].value.trim(),value:i[1].value.trim(),
@@ -468,7 +468,7 @@ $("runc").onclick=async()=>{$("runc").disabled=true;$("runc").textContent="readi
468
  <td>${r.updated?`<span class="pill">was ${esc(r.old)}</span>`:""}${r.ok?"":" ✗"}</td></tr>`).join("");
469
  $("cres").style.display="block";
470
  $("ccap").innerHTML=`${d.n_pairs} of your facts stored in ${d.T.toLocaleString()} tokens of your text`+
471
- (d.n_upd?`, ${d.n_upd} changed mid-stream mid-stream`:"")+` · recall <b>${d.acc}</b> · ${d.us_per_token} &mu;s/token`+
472
  ` · key ids: `+Object.entries(d.keymap).slice(0,4).map(([n,k])=>`${esc(n)}=${k}`).join(", ")+`&hellip;`;
473
  }catch(e){alert(e)}$("runc").disabled=false;$("runc").textContent="Read, store, overwrite — and answer"};
474
  /* section 02 */
@@ -483,7 +483,7 @@ function drawLatt(pts,sc){const c=$("latt"),x=c.getContext("2d");
483
  x.beginPath();x.moveTo(0,p*H);x.lineTo(W,p*H);x.stroke()}
484
  x.fillStyle="#2547d0";for(const p of pts){const u=(p[0]/sc+1)/2,v=(p[1]/sc+1)/2;
485
  x.beginPath();x.arc(u*W,v*H,1.7,0,7);x.fill()}}
486
- $("run").onclick=async()=>{$("run").disabled=true;$("run").textContent="streaming&hellip;";
487
  try{const d=await api("/api/store",{n_pairs:+$("np").value,filler:+$("fl").value,
488
  overwrite_frac:+$("ow").value/100,seed:(Math.random()*1e6)|0});
489
  $("meta").textContent=`scale ${d.scale} · ${d.params.toLocaleString()} params · ${d.device} · run ${d.ts}`;
@@ -492,7 +492,7 @@ $("run").onclick=async()=>{$("run").disabled=true;$("run").textContent="streamin
492
  d.rows.map(r=>`<tr><td>${r.key}</td><td class="${r.ok?"y":"n"}">${r.pred}</td>`+
493
  `<td class="${r.updated?"updv":""}">${r.gold}</td>`+
494
  `<td>${r.updated?'<span class="pill">changed mid-stream</span>':""}${r.ok?"":" ✗"}</td></tr>`).join("");
495
- }catch(e){alert(e)}$("run").disabled=false;$("run").textContent="stream & query"};
496
  /* section 03 */
497
  function drawCC(data){const c=$("cc"),x=c.getContext("2d");c.width=c.clientWidth*2;c.height=600;
498
  x.scale(2,2);const W=c.width/2,H=300,P=48;
@@ -519,7 +519,7 @@ function drawCC(data){const c=$("cc"),x=c.getContext("2d");c.width=c.clientWidth
519
  for(const d of data)x.fillText(d.T.toLocaleString(),X(d.T)-16,H-14);
520
  x.fillText("stream length (tokens, log scale)",W/2-80,H-2);
521
  x.fillText("&mu;s/token (blue, flat = constant) · cells (green) · attention O(T²) (dashed red)",P,16)}
522
- $("cost").onclick=async()=>{$("cost").disabled=true;$("cost").textContent="measuring&hellip;";
523
  try{const sizes=[64,256,1024,2048,4096,8192].map(n=>({n_pairs:n,filler:14}));
524
  const d=await api("/api/cost",{sizes});drawCC(d)}catch(e){alert(e)}
525
  $("cost").disabled=false;$("cost").textContent="measure the cost curve"};
@@ -538,7 +538,7 @@ $("cv").onclick=async()=>{$("cv").disabled=true;
538
  <p class="note" style="margin:8px 0 0">key id ${d.kid} &rarr; address on grid scale ${d.scale};
539
  the write lands as <code>W &larr; &alpha;W + &beta;(v<sub>new</sub> &minus; &alpha;W&kappa;)&kappa;<sup>T</sup>:
540
  the old association is subtracted out, the new one takes its place &mdash; nothing is appended.</p>`;
541
- drawCell(d)}catch(e){alert(e)}$("cv").disabled=false};
542
  function drawCell(d){const c=$("cellcv"),x=c.getContext("2d");
543
  c.width=c.clientWidth*2;c.height=600;x.scale(2,2);const W=c.width/2,H=300;
544
  x.fillStyle="#fff";x.fillRect(0,0,W,H);const cw=W/3,ch=H/3;
 
117
  @torch.no_grad()
118
  def run_custom(doc_text: str, pairs: list, seed: int) -> dict:
119
  """Stream the USER's own text with the USER's own named key->value pairs,
120
+ some changed mid-stream, then query. Names map deterministically into
121
  the model's token space (shown in the response); the model only ever sees
122
  ids -- exactly the MQAR regime it was trained on."""
123
  from mulattice.protocol import logits_at
 
342
  <section>
343
  <div class="sn"><span class="n">01</span><h2 class="serif">Stream your own document</h2></div>
344
  <p class="lead">Paste any text. Define facts as <em>name &rarr; value</em> pairs. Mark any to be
345
+ <strong>changed mid-stream</strong>. The model reads the stream, stores the facts,
346
  and returns the <em>latest</em> value for each.</p>
347
  <div class="fig">
348
  <div class="grid2">
 
452
  d.querySelector(".del").onclick=()=>d.remove();return d}
453
  DEF.forEach(x=>$("pairs").appendChild(prow(...x)));
454
  $("addp").onclick=()=>$("pairs").appendChild(prow("","",""));
455
+ $("runc").onclick=async()=>{$("runc").disabled=true;$("runc").textContent="reading your stream...";
456
  try{
457
  const pairs=[...document.querySelectorAll("#pairs .prow")].map(r=>{
458
  const i=r.querySelectorAll("input");return{name:i[0].value.trim(),value:i[1].value.trim(),
 
468
  <td>${r.updated?`<span class="pill">was ${esc(r.old)}</span>`:""}${r.ok?"":" ✗"}</td></tr>`).join("");
469
  $("cres").style.display="block";
470
  $("ccap").innerHTML=`${d.n_pairs} of your facts stored in ${d.T.toLocaleString()} tokens of your text`+
471
+ (d.n_upd?`, ${d.n_upd} changed mid-stream`:"")+` · recall <b>${d.acc}</b> · ${d.us_per_token} &mu;s/token`+
472
  ` · key ids: `+Object.entries(d.keymap).slice(0,4).map(([n,k])=>`${esc(n)}=${k}`).join(", ")+`&hellip;`;
473
  }catch(e){alert(e)}$("runc").disabled=false;$("runc").textContent="Read, store, overwrite — and answer"};
474
  /* section 02 */
 
483
  x.beginPath();x.moveTo(0,p*H);x.lineTo(W,p*H);x.stroke()}
484
  x.fillStyle="#2547d0";for(const p of pts){const u=(p[0]/sc+1)/2,v=(p[1]/sc+1)/2;
485
  x.beginPath();x.arc(u*W,v*H,1.7,0,7);x.fill()}}
486
+ $("run").onclick=async()=>{$("run").disabled=true;$("run").textContent="streaming...";
487
  try{const d=await api("/api/store",{n_pairs:+$("np").value,filler:+$("fl").value,
488
  overwrite_frac:+$("ow").value/100,seed:(Math.random()*1e6)|0});
489
  $("meta").textContent=`scale ${d.scale} · ${d.params.toLocaleString()} params · ${d.device} · run ${d.ts}`;
 
492
  d.rows.map(r=>`<tr><td>${r.key}</td><td class="${r.ok?"y":"n"}">${r.pred}</td>`+
493
  `<td class="${r.updated?"updv":""}">${r.gold}</td>`+
494
  `<td>${r.updated?'<span class="pill">changed mid-stream</span>':""}${r.ok?"":" ✗"}</td></tr>`).join("");
495
+ }catch(e){console.error(e);alert(e)}finally{$("run").disabled=false;$("run").textContent="stream & query"}};
496
  /* section 03 */
497
  function drawCC(data){const c=$("cc"),x=c.getContext("2d");c.width=c.clientWidth*2;c.height=600;
498
  x.scale(2,2);const W=c.width/2,H=300,P=48;
 
519
  for(const d of data)x.fillText(d.T.toLocaleString(),X(d.T)-16,H-14);
520
  x.fillText("stream length (tokens, log scale)",W/2-80,H-2);
521
  x.fillText("&mu;s/token (blue, flat = constant) · cells (green) · attention O(T²) (dashed red)",P,16)}
522
+ $("cost").onclick=async()=>{$("cost").disabled=true;$("cost").textContent="measuring...";
523
  try{const sizes=[64,256,1024,2048,4096,8192].map(n=>({n_pairs:n,filler:14}));
524
  const d=await api("/api/cost",{sizes});drawCC(d)}catch(e){alert(e)}
525
  $("cost").disabled=false;$("cost").textContent="measure the cost curve"};
 
538
  <p class="note" style="margin:8px 0 0">key id ${d.kid} &rarr; address on grid scale ${d.scale};
539
  the write lands as <code>W &larr; &alpha;W + &beta;(v<sub>new</sub> &minus; &alpha;W&kappa;)&kappa;<sup>T</sup>:
540
  the old association is subtracted out, the new one takes its place &mdash; nothing is appended.</p>`;
541
+ drawCell(d)}catch(e){console.error(e);alert(e)}finally{$("cv").disabled=false;$("cv").textContent="inspect the cell"}};
542
  function drawCell(d){const c=$("cellcv"),x=c.getContext("2d");
543
  c.width=c.clientWidth*2;c.height=600;x.scale(2,2);const W=c.width/2,H=300;
544
  x.fillStyle="#fff";x.fillRect(0,0,W,H);const cw=W/3,ch=H/3;
src/mulattice/__pycache__/autoscan.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/autoscan.cpython-314.pyc and b/src/mulattice/__pycache__/autoscan.cpython-314.pyc differ
 
src/mulattice/__pycache__/fastscan.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/fastscan.cpython-314.pyc and b/src/mulattice/__pycache__/fastscan.cpython-314.pyc differ
 
src/mulattice/__pycache__/kernel.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/kernel.cpython-314.pyc and b/src/mulattice/__pycache__/kernel.cpython-314.pyc differ
 
src/mulattice/__pycache__/models.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/models.cpython-314.pyc and b/src/mulattice/__pycache__/models.cpython-314.pyc differ
 
src/mulattice/__pycache__/protocol.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/protocol.cpython-314.pyc and b/src/mulattice/__pycache__/protocol.cpython-314.pyc differ
 
src/mulattice/__pycache__/sparse_scan.cpython-314.pyc CHANGED
Binary files a/src/mulattice/__pycache__/sparse_scan.cpython-314.pyc and b/src/mulattice/__pycache__/sparse_scan.cpython-314.pyc differ