figures / unit3-data-episodes.html
sergiopaniego's picture
sergiopaniego HF Staff
unit3-data-episodes: upload the built page, not the fragment
1e7ce8a verified
Raw History Blame Contribute Delete
14.9 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Whole episodes vs first turn, distilling a data-analysis agent</title>
<!-- Generated by build.py from fragments/. Runtime and theme tokens come from the research-article template. -->
<link rel="stylesheet" href="runtime/variables.css">
<script>
// The iframe can't read the course page's theme, so follow ?theme= if given, else the OS setting.
(function () {
const forced = new URLSearchParams(location.search).get('theme');
const mq = matchMedia('(prefers-color-scheme: dark)');
const apply = () => document.documentElement.setAttribute('data-theme', forced || (mq.matches ? 'dark' : 'light'));
apply();
if (!forced) mq.addEventListener('change', apply);
})();
</script>
<script src="runtime/color-palettes.js"></script>
<script src="runtime/rough.js"></script>
<script src="runtime/hand.js"></script>
<script src="runtime/embed-runtime.js"></script>
<style>
html, body { margin: 0; padding: 0; }
/* An opaque card with its own background, so it stays readable whatever theme the course page uses */
body { background: transparent; }
.figure-card { font-family: 'Source Sans 3', var(--default-font-family); color: var(--text-color); background: var(--page-bg);
border: 1px solid var(--border-color); border-radius: 10px; padding: 12px 14px 10px; }
</style>
<script>
// Clean look by default, in Source Sans. ?style=hand brings back the old hand-drawn look for comparison:
// it loads Excalifont and uses it for the whole card.
if (new URLSearchParams(location.search).get('style') === 'hand') {
const st = document.createElement('style');
st.textContent = "@font-face { font-family: 'Excalifont'; src: url('runtime/fonts/Excalifont-Regular.woff2') format('woff2'); font-display: swap; }" +
".figure-card { font-family: 'Excalifont', 'Source Sans 3', var(--default-font-family); }";
document.head.appendChild(st);
} else {
document.documentElement.classList.add('style-clean');
const l = document.createElement('link'); l.rel = 'stylesheet';
l.href = 'https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600;700&display=swap';
document.head.appendChild(l);
}
</script>
</head>
<body>
<div class="figure-card">
<!-- title: Whole episodes vs first turn, distilling a data-analysis agent -->
<div class="fig-u3-data-episodes"></div>
<style>
.fig-u3-data-episodes { position: relative; color: var(--text-color); font-size: 14px; }
.fig-u3-data-episodes .fig-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.fig-u3-data-episodes button {
font: inherit; font-size: 14px; min-height: 30px; padding: 2px 12px; border-radius: 6px; cursor: pointer;
color: var(--text-color); background: var(--surface-bg); border: 1px solid var(--border-color);
}
.fig-u3-data-episodes button[aria-pressed="true"] { border-color: var(--primary-color); }
.fig-u3-data-episodes button:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.fig-u3-data-episodes svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.fig-u3-data-episodes svg .hit { cursor: pointer; outline: none; }
.fig-u3-data-episodes svg .hit:focus-visible { stroke: var(--primary-color); stroke-width: 2; }
.fig-u3-data-episodes .fig-readout { margin: 6px 0 0; min-height: 4.35em; line-height: 1.45; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .fig-u3-data-episodes .fig-readout { min-height: 7.25em; } }
</style>
<script>
Embed.mount('fig-u3-data-episodes', (ctx) => {
// Unit 3, distilling the data-analysis agent (Qwen3.5-2B) over whole episodes vs only its first turn, three seeds each.
// Mean reward = share of tasks answered correctly, 8 runs per task, base model and all six students in the same job.
// eval_verified: 61 tasks, 16 turns per run, job 6b0428a2. test: 194 harder tasks, 10 turns per run, job 6b0428a4.
// Gains: whole episodes minus first turn of the same seed, task by task, 95% bootstrap interval over tasks,
// with the better/worse/tied task counts.
const D = {"sets": [{"button": "eval_verified, 61 tasks, 16 turns", "tasks": 61, "base": 0.189, "first": [0.287, 0.285, 0.287], "episodes": [0.355, 0.344, 0.35], "gains": [{"seed": 42, "diff": 0.068, "ci": [0.033, 0.105], "bwt": [24, 6, 31]}, {"seed": 43, "diff": 0.059, "ci": [0.023, 0.096], "bwt": [25, 8, 28]}, {"seed": 44, "diff": 0.064, "ci": [0.029, 0.1], "bwt": [28, 10, 23]}], "notes": {"base": "Qwen3.5-2B with no training answered 0.189 of the 61 eval_verified tasks correctly, with 16 turns per run and 8 runs per task. The base model and the six students ran in the same job.", "first": "Distilled on the first turn only, three seeds: seed 42 0.287, seed 43 0.285, seed 44 0.287. All three beat the base model (0.189).", "episodes": "Distilled over whole episodes, three seeds: seed 42 0.355, seed 43 0.344, seed 44 0.350. All three beat the base model (0.189) and the first-turn runs.", "s42": "Seed 42: whole episodes minus first turn, task by task, is +0.068 with a 95% interval of [+0.033, +0.105], all above 0. Whole episodes scored higher on 24 of the 61 tasks, lower on 6 and the same on 31.", "s43": "Seed 43: whole episodes minus first turn, task by task, is +0.059 with a 95% interval of [+0.023, +0.096], all above 0. Whole episodes scored higher on 25 of the 61 tasks, lower on 8 and the same on 28.", "s44": "Seed 44: whole episodes minus first turn, task by task, is +0.064 with a 95% interval of [+0.029, +0.100], all above 0. Whole episodes scored higher on 28 of the 61 tasks, lower on 10 and the same on 23."}}, {"button": "test, 194 harder tasks, 10 turns", "tasks": 194, "base": 0.143, "first": [0.239, 0.227, 0.222], "episodes": [0.281, 0.273, 0.282], "gains": [{"seed": 42, "diff": 0.042, "ci": [0.016, 0.069], "bwt": [59, 34, 101]}, {"seed": 43, "diff": 0.046, "ci": [0.021, 0.07], "bwt": [61, 33, 100]}, {"seed": 44, "diff": 0.059, "ci": [0.034, 0.084], "bwt": [64, 23, 107]}], "notes": {"base": "Qwen3.5-2B with no training answered 0.143 of the 194 test tasks correctly, with 10 turns per run and 8 runs per task. The base model and the six students ran in the same job.", "first": "Distilled on the first turn only, three seeds: seed 42 0.239, seed 43 0.227, seed 44 0.222. All three beat the base model (0.143).", "episodes": "Distilled over whole episodes, three seeds: seed 42 0.281, seed 43 0.273, seed 44 0.282. All three beat the base model (0.143) and the first-turn runs.", "s42": "Seed 42: whole episodes minus first turn, task by task, is +0.042 with a 95% interval of [+0.016, +0.069], all above 0. Whole episodes scored higher on 59 of the 194 tasks, lower on 34 and the same on 101.", "s43": "Seed 43: whole episodes minus first turn, task by task, is +0.046 with a 95% interval of [+0.021, +0.070], all above 0. Whole episodes scored higher on 61 of the 194 tasks, lower on 33 and the same on 100.", "s44": "Seed 44: whole episodes minus first turn, task by task, is +0.059 with a 95% interval of [+0.034, +0.084], all above 0. Whole episodes scored higher on 64 of the 194 tasks, lower on 23 and the same on 107."}}], "gainAxis": [-0.05, 0.15], "gainTicks": [-0.05, 0, 0.05, 0.1, 0.15], "idle": "Hover or tap a part of the figure to read it. The buttons switch the task set.", "describe": "Distilling a Qwen3.5-2B data-analysis agent over whole episodes versus only its first turn, three seeds each, all evaluated with the base model in one job per task set, 8 runs per task. Two buttons switch the task set. eval_verified, 61 tasks, 16 turns: no training 0.189, first turn 0.287, 0.285 and 0.287, whole episodes 0.355, 0.344 and 0.350. Whole episodes minus first turn of the same seed: seed 42 +0.068, 95% interval +0.033 to +0.105. Seed 43 +0.059, +0.023 to +0.096. Seed 44 +0.064, +0.029 to +0.100. test, 194 harder tasks, 10 turns: no training 0.143, first turn 0.239, 0.227 and 0.222, whole episodes 0.281, 0.273 and 0.282. Whole episodes minus first turn: seed 42 +0.042, +0.016 to +0.069. Seed 43 +0.046, +0.021 to +0.070. Seed 44 +0.059, +0.034 to +0.084. Every interval is above 0."};
const NS = 'http://www.w3.org/2000/svg';
let width = 640, focus = null, set = 0;
const controls = document.createElement('div');
controls.className = 'fig-controls';
const buttons = D.sets.map((s, i) => {
const b = document.createElement('button');
b.type = 'button';
b.textContent = s.button;
b.addEventListener('click', () => { set = i; focus = null; draw(); }, { signal: ctx.signal });
controls.appendChild(b);
return b;
});
const svg = document.createElementNS(NS, 'svg');
const readout = document.createElement('p');
readout.className = 'fig-readout';
readout.setAttribute('aria-live', 'polite');
ctx.root.append(controls, svg, readout);
ctx.describe(D.describe);
const sign = (v) => (v >= 0 ? '+' : '−') + Math.abs(v).toFixed(3);
const el = (parent, tag, attrs) => { const n = document.createElementNS(NS, tag); Object.entries(attrs).forEach(([k, v]) => n.setAttribute(k, v)); parent.appendChild(n); return n; };
const setFocus = (k) => { if (k !== focus) { focus = k; draw(); } };
function draw() {
buttons.forEach((b, i) => b.setAttribute('aria-pressed', String(i === set)));
const T = D.sets[set];
const C = Hand.colors(ctx.root);
svg.replaceChildren();
const h = Hand.create(svg, { seed: 31 });
const narrow = width < 520;
const x0 = 4, x1 = width - 4;
const halo = (t) => { t.setAttribute('stroke', C.bg); t.setAttribute('stroke-width', 4); t.setAttribute('paint-order', 'stroke'); return t; };
const dim = (k) => (focus && focus !== k ? 0.35 : 1);
const hits = [];
const hit = (key, x, y, w, hh) => hits.push({ key, x, y, w, hh });
const heading = (y, text) => h.text(x0, y, text, { size: 13, color: C.muted, weight: 600 });
// 1. Scores on the full 0 to 1 axis: the base model, then one lane per student, one dot per seed
let y = 16;
heading(y, 'Score in the same job');
const S = (v) => x0 + v * (x1 - x0);
const lanes = [
{ key: 'base', name: 'no training', vals: [T.base], color: C.grey, text: C.greyText },
{ key: 'first', name: 'first turn', vals: T.first, color: C.orange, text: C.orangeText },
{ key: 'episodes', name: 'whole episodes', vals: T.episodes, color: C.purple, text: C.purpleText },
];
const laneH = 30;
lanes.forEach((ln, i) => {
const ly = y + 30 + i * laneH;
const g = el(svg, 'g', { opacity: dim(ln.key) });
const hl = Hand.create(g, { seed: 32 + i });
// translucent dots, so seeds with the same score read as one darker dot
ln.vals.forEach((v) => el(g, 'circle', { cx: S(v), cy: ly, r: 7, fill: ln.color, 'fill-opacity': ln.vals.length > 1 ? 0.55 : 1, stroke: ln.color, 'stroke-width': 1.2 }));
const lo = Math.min(...ln.vals), hi = Math.max(...ln.vals);
const val = lo === hi ? lo.toFixed(3) : `${lo.toFixed(3)} to ${hi.toFixed(3)}`;
const tx = S(hi) + 13;
const tn = halo(hl.text(tx, ly + 4.5, ln.name, { size: 13, color: ln.text, weight: 600 }));
halo(hl.text(tx + tn.getComputedTextLength() + 8, ly + 4.5, val, { size: 13, color: C.ink }));
hit(ln.key, x0, ly - laneH / 2, x1 - x0, laneH);
});
const axis1 = y + 30 + 2 * laneH + 20;
h.line(x0, axis1, x1, axis1, { stroke: C.muted, width: 1 });
for (let t = 0; t <= 10; t += narrow ? 2 : 1) {
h.line(S(t / 10), axis1, S(t / 10), axis1 + 4, { stroke: C.muted, width: 1 });
h.text(S(t / 10), axis1 + 18, (t / 10).toFixed(1), { size: 12, anchor: t === 0 ? 'start' : t === 10 ? 'end' : 'middle', color: C.muted });
}
// 2. Whole episodes minus first turn, same seed, task by task, with the 95% interval, on a zoomed axis
y = axis1 + 50;
heading(y, narrow ? 'Whole episodes minus first turn, 95% interval' : 'Gain of whole episodes over first turn, same seed, with its 95% interval');
const G = (v) => x0 + (v - D.gainAxis[0]) / (D.gainAxis[1] - D.gainAxis[0]) * (x1 - x0);
const rowH = 40, top = y + 26;
const axis2 = top + T.gains.length * rowH + 8;
h.line(G(0), y + 10, G(0), axis2, { stroke: C.ink, width: 1, dashed: true });
halo(h.text(G(0) + 5, y + 22, 'no gain', { size: 12, color: C.muted }));
T.gains.forEach((g, i) => {
const key = 's' + g.seed;
const ry = top + i * rowH;
const barY = ry + 26;
const gg = el(svg, 'g', { opacity: dim(key) });
const hg = Hand.create(gg, { seed: 40 + i });
hg.rect(G(g.ci[0]), barY - 6, G(g.ci[1]) - G(g.ci[0]), 12, { fill: C.purpleSoft, stroke: C.purple, width: 1.2, radius: 3 });
hg.line(G(g.diff), barY - 9, G(g.diff), barY + 9, { stroke: C.purple, width: 2.4 });
halo(hg.text(x0, barY + 4.5, `seed ${g.seed}`, { size: 13, color: C.muted }));
const gainText = `${sign(g.diff)} [${sign(g.ci[0])}, ${sign(g.ci[1])}]`;
const gw = gainText.length * 7.2;
const gx = Math.min(x1 - gw / 2, Math.max(G(0) + 8 + gw / 2, G(g.diff)));
halo(hg.text(gx, barY - 11, gainText, { size: 13, anchor: 'middle', color: C.ink, weight: 600 }));
hit(key, x0, ry, x1 - x0, rowH);
});
h.line(x0, axis2, x1, axis2, { stroke: C.muted, width: 1 });
D.gainTicks.forEach((v) => {
h.line(G(v), axis2, G(v), axis2 + 4, { stroke: C.muted, width: 1 });
h.text(G(v), axis2 + 18, v === 0 ? '0' : (v > 0 ? '+' : '−') + Math.abs(v).toFixed(2), { size: 12, anchor: v === D.gainAxis[0] ? 'start' : v === D.gainAxis[1] ? 'end' : 'middle', color: C.muted });
});
const H = axis2 + 24;
svg.setAttribute('viewBox', `0 0 ${width} ${H}`);
svg.setAttribute('height', H);
// invisible targets on top: hover, tap or keyboard focus a part to read it
hits.forEach((t) => {
const r = el(svg, 'rect', { x: t.x, y: t.y, width: Math.max(8, t.w), height: t.hh, fill: 'transparent', class: 'hit', tabindex: 0, role: 'button', 'aria-label': T.notes[t.key] });
r.addEventListener('pointerenter', () => setFocus(t.key));
r.addEventListener('pointerdown', () => setFocus(t.key));
r.addEventListener('focus', () => setFocus(t.key));
r.addEventListener('pointerleave', (e) => { if (e.pointerType === 'mouse') setFocus(null); });
r.addEventListener('blur', () => setFocus(null));
});
readout.textContent = focus ? T.notes[focus] : D.idle;
}
return ({ width: w }) => { width = w; draw(); };
}, { deps: [] });
</script>
</div>
</body>
</html>