Spaces:
Running
Running
step-through viewer over recorded decoder traces
Browse files- README.md +21 -4
- index.html +298 -18
- traces.json +0 -0
README.md
CHANGED
|
@@ -1,10 +1,27 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Set Block Decoding
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: gray
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
models:
|
| 11 |
+
- belumind/sbd-sql-0.5b
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Set Block Decoding, step by step
|
| 15 |
+
|
| 16 |
+
Step through real decoding runs of [`belumind/sbd-sql-0.5b`](https://huggingface.co/belumind/sbd-sql-0.5b):
|
| 17 |
+
one 0.5B model proposing a block of tokens past the frontier and verifying every one of them exactly.
|
| 18 |
+
|
| 19 |
+
Each token is coloured by where the accepted proposal came from — the causal NTP frontier, the
|
| 20 |
+
masked block (MATP), or an n-gram copied out of the prompt — and rollbacks show the verifier
|
| 21 |
+
refusing a guess and committing the true conditional instead.
|
| 22 |
+
|
| 23 |
+
These are **recorded runs, not live inference**: every step is a real `sbd_generate` call executed on
|
| 24 |
+
an A100 in bf16 and logged forward pass by forward pass. The tracer was checked against the shipped
|
| 25 |
+
decoder and reproduces it token for token. For live generation, run
|
| 26 |
+
[`demo/demo_colab.ipynb`](https://huggingface.co/belumind/sbd-sql-0.5b/blob/main/demo/demo_colab.ipynb)
|
| 27 |
+
on a Colab GPU.
|
index.html
CHANGED
|
@@ -1,19 +1,299 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
+
<title>Set Block Decoding — step through a real run</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root{
|
| 9 |
+
--bg:#fbfbfa; --panel:#ffffff; --ink:#1d1c1a; --muted:#6b6862; --line:#e4e1db;
|
| 10 |
+
--ntp:#8a8781; --ntp-bg:#f1efeb;
|
| 11 |
+
--matp:#2f6f8f; --matp-bg:#e2eef4;
|
| 12 |
+
--ngram:#9a6b1f; --ngram-bg:#f7eddb;
|
| 13 |
+
--bad:#a33a2c; --bad-bg:#f8e6e2;
|
| 14 |
+
--accent:#1d1c1a;
|
| 15 |
+
}
|
| 16 |
+
@media (prefers-color-scheme: dark){
|
| 17 |
+
:root:not([data-theme="light"]){
|
| 18 |
+
--bg:#141413; --panel:#1c1c1a; --ink:#eeece7; --muted:#93908a; --line:#2f2e2b;
|
| 19 |
+
--ntp:#8f8c86; --ntp-bg:#262623;
|
| 20 |
+
--matp:#7fc2e0; --matp-bg:#16303c;
|
| 21 |
+
--ngram:#e0b46a; --ngram-bg:#3a2d15;
|
| 22 |
+
--bad:#e8897a; --bad-bg:#3a201c;
|
| 23 |
+
--accent:#eeece7;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
*{box-sizing:border-box}
|
| 27 |
+
body{margin:0;background:var(--bg);color:var(--ink);
|
| 28 |
+
font:15px/1.55 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Inter,sans-serif;
|
| 29 |
+
-webkit-font-smoothing:antialiased}
|
| 30 |
+
.wrap{max-width:1080px;margin:0 auto;padding:32px 20px 72px}
|
| 31 |
+
h1{font-size:26px;line-height:1.2;margin:0 0 6px;letter-spacing:-.01em}
|
| 32 |
+
h2{font-size:15px;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);
|
| 33 |
+
margin:36px 0 12px;font-weight:600}
|
| 34 |
+
a{color:inherit;text-decoration:underline;text-underline-offset:2px;text-decoration-thickness:1px}
|
| 35 |
+
.sub{color:var(--muted);margin:0 0 20px;max-width:62ch}
|
| 36 |
+
.note{border:1px solid var(--line);border-left:3px solid var(--accent);background:var(--panel);
|
| 37 |
+
padding:12px 14px;border-radius:6px;color:var(--muted);font-size:13.5px;max-width:72ch;margin:0 0 26px}
|
| 38 |
+
.note b{color:var(--ink)}
|
| 39 |
+
.panel{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:16px}
|
| 40 |
+
.controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;margin-bottom:14px}
|
| 41 |
+
label{display:block;font-size:12px;text-transform:uppercase;letter-spacing:.06em;
|
| 42 |
+
color:var(--muted);margin-bottom:5px;font-weight:600}
|
| 43 |
+
select,button{font:inherit;font-size:14px;color:var(--ink);background:var(--panel);
|
| 44 |
+
border:1px solid var(--line);border-radius:6px;padding:7px 9px;width:100%}
|
| 45 |
+
button{cursor:pointer;font-weight:500}
|
| 46 |
+
button:hover{border-color:var(--muted)}
|
| 47 |
+
button:disabled{opacity:.4;cursor:default}
|
| 48 |
+
.row{display:flex;gap:8px;align-items:center}
|
| 49 |
+
.row button{width:auto;padding:7px 14px}
|
| 50 |
+
input[type=range]{width:100%;accent-color:var(--accent)}
|
| 51 |
+
.layout{display:grid;grid-template-columns:1fr 250px;gap:16px;align-items:start}
|
| 52 |
+
@media(max-width:820px){.layout{grid-template-columns:1fr}}
|
| 53 |
+
.stream{font:13.5px/1.9 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
|
| 54 |
+
white-space:pre-wrap;word-break:break-word;min-height:180px}
|
| 55 |
+
.tk{border-radius:3px;padding:1px 0}
|
| 56 |
+
.tk.ntp{background:var(--ntp-bg)}
|
| 57 |
+
.tk.matp{background:var(--matp-bg);color:var(--matp)}
|
| 58 |
+
.tk.ngram{background:var(--ngram-bg);color:var(--ngram)}
|
| 59 |
+
.tk.fix{background:var(--bad-bg);color:var(--bad);text-decoration:underline;
|
| 60 |
+
text-decoration-style:wavy;text-underline-offset:3px}
|
| 61 |
+
.prop{opacity:.95}
|
| 62 |
+
.prop .tk{outline:1px dashed currentColor;outline-offset:1px}
|
| 63 |
+
.prop .rej{opacity:.35;text-decoration:line-through}
|
| 64 |
+
.cursor{display:inline-block;width:2px;height:1em;background:var(--accent);
|
| 65 |
+
vertical-align:-2px;margin:0 1px;animation:b 1.1s steps(1) infinite}
|
| 66 |
+
@keyframes b{50%{opacity:0}}
|
| 67 |
+
.stat{display:flex;justify-content:space-between;gap:10px;padding:7px 0;
|
| 68 |
+
border-bottom:1px solid var(--line);font-size:13.5px}
|
| 69 |
+
.stat:last-child{border-bottom:0}
|
| 70 |
+
.stat span:first-child{color:var(--muted)}
|
| 71 |
+
.stat b{font-variant-numeric:tabular-nums;font-weight:600}
|
| 72 |
+
.big{font-size:26px;font-variant-numeric:tabular-nums;letter-spacing:-.02em;margin:2px 0 0}
|
| 73 |
+
.verdict{margin-top:12px;font-size:13.5px;padding:9px 11px;border-radius:6px;
|
| 74 |
+
border:1px solid var(--line);background:var(--bg)}
|
| 75 |
+
.verdict.roll{border-color:var(--bad);color:var(--bad)}
|
| 76 |
+
.key{display:flex;flex-wrap:wrap;gap:14px;margin:12px 0 0;font-size:12.5px;color:var(--muted)}
|
| 77 |
+
.key i{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:5px;
|
| 78 |
+
vertical-align:-1px;font-style:normal}
|
| 79 |
+
table{border-collapse:collapse;width:100%;font-size:13.5px;margin-top:4px}
|
| 80 |
+
th,td{text-align:left;padding:7px 10px;border-bottom:1px solid var(--line)}
|
| 81 |
+
th{color:var(--muted);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.05em}
|
| 82 |
+
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums}
|
| 83 |
+
.scroll{overflow-x:auto}
|
| 84 |
+
details{margin-top:10px;border-top:1px solid var(--line);padding-top:10px}
|
| 85 |
+
summary{cursor:pointer;color:var(--muted);font-size:13px}
|
| 86 |
+
pre.pt{font:12.5px/1.6 ui-monospace,Menlo,monospace;white-space:pre-wrap;
|
| 87 |
+
color:var(--muted);max-height:200px;overflow:auto;margin:8px 0 0}
|
| 88 |
+
footer{margin-top:44px;padding-top:18px;border-top:1px solid var(--line);
|
| 89 |
+
color:var(--muted);font-size:13px}
|
| 90 |
+
</style>
|
| 91 |
+
</head>
|
| 92 |
+
<body>
|
| 93 |
+
<div class="wrap">
|
| 94 |
+
|
| 95 |
+
<h1>Set Block Decoding, step by step</h1>
|
| 96 |
+
<p class="sub">One 0.5B model proposes a block of tokens past the frontier and verifies every one of
|
| 97 |
+
them exactly. Step through a run and watch where each accepted token came from — and what happens
|
| 98 |
+
when the verifier says no.</p>
|
| 99 |
+
|
| 100 |
+
<div class="note">
|
| 101 |
+
<b>These are recorded runs, not live inference.</b> Every step below is a real
|
| 102 |
+
<code>sbd_generate</code> call on <a href="https://huggingface.co/belumind/sbd-sql-0.5b">belumind/sbd-sql-0.5b</a>,
|
| 103 |
+
executed on an A100 in bf16 and logged forward pass by forward pass; the tracer was checked
|
| 104 |
+
against the shipped decoder and reproduces it token for token. A live Gradio Space needs paid
|
| 105 |
+
hardware, so the interactive version runs in Colab —
|
| 106 |
+
<a href="https://huggingface.co/belumind/sbd-sql-0.5b/blob/main/demo/demo_colab.ipynb">demo/demo_colab.ipynb</a>.
|
| 107 |
+
</div>
|
| 108 |
+
|
| 109 |
+
<div class="controls">
|
| 110 |
+
<div><label for="p">Prompt</label><select id="p"></select></div>
|
| 111 |
+
<div><label for="m">Proposal sources</label><select id="m"></select></div>
|
| 112 |
+
<div><label for="s">Step</label><div class="row">
|
| 113 |
+
<button id="prev">←</button><button id="next">→</button><button id="play">Play</button>
|
| 114 |
+
</div></div>
|
| 115 |
+
</div>
|
| 116 |
+
<input type="range" id="s" min="0" value="0" style="margin-bottom:16px">
|
| 117 |
+
|
| 118 |
+
<div class="layout">
|
| 119 |
+
<div class="panel">
|
| 120 |
+
<div class="stream" id="stream"></div>
|
| 121 |
+
<div class="verdict" id="verdict"></div>
|
| 122 |
+
<div class="key">
|
| 123 |
+
<span><i style="background:var(--ntp-bg);border:1px solid var(--ntp)"></i>NTP frontier</span>
|
| 124 |
+
<span><i style="background:var(--matp-bg);border:1px solid var(--matp)"></i>MATP block</span>
|
| 125 |
+
<span><i style="background:var(--ngram-bg);border:1px solid var(--ngram)"></i>n-gram copy</span>
|
| 126 |
+
<span><i style="background:var(--bad-bg);border:1px solid var(--bad)"></i>correction after rollback</span>
|
| 127 |
+
<span>dashed outline = proposed, not yet verified</span>
|
| 128 |
+
</div>
|
| 129 |
+
<details><summary>Show the prompt</summary><pre class="pt" id="ptxt"></pre></details>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<div class="panel">
|
| 133 |
+
<div style="color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.06em;font-weight:600">tokens / forward</div>
|
| 134 |
+
<div class="big" id="tpf">—</div>
|
| 135 |
+
<div style="height:10px"></div>
|
| 136 |
+
<div class="stat"><span>forward passes</span><b id="fw">0</b></div>
|
| 137 |
+
<div class="stat"><span>tokens committed</span><b id="tc">0</b></div>
|
| 138 |
+
<div class="stat"><span>rollbacks</span><b id="rb">0</b></div>
|
| 139 |
+
<div class="stat"><span>from NTP</span><b id="a-ntp">0</b></div>
|
| 140 |
+
<div class="stat"><span>from MATP</span><b id="a-matp">0</b></div>
|
| 141 |
+
<div class="stat"><span>from n-gram</span><b id="a-ngram">0</b></div>
|
| 142 |
+
<div class="stat" style="border-top:1px solid var(--line);margin-top:8px;padding-top:9px">
|
| 143 |
+
<span>run total</span><b id="final">—</b></div>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<h2>What the whole run measures</h2>
|
| 148 |
+
<div class="panel scroll">
|
| 149 |
+
<table id="runs"><thead><tr>
|
| 150 |
+
<th>Prompt</th><th>Sources</th><th class="n">τ</th><th class="n">tok/fwd</th>
|
| 151 |
+
<th class="n">forwards</th><th class="n">rollbacks</th><th class="n">MATP</th><th class="n">n-gram</th>
|
| 152 |
+
</tr></thead><tbody></tbody></table>
|
| 153 |
+
</div>
|
| 154 |
+
<p class="sub" style="margin-top:12px;font-size:13.5px">
|
| 155 |
+
Single runs, so they scatter. The averaged numbers — 1.87 tok/fwd on 20 held-out real documents,
|
| 156 |
+
2.28 on a template-generated set, and what that gap means — are on the
|
| 157 |
+
<a href="https://huggingface.co/belumind/sbd-sql-0.5b">model card</a>.</p>
|
| 158 |
+
|
| 159 |
+
<h2>How to read it</h2>
|
| 160 |
+
<div class="panel" style="max-width:74ch">
|
| 161 |
+
<p style="margin-top:0"><b>Every forward pass proposes and verifies at the same time.</b> The block of
|
| 162 |
+
8 mask tokens appended after the frontier gives the MATP guesses; the same pass recomputes the true
|
| 163 |
+
conditionals for the tokens proposed last round, which is what verification costs — nothing extra.</p>
|
| 164 |
+
<p><b>The first proposed token is always exact.</b> It is the ordinary next-token prediction at a
|
| 165 |
+
purely causal frontier, so the decoder can never fall below one token per forward.</p>
|
| 166 |
+
<p><b>A rollback is not an error.</b> It is the verifier refusing a guess. Output stays identical to
|
| 167 |
+
greedy decoding — measured at 100% agreement in bf16 and fp32 — and τ only trades rollbacks
|
| 168 |
+
against speed. Loosen it and you will see more crossed-out tokens here, and a higher tok/fwd anyway.</p>
|
| 169 |
+
<p style="margin-bottom:0"><b>tokens/forward is not wall-clock.</b> This reference decoder keeps no
|
| 170 |
+
KV cache and recomputes the whole sequence every step. It still beat
|
| 171 |
+
<code>generate(use_cache=True)</code> by 1.58× end to end on the same A100 — a
|
| 172 |
+
<code>transformers</code> baseline, not an optimised server.</p>
|
| 173 |
+
</div>
|
| 174 |
+
|
| 175 |
+
<footer>
|
| 176 |
+
Built by <a href="https://huggingface.co/belumind">Belumind</a> ·
|
| 177 |
+
<a href="https://huggingface.co/belumind/sbd-sql-0.5b">model & card</a> ·
|
| 178 |
+
method: <a href="https://arxiv.org/abs/2509.04185">Set Block Decoding</a> (arXiv 2509.04185)
|
| 179 |
+
<span id="meta" style="display:block;margin-top:6px"></span>
|
| 180 |
+
</footer>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
<script>
|
| 184 |
+
let B=null,cur=null,step=0,timer=null;
|
| 185 |
+
|
| 186 |
+
const $=id=>document.getElementById(id);
|
| 187 |
+
const esc=s=>s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
| 188 |
+
const vis=s=>esc(s).replace(/\n/g,"⏎\n");
|
| 189 |
+
const MODES={union:"NTP + MATP + n-gram",matp:"NTP + MATP",ngram:"NTP + n-gram",ntp:"NTP only (no speculation)"};
|
| 190 |
+
|
| 191 |
+
fetch("traces.json").then(r=>r.json()).then(b=>{B=b;init()})
|
| 192 |
+
.catch(e=>{$("stream").textContent="Could not load traces.json — "+e});
|
| 193 |
+
|
| 194 |
+
function init(){
|
| 195 |
+
$("meta").textContent = B.meta.model+" · "+B.meta.gpu+" · "+B.meta.dtype
|
| 196 |
+
+" · block "+B.meta.block_size+" · "+B.meta.prompt_tokens+"-token prompt, "
|
| 197 |
+
+B.meta.max_new_tokens+" new tokens · recorded "+B.meta.recorded;
|
| 198 |
+
B.prompts.forEach(p=>{const o=document.createElement("option");o.value=p.id;o.textContent=p.label;$("p").appendChild(o)});
|
| 199 |
+
const seen=[];
|
| 200 |
+
B.runs.forEach(r=>{const k=r.mode+"|"+r.tau;
|
| 201 |
+
if(seen.indexOf(k)<0){seen.push(k);
|
| 202 |
+
const o=document.createElement("option");o.value=k;
|
| 203 |
+
o.textContent=MODES[r.mode]+(r.mode==="ntp"?"":" · τ "+r.tau.toFixed(2));
|
| 204 |
+
$("m").appendChild(o)}});
|
| 205 |
+
$("m").value="union|0.6";
|
| 206 |
+
fillTable();
|
| 207 |
+
["p","m"].forEach(id=>$(id).onchange=pick);
|
| 208 |
+
$("s").oninput=()=>{step=+$("s").value;stop();render()};
|
| 209 |
+
$("prev").onclick=()=>{stop();step=Math.max(0,step-1);render()};
|
| 210 |
+
$("next").onclick=()=>{stop();step=Math.min(cur.steps.length-1,step+1);render()};
|
| 211 |
+
$("play").onclick=play;
|
| 212 |
+
pick();
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
function pick(){
|
| 216 |
+
const [m,t]=$("m").value.split("|");
|
| 217 |
+
cur=B.runs.find(r=>r.prompt===$("p").value&&r.mode===m&&r.tau===+t);
|
| 218 |
+
step=0;$("s").max=cur.steps.length-1;$("s").value=0;
|
| 219 |
+
$("ptxt").textContent=B.prompts.find(p=>p.id===cur.prompt).text;
|
| 220 |
+
stop();render();
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
function play(){
|
| 224 |
+
if(timer){stop();return}
|
| 225 |
+
if(step>=cur.steps.length-1)step=0;
|
| 226 |
+
$("play").textContent="Pause";
|
| 227 |
+
timer=setInterval(()=>{
|
| 228 |
+
if(step>=cur.steps.length-1){stop();return}
|
| 229 |
+
step++;$("s").value=step;render();
|
| 230 |
+
},520);
|
| 231 |
+
}
|
| 232 |
+
function stop(){if(timer)clearInterval(timer);timer=null;$("play").textContent="Play"}
|
| 233 |
+
|
| 234 |
+
function render(){
|
| 235 |
+
$("s").value=step;
|
| 236 |
+
let html="",fw=0,tc=0,rb=0,a={ntp:0,matp:0,ngram:0};
|
| 237 |
+
for(let i=0;i<step;i++){
|
| 238 |
+
const st=cur.steps[i],v=st.verdict;fw++;
|
| 239 |
+
if(!v){continue}
|
| 240 |
+
const kept=v.kept;
|
| 241 |
+
for(let j=0;j<kept;j++){
|
| 242 |
+
const tk=st.propose[j];
|
| 243 |
+
html+='<span class="tk '+tk.src+'">'+vis(tk.t)+'</span>';
|
| 244 |
+
a[tk.src]++;tc++;
|
| 245 |
+
}
|
| 246 |
+
if(v.rollback){
|
| 247 |
+
rb++;html+='<span class="tk fix">'+vis(v.fix)+'</span>';
|
| 248 |
+
a.ntp++;tc++;
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
const st=cur.steps[step];fw++;
|
| 252 |
+
html+='<span class="cursor"></span><span class="prop">';
|
| 253 |
+
const v=st.verdict,kept=v?v.kept:st.propose.length;
|
| 254 |
+
st.propose.forEach((tk,j)=>{
|
| 255 |
+
const rej=v&&v.rollback&&j>=kept;
|
| 256 |
+
html+='<span class="tk '+tk.src+(rej?" rej":"")+'">'+vis(tk.t)+'</span>';
|
| 257 |
+
});
|
| 258 |
+
html+='</span>';
|
| 259 |
+
$("stream").innerHTML=html;
|
| 260 |
+
|
| 261 |
+
let msg;
|
| 262 |
+
if(!v){msg="Last block of the run — nothing left to verify.";$("verdict").className="verdict"}
|
| 263 |
+
else if(v.rollback){
|
| 264 |
+
msg="Next pass verified "+kept+" of "+st.propose.length+" proposed token"
|
| 265 |
+
+(st.propose.length===1?"":"s")+", then rejected the rest and committed "
|
| 266 |
+
+JSON.stringify(v.fix)+" from the true conditional.";
|
| 267 |
+
$("verdict").className="verdict roll";
|
| 268 |
+
}else{
|
| 269 |
+
msg="Next pass verified all "+kept+" proposed token"+(kept===1?"":"s")+" — "
|
| 270 |
+
+kept+" token"+(kept===1?"":"s")+" from one forward pass.";
|
| 271 |
+
$("verdict").className="verdict";
|
| 272 |
+
}
|
| 273 |
+
$("verdict").textContent="Step "+(step+1)+" of "+cur.steps.length+". "+msg;
|
| 274 |
+
|
| 275 |
+
$("fw").textContent=fw;$("tc").textContent=tc;$("rb").textContent=rb;
|
| 276 |
+
$("a-ntp").textContent=a.ntp;$("a-matp").textContent=a.matp;$("a-ngram").textContent=a.ngram;
|
| 277 |
+
$("tpf").textContent=fw?(tc/fw).toFixed(2):"—";
|
| 278 |
+
$("final").textContent=cur.tok_per_fwd.toFixed(2)+" tok/fwd";
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function fillTable(){
|
| 282 |
+
const tb=$("runs").querySelector("tbody");
|
| 283 |
+
B.runs.forEach(r=>{
|
| 284 |
+
const tot=r.accepted.ntp+r.accepted.matp+r.accepted.ngram||1;
|
| 285 |
+
const tr=document.createElement("tr");
|
| 286 |
+
tr.innerHTML="<td>"+B.prompts.find(p=>p.id===r.prompt).label+"</td>"
|
| 287 |
+
+"<td>"+MODES[r.mode]+"</td>"
|
| 288 |
+
+'<td class="n">'+(r.mode==="ntp"?"—":r.tau.toFixed(2))+"</td>"
|
| 289 |
+
+'<td class="n"><b>'+r.tok_per_fwd.toFixed(2)+"</b></td>"
|
| 290 |
+
+'<td class="n">'+r.forwards+"</td>"
|
| 291 |
+
+'<td class="n">'+r.rollbacks+"</td>"
|
| 292 |
+
+'<td class="n">'+Math.round(100*r.accepted.matp/tot)+"%</td>"
|
| 293 |
+
+'<td class="n">'+Math.round(100*r.accepted.ngram/tot)+"%</td>";
|
| 294 |
+
tb.appendChild(tr);
|
| 295 |
+
});
|
| 296 |
+
}
|
| 297 |
+
</script>
|
| 298 |
+
</body>
|
| 299 |
+
</html>
|
traces.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|