Spaces:
Running
Running
Download eval.html from Unt1l1f1nd/coalescence: direct link, hf CLI and curl.
- Browser
- Download file 12 kB
-
https://huggingface.co/spaces/Unt1l1f1nd/coalescence/resolve/main/eval.html
- Command line
-
hf download hf://spaces/Unt1l1f1nd/coalescence/eval.html
-
curl -L -o eval.html https://huggingface.co/spaces/Unt1l1f1nd/coalescence/resolve/main/eval.html
12 kB
| <meta charset="utf-8"> | |
| <title>coalescence — does the 0.5B actually understand the sliders?</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <style> | |
| :root{--bg:#0b0f14;--fg:#e7eef6;--dim:#8fa0b3;--line:#1e2937;--ok:#57c96a; | |
| --bad:#ef6b6b;--warn:#e2b04a;--acc:#6fb2ff} | |
| *{box-sizing:border-box} | |
| body{margin:0;background:var(--bg);color:var(--fg); | |
| font:15px/1.6 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif} | |
| .wrap{max-width:900px;margin:0 auto;padding:26px 18px 70px} | |
| h1{font-size:22px;margin:0 0 6px;font-weight:600} | |
| p.sub{color:var(--dim);margin:0 0 20px;max-width:74ch} | |
| button{background:var(--acc);color:#04121f;border:0;border-radius:8px; | |
| padding:11px 18px;font-size:15px;font-weight:600;cursor:pointer} | |
| button[disabled]{opacity:.5;cursor:default} | |
| #status{color:var(--dim);font-size:13px;margin:14px 0} | |
| table{border-collapse:collapse;width:100%;margin-top:18px;font-size:13.5px} | |
| th,td{text-align:left;padding:7px 9px;border-bottom:1px solid var(--line); | |
| vertical-align:top} | |
| th{color:var(--dim);font-weight:500;font-size:12px;text-transform:uppercase; | |
| letter-spacing:.04em} | |
| td.q{color:var(--fg)} | |
| code{font:12.5px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--dim)} | |
| .pass{color:var(--ok)} .fail{color:var(--bad)} .part{color:var(--warn)} | |
| .score{display:flex;gap:26px;flex-wrap:wrap;margin:20px 0 4px; | |
| padding:16px;border:1px solid var(--line);border-radius:10px; | |
| background:#0d1117} | |
| .score div{min-width:120px} | |
| .score b{display:block;font-size:26px;font-weight:600;letter-spacing:-.5px} | |
| .score span{color:var(--dim);font-size:12px} | |
| .note{color:var(--dim);font-size:12.5px;margin-top:8px} | |
| </style> | |
| <div class="wrap"> | |
| <h1>does the 0.5B actually understand the sliders?</h1> | |
| <p class="sub"> | |
| Every case below is scored on <b>direction</b>, not on matching a number. | |
| "dry the window out" is correct if it moves film thickness <em>down</em>, | |
| whatever value it picks. The model controls the rain only — roof pitch, framing and scene | |
| distance stay the human’s sliders. The prompt, the limits and the parser are | |
| imported from <code>llm.js</code> — the same file the app ships — so this | |
| scores what actually runs, not a copy of it. | |
| </p> | |
| <button id="run">run the eval</button> | |
| <div id="status">the model is ~483 MB and is downloaded once, into your browser.</div> | |
| <div id="score"></div> | |
| <div id="out"></div> | |
| </div> | |
| <script type="module"> | |
| import { SYS, LIM, byRules, decide, clampToLimits, GEN_OPTS, MODEL_ID } | |
| from './llm.js'; | |
| // Each case says which way a key must move, not what value it must take. | |
| // lo/hi are the thresholds that make the intent unambiguous inside LIM. | |
| // HELD OUT ON PURPOSE: not one of these strings appears in SYS. An earlier | |
| // version of this list reused the prompt's own examples verbatim for 10 of 19 | |
| // cases, which measured recall rather than understanding and flattered the | |
| // score. Every case below is a paraphrase the model has not been shown. | |
| // Rain-intensity phrasings only, because that is the only question the tool | |
| // asks now. None of these strings appear in the prompt. | |
| // 32 cases. The prompt contains no examples at all -- it is one question -- | |
| // so every phrasing here is held out by construction. Deliberately includes | |
| // idioms ("chucking it down"), bare imperatives ("turn the rain up") and | |
| // indirect descriptions ("the storm is passing"). | |
| const UP = { rate: ['>', 6000] }; | |
| const DOWN = { rate: ['<', 1500] }; | |
| const CASES = [ | |
| { q: 'make it pour', want: UP }, | |
| { q: 'make it rain harder', want: UP }, | |
| { q: 'much heavier rain', want: UP }, | |
| { q: 'a proper cloudburst', want: UP }, | |
| { q: 'absolutely hammering down', want: UP }, | |
| { q: 'torrential rain', want: UP }, | |
| { q: 'really coming down now', want: UP }, | |
| { q: 'bucketing down', want: UP }, | |
| { q: 'turn the rain up', want: UP }, | |
| { q: 'I want a proper storm', want: UP }, | |
| { q: 'more rain please', want: UP }, | |
| { q: 'let it lash against the glass', want: UP }, | |
| { q: 'crank it up', want: UP }, | |
| { q: 'rain like the end of the world', want: UP }, | |
| { q: 'it should be chucking it down', want: UP }, | |
| { q: 'the heavens have opened', want: UP }, | |
| { q: 'just a drizzle', want: DOWN }, | |
| { q: 'a light sprinkle', want: DOWN }, | |
| { q: 'barely any rain at all', want: DOWN }, | |
| { q: 'calm it right down', want: DOWN }, | |
| { q: 'ease off the rain a bit', want: DOWN }, | |
| { q: 'a gentle shower', want: DOWN }, | |
| { q: 'make the rain stop', want: DOWN }, | |
| { q: 'hardly anything now', want: DOWN }, | |
| { q: 'turn the rain down', want: DOWN }, | |
| { q: 'softer rain please', want: DOWN }, | |
| { q: 'let it die down', want: DOWN }, | |
| { q: 'almost nothing now', want: DOWN }, | |
| { q: 'it is only spitting', want: DOWN }, | |
| { q: 'quiet rain', want: DOWN }, | |
| { q: 'less rain', want: DOWN }, | |
| { q: 'the storm is passing', want: DOWN }, | |
| ]; | |
| // ?prompt=v2 runs the PREVIOUS prompt (commit 2afd1dd) against this same | |
| // held-out case list, so a change in score can be attributed to the prompt | |
| // rather than to the cases having been swapped at the same time. | |
| const SYS_V2 = `You set the rain in a simulation by replying with JSON. | |
| Reply with ONLY a JSON object. No prose, no explanation. | |
| There are exactly three keys. Use only the ones the request is about. | |
| h0 how wet the glass ALREADY is, in micrometres, 8-160. | |
| 8 = bone dry, 25 = barely damp, 60 = wet, 160 = soaking. | |
| rate how hard it rains, drops per square metre per second, 200-12000. | |
| 200 = almost stopped, 3000 = steady, 12000 = downpour. | |
| drop drop diameter in mm, 0.4-2.4. | |
| 0.4 = fine mist, 1.0 = ordinary, 2.4 = fat heavy drops. | |
| Examples: | |
| "dry the window out" -> {"h0": 10} | |
| "soak the glass" -> {"h0": 150} | |
| "it rained all afternoon" -> {"h0": 150} | |
| "the pane is barely damp" -> {"h0": 20} | |
| "make the drops linger" -> {"h0": 10} | |
| "make them vanish instantly" -> {"h0": 155} | |
| "make it pour" -> {"rate": 11000, "drop": 2.0} | |
| "just a drizzle" -> {"rate": 600, "drop": 0.6} | |
| "stop the rain" -> {"rate": 200} | |
| "big fat drops" -> {"drop": 2.2} | |
| "fine misty drops" -> {"drop": 0.5}`; | |
| const SYS_ACTIVE = new URLSearchParams(location.search).get('prompt') === 'v2' ? SYS_V2 : SYS; | |
| const el = id => document.getElementById(id); | |
| const cmp = (v, [op, t]) => op === '>' ? v > t : v < t; | |
| function scoreOne(parsed, want) { | |
| const checks = []; | |
| for (const k in want) { | |
| const present = parsed && k in parsed; | |
| checks.push({ key: k, present, | |
| ok: present && cmp(parsed[k], want[k]), | |
| got: present ? parsed[k] : null, | |
| need: want[k][0] + ' ' + want[k][1] }); | |
| } | |
| const ok = checks.filter(c => c.ok).length; | |
| return { checks, ok, total: checks.length }; | |
| } | |
| el('run').addEventListener('click', async () => { | |
| el('run').disabled = true; | |
| const status = el('status'); | |
| status.textContent = 'loading transformers.js…'; | |
| const { pipeline } = await import( | |
| 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.5.1'); | |
| // ?device=wasm forces CPU. This matters: on an AMD 780M reached by overriding | |
| // Chrome's GPU blocklist, the q4f16 WebGPU path returns fluent-looking garbage | |
| // ("write to write to write write write") rather than JSON -- 0/23 usable, while | |
| // the identical prompt on wasm answers correctly. Numerically broken backends | |
| // are exactly what that blocklist is for, so the scored runs are wasm runs. | |
| const forced = new URLSearchParams(location.search).get('device'); | |
| let device = 'wasm'; | |
| if (forced) device = forced; | |
| else { try { if (navigator.gpu && await navigator.gpu.requestAdapter()) device = 'webgpu'; } | |
| catch { /* stay on wasm */ } } | |
| const mk = dev => pipeline('text-generation', MODEL_ID, { | |
| dtype: 'q4f16', device: dev, | |
| progress_callback: p => { | |
| if (p.status === 'progress' && p.total > 5e6) | |
| status.textContent = `downloading ${p.file?.split('/').pop() ?? ''} … ` | |
| + Math.round(p.progress) + '%'; | |
| } }); | |
| let gen; | |
| try { gen = await mk(device); } | |
| catch (e) { if (device === 'wasm') throw e; device = 'wasm'; gen = await mk('wasm'); } | |
| status.textContent = `running ${CASES.length} cases on ` | |
| + (device === 'webgpu' ? 'WebGPU' : 'CPU') + '…'; | |
| const rows = []; | |
| const t0 = performance.now(); | |
| for (let i = 0; i < CASES.length; i++) { | |
| const c = CASES[i]; | |
| status.textContent = `case ${i + 1}/${CASES.length} on ` | |
| + (device === 'webgpu' ? 'WebGPU' : 'CPU') + ' — "' + c.q + '"'; | |
| const t = performance.now(); | |
| let raw = '', parsed = null, err = null; | |
| try { | |
| const d = await decide(c.q, gen, GEN_OPTS); | |
| raw = String(d.said).trim(); | |
| if (d.params) parsed = clampToLimits(d.params).values; | |
| } catch (e) { err = String(e); } | |
| const sc = scoreOne(parsed, c.want); | |
| const fellBack = !parsed || sc.ok === 0; | |
| rows.push({ q: c.q, raw, parsed, err, ...sc, | |
| ms: Math.round(performance.now() - t), | |
| rulesWouldCatch: fellBack ? byRules(c.q) : null }); | |
| render(rows, device, t0); | |
| window.__EVAL_PARTIAL = { device, done: i + 1, total: CASES.length, cases: rows }; | |
| } | |
| status.textContent = 'done — ' + CASES.length + ' cases on ' | |
| + (device === 'webgpu' ? 'WebGPU' : 'CPU') | |
| + ', ' + Math.round((performance.now() - t0) / 1000) + ' s total'; | |
| window.__EVAL_RESULT = { device, cases: rows, | |
| totalMs: Math.round(performance.now() - t0) }; | |
| }); | |
| function render(rows, device, t0) { | |
| const checksTotal = rows.reduce((a, r) => a + r.total, 0); | |
| const checksOk = rows.reduce((a, r) => a + r.ok, 0); | |
| const jsonOk = rows.filter(r => r.parsed).length; | |
| const fullyOk = rows.filter(r => r.ok === r.total).length; | |
| const pct = (a, b) => b ? Math.round(100 * a / b) + '%' : '–'; | |
| el('score').innerHTML = | |
| `<div class="score"> | |
| <div><b>${pct(jsonOk, rows.length)}</b><span>emitted usable JSON<br>${jsonOk}/${rows.length}</span></div> | |
| <div><b>${pct(fullyOk, rows.length)}</b><span>fully correct<br>${fullyOk}/${rows.length}</span></div> | |
| <div><b>${pct(checksOk, checksTotal)}</b><span>directions right<br>${checksOk}/${checksTotal}</span></div> | |
| <div><b>${Math.round(rows.reduce((a, r) => a + r.ms, 0) / rows.length / 100) / 10}s</b> | |
| <span>median-ish per call<br>on ${device === 'webgpu' ? 'WebGPU' : 'CPU'}</span></div> | |
| </div> | |
| <p class="note">Scored on direction only. A case counts as fully correct | |
| when every key it names moves the right way.</p>`; | |
| el('out').innerHTML = | |
| '<table><tr><th>asked</th><th>model returned</th><th>checks</th></tr>' + | |
| rows.map(r => { | |
| const cls = r.ok === r.total ? 'pass' : r.ok ? 'part' : 'fail'; | |
| const mark = r.ok === r.total ? '✓' : r.ok ? '~' : '✗'; | |
| const checks = r.checks.map(c => | |
| `<span class="${c.ok ? 'pass' : 'fail'}">${c.ok ? '✓' : '✗'} ${c.key} ` | |
| + (c.present ? c.got : 'missing') + ` (need ${c.need})</span>`).join('<br>'); | |
| const fb = r.rulesWouldCatch | |
| ? `<br><code>keyword rules would have caught this: ` | |
| + JSON.stringify(r.rulesWouldCatch) + `</code>` : ''; | |
| return `<tr><td class="q">${r.q}</td>` | |
| + `<td><code>${r.parsed ? JSON.stringify(r.parsed) | |
| : '(no JSON) ' + (r.raw || r.err || '').slice(0, 60)}</code>${fb}</td>` | |
| + `<td class="${cls}">${mark} ${r.ok}/${r.total}<br>${checks}</td></tr>`; | |
| }).join('') + '</table>'; | |
| } | |
| </script> | |