retroenv-rollouts / index.src.html
AdithyaSK's picture
AdithyaSK HF Staff
Open the header links in a new tab: the page is framed on huggingface.co
5c433f0 verified
Raw History Blame Contribute Delete
49.8 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RetroEnv rollouts</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap">
<script src="https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.4.2/3Dmol-min.js" defer></script>
<!--INLINE-DATA-->
<style>
:root{
--bg:#fafbfa;--surface:#f1f4f2;--sunk:#e9edea;--fg:#141918;--fg-mid:#3f4c49;--fg-dim:#687672;
--line:#dce2df;--line2:#c3ccc8;--accent:#2f6b50;--wash:#dceae1;--bad:#8a3c2e;--badwash:#f2ddd7;
--bar:#c3ccc8;--stock:#2f6b50;--make:#8a6a3c;--ink:#141918;
--sans:"Inter",system-ui,-apple-system,sans-serif;--mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
color-scheme:light;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.6 var(--sans);-webkit-font-smoothing:antialiased}
.wrap{max-width:1180px;margin:0 auto;padding:28px 16px 64px}
h1{font-size:23px;font-weight:600;margin:0 0 4px;letter-spacing:-.01em}
h2{font-size:17px;font-weight:600;margin:0 0 6px}
h3{font-size:14px;font-weight:600;margin:0}
p{margin:0}
a{color:var(--accent)}
.sub{color:var(--fg-dim);font-size:13.5px;max-width:80ch}
.mono{font-family:var(--mono);font-variant-numeric:tabular-nums}
header{border-bottom:2px solid var(--fg);padding-bottom:16px;margin-bottom:18px}
.meta{display:flex;flex-wrap:wrap;gap:6px 18px;font-size:12.5px;color:var(--fg-dim);margin-top:8px}
nav{display:flex;gap:2px;border-bottom:1px solid var(--line);margin-bottom:20px;overflow-x:auto}
nav button{appearance:none;background:none;border:0;border-bottom:2px solid transparent;color:var(--fg-dim);
font:500 14px var(--sans);padding:9px 14px;cursor:pointer;white-space:nowrap}
nav button[aria-selected=true]{color:var(--fg);border-bottom-color:var(--accent)}
nav button:hover{color:var(--fg)}
section[hidden]{display:none}
.scroll{overflow-x:auto;border:1px solid var(--line);border-radius:3px}
table{border-collapse:collapse;width:100%;font-size:13px;font-variant-numeric:tabular-nums}
th,td{text-align:right;padding:6px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
th:first-child,td:first-child{text-align:left}
thead th{background:var(--surface);font-weight:600;font-size:12px;color:var(--fg-mid)}
tbody tr:last-child td{border-bottom:0}
tr.ours td{background:var(--wash);font-weight:600}
.chart svg{display:block;width:100%;height:auto;overflow:visible}
.setswitch{display:inline-flex;border:1px solid var(--line2);border-radius:4px;overflow:hidden}
.setswitch button{font:12px var(--mono);padding:3px 10px;border:0;background:none;color:var(--fg-mid);cursor:pointer}
.setswitch button[aria-pressed=true]{background:var(--accent);color:var(--bg)}
.legend{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:12.5px;color:var(--fg-mid);margin:8px 0}
.legend span{display:inline-flex;align-items:center;gap:6px}
.sw{width:14px;height:3px;border-radius:2px}
.stack{display:flex;flex-direction:column;gap:16px}
.row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
select{font:14px var(--sans);padding:6px 9px;border:1px solid var(--line2);border-radius:3px;
background:var(--surface);color:var(--fg);max-width:100%}
.note{font-size:12.5px;color:var(--fg-dim)}
.tag{font:500 11px var(--mono);letter-spacing:.05em;text-transform:uppercase;color:var(--fg-dim)}
/* ---- the picker: every target, drawn ---- */
.pickbar{display:flex;flex-wrap:wrap;gap:6px 18px;align-items:baseline;justify-content:space-between}
.keys{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;color:var(--fg-dim)}
.keys span{display:inline-flex;align-items:center;gap:6px}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}
.dot.fixed{background:var(--accent)}
.dot.both{background:var(--line2)}
.dot.none{background:transparent;border:1px solid var(--line2)}
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:8px}
.card{appearance:none;font:inherit;text-align:left;cursor:pointer;padding:5px;background:var(--bg);
border:1px solid var(--line);border-radius:4px;display:flex;flex-direction:column;gap:3px;min-width:0;
transition:border-color .12s,box-shadow .12s}
.card:hover{border-color:var(--accent)}
.card[aria-selected=true]{border-color:var(--accent);box-shadow:0 0 0 2px var(--wash)}
.card .thumb{background:var(--sunk);border-radius:3px;color:var(--ink);display:flex;align-items:center;
justify-content:center;aspect-ratio:4/3;overflow:hidden}
.card .thumb svg{width:100%;height:100%}
.card .line{display:flex;align-items:center;gap:5px;font:10.5px var(--mono);color:var(--fg-dim);min-width:0}
.card .line .f{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.card .tierdot{font:500 9.5px var(--mono);letter-spacing:.04em;text-transform:uppercase;flex:none}
.card.easy .tierdot{color:var(--fg-dim)}
.card.medium .tierdot{color:var(--make)}
.card.hard .tierdot{color:var(--bad)}
#view-gallery,#view-detail{display:flex;flex-direction:column;gap:16px}
[hidden]{display:none!important}
.grouphead{display:flex;align-items:baseline;gap:9px;margin:2px 0 6px}
.grouphead h3{font:600 13px var(--sans)}
.grouphead .n{font:11px var(--mono);color:var(--fg-dim)}
.grouphead .rule{flex:1;height:1px;background:var(--line)}
.detailbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.back,.stepper button{appearance:none;cursor:pointer;font:500 12.5px var(--sans);
border:1px solid var(--line2);background:var(--surface);color:var(--fg);border-radius:3px;padding:5px 11px}
.back:hover,.stepper button:hover{border-color:var(--accent);color:var(--accent)}
.stepper{display:flex;gap:4px;margin-left:auto}
.stepper button{padding:4px 11px;font-size:15px;line-height:1}
.crumb{font:12.5px var(--mono);color:var(--fg-dim)}
.crumb b{color:var(--fg);font-weight:600}
/* ---- the target strip: big 2D depiction + a 3D viewer ---- */
.target{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:14px;
border:1px solid var(--line);border-radius:3px;overflow:hidden;background:var(--surface)}
@media(max-width:780px){.target{grid-template-columns:1fr}}
.target .pane{padding:12px;min-width:0}
.target .pane+.pane{border-left:1px solid var(--line)}
@media(max-width:780px){.target .pane+.pane{border-left:0;border-top:1px solid var(--line)}}
.depict{display:flex;align-items:center;justify-content:center;min-height:200px}
.depict{color:var(--ink)}
.depict svg{width:100%;height:auto;max-height:260px}
#viewer3d{width:100%;height:260px;position:relative;border-radius:3px;background:var(--sunk);overflow:hidden}
#viewer3d canvas{border-radius:3px}
.v3-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin-bottom:8px}
.v3-ctl{display:flex;gap:4px}
.v3-ctl button{appearance:none;font:500 11.5px var(--sans);padding:3px 9px;border:1px solid var(--line2);
background:var(--bg);color:var(--fg-mid);border-radius:3px;cursor:pointer}
.v3-ctl button[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:var(--bg)}
.facts{display:flex;flex-wrap:wrap;gap:4px 14px;font:12px var(--mono);color:var(--fg-dim);margin-top:8px}
/* ---- route graph ---- */
.routes{display:flex;flex-direction:column;gap:14px}
.routewrap{overflow-x:auto;padding:4px 2px 10px}
.tree{display:flex;flex-direction:column;align-items:center;gap:0;min-width:max-content;margin:0 auto}
.kids{display:flex;gap:18px;align-items:flex-start;justify-content:center}
.branch{display:flex;flex-direction:column;align-items:center}
.stem{width:1px;height:14px;background:var(--line2)}
/* Connectors: a rail across the siblings, a stem dropping into each. */
.kids>.branch{position:relative;padding-top:15px}
.kids>.branch::before{content:"";position:absolute;top:0;left:50%;width:1px;height:15px;background:var(--line2)}
.kids>.branch::after{content:"";position:absolute;top:0;left:-9px;right:-9px;height:1px;background:var(--line2)}
.kids>.branch:first-child::after{left:50%}
.kids>.branch:last-child::after{right:50%}
.kids>.branch:only-child::after{display:none}
.rxn{font:500 10.5px var(--mono);letter-spacing:.02em;color:var(--fg-mid);background:var(--surface);
border:1px solid var(--line);border-radius:10px;padding:2px 9px;white-space:nowrap;cursor:help;max-width:230px;
overflow:hidden;text-overflow:ellipsis}
.rail{height:1px;background:var(--line2)}
.node{width:168px;border:1px solid var(--line);border-radius:4px;background:var(--bg);padding:6px;
display:flex;flex-direction:column;gap:4px;cursor:pointer;transition:border-color .12s,box-shadow .12s}
.node:hover{border-color:var(--accent)}
.node[aria-current=true]{border-color:var(--accent);box-shadow:0 0 0 2px var(--wash)}
.node.target{width:200px}
.node .pic{background:var(--sunk);border-radius:3px;display:flex;align-items:center;justify-content:center;padding:2px}
.node .pic{color:var(--ink)}
.node .pic svg{width:100%;height:auto;max-height:104px}
.node .cap{display:flex;justify-content:space-between;align-items:baseline;gap:6px;font:11px var(--mono)}
.node .cap .f{color:var(--fg-mid);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.badge{font:500 10px var(--mono);letter-spacing:.04em;text-transform:uppercase;white-space:nowrap}
.badge.in{color:var(--stock)}
.badge.make{color:var(--make)}
.leafrow{display:flex;gap:10px;flex-wrap:wrap;align-items:center;font-size:12px;color:var(--fg-dim)}
/* ---- loading ---- */
.spin{display:inline-block;width:13px;height:13px;border:2px solid var(--line2);border-top-color:var(--accent);
border-radius:50%;animation:sp .7s linear infinite;vertical-align:-2px;flex:none}
@keyframes sp{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spin{animation-duration:2.4s}}
.loading{display:flex;align-items:center;gap:9px;color:var(--fg-dim);font-size:13.5px;
border:1px dashed var(--line2);border-radius:3px;padding:14px 16px}
.crumb .spin{margin-right:4px}
/* ---- model chips ---- */
.modelbar{display:flex;flex-wrap:wrap;gap:4px 16px;align-items:baseline;justify-content:space-between}
.models{display:flex;flex-wrap:wrap;gap:6px}
.chip{appearance:none;cursor:pointer;font:500 12px var(--sans);border-radius:999px;padding:4px 11px;
border:1px solid var(--line2);background:var(--bg);color:var(--fg-mid);display:inline-flex;align-items:center;gap:6px}
.chip:hover{border-color:var(--accent)}
.chip[aria-pressed=true]{background:var(--wash);border-color:var(--accent);color:var(--fg)}
.chip .mk{font:600 11px var(--mono)}
.chip.ok .mk{color:var(--stock)}
.chip.no .mk{color:var(--fg-dim)}
.chip.ours{border-style:dashed}
/* Left to right, the way a retrosynthesis is drawn — but only once the panel is wide
enough for it to pay. Measured on a depth-5 route: horizontal is 902x519 against
vertical's 654x541, so in a narrow column it only adds sideways scrolling. Showing
one model gives the panel the full width and the scheme fits. */
@container route (min-width:620px){
.tree{align-items:flex-start}
.branch{flex-direction:row;align-items:center}
.stem{width:9px;height:1px}
/* The label rides the connector instead of sitting inline, or each level would
cost its full width. The whole class and the explanation stay on hover. */
.rxn{width:86px;max-width:86px;font-size:9.5px;padding:2px 6px;text-align:center}
.node{width:132px}
.node.target{width:152px}
.node .pic svg{max-height:84px}
.kids{flex-direction:column;gap:14px;align-items:flex-start;justify-content:flex-start}
.kids>.branch{padding-top:0;padding-left:14px}
.kids>.branch::before{top:50%;left:0;width:14px;height:1px}
.kids>.branch::after{top:-7px;bottom:-7px;left:0;right:auto;width:1px;height:auto}
.kids>.branch:first-child::after{top:50%;bottom:-7px}
.kids>.branch:last-child::after{top:-7px;bottom:50%}
.kids>.branch:only-child::after{display:none}
}
/* ---- side by side ---- */
.pair{display:grid;grid-template-columns:repeat(auto-fit,minmax(330px,1fr));gap:14px}
@media(max-width:980px){.pair{grid-template-columns:1fr}}
.col{border:1px solid var(--line);border-radius:3px;overflow:hidden;min-width:0;container:route / inline-size}
.col>.head{background:var(--surface);padding:9px 12px;border-bottom:1px solid var(--line);
display:flex;justify-content:space-between;align-items:baseline;gap:10px}
.verdict{font:600 12px var(--mono)}
.solved{color:var(--accent)}.failed{color:var(--bad)}
.col>.body{padding:12px;display:flex;flex-direction:column;gap:12px;min-width:0}
.kv{display:grid;grid-template-columns:auto 1fr;gap:2px 12px;font-size:12.5px}
.kv dt{color:var(--fg-dim)}
.kv dd{margin:0;font-family:var(--mono)}
.turn{border-left:2px solid var(--line2);padding:2px 0 2px 10px;display:flex;flex-direction:column;gap:6px}
.turn.tool{border-left-color:var(--accent)}
.role{font:500 11px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--fg-dim)}
.think{font-size:13px;color:var(--fg-mid);white-space:pre-wrap;word-break:break-word}
.call{font-family:var(--mono);font-size:12px;background:var(--sunk);border:1px solid var(--line);
border-radius:3px;padding:7px 9px;overflow-x:auto;white-space:pre}
.out{font-family:var(--mono);font-size:11.5px;color:var(--fg-mid);background:var(--sunk);
border:1px solid var(--line);border-radius:3px;padding:7px 9px;max-height:220px;overflow:auto;white-space:pre-wrap;word-break:break-word}
details>summary{cursor:pointer;font-size:12.5px;color:var(--fg-dim);padding:3px 0}
.bars{display:grid;grid-template-columns:auto 1fr auto;gap:3px 8px;align-items:center;font-size:12px}
.bars .t{font-family:var(--mono);color:var(--fg-dim)}
.bars .track{background:var(--sunk);height:7px;border-radius:2px;overflow:hidden}
.bars .fill{height:100%;background:var(--accent)}
.bars .v{font-family:var(--mono);color:var(--fg-mid)}
.empty{color:var(--fg-dim);font-size:13px;padding:12px;border:1px dashed var(--line2);border-radius:3px}
.why{font-size:12.5px;color:var(--fg-mid);border-left:2px solid var(--accent);padding-left:9px}
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>RetroEnv rollouts</h1>
<p class="sub">Qwen3.8-27B trained with GRPO to plan retrosyntheses back to purchasable molecules. Every episode here came from the environment server: real tool calls, a real submitted route tree, and the reward the verifier returned. Structures are drawn with RDKit from the exact SMILES the model submitted.</p>
<div class="meta">
<span><a href="https://huggingface.co/spaces/FineEnvs/retroenv" target="_blank" rel="noopener">environment</a></span>
<span><a href="https://huggingface.co/datasets/LiteFold/RetroEnv-Curated" target="_blank" rel="noopener">dataset</a></span>
<span><a href="https://huggingface.co/FineEnvs/retroenv-qwen3.8-27b-grpo" target="_blank" rel="noopener">model</a></span>
<span><a href="https://huggingface.co/FineEnvs/retroenv-qwen3.8-27b-grpo-checkpoints" target="_blank" rel="noopener">all 42 adapters</a></span>
<span><a href="https://huggingface.co/buckets/AdithyaSK/retroenv-rl-runs" target="_blank" rel="noopener">runs bucket</a></span>
<span><a href="https://github.com/adithya-s-k/FineEnvs" target="_blank" rel="noopener">code</a></span>
</div>
</header>
<nav role="tablist">
<button role="tab" aria-selected="true" data-tab="rollouts">Rollouts</button>
<button role="tab" aria-selected="false" data-tab="board">Board</button>
<button role="tab" aria-selected="false" data-tab="curves">Training curves</button>
<button role="tab" aria-selected="false" data-tab="checkpoints">Checkpoints</button>
</nav>
<section id="rollouts" class="stack">
<div>
<h2>The same molecule, before and after</h2>
<p class="sub">The thirty core30 molecules, each run by every model on the board in the same training harness with thinking on. Every column is that model's first of four attempts, nothing cherry-picked. <b id="r-head">—</b></p>
</div>
<div id="view-gallery">
<div class="pickbar">
<span class="tag" id="pick-label">Pick a target — all thirty, drawn to scale</span>
<span class="setswitch" id="setswitch" role="group" aria-label="Task set"><button data-set="core30" aria-pressed="true">core30</button><button data-set="core150" aria-pressed="false">core150</button></span>
<span class="keys">
<span><i class="dot fixed"></i>RL fixed it</span>
<span><i class="dot both"></i>both solved</span>
<span><i class="dot none"></i>neither solved</span>
</span>
</div>
<div id="groups"></div>
</div>
<div id="view-detail" hidden>
<div class="detailbar">
<button class="back" id="back">← All thirty</button>
<span class="crumb" id="crumb">—</span>
<span class="stepper"><button id="prev" title="Previous target">‹</button><button id="next" title="Next target">›</button></span>
</div>
<div class="target">
<div class="pane">
<div class="v3-head"><h3>Target</h3><span class="tag" id="t-tier">—</span></div>
<div class="depict" id="t-2d"></div>
<div class="facts" id="t-facts"></div>
</div>
<div class="pane">
<div class="v3-head">
<h3 id="v3-title">In three dimensions</h3>
<div class="v3-ctl">
<button id="v3-stick" aria-pressed="true">stick</button>
<button id="v3-ball" aria-pressed="false">ball &amp; stick</button>
<button id="v3-spin" aria-pressed="true">spin</button>
</div>
</div>
<div id="viewer3d"></div>
<p class="note" style="margin-top:6px">Drag to rotate, scroll to zoom. Click any molecule in a route below to bring it here.</p>
</div>
</div>
<div class="modelbar">
<span class="tag">Compare models on this molecule — click to show or hide a column</span>
<span class="note" id="harness-note"></span>
</div>
<div class="models" id="models"></div>
<div class="pair" id="pair"></div>
</div>
</section>
<section id="board" class="stack" hidden>
<div>
<h2>Where it lands against the field</h2>
<p class="sub">Every model in the same harness: the training tools and result strings, 20 turns, no forced submission, thinking on. Highlighted rows are Qwen3.8-27B, untrained and after RL.</p>
</div>
<div>
<h3>core30, four attempts per molecule</h3>
<p class="sub">Each bar is every attempt a model made, 100% wide: the solid part is pass@1 (the mean over four attempts, with a 95% interval from resampling the thirty molecules), then the attempts it declined on safety grounds, the ones it never submitted, and the rest it submitted wrong. The dark tick is pass@4, solved in any of the four.</p>
</div>
<div class="legend" id="lg-board"></div>
<div class="chart" id="ch-board"></div>
<div class="why" id="opus-note" style="font-size:13.5px;line-height:1.55;color:var(--fg)"></div>
<div>
<h3>core150, one attempt per molecule</h3>
<p class="sub">The full held-out set, with core30 inside it: each model's single attempt, split the same way, with a 95% interval. Our rows come from the four-attempt checkpoint evaluation, so their solid part is the mean over four attempts, the tick is pass@4, and their failures are not split.</p>
</div>
<div class="legend" id="lg-board150"></div>
<div class="chart" id="ch-board150"></div>
<p class="note" id="board-note"></p>
<ul class="note" id="board-models" style="margin:4px 0 0 18px;padding:0"></ul>
</section>
<section id="curves" class="stack" hidden>
<div>
<h2>Four runs</h2>
<p class="sub">Every point is a checkpoint scored on core150 in the training harness, four attempts per task. Steps are absolute: each run resumes from a checkpoint of the one before.</p>
</div>
<div class="legend" id="lg-runs"></div>
<div class="chart" id="ch-runs"></div>
<div>
<h3>By difficulty tier, the two mixed-pool runs</h3>
<p class="sub">First-attempt rate per tier. core150 is equal thirds, so these three average to the first-attempt pass rate.</p>
</div>
<div class="legend" id="lg-tiers"></div>
<div class="chart" id="ch-tiers"></div>
</section>
<section id="checkpoints" class="stack" hidden>
<div>
<h2>Every scored checkpoint</h2>
<p class="sub">All 42, recomputed from every evaluation shard on the runs bucket. Each one is downloadable as a LoRA adapter from the checkpoints repo, under <span class="mono">&lt;run&gt;/step-&lt;step&gt;</span>.</p>
</div>
<div class="scroll"><table id="ck"><thead><tr>
<th>Run</th><th>Step</th><th>Thinking</th><th>pass@1</th><th>pass@4</th>
<th>easy</th><th>medium</th><th>hard</th><th>Reward</th><th>Tasks</th>
</tr></thead><tbody></tbody></table></div>
<p class="note" id="ck-note"></p>
</section>
</div>
<script>
const NS='http://www.w3.org/2000/svg';
const $=s=>document.querySelector(s);
const sv=(t,a,p)=>{const n=document.createElementNS(NS,t);for(const k in a)if(a[k]!=null)n.setAttribute(k,a[k]);p&&p.appendChild(n);return n;};
const f3=v=>v==null||isNaN(v)?'—':Number(v).toFixed(3);
const f2=v=>v==null||isNaN(v)?'—':Number(v).toFixed(2);
const esc=s=>String(s==null?'':s).replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
function ticks(lo,hi,n){const sp=hi-lo;if(!(sp>0))return[lo];
const raw=sp/n,mag=Math.pow(10,Math.floor(Math.log10(raw))),nm=raw/mag;
const st=(nm>=7.5?10:nm>=3.5?5:nm>=1.5?2:1)*mag;const o=[];
for(let v=Math.ceil(lo/st)*st;v<=hi+st*1e-9;v+=st)o.push(Math.round(v/st)*st);return o;}
function lineChart(host,series,opt={}){
host.textContent='';const W=host.clientWidth||700,H=opt.h||Math.max(200,Math.min(300,W*0.44));
const m={t:12,r:10,b:26,l:42};const svg=sv('svg',{viewBox:`0 0 ${W} ${H}`,role:'img','aria-label':opt.label||''},host);
const xs=[],ys=[];series.forEach(s=>s.points.forEach(p=>{xs.push(p.x);ys.push(p.y);}));
if(!xs.length)return;
const x0=Math.min(...xs),x1=Math.max(...xs),y1=Math.max(...ys)*1.12;
const X=v=>m.l+(v-x0)/((x1-x0)||1)*(W-m.l-m.r),Y=v=>H-m.b-(v/y1)*(H-m.t-m.b);
ticks(0,y1,4).forEach(t=>{sv('line',{x1:m.l,x2:W-m.r,y1:Y(t),y2:Y(t),style:'stroke:var(--line)'},svg);
sv('text',{x:m.l-7,y:Y(t)+3.5,'text-anchor':'end',style:'fill:var(--fg-dim);font:11px var(--mono)'},svg).textContent=f2(t);});
ticks(x0,x1,5).forEach(t=>{if(t<x0||t>x1)return;
sv('text',{x:X(t),y:H-8,'text-anchor':'middle',style:'fill:var(--fg-dim);font:11px var(--mono)'},svg).textContent=t;});
sv('line',{x1:m.l,x2:W-m.r,y1:H-m.b,y2:H-m.b,style:'stroke:var(--line2)'},svg);
series.forEach(s=>{const pts=[...s.points].sort((a,b)=>a.x-b.x);if(!pts.length)return;
sv('path',{d:pts.map((p,i)=>(i?'L':'M')+X(p.x).toFixed(1)+' '+Y(p.y).toFixed(1)).join(' '),fill:'none',
'stroke-dasharray':s.dash||null,style:`stroke:${s.color};stroke-width:1.9;stroke-linejoin:round`},svg);
pts.forEach(p=>{const c=sv('circle',{cx:X(p.x),cy:Y(p.y),r:2.5,style:`fill:${s.color}`},svg);
sv('title',{},c).textContent=`${s.name} · step ${p.x} · ${f3(p.y)}`;});});
if(opt.y)sv('text',{x:m.l-4,y:m.t-1,style:'fill:var(--fg-dim);font:11px var(--mono)'},svg).textContent=opt.y;
}
function legend(id,items){const el=$(id);el.textContent='';
items.forEach(it=>{const s=document.createElement('span');const w=document.createElement('i');
w.className='sw';if(it.dash){w.style.borderTop='3px dotted '+it.color;w.style.height='0';}else w.style.background=it.color;
s.append(w,document.createTextNode(it.name));el.append(s);});}
const OURS_T=['Qwen3.8-27B base','Qwen3.8-27B + RL 525'], OURS_N=['Qwen3.8-27B base, non-thinking','Qwen3.8-27B + RL 300, non-thinking'];
const COL_T='var(--accent)', COL_N='#7a5aa6';
const oursCol=r=>OURS_N.includes(r.model)?COL_N:COL_T;
function boardChart(host,rows,opt){
// Each bar is 100% of a model's attempts: solved | declined (safety) | never submitted | submitted and wrong.
opt=opt||{};host.textContent='';const W=host.clientWidth||700,stack=W<560,rh=stack?36:25,H=rows.length*rh+14;
const svg=sv('svg',{viewBox:`0 0 ${W} ${H}`,role:'img','aria-label':opt.label||'Outcome of every attempt by model'},host);
const defs=sv('defs',{},svg);
[['hd','var(--bad)','var(--badwash)'],['hn','#b07a4c','#f3e8dc']].forEach(([id,fg,bg])=>{
const pt=sv('pattern',{id:host.id+id,width:6,height:6,patternUnits:'userSpaceOnUse',patternTransform:'rotate(45)'},defs);
sv('rect',{width:6,height:6,style:`fill:${bg}`},pt);sv('line',{x1:0,y1:0,x2:0,y2:6,style:`stroke:${fg};stroke-width:2.2`},pt);});
const pr=sv('text',{x:-999,y:-999,style:'font:600 12px var(--sans)'},svg);let lw=0; // bold: our rows are drawn bold
const name=r=>r.model+(r.partial?' (still running)':'');
rows.forEach(r=>{pr.textContent=name(r);lw=Math.max(lw,pr.getComputedTextLength());});svg.removeChild(pr);
const G=rows.some(r=>r.ours)?100:0; // left gutter: base -> trained arrows
const L=stack?G:G+8+Math.min(Math.max(90,lw+12),Math.max(100,(W-G)*0.42)),R=stack?84:100;
const X=v=>L+Math.max(0,Math.min(1,v))*(W-L-R);
const fmt=opt.fmt||(r=>f3(r.pass1)+(r.pass4!=null?' / '+f3(r.pass4):''));
rows.forEach((r,i)=>{const y=(stack?18:7)+i*rh,h=stack?13:rh-9,mid=y+h/2;
sv('text',stack?{x:G,y:y-4}:{x:L-9,y:mid+4,'text-anchor':'end'},svg).setAttribute('style',`font:12px var(--sans);fill:${r.ours?'var(--fg)':'var(--fg-mid)'};font-weight:${r.ours?600:400}`);
svg.lastChild.textContent=name(r);
const tip=`${r.model} · pass@1 ${f3(r.pass1)}`+(r.lo!=null?` [${f2(r.lo)}, ${f2(r.hi)}]`:'')+(r.pass4!=null?` · pass@4 ${f3(r.pass4)}`:'')
+(r.unsplit?'':` · declined ${Math.round(100*(r.refused||0))}% · never submitted ${Math.round(100*(r.no_submit||0))}%`)+(r.note?` · ${r.note}`:'');
const g=sv('g',{},svg); sv('title',{},g).textContent=tip;
sv('rect',{x:L,y,width:X(1)-L,height:h,rx:2,style:'fill:#e8ecea'},g);
let at=0;
const seg=(v,fill)=>{if(!(v>0))return;const x0=X(at),x1=X(at+v);sv('rect',{x:x0,y,width:Math.max(.8,x1-x0),height:h,style:`fill:${fill}`},g);at+=v;};
seg(r.pass1||0,r.ours?oursCol(r):'#7f8d88');
if(!r.unsplit){seg(r.refused||0,`url(#${host.id}hd)`);seg(r.no_submit||0,`url(#${host.id}hn)`);}
if(r.lo!=null&&r.hi!=null){
sv('line',{x1:X(r.lo),x2:X(r.hi),y1:mid,y2:mid,style:'stroke:var(--fg);opacity:.55'},g);
[r.lo,r.hi].forEach(v=>sv('line',{x1:X(v),x2:X(v),y1:mid-3.5,y2:mid+3.5,style:'stroke:var(--fg);opacity:.55'},g));}
if(r.pass4!=null) sv('line',{x1:X(r.pass4),x2:X(r.pass4),y1:y-2,y2:y+h+2,style:'stroke:var(--ink);stroke-width:2'},g);
sv('text',{x:X(1)+6,y:mid+4,style:'font:11.5px var(--mono);fill:var(--fg-mid)'},svg).textContent=fmt(r);});
// Curved arrow from each base row to its trained row, labelled with the pass@1 gain. Each pair has
// its own column in the gutter (thinking outer, non-thinking inner), so the two never lie on each other.
const rowMid=name=>{const i=rows.findIndex(r=>r.model===name);if(i<0)return null;
const y=(stack?18:7)+i*rh,h=stack?13:rh-9;return y+h/2;};
const defs2=svg.querySelector('defs');
[[OURS_T,COL_T,G-46,14,'t'],[OURS_N,COL_N,G-14,10,'n']].forEach(([[base,tuned],col,xc,bow,k])=>{
const yb=rowMid(base),yt=rowMid(tuned);if(yb==null||yt==null)return;
const rb=rows.find(r=>r.model===base),rt=rows.find(r=>r.model===tuned);
const mk=sv('marker',{id:host.id+'ar'+k,viewBox:'0 0 8 8',refX:7,refY:4,markerWidth:7,markerHeight:7,orient:'auto'},defs2);
sv('path',{d:'M0,0 L8,4 L0,8 z',style:`fill:${col}`},mk);
const end=G-3,xl=xc-bow;
const d=`M ${end} ${yb} L ${xc} ${yb} C ${xl} ${yb}, ${xl} ${yt}, ${xc} ${yt} L ${end} ${yt}`;
const path=sv('path',{d,'marker-end':`url(#${host.id}ar${k})`,style:`fill:none;stroke:${col};stroke-width:1.6`},svg);
sv('title',{},path).textContent=`${base} → ${tuned}: pass@1 ${f3(rb.pass1)} → ${f3(rt.pass1)}`;
const gain=(rt.pass1||0)-(rb.pass1||0);
sv('text',{x:xl-4,y:(yb+yt)/2+4,'text-anchor':'end',style:`font:600 10.5px var(--mono);fill:${col};paint-order:stroke;stroke:var(--bg);stroke-width:3px`},svg)
.textContent=(gain>=0?'+':'')+gain.toFixed(2);
});
}
function boardLegend(id){const el=$(id);if(!el)return;
const sw=(st,label)=>`<span><i class="sw" style="height:10px;${st}"></i>${label}</span>`;
el.innerHTML=sw('background:var(--accent)','ours, thinking')+sw('background:#7a5aa6','ours, non-thinking')+sw('background:#7f8d88','other models')
+sw('background:repeating-linear-gradient(45deg,var(--bad) 0 2px,var(--badwash) 2px 5px)','declined on safety grounds')
+sw('background:repeating-linear-gradient(45deg,#b07a4c 0 2px,#f3e8dc 2px 5px)','never submitted (out of turns or tokens)')
+sw('background:#e8ecea;outline:1px solid var(--line2)','submitted and wrong')
+sw('width:2px;height:13px;border-radius:0;background:var(--ink)','pass@4')
+sw('width:14px;height:0;border-radius:0;border-top:1px solid var(--fg)','95% interval on pass@1')
+sw('width:14px;height:0;border-radius:0;border-top:2px solid var(--accent)','base → after RL, pass@1 gain');}
/* ---------------- molecules: 2D depiction and the 3D viewer ------------- */
let MOL={}, viewer=null, spinning=true, style3d='stick', current3d=null;
const depict=s=>(MOL[s]&&MOL[s].svg)||'';
function facts(s){const m=MOL[s];if(!m)return '';
return `<span>${esc(m.formula)}</span><span>MW ${m.mw}</span><span>${m.atoms} heavy atoms</span><span>${m.rings} ring${m.rings===1?'':'s'}</span>`;}
function ensureViewer(){
if(viewer||!window.$3Dmol)return viewer;
viewer=$3Dmol.createViewer(document.getElementById('viewer3d'),{backgroundColor:'#e9edea'});
return viewer;
}
function apply3dStyle(){
if(!viewer)return;
viewer.setStyle({}, style3d==='stick'
? {stick:{radius:0.14,colorscheme:'Jmol'}}
: {stick:{radius:0.1,colorscheme:'Jmol'},sphere:{scale:0.26,colorscheme:'Jmol'}});
viewer.render();
}
function show3d(smiles,label){
const rec=MOL[smiles];
const title=document.getElementById('v3-title');
if(!rec||!rec.mol3d){if(title)title.textContent='No 3D conformer';return;}
current3d=smiles;
if(title)title.textContent=label||'In three dimensions';
const v=ensureViewer();
if(!v){setTimeout(()=>show3d(smiles,label),300);return;}
v.removeAllModels();
v.addModel(rec.mol3d,'mol');
apply3dStyle();
v.zoomTo();
v.spin(spinning?'y':false);
v.render();
document.querySelectorAll('.node[aria-current=true]').forEach(n=>n.setAttribute('aria-current','false'));
document.querySelectorAll(`.node[data-s="${CSS.escape(smiles)}"]`).forEach(n=>n.setAttribute('aria-current','true'));
}
/* ---------------- route tree ------------------------------------------- */
function nodeHTML(n,isTarget){
const pic=depict(n.s);
const m=MOL[n.s]||{};
const badge=n.stock?'<span class="badge in">in stock</span>':'<span class="badge make">make it</span>';
return `<div class="node${isTarget?' target':''}" data-s="${esc(n.s)}" role="button" tabindex="0" title="${esc(n.s)}">
<div class="pic">${pic||'<span class="note">no depiction</span>'}</div>
<div class="cap"><span class="f">${esc(m.formula||'')}</span>${badge}</div>
</div>`;
}
function treeHTML(n,isTarget){
let html=`<div class="branch">${nodeHTML(n,isTarget)}`;
const kids=n.kids||[];
if(kids.length&&n.via){
const v=n.via;
const tip=[v.cls,v.conf!=null?`confidence ${v.conf}`:null,v.why].filter(Boolean).join(' — ');
html+=`<div class="stem"></div>
<div class="rxn" title="${esc(tip)}">${esc(v.cls||'disconnection')}${v.conf!=null?` · ${v.conf}`:''}</div>
<div class="stem"></div>`;
html+=`<div class="kids">${kids.map(k=>treeHTML(k,false)).join('')}</div>`;
}
html+='</div>';
return html;
}
function routesHTML(ep){
if(ep.tree&&ep.tree.length){
return `<div class="routes">`+ep.tree.map((r,i)=>
`<div><div class="tag" style="margin-bottom:6px">Route ${i+1} — each molecule is made from the ones it points to</div>
<div class="routewrap"><div class="tree">${treeHTML(r,true)}</div></div></div>`).join('')+`</div>`;
}
if(ep.raw_submission)
return `<div class="empty">The submission was not valid JSON, so there is no tree to draw. The first 1,500 characters the model emitted:<div class="out" style="margin-top:8px">${esc(ep.raw_submission)}</div></div>`;
return `<div class="empty">The episode ended without calling <span class="mono">emit_routes</span>, so nothing was submitted and the reward is 0.</div>`;
}
function components(c){
const order=['parse','structure','steps','stock','constraints','efficiency','diversity','reference_similarity','reference_match'];
const keys=order.filter(k=>k in (c||{}));
if(!keys.length)return '';
return `<div class="bars">`+keys.map(k=>
`<span class="t">${k}</span><span class="track"><span class="fill" style="width:${Math.max(0,Math.min(1,c[k]))*100}%"></span></span><span class="v">${f2(c[k])}</span>`
).join('')+`</div>`;
}
function turns(tr){
return tr.map(m=>{
if(m.r==='a'){
const think=m.think?`<div class="think">${esc(m.think)}</div>`:'';
const text=m.text?`<div class="think">${esc(m.text)}</div>`:'';
const calls=(m.calls||[]).map(c=>
`<div class="call">${esc(c.name)}(${esc(JSON.stringify(c.args)).slice(0,420)})</div>`).join('');
return `<div class="turn"><span class="role">model</span>${think}${text}${calls}</div>`;
}
let pretty=m.out;
try{pretty=JSON.stringify(JSON.parse(m.out),null,1);}catch(e){}
return `<details class="turn tool"><summary><span class="role">${esc(m.name)}</span> returned</summary><div class="out">${esc(pretty)}</div></details>`;
}).join('');
}
function panel(title,ep){
const ok=ep.valid;
if(ep.missing) return `<div class="col"><div class="head"><h3>${esc(title)}</h3><span class="verdict">still running</span></div>
<div class="body"><p class="empty">${esc(ep.note||'No graded attempt yet.')}</p></div></div>`;
const m=(DATA.idx.models.find(x=>x.name===title)||{});
const sub=[(ep.of===1?'its one attempt':'attempt '+(ep.attempt||1)+' of 4')].concat(m.provider?[m.provider]:[]).join(' · ');
return `<div class="col">
<div class="head"><h3>${esc(title)}<span class="note" style="font-weight:400"> · ${esc(sub)}</span></h3><span class="verdict ${ok?'solved':'failed'}">${ok?'solved':'not solved'}</span></div>
<div class="body">
${ep.note?`<p class="note" style="margin:0 0 4px;color:var(--fg-mid)">${esc(ep.note)}</p>`:''}${m.note?`<p class="note" style="margin:0 0 8px">${esc(m.note)}</p>`:''}
<dl class="kv">
<dt>reward</dt><dd>${f3(ep.reward)}</dd>
<dt>turns</dt><dd>${ep.turns} · ${ep.tool_calls} tool calls</dd>
<dt>routes submitted</dt><dd>${ep.routes ?? 0}</dd>
</dl>
${components(ep.components)}
${routesHTML(ep)}
<details><summary>Full rollout — ${ep.transcript.length} messages</summary><div class="stack" style="gap:8px;margin-top:8px">${turns(ep.transcript)}</div></details>
</div></div>`;
}
/* ---------------- boot -------------------------------------------------- */
let DATA={};
async function boot(){
// The three startup files are inlined into this page at build time, so the first
// render needs no network at all; they are fetched only if the inline copy is absent.
const inline=id=>{const el=document.getElementById(id);return el?JSON.parse(el.textContent):null;};
const grab=async(id,file)=>inline(id)||fetch(file).then(r=>r.json());
const [idx,ck,front]=await Promise.all([
grab('d-index','index.json'), grab('d-checkpoints','checkpoints.json'), grab('d-frontier','frontier.json')]);
DATA={idx,ck,front};
const BASE='Qwen3.8-27B base', TUNED='Qwen3.8-27B + RL 525';
DATA.BASE=BASE; DATA.TUNED=TUNED;
DATA.ALL=idx.tasks.concat(idx.tasks150||[]);
const ALL=DATA.ALL;
const fixedAll=ALL.filter(t=>t.solved[TUNED]&&!t.solved[BASE]).map(t=>t.id);
DATA.summary={fixed:fixedAll};
const nOthers=idx.models.filter(m=>!m.ours).length;
const SETS={core30:ALL.map((t,i)=>i).slice(0,idx.tasks.length),core150:ALL.map((t,i)=>i)};
function renderSet(set){
DATA.SET=set;
document.querySelectorAll('#setswitch button').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.set===set)));
const ids=SETS[set], tasks=ids.map(i=>ALL[i]), n=tasks.length;
const nb=tasks.filter(t=>t.solved[BASE]).length, nt=tasks.filter(t=>t.solved[TUNED]).length;
const fixed=tasks.filter(t=>t.solved[TUNED]&&!t.solved[BASE]).length;
const broke=tasks.filter(t=>t.solved[BASE]&&!t.solved[TUNED]).length;
$('#r-head').textContent=`On the first attempt the untrained model solves ${nb} of ${n} and the trained one ${nt}; `
+`RL fixed ${fixed} and broke ${broke===0?'none':broke}. One attempt is a noisy draw: the Board tab averages four on core30. `
+`${nOthers} other models ran the same ${n===30?'thirty':n} in the same harness — open any molecule to compare them.`;
$('#pick-label').textContent=n===30?'Pick a target — all thirty, drawn to scale':`Pick a target — all ${n}, drawn to scale`;
$('#back').textContent=n===30?'← All thirty':`← All ${n}`;
const TIER=['easy','medium','hard'];
ORDER=[];
const galleryHost=$('#groups'); galleryHost.textContent='';
TIER.forEach(tier=>{
const idxs=ids.filter(i=>ALL[i].tier===tier);
if(!idxs.length)return;
const head=document.createElement('div'); head.className='grouphead';
const solved=idxs.filter(i=>ALL[i].solved[TUNED]).length;
head.innerHTML=`<h3>${esc(tier)}</h3><span class="n">${idxs.length} tasks · trained model solves ${solved}</span><span class="rule"></span>`;
galleryHost.append(head);
const grid=document.createElement('div'); grid.className='gallery';
grid.setAttribute('role','listbox'); grid.setAttribute('aria-label',tier+' targets');
idxs.forEach(i=>{
ORDER.push(i);
const t=ALL[i];
const isFixed=fixedAll.includes(t.id);
const kind=isFixed?'fixed':(t.solved[TUNED]?'both':'none');
const label=isFixed?'RL fixed this one':(t.solved[TUNED]?'both solved':'neither solved');
const nsolve=Object.values(t.solved).filter(Boolean).length, nmod=Object.keys(t.solved).length;
const b=document.createElement('button');
b.className='card '+t.tier; b.dataset.i=i; b.setAttribute('role','option');
b.setAttribute('aria-selected','false');
b.title=`${t.tier} · ${t.formula} · ${label} · ${nsolve} of ${nmod} models solved it`;
b.innerHTML=`<span class="thumb">${t.svg||''}</span>
<span class="line"><i class="dot ${kind}"></i><span class="f">${esc(t.formula||t.id)}</span></span>
<span class="line"><span class="tierdot">${esc(t.tier)}</span> <span class="f">${nsolve}/${nmod} solved</span></span>`;
b.onclick=()=>select(i);
grid.append(b);
});
galleryHost.append(grid);
});
}
document.querySelectorAll('#setswitch button').forEach(b=>b.onclick=()=>{showGallery();renderSet(b.dataset.set);});
renderSet('core30');
$('#harness-note').textContent=idx.note;
$('#back').onclick=showGallery;
$('#prev').onclick=()=>step(-1);
$('#next').onclick=()=>step(1);
document.getElementById('v3-stick').onclick=()=>{style3d='stick';syncBtns();apply3dStyle();};
document.getElementById('v3-ball').onclick=()=>{style3d='ball';syncBtns();apply3dStyle();};
document.getElementById('v3-spin').onclick=()=>{spinning=!spinning;syncBtns();if(viewer){viewer.spin(spinning?'y':false);viewer.render();}};
function syncBtns(){
document.getElementById('v3-stick').setAttribute('aria-pressed',String(style3d==='stick'));
document.getElementById('v3-ball').setAttribute('aria-pressed',String(style3d==='ball'));
document.getElementById('v3-spin').setAttribute('aria-pressed',String(spinning));
}
const drawBoards=()=>{
boardChart($('#ch-board'),front.core30,{label:'Pass at 1 and pass at 4 on core30 for every model, four attempts each'});
boardChart($('#ch-board150'),front.core150,{label:'Pass at 1 on core150, one attempt each, with our rows at pass at 1 and pass at 4',
fmt:r=>r.ours?`${f3(r.pass1)} / ${f3(r.pass4)}`:`${r.solved}/${r.tasks}`});};
drawBoards(); boardLegend('#lg-board'); boardLegend('#lg-board150');
if(front.opus){const o=front.opus,a=o.core30,b=o.core150,pc=(x,y)=>Math.round(100*x/y)+'%';
$('#opus-note').innerHTML=`<b>Why claude-opus-5-5 is low.</b> Opus 5.5 is low here because it declines most of these tasks on safety grounds (category ${esc(a.categories.join(', '))}), not because it fails them. A declined episode counts as unsolved. `
+`On core30 it declined ${a.declined} of ${a.attempts} attempts (${pc(a.declined,a.attempts)}), and ${a.every_attempt} of the 30 molecules on every attempt; of the ${a.answered} attempts it answered it solved ${a.solved_answered} (${pc(a.solved_answered,a.answered)}), the highest solve rate on the board when it answers. `
+`On core150 it declined ${b.declined} of ${b.episodes} (${pc(b.declined,b.episodes)}), ${b.first_turn} of them on the very first turn before any tool call, and solved ${b.solved_answered} of the ${b.answered} it answered (${pc(b.solved_answered,b.answered)}). `
+`On the old board, with thinking off, it declined ${o.old_board.declined} of ${o.old_board.tasks}.`;}
$('#board-note').textContent=front.note+(front.core30.concat(front.core150).some(r=>r.partial)?' Rows marked still running are drawn from the attempts graded so far.':'');
const notes=idx.models.filter(m=>m.note);
$('#board-models').innerHTML=notes.map(m=>`<li>${esc(m.name)}: ${esc(m.note)}</li>`).join('');
const LAB={'easy2k-shaped-r1':'Non-thinking, easy pool','easy2k-shaped-think-r2':'Thinking, easy pool','think-mixed-r3':'Mixed pool, lr 1e-4','think-mixed-r4':'Resumed from 425, lr 5e-5'};
const COL={'easy2k-shaped-r1':'var(--bar)','easy2k-shaped-think-r2':'#b07a4c','think-mixed-r3':'var(--accent)','think-mixed-r4':'#8a6aa3'};
const comp=ck.checkpoints.filter(r=>r.complete);
const groups={'easy2k-shaped-r1':comp.filter(r=>r.run.startsWith('easy2k-shaped-r1')),
'easy2k-shaped-think-r2':comp.filter(r=>r.run==='easy2k-shaped-think-r2'),
'think-mixed-r3':comp.filter(r=>r.run==='think-mixed-r3'),
'think-mixed-r4':comp.filter(r=>r.run==='think-mixed-r4')};
const runSeries=Object.entries(groups).map(([k,rows])=>({name:LAB[k],color:COL[k],
dash:k.startsWith('easy2k')?'4 3':null,points:rows.map(r=>({x:r.step,y:r.pass_at_1}))}));
legend('#lg-runs',runSeries); lineChart($('#ch-runs'),runSeries,{y:'pass@1',label:'Pass at 1 by absolute training step for four runs'});
const tierCol={easy:'#6b7f9e',medium:'#b07a4c',hard:'var(--accent)'};
const tierSeries=[];
['easy','medium','hard'].forEach(t=>{
tierSeries.push({name:t,color:tierCol[t],points:groups['think-mixed-r3'].map(r=>({x:r.step,y:r.tiers_first_attempt[t]}))});
tierSeries.push({name:t+' (resumed)',color:tierCol[t],dash:'3 3',points:groups['think-mixed-r4'].map(r=>({x:r.step,y:r.tiers_first_attempt[t]}))});
});
legend('#lg-tiers',['easy','medium','hard'].map(t=>({name:t,color:tierCol[t]})).concat([{name:'dashed: the resumed run',color:'var(--fg-dim)',dash:true}]));
lineChart($('#ch-tiers'),tierSeries,{y:'pass@1',label:'First attempt pass rate by difficulty tier'});
const tb=$('#ck tbody'); const best=comp.reduce((a,b)=>b.pass_at_1>a.pass_at_1?b:a,comp[0]);
[...ck.checkpoints].sort((a,b)=>(a.thinking===b.thinking?a.step-b.step:(a.thinking?1:-1))).forEach(r=>{
const tr=document.createElement('tr'); if(r===best)tr.className='ours';
const t=r.tiers_first_attempt||{};
[[r.run,'l'],[r.step],[r.thinking?'yes':'no'],[f3(r.pass_at_1)],[f3(r.pass_at_4)],
[f2(t.easy)],[f2(t.medium)],[f2(t.hard)],[f3(r.mean_reward)],[r.complete?'150':r.tasks+' of 150']]
.forEach(([v,l],i)=>{const td=document.createElement('td');if(l)td.style.textAlign='left';
if(i>0)td.className='mono';td.textContent=v;tr.append(td);});
tb.append(tr);
});
$('#ck-note').textContent=ck.note;
addEventListener('resize',()=>{clearTimeout(window._t);window._t=setTimeout(()=>{
drawBoards();
lineChart($('#ch-runs'),runSeries,{y:'pass@1'});lineChart($('#ch-tiers'),tierSeries,{y:'pass@1'});
if(viewer)viewer.resize();},180);});
}
let chosen=0, ORDER=[];
function showGallery(){
$('#view-detail').hidden=true; $('#view-gallery').hidden=false;
const card=document.querySelector(`.card[data-i="${chosen}"]`);
if(card)card.scrollIntoView({block:'nearest'});
}
function step(d){
const at=ORDER.indexOf(chosen);
if(at<0)return;
select(ORDER[(at+d+ORDER.length)%ORDER.length]);
}
const TASKCACHE=new Map();
let TASK=null, SHOWN=[];
// Embedded on huggingface.co this page cannot request its own origin as a
// subresource at all: fetch, XMLHttpRequest and <script src> are each refused
// before a request leaves the browser, while a cross-origin CDN request and a
// nested *document* both load. So each task ships as tasks/<id>.html, whose
// inline script calls back into this page from a hidden iframe.
window.__RETROTASK__=d=>{const w=TASKCACHE.get(d.id); TASKCACHE.set(d.id,d); if(w&&w.resolve)w.resolve(d);};
function loadTask(id){
const hit=TASKCACHE.get(id);
if(hit&&!hit.resolve)return Promise.resolve(hit);
if(hit&&hit.promise)return hit.promise;
let resolve,reject;
const promise=new Promise((a,b)=>{resolve=a;reject=b;});
TASKCACHE.set(id,{promise,resolve,reject});
const fr=document.createElement('iframe');
fr.setAttribute('aria-hidden','true');
fr.setAttribute('tabindex','-1');
fr.style.cssText='position:absolute;left:-9999px;width:0;height:0;border:0';
let settled=false;
const pending=()=>{const c=TASKCACHE.get(id);return c&&c.resolve;};
const clean=()=>{settled=true;clearTimeout(timer);fr.remove();};
const fail=()=>{if(settled)return;clean();TASKCACHE.delete(id);
reject(new Error('could not load tasks/'+id+'.html'));};
const timer=setTimeout(fail,45000);
fr.onerror=fail;
// The inline script runs while the document parses, so by load it has called back.
fr.onload=()=>{if(settled)return; if(pending())fail(); else clean();};
fr.src=`tasks/${id}.html`;
document.body.append(fr);
return promise;
}
async function select(i){
chosen=i;
document.querySelectorAll('.card').forEach(c=>c.setAttribute('aria-selected',String(Number(c.dataset.i)===i)));
$('#view-gallery').hidden=true; $('#view-detail').hidden=false;
const meta=DATA.ALL[i];
$('#crumb').innerHTML=`<span class="spin"></span><b>${esc(meta.formula||meta.id)}</b> · loading`;
$('#models').innerHTML='';
$('#pair').innerHTML='<div class="loading"><span class="spin"></span>Loading every rollout for this molecule…</div>';
const bar=document.querySelector('.detailbar'); if(bar)bar.scrollIntoView({block:'nearest'});
try{
TASK=await loadTask(meta.id);
}catch(e){
$('#pair').innerHTML=`<p class="empty">Could not load this task: ${esc(e.message)}</p>`;
$('#crumb').innerHTML=`<b>${esc(meta.formula||meta.id)}</b> · failed to load`;return;
}
if(chosen!==i)return; // a faster click won
MOL=TASK.molecules||{};
const names=Object.keys(TASK.episodes);
SHOWN=[DATA.BASE,DATA.TUNED].filter(n=>names.includes(n));
if(!SHOWN.length)SHOWN=names.slice(0,2);
drawTask();
}
function toggleModel(name){
SHOWN=SHOWN.includes(name)?SHOWN.filter(n=>n!==name):[...SHOWN,name];
drawTask();
}
function drawTask(){
const meta=DATA.ALL[chosen], t=TASK;
const s=DATA.summary;
const label=s.fixed.includes(meta.id)?'RL fixed this one':(meta.solved[DATA.TUNED]?'both solved':'neither solved');
const at=ORDER.indexOf(chosen);
$('#crumb').innerHTML=`<b>${esc(meta.formula||meta.id)}</b> · ${esc(meta.tier)} · ${esc(label)} · ${at+1} of ${ORDER.length}`;
$('#t-tier').textContent=`${meta.tier} · depth budget ${t.max_depth}`;
$('#t-2d').innerHTML=depict(t.target)||`<span class="note mono">${esc(t.target)}</span>`;
$('#t-facts').innerHTML=facts(t.target)+`<span class="mono" style="word-break:break-all">${esc(t.target)}</span>`;
const order=DATA.idx.models.map(m=>m.name).filter(n=>n in t.episodes);
$('#models').innerHTML=order.map(n=>{
const ep=t.episodes[n], ours=!!(DATA.idx.models.find(m=>m.name===n)||{}).ours;
return `<button class="chip ${ep.valid?'ok':'no'}${ours?' ours':''}" data-m="${esc(n)}"
aria-pressed="${SHOWN.includes(n)}" title="${esc(n)} — ${ep.valid?'solved':'not solved'}, reward ${f3(ep.reward)}${ep.note?', '+esc(ep.note):''}">
<span class="mk">${ep.missing?'…':(ep.valid?'✓':'✗')}</span>${esc(n)}</button>`;}).join('');
document.querySelectorAll('#models .chip').forEach(c=>c.onclick=()=>toggleModel(c.dataset.m));
$('#pair').innerHTML = SHOWN.length
? SHOWN.map(n=>panel(n,t.episodes[n])).join('')
: '<p class="empty">No model selected — pick one above.</p>';
document.querySelectorAll('.node').forEach(n=>{
const go=()=>show3d(n.dataset.s,(MOL[n.dataset.s]||{}).formula||'In three dimensions');
n.addEventListener('click',go);
n.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();go();}});
});
show3d(t.target,(MOL[t.target]||{}).formula||'Target');
}
document.querySelectorAll('nav button').forEach(b=>b.onclick=()=>{
document.querySelectorAll('nav button').forEach(x=>x.setAttribute('aria-selected',String(x===b)));
document.querySelectorAll('section').forEach(s=>s.hidden=s.id!==b.dataset.tab);
dispatchEvent(new Event('resize'));
});
boot().catch(e=>{document.querySelector('.wrap').insertAdjacentHTML('beforeend',
`<p class="empty">Could not load the data files: ${esc(e.message)}</p>`);});
</script>
</body>
</html>