Download app.js from Rogue-Intelligence/val-llm-boost: direct link, hf CLI and curl.
- Browser
- Download file 7.54 kB
-
https://huggingface.co/spaces/Rogue-Intelligence/val-llm-boost/resolve/main/app.js
- Command line
-
hf download hf://spaces/Rogue-Intelligence/val-llm-boost/app.js
-
curl -L -o app.js https://huggingface.co/spaces/Rogue-Intelligence/val-llm-boost/resolve/main/app.js
7.54 kB
| (async function () { | |
| const $ = id => document.getElementById(id); | |
| const BLUE = "var(--blue)", TEAL = "var(--teal)", GREEN = "var(--green)", GRAY = "#94a3b8", RED = "#e5484d"; | |
| const GR = "#94a3b8"; | |
| $("diagram").innerHTML = `<svg viewBox="0 0 960 220" role="img" aria-label="Corpus to structured memory to evidence to verdict to answer or silence"> | |
| <defs><marker id="ar" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="${GR}"/></marker></defs><g font-size="15"> | |
| <rect x="6" y="55" width="160" height="110" rx="14" fill="rgba(148,163,184,.12)" stroke="${GR}"/><text x="86" y="97" text-anchor="middle" font-weight="700">Your corpus</text><text x="86" y="121" text-anchor="middle" font-size="13" class="mut">millions of tokens</text><text x="86" y="141" text-anchor="middle" font-size="13" class="mut">never in the window</text> | |
| <line x1="168" y1="110" x2="204" y2="110" stroke="${GR}" stroke-width="2" marker-end="url(#ar)"/> | |
| <rect x="208" y="55" width="178" height="110" rx="14" fill="rgba(0,102,255,.10)" stroke="${BLUE}"/><text x="297" y="97" text-anchor="middle" font-weight="700">Structured memory</text><text x="297" y="121" text-anchor="middle" font-size="13" class="mut">persistent · compact</text><text x="297" y="141" text-anchor="middle" font-size="13" class="mut">ingest once</text> | |
| <line x1="388" y1="110" x2="424" y2="110" stroke="${GR}" stroke-width="2" marker-end="url(#ar)"/> | |
| <rect x="428" y="55" width="150" height="110" rx="14" fill="rgba(0,102,255,.06)" stroke="${BLUE}" stroke-dasharray="5 4"/><text x="503" y="97" text-anchor="middle" font-weight="700">Evidence</text><text x="503" y="121" text-anchor="middle" font-size="13" class="mut">≤12 lines</text><text x="503" y="141" text-anchor="middle" font-size="13" class="mut">per question</text> | |
| <line x1="580" y1="110" x2="616" y2="110" stroke="${GR}" stroke-width="2" marker-end="url(#ar)"/> | |
| <rect x="620" y="55" width="150" height="110" rx="14" fill="rgba(0,169,154,.12)" stroke="${TEAL}"/><text x="695" y="97" text-anchor="middle" font-weight="700">Verdict</text><text x="695" y="121" text-anchor="middle" font-size="13" class="mut">answer or abstain</text><text x="695" y="141" text-anchor="middle" font-size="13" class="mut">poison isolated</text> | |
| <line x1="772" y1="92" x2="806" y2="54" stroke="${GR}" stroke-width="2" marker-end="url(#ar)"/><line x1="772" y1="128" x2="806" y2="166" stroke="${GR}" stroke-width="2" marker-end="url(#ar)"/> | |
| <rect x="810" y="16" width="144" height="76" rx="12" fill="rgba(0,200,83,.12)" stroke="${GREEN}"/><text x="882" y="46" text-anchor="middle" font-weight="700">Answer</text><text x="882" y="68" text-anchor="middle" font-size="12" class="mut">evidence + source</text> | |
| <rect x="810" y="128" width="144" height="76" rx="12" fill="rgba(229,72,77,.10)" stroke="${RED}"/><text x="882" y="158" text-anchor="middle" font-weight="700">Abstain</text><text x="882" y="180" text-anchor="middle" font-size="12" class="mut">"can't determine"</text> | |
| </g></svg>`; | |
| const H = window.RIcharts.hbar, frac = (a, b) => ({ value: a / b, text: `${a}/${b}` }); | |
| H($("scaleChart"), [ | |
| Object.assign({ label: "VAL-LLM BOOST · 0.45M tokens", color: BLUE }, frac(17, 21)), | |
| Object.assign({ label: "VAL-LLM BOOST · 1.5M tokens", color: BLUE }, frac(17, 21)), | |
| Object.assign({ label: "VAL-LLM BOOST · 14.95M tokens", color: BLUE }, frac(17, 21)), | |
| { label: "Full window · 45K tokens", value: 0.004, text: "0/13", color: RED }], { max: 1, labelW: 220, w: 560 }); | |
| H($("boostChart"), [ | |
| Object.assign({ label: "All 21 · memory alone", color: GRAY }, frac(17, 21)), | |
| Object.assign({ label: "All 21 · with BOOST", color: TEAL }, frac(20, 21)), | |
| { label: "Multi-hop · memory alone", value: 0.004, text: "0/2", color: GRAY }, | |
| Object.assign({ label: "Multi-hop · with BOOST", color: TEAL }, frac(1, 2)), | |
| { label: "Aggregation · memory alone", value: 0.004, text: "0/2", color: GRAY }, | |
| Object.assign({ label: "Aggregation · with BOOST", color: TEAL }, frac(2, 2))], { max: 1, labelW: 220, w: 560 }); | |
| const txt = await (await fetch("evidence/ledger.jsonl")).text(); | |
| const ROWS = txt.split("\n").filter(l => l.trim()).map(l => JSON.parse(l)); | |
| const SUM = await (await fetch("evidence/summary.json")).json(); | |
| const seg = SUM.local_312_summary.segments; | |
| const pct = s => { const [a, b] = s.split("/").map(Number); return { value: a / b, text: s }; }; | |
| H($("segChart"), [ | |
| Object.assign({ label: "Core · first third", color: BLUE }, pct(seg.first.core)), | |
| Object.assign({ label: "Core · middle third", color: BLUE }, pct(seg.middle.core)), | |
| Object.assign({ label: "Core · last third", color: BLUE }, pct(seg.last.core)), | |
| Object.assign({ label: "Traps · first", color: TEAL }, pct(seg.first.traps)), | |
| Object.assign({ label: "Traps · middle", color: TEAL }, pct(seg.middle.traps)), | |
| Object.assign({ label: "Traps · last", color: TEAL }, pct(seg.last.traps)), | |
| { label: "Hallucinated tokens", value: 0.004, text: "0", color: GREEN }], { max: 1, labelW: 180, w: 560 }); | |
| const local312 = ROWS.filter(r => r.edition === "local" && r.run.startsWith("312")); | |
| $("kAns").textContent = local312.filter(r => r.verdict === "emit").length; | |
| $("kSil").textContent = local312.filter(r => r.verdict !== "emit").length; | |
| const SILENT = "根据已摄入的资料无法确定。"; | |
| const key = r => `${r.edition} · ${r.run}`; | |
| const esc = s => String(s).replace(/[&<>"]/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c])); | |
| const runs = [...new Set(ROWS.map(key))]; | |
| $("run").innerHTML = runs.map(r => `<option>${esc(r)}</option>`).join(""); | |
| $("kind").innerHTML = ["all", ...[...new Set(ROWS.map(r => r.kind))].sort()].map(k => `<option>${k}</option>`).join(""); | |
| function view() { | |
| const run = $("run").value, kind = $("kind").value, vd = $("verdict").value; | |
| const rows = ROWS.filter(r => key(r) === run && (kind === "all" || r.kind === kind) && (vd === "all" || r.verdict === vd)); | |
| const emit = rows.filter(r => r.verdict === "emit").length, fab = rows.reduce((a, r) => a + (r.fabricated || 0), 0); | |
| const core = rows.filter(r => ["n_start", "n_mid", "n_end"].includes(r.qid)), coreOk = core.filter(r => r.pass === true).length; | |
| $("cards").innerHTML = [[rows.length, "turns shown", "b"], [`${emit} / ${rows.length - emit}`, "answered / silent", "t"], | |
| [core.length ? `${coreOk}/${core.length}` : "—", "core questions correct", "g"], [fab, "hallucinated tokens", "g"]] | |
| .map(([v, l, c]) => `<div class="card stat"><div class="n ${c}">${v}</div><div class="l">${l}</div></div>`).join(""); | |
| $("t").tBodies[0].innerHTML = rows.map(r => { | |
| const ans = r.answer === SILENT ? `<span class="mut">${esc(r.answer)} (can't determine from the ingested material)</span>` : esc(r.answer); | |
| const sc = r.pass === true ? `<span class="ok">✓</span>` : r.pass === false ? `<span class="bad">✗</span>` : `<span class="mut">n/a</span>`; | |
| return `<tr><td>${r.turn}</td><td><code>${r.kind}</code></td><td>${esc(r.question)}</td><td>${r.verdict === "emit" ? "answer" : "silent"}</td><td>${ans}</td><td>${sc}</td><td class="num">${r.fabricated || 0}</td></tr>`; | |
| }).join(""); | |
| } | |
| ["run", "kind", "verdict"].forEach(id => $(id).addEventListener("change", view)); | |
| view(); | |
| })().catch(e => document.body.insertAdjacentHTML("afterbegin", `<p style="color:#e5484d;padding:12px">Failed to load: ${e}</p>`)); | |