scaling-swarms / backend /src /agent /embed-starters.generated.ts
tfrere's picture
tfrere HF Staff
Cursor
feat(embed-studio): tweak panel, inspect, automatic check, launcher, inline edit
4953bfd
Raw History Blame Contribute Delete
82.9 kB
// GENERATED FILE - do not edit by hand.
// Source: backend/embed-kit/gallery/{chinchilla-scaling-law,smollm3-benchmarks,arena-win-rate-matrix,moe-banner}
// Regenerate with `npm run gen:embed-kit` in backend/.
export interface EmbedStarter { slug: string; title: string; summary: string; kind: "chart" | "banner"; html: string }
export const EMBED_STARTERS: EmbedStarter[] = [
{
"slug": "chinchilla-scaling-law",
"title": "Chinchilla scaling law",
"summary": "Final loss against training compute for the 245 Chinchilla runs, one line per model size, with a power law fitted to the best run at each compute level.",
"kind": "chart",
"html": "<div class=\"d3-chinchilla-scaling\"></div>\n<style>\n .d3-chinchilla-scaling { position: relative; color: var(--text-color); font-size: 12px; }\n .d3-chinchilla-scaling .title { font-size: 14px; font-weight: 600; line-height: 1.35; }\n .d3-chinchilla-scaling .subtitle { font-size: 12px; color: var(--muted-color); margin-top: 3px; line-height: 1.45; max-width: 64ch; }\n .d3-chinchilla-scaling .legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 10px 0 2px; font-size: 11.5px; color: var(--muted-color); }\n .d3-chinchilla-scaling .legend .item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }\n .d3-chinchilla-scaling .ramp { width: 72px; height: 8px; border-radius: 4px; }\n .d3-chinchilla-scaling .stroke { width: 16px; border-top: 2px solid var(--text-color); }\n .d3-chinchilla-scaling svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }\n .d3-chinchilla-scaling text { font-family: inherit; }\n .d3-chinchilla-scaling .axis path, .d3-chinchilla-scaling .axis line { stroke: var(--axis-color); }\n .d3-chinchilla-scaling .axis text { fill: var(--tick-color); font-size: 11px; }\n .d3-chinchilla-scaling .axis-minor line { stroke: var(--axis-color); opacity: .5; }\n .d3-chinchilla-scaling .grid line { stroke: var(--grid-color); }\n .d3-chinchilla-scaling .axis-title { fill: var(--muted-color); font-size: 11.5px; }\n .d3-chinchilla-scaling .size-line { fill: none; stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; transition: opacity .15s; }\n .d3-chinchilla-scaling .run { transition: opacity .15s; }\n .d3-chinchilla-scaling .fit-halo { fill: none; stroke: var(--page-bg); stroke-width: 5; stroke-linecap: round; opacity: .8; }\n .d3-chinchilla-scaling .fit { fill: none; stroke: var(--text-color); stroke-width: 2; stroke-linecap: round; }\n .d3-chinchilla-scaling .floor { stroke: var(--muted-color); stroke-dasharray: 4 4; }\n .d3-chinchilla-scaling .note { fill: var(--muted-color); font-size: 11px; }\n .d3-chinchilla-scaling .note-strong { fill: var(--text-color); font-size: 11.5px; }\n .d3-chinchilla-scaling .end-label { font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--page-bg); stroke-width: 3px; stroke-linejoin: round; }\n .d3-chinchilla-scaling .hover { fill: none; stroke: var(--text-color); stroke-width: 1.5; pointer-events: none; }\n .d3-chinchilla-scaling.focus .size-line:not(.on), .d3-chinchilla-scaling.focus .run:not(.on) { opacity: .15; }\n .d3-chinchilla-scaling .size-line.on { stroke-width: 2.6; }\n .d3-chinchilla-scaling .tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--surface-bg); border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 9px; font-size: 11.5px; line-height: 1.5; white-space: nowrap; box-shadow: 0 2px 10px rgba(0,0,0,.15); opacity: 0; transition: opacity .12s; z-index: 2; }\n .d3-chinchilla-scaling .tip .muted { color: var(--muted-color); }\n</style>\n<script>\nEmbed.mount('d3-chinchilla-scaling', (ctx) => {\n // [parameters, training FLOP, final loss]: the 245 runs of Hoffmann et al. 2022\n // (Chinchilla), as extracted by Epoch AI (epoch-research/analyzing-chinchilla).\n const RAW = [\n [6795600349, 9.994e18, 5.0056], [2979521172, 9.228e18, 4.6652], [2638630841, 9.753e18, 3.7656], [2282804341, 9.623e18, 3.7939],\n [2006673381, 9.772e18, 3.4470], [1730543416, 9.086e18, 3.3957], [2979521172, 9.691e19, 2.6283], [2638630841, 9.836e19, 2.5853],\n [2006673381, 9.693e19, 2.5776], [1730543416, 9.813e19, 2.5660], [1793808924, 8.811e18, 3.4059], [1609079314, 9.746e18, 3.2856],\n [1429232579, 9.72e18, 3.1839], [1265593129, 9.39e18, 3.1318], [1793808924, 9.726e19, 2.5776], [1265593129, 9.779e19, 2.5545],\n [1143251954, 9.559e18, 3.0945], [1017958925, 9.618e18, 3.0714], [816341493, 9.292e18, 3.0485], [632223970, 9.387e18, 2.9987],\n [586598190, 9.31e18, 2.9852], [552481733, 9.219e18, 2.9852], [424609581, 9.395e18, 2.9630], [1143252494, 9.24e19, 2.5545],\n [1017959165, 9.639e19, 2.5469], [816341686, 9.415e19, 2.5660], [632224269, 8.926e19, 2.5660], [586598329, 8.956e19, 2.5853],\n [552481994, 8.46e19, 2.5776], [424609581, 8.938e19, 2.5970], [552481994, 5.484e18, 3.1839], [424609581, 5.597e18, 3.1225],\n [1793809772, 2.893e19, 2.8370], [1609079695, 2.849e19, 2.8243], [1429233255, 2.904e19, 2.8032], [1265593428, 2.923e19, 2.7698],\n [1609079695, 5.862e19, 2.6600], [1429233255, 5.813e19, 2.6600], [1265593428, 5.856e19, 2.6480], [305635704, 5.131e18, 3.0714],\n [278352107, 5.507e18, 3.0714], [216725143, 5.394e18, 3.0853], [174942805, 5.616e18, 3.0485], [139739646, 5.402e18, 3.0577],\n [105811837, 4.745e18, 3.0945], [73824672, 5.77e18, 3.0945], [57334197, 5.8e18, 3.1601], [73824672, 1.397e18, 3.4059],\n [105811837, 2.056e18, 3.3004], [89818214, 1.766e18, 3.3253], [162765880, 3.934e18, 3.1085], [139739646, 3.41e18, 3.1318],\n [116713554, 2.867e18, 3.1982], [195834199, 5.397e18, 3.0485], [216725296, 6.372e18, 3.0212], [174942929, 5.151e18, 3.0485],\n [251068939, 8.136e18, 2.9763], [305636065, 1.02e19, 2.9145], [278352370, 9.295e18, 2.9408], [12568979685, 6.082e20, 2.5241],\n [1143252765, 2.871e19, 2.7574], [1017959646, 2.891e19, 2.7450], [816342072, 2.824e19, 2.7698], [632224419, 2.784e19, 2.7368],\n [586598606, 2.824e19, 2.7368], [552482125, 2.762e19, 2.7450], [1143252765, 5.724e19, 2.6165], [1017959646, 5.362e19, 2.6283],\n [424609581, 2.678e19, 2.7574], [816341686, 5.582e19, 2.6283], [632224269, 5.76e19, 2.6401], [552481994, 5.347e19, 2.6401],\n [424609581, 5.67e19, 2.6600], [1592872901, 9.272e19, 2.6087], [1265593428, 7.462e19, 2.6480], [1793809772, 1.19e20, 2.5545],\n [1609079695, 1.069e20, 2.5970], [305635704, 9.064e18, 2.9497], [278352107, 9.16e18, 2.9408], [216725143, 8.996e18, 2.9497],\n [174942805, 9.352e18, 2.9408], [139739646, 9.075e18, 2.9763], [105811837, 8.703e18, 2.9987], [488545739, 1.688e19, 2.8370],\n [552481994, 1.939e19, 2.8032], [509239983, 2.062e19, 2.7906], [586598606, 2.404e19, 2.7781], [663957063, 2.738e19, 2.7450],\n [632224419, 2.784e19, 2.7368], [816342072, 3.682e19, 2.7042], [724283354, 3.275e19, 2.7245], [1143252765, 5.207e19, 2.6401],\n [1017959646, 4.722e19, 2.6720], [892666348, 4.387e19, 2.6720], [73824672, 2.891e18, 3.2223], [89818277, 3.52e18, 3.1839],\n [116713582, 5.446e18, 3.0714], [139739745, 6.837e18, 3.0122], [162765996, 7.998e18, 2.9630], [174943053, 9.987e18, 2.9408],\n [195834245, 1.154e19, 2.8928], [251069058, 1.575e19, 2.8455], [278352501, 1.83e19, 2.8116], [305636138, 2.033e19, 2.7781],\n [12568994539, 1.014e21, 2.4168], [11451830548, 1.015e21, 2.4059], [6795609987, 2.991e20, 2.5241], [4516062221, 2.988e20, 2.4569],\n [6795609987, 6.028e20, 2.4059], [4516062221, 5.626e20, 2.3880], [16183346311, 2.929e21, 2.2864], [12568994539, 2.974e21, 2.2660],\n [11451830548, 3.019e21, 2.2660], [2006676701, 1.958e20, 2.4866], [2282807579, 2.24e20, 2.4754], [1730545870, 1.701e20, 2.5053],\n [2297743486, 2.404e20, 2.4643], [2979525398, 3.263e20, 2.4349], [1592874407, 1.7e20, 2.4940], [1265594923, 1.48e20, 2.5241],\n [1429234944, 1.684e20, 2.5053], [1609081596, 2.129e20, 2.4569], [1424351714, 1.898e20, 2.4940], [1793811468, 2.397e20, 2.4569],\n [9293222063, 1.012e21, 2.3595], [6795609987, 9.283e20, 2.3419], [4516062221, 9.947e20, 2.3036], [4516062221, 9.898e20, 2.3210],\n [6795609987, 1.58e21, 2.2933], [9293224259, 2.442e21, 2.2592], [1592874407, 1.858e20, 2.4940], [1265594923, 1.485e20, 2.5165],\n [1429234944, 1.683e20, 2.4940], [1424351714, 1.732e20, 2.4940], [1793811468, 2.283e20, 2.4643], [1609081596, 2.149e20, 2.4643],\n [73824689, 5.266e18, 3.1085], [89818341, 6.83e18, 3.0485], [105811988, 8.304e18, 2.9987], [116713665, 1.08e19, 2.9497],\n [139739844, 1.373e19, 2.9058], [174943053, 1.911e19, 2.8583], [216725450, 2.397e19, 2.7906], [195834245, 2.243e19, 2.8116],\n [305636138, 3.744e19, 2.7042], [278352501, 3.576e19, 2.7123], [424609882, 3.098e19, 2.7368], [552482255, 4.119e19, 2.6800],\n [488546085, 3.65e19, 2.7042], [509240224, 4.084e19, 2.6800], [586598744, 4.728e19, 2.6480], [663957220, 5.479e19, 2.6283],\n [724283354, 6.291e19, 2.6165], [816342072, 7.379e19, 2.5970], [632224419, 5.715e19, 2.6283], [892666348, 8.346e19, 2.5776],\n [1143252765, 1.123e20, 2.5165], [1017959646, 9.996e19, 2.5545], [9293215473, 2.876e21, 2.2390], [6795606774, 2.877e21, 2.2057],\n [4516059019, 2.989e21, 2.2057], [305636065, 2.72e19, 2.7450], [278352370, 2.532e19, 2.7698], [216725296, 2.538e19, 2.7781],\n [174942929, 2.806e19, 2.8032], [278352370, 5.247e19, 2.6920], [139739745, 2.676e19, 2.8370], [1730544643, 3.24e20, 2.4277],\n [2282805960, 4.487e20, 2.3773], [2979523285, 5.917e20, 2.3595], [2979523285, 5.588e20, 2.3595], [2006674804, 5.87e20, 2.3314],\n [2006674804, 3.935e20, 2.3987], [2297741856, 4.722e20, 2.3702], [2638632712, 5.8e20, 2.3489], [2979523285, 2.934e20, 2.4349],\n [2282805960, 2.751e20, 2.4168], [2006674804, 2.93e20, 2.3987], [4516059019, 1.987e21, 2.2491], [6795606774, 3.221e21, 2.2057],\n [1265594026, 2.875e20, 2.4349], [1429233593, 3.367e20, 2.4168], [1793810196, 4.717e20, 2.3773], [1609080455, 4.3e20, 2.3880],\n [1424350704, 3.808e20, 2.4059], [9293216132, 5.031e21, 2.1794], [424609882, 5.914e19, 2.6401], [488546085, 7.022e19, 2.6165],\n [552482255, 8.254e19, 2.5853], [586598744, 8.775e19, 2.5776], [816342265, 1.361e20, 2.5053], [632224717, 1.093e20, 2.5469],\n [724283696, 1.268e20, 2.5241], [892666559, 1.752e20, 2.4866], [1017959887, 1.999e20, 2.4569], [1143253305, 2.248e20, 2.4459],\n [73824689, 1.115e19, 3.0485], [139739844, 2.477e19, 2.8370], [162766111, 3.2e19, 2.7906], [195834384, 4.443e19, 2.7450],\n [174943219, 4.059e19, 2.7698], [216725655, 5.113e19, 2.7042], [278352699, 6.83e19, 2.6600], [251069236, 6.475e19, 2.6800],\n [305636354, 8.032e19, 2.6401], [1793812740, 2.781e20, 2.4277], [1429235620, 2.855e20, 2.4059], [2979527510, 9.648e20, 2.3036],\n [2638636454, 9.769e20, 2.2864], [2282809197, 9.729e20, 2.2933], [2006678124, 9.786e20, 2.3036], [1730547097, 9.846e20, 2.3036],\n [1793812740, 5.838e20, 2.3489], [1429235620, 5.765e20, 2.3595], [1730547097, 6.572e20, 2.3489], [2282809197, 8.809e20, 2.3140],\n [2979527510, 1.293e21, 2.2762], [1265595821, 5.532e20, 2.3702], [1592875537, 7.409e20, 2.3314], [1609082737, 8.553e20, 2.3210],\n [1793812740, 9.589e20, 2.3036], [1143254386, 5.473e20, 2.3702], [816343229, 5.497e20, 2.3987], [632225315, 5.446e20, 2.4459],\n [1143254386, 2.787e20, 2.4349], [816343229, 2.809e20, 2.4349], [586599438, 2.704e20, 2.4643], [424610585, 2.838e20, 2.5165],\n [2979527510, 2.945e21, 2.2123], [2638636454, 2.956e21, 2.2057], [1793812740, 9.528e20, 2.3036], [1609082737, 9.775e20, 2.3140],\n [1429235620, 9.637e20, 2.3314], [1265595821, 9.74e20, 2.3314], [488546662, 1.382e20, 2.5545], [586599438, 1.83e20, 2.5053],\n [663958005, 2.192e20, 2.4754], [1143254386, 4.083e20, 2.3880], [816343229, 2.953e20, 2.4459], [2006678124, 1.499e21, 2.2660],\n [1730547097, 1.297e21, 2.2864], [2282809197, 1.795e21, 2.2491], [2638636454, 2.308e21, 2.2223], [2979527510, 2.621e21, 2.2123],\n [6795614805, 1.296e22, 2.0774]\n ];\n\n const runs = RAW.map((d) => ({ n: d[0], c: d[1], l: d[2] }));\n if (!runs.length) throw new Error('No runs to plot.');\n runs.sort((a, b) => a.c - b.c || a.l - b.l);\n\n // Runs of one model size differ only by training tokens; the extracted\n // parameter counts carry digitization noise, hence 3 significant digits.\n const models = d3.groups(runs, (d) => +d.n.toPrecision(3))\n .map(([n, rs]) => ({ n, runs: rs, best: d3.least(rs, (d) => d.l) }))\n .sort((a, b) => a.n - b.n);\n runs.forEach((r) => { r.model = models.find((m) => m.n === +r.n.toPrecision(3)); });\n\n // Best run so far as compute grows: the empirical compute-optimal frontier.\n const best = [];\n let low = Infinity;\n for (const r of runs) if (r.l < low - 1e-9) { best.push(r); low = r.l; }\n\n // L(C) = E + K * (C / 1e18)^-alpha fitted to the frontier: grid search over\n // E, least squares on log(L - E).\n const C0 = 1e18;\n const lx = best.map((d) => Math.log10(d.c / C0));\n let fit = null;\n for (let E = 0.5; E <= low - 0.1; E += 0.005) {\n const ly = best.map((d) => Math.log10(d.l - E));\n const mx = d3.mean(lx), my = d3.mean(ly);\n const slope = d3.sum(lx, (x, i) => (x - mx) * (ly[i] - my)) / d3.sum(lx, (x) => (x - mx) ** 2);\n const K = 10 ** (my - slope * mx), alpha = -slope;\n const sse = d3.sum(best, (d) => (E + K * (d.c / C0) ** -alpha - d.l) ** 2);\n if (!fit || sse < fit.sse) fit = { E, K, alpha, sse };\n }\n const predict = (c) => fit.E + fit.K * (c / C0) ** -fit.alpha;\n const decadeGain = predict(1e20) - predict(1e21);\n\n const fmtSize = (n) => n >= 1e9 ? d3.format('.2~r')(n / 1e9) + 'B' : d3.format('.2~r')(n / 1e6) + 'M';\n const SUP = { '-': '⁻', 0: '⁰', 1: '¹', 2: '²', 3: '³', 4: '⁴', 5: '⁵', 6: '⁶', 7: '⁷', 8: '⁸', 9: '⁹' };\n const pow10 = (k) => '10' + String(k).split('').map((ch) => SUP[ch]).join('');\n const fmtFlop = (c) => {\n const k = Math.floor(Math.log10(c));\n return (c / 10 ** k).toFixed(1) + ' × ' + pow10(k);\n };\n const first = best[0], last = best[best.length - 1];\n const sizeExtent = d3.extent(models, (m) => m.n);\n const Y_MAX = 3.55;\n const offChart = runs.filter((d) => d.l > Y_MAX);\n\n ctx.describe(\n 'Line chart of ' + runs.length + ' Chinchilla training runs: final loss against training compute on a log scale, one line per model size (' +\n models.length + ' sizes, ' + fmtSize(sizeExtent[0]) + ' to ' + fmtSize(sizeExtent[1]) + ' parameters), colored by size. ' +\n 'Each line flattens as its model trains longer, and the lowest loss at each budget moves to ever larger models, from ' +\n fmtSize(first.n) + ' at ' + fmtFlop(first.c) + ' FLOP to ' + fmtSize(last.n) + ' at ' + fmtFlop(last.c) + ' FLOP. ' +\n 'A power law fitted to those best runs, L = ' + fit.E.toFixed(2) + ' + ' + fit.K.toFixed(2) + ' × (C / 10^18)^-' + fit.alpha.toFixed(2) +\n ', gives about ' + decadeGain.toFixed(2) + ' lower loss for 10x more compute and flattens toward ' + fit.E.toFixed(2) + '.'\n );\n\n const root = d3.select(ctx.root);\n root.append('div').attr('class', 'title').text('Loss falls as a power law of compute, and the best model grows with it');\n root.append('div').attr('class', 'subtitle').text(\n 'Each line is one model size trained on more and more tokens (' + runs.length + ' Chinchilla runs). ' +\n 'Small models flatten out early, so the lowest loss at each budget keeps moving to larger ones.'\n );\n const legend = root.append('div').attr('class', 'legend');\n const rampItem = legend.append('span').attr('class', 'item');\n rampItem.append('span').text(fmtSize(sizeExtent[0]));\n const ramp = rampItem.append('span').attr('class', 'ramp');\n rampItem.append('span').text(fmtSize(sizeExtent[1]) + ' parameters');\n legend.append('span').attr('class', 'item').html('<span class=\"stroke\"></span>Power law fitted to the best runs');\n const tip = root.append('div').attr('class', 'tip');\n\n const svg = root.append('svg');\n const clipId = 'chinchilla-clip-' + Math.random().toString(36).slice(2, 8);\n const clipRect = svg.append('clipPath').attr('id', clipId).append('rect');\n const gGrid = svg.append('g').attr('class', 'grid');\n const gFloor = svg.append('g');\n const gPlot = svg.append('g').attr('clip-path', 'url(#' + clipId + ')');\n const gLines = gPlot.append('g');\n const gRuns = gPlot.append('g');\n const gFit = gPlot.append('g');\n const gNotes = svg.append('g');\n const gAxes = svg.append('g');\n const gxMinor = gAxes.append('g').attr('class', 'axis axis-minor');\n const gx = gAxes.append('g').attr('class', 'axis');\n const gy = gAxes.append('g').attr('class', 'axis');\n const xTitle = gAxes.append('text').attr('class', 'axis-title').attr('text-anchor', 'middle').text('Training compute (FLOP, log scale)');\n const yTitle = gAxes.append('text').attr('class', 'axis-title').attr('text-anchor', 'middle').text('Final loss (nats per token)');\n const hover = svg.append('circle').attr('class', 'hover').attr('r', 5.5).style('opacity', 0);\n\n let x = null, y = null;\n const focus = (model) => {\n ctx.root.classList.toggle('focus', !!model);\n gLines.selectAll('path').classed('on', (m) => m === model);\n gRuns.selectAll('.run').classed('on', (d) => d.model === model);\n };\n const hide = () => { hover.style('opacity', 0); tip.style('opacity', 0); focus(null); };\n svg.on('pointermove', (event) => {\n if (!x) return;\n const [px, py] = d3.pointer(event);\n const yOf = (r) => y(Math.min(r.l, Y_MAX));\n const hit = d3.least(runs, (r) => (x(r.c) - px) ** 2 + (yOf(r) - py) ** 2);\n if (!hit || (x(hit.c) - px) ** 2 + (yOf(hit) - py) ** 2 > 400) { hide(); return; }\n const hx = x(hit.c), hy = yOf(hit);\n hover.attr('cx', hx).attr('cy', hy).style('opacity', 1);\n focus(hit.model);\n const mb = hit.model.best;\n tip.html(\n '<b>' + fmtSize(hit.n) + ' parameters</b><br>' +\n 'This run: loss ' + hit.l.toFixed(2) + ' at ' + fmtFlop(hit.c) + ' FLOP<br>' +\n '<span class=\"muted\">Best of ' + hit.model.runs.length + ' runs: ' + mb.l.toFixed(2) + ' at ' + fmtFlop(mb.c) + '</span>'\n ).style('opacity', 1);\n const tw = tip.node().offsetWidth, th = tip.node().offsetHeight, top = svg.node().offsetTop;\n let tx = hx + 12, ty = top + hy - th - 10;\n if (tx + tw > ctx.root.clientWidth) tx = hx - tw - 12;\n if (ty < top) ty = top + hy + 12;\n tip.style('left', Math.max(0, tx) + 'px').style('top', ty + 'px');\n });\n svg.on('pointerleave', hide);\n\n return ({ width, theme }) => {\n hide();\n const small = width < 520;\n const m = { top: 18, right: small ? 12 : 20, bottom: 46, left: small ? 40 : 50 };\n const H = Math.round(Math.max(360, Math.min(480, width * 0.62)));\n const iw = width - m.left - m.right, ih = H - m.top - m.bottom;\n svg.attr('viewBox', '0 0 ' + width + ' ' + H).attr('height', H);\n clipRect.attr('x', m.left).attr('y', m.top - 4).attr('width', iw + 4).attr('height', ih + 4);\n\n // Larger models sit at the end of the ramp farthest from the page\n // background, so they stay the most salient in both themes.\n const stops = ctx.colors('sequential', 9);\n const smallToLarge = theme === 'dark' ? stops : stops.slice().reverse();\n const sizeT = d3.scaleLog().domain(sizeExtent).range([0, 1]);\n const color = (n) => d3.interpolateRgbBasis(smallToLarge)(sizeT(n));\n ramp.style('background', 'linear-gradient(90deg, ' + smallToLarge.join(', ') + ')');\n\n x = d3.scaleLog().domain([1e18, 2e22]).range([m.left, m.left + iw]);\n y = d3.scaleLinear().domain([fit.E - 0.25, Y_MAX]).range([m.top + ih, m.top]);\n const decades = [1e18, 1e19, 1e20, 1e21, 1e22];\n const yTicks = y.ticks(small ? 5 : 8).filter((v) => v <= Y_MAX);\n\n gGrid.selectAll('line').data(yTicks).join('line')\n .attr('x1', m.left).attr('x2', m.left + iw).attr('y1', y).attr('y2', y);\n\n const minor = d3.range(18, 23).flatMap((k) => d3.range(2, 10).map((d) => d * 10 ** k)).filter((v) => v < x.domain()[1]);\n gxMinor.attr('transform', 'translate(0,' + (m.top + ih) + ')')\n .call(d3.axisBottom(x).tickValues(minor).tickSize(3).tickFormat(() => ''))\n .call((g) => g.select('.domain').remove());\n gx.attr('transform', 'translate(0,' + (m.top + ih) + ')')\n .call(d3.axisBottom(x).tickValues(decades).tickSize(5).tickFormat((d) => pow10(Math.round(Math.log10(d)))));\n gy.attr('transform', 'translate(' + m.left + ',0)')\n .call(d3.axisLeft(y).tickValues(yTicks).tickSize(4).tickFormat(d3.format('.1f')))\n .call((g) => g.select('.domain').remove());\n xTitle.attr('x', m.left + iw / 2).attr('y', H - 8);\n yTitle.attr('transform', 'translate(11,' + (m.top + ih / 2) + ') rotate(-90)');\n\n gFloor.selectAll('line').data([fit.E]).join('line').attr('class', 'floor')\n .attr('x1', m.left).attr('x2', m.left + iw).attr('y1', y).attr('y2', y);\n\n // Off-chart runs leave the lines and become ticks on the top edge: a straight\n // segment from loss 5 down to the next run would read as a training curve.\n const line = d3.line().x((d) => x(d.c)).y((d) => y(d.l));\n gLines.selectAll('path').data(models.filter((md) => md.runs.length > 1)).join('path')\n .attr('class', 'size-line').attr('stroke', (md) => color(md.n))\n .attr('d', (md) => line(md.runs.filter((d) => d.l <= Y_MAX)));\n gRuns.selectAll('circle').data(runs.filter((d) => d.l <= Y_MAX)).join('circle').attr('class', 'run')\n .attr('cx', (d) => x(d.c)).attr('cy', (d) => y(d.l)).attr('r', small ? 1.8 : 2.2)\n .attr('fill', (d) => color(d.n));\n gRuns.selectAll('path.run').data(offChart).join('path').attr('class', 'run')\n .attr('d', (d) => 'M' + (x(d.c) - 3.5) + ',' + (m.top + 5) + 'L' + x(d.c) + ',' + (m.top - 1) + 'L' + (x(d.c) + 3.5) + ',' + (m.top + 5) + 'Z')\n .attr('fill', (d) => color(d.n));\n\n const curve = d3.range(121).map((i) => {\n const c = 10 ** (18 + (Math.log10(x.domain()[1]) - 18) * i / 120);\n return [x(c), y(predict(c))];\n });\n gFit.selectAll('path').data(['fit-halo', 'fit']).join('path')\n .attr('class', (d) => d).attr('d', d3.line()(curve));\n\n gNotes.selectAll('*').remove();\n\n // Name the two ends of the frontier: the smallest and the largest winner.\n gNotes.append('text').attr('class', 'end-label').attr('fill', ctx.labelColor(color(first.n)))\n .attr('x', x(first.c) + 6).attr('y', y(first.l) - 8).text(fmtSize(first.n));\n gNotes.append('text').attr('class', 'end-label').attr('fill', ctx.labelColor(color(last.n)))\n .attr('text-anchor', 'end').attr('x', x(last.c) - 6).attr('y', y(last.l) + 17).text(fmtSize(last.n));\n\n // Runs above the cut: billion-parameter models given almost no compute.\n if (offChart.length) {\n const nx = x(d3.max(offChart, (d) => d.c)) + 9;\n const sizes = d3.extent(offChart, (d) => d.n).map(fmtSize);\n const budget = pow10(Math.round(Math.log10(d3.median(offChart, (d) => d.c))));\n const note = gNotes.append('text').attr('class', 'note').attr('x', nx).attr('y', m.top + 6);\n note.append('tspan').attr('class', 'note-strong')\n .text(offChart.length + ' runs off the top, up to ' + d3.max(offChart, (d) => d.l).toFixed(1));\n note.append('tspan').attr('x', nx).attr('dy', 15)\n .text(sizes[0] + '–' + sizes[1] + ' models on ' + budget + ' FLOP');\n }\n\n // Fit equation and its reading, in the empty band above the floor.\n const ex = m.left + 8, ey = y(fit.E) - (small ? 34 : 38);\n const eq = gNotes.append('text').attr('class', 'note-strong').attr('x', ex).attr('y', ey);\n eq.append('tspan').text('L = ' + fit.E.toFixed(2) + ' + ' + fit.K.toFixed(2) + ' · (C / 10¹⁸)');\n eq.append('tspan').attr('dy', -5).attr('font-size', 9).text('−' + fit.alpha.toFixed(2));\n gNotes.append('text').attr('class', 'note').attr('x', ex).attr('y', ey + 16)\n .text('10× compute ≈ ' + decadeGain.toFixed(2) + ' lower loss (10²⁰ → 10²¹ FLOP)');\n gNotes.append('text').attr('class', 'note').attr('text-anchor', 'end')\n .attr('x', m.left + iw).attr('y', y(fit.E) + 15)\n .text('Irreducible loss E ≈ ' + fit.E.toFixed(2));\n };\n});\n</script>"
},
{
"slug": "smollm3-benchmarks",
"title": "SmolLM3-3B benchmarks",
"summary": "How many points SmolLM3-3B scores above or below four other instruct models on 8 benchmarks, with the lead over the closest same-size or smaller rival drawn as a bar.",
"kind": "chart",
"html": "<div class=\"d3-smollm3-benchmarks\"></div>\n<style>\n .d3-smollm3-benchmarks { position: relative; color: var(--text-color); font-size: 12px; }\n .d3-smollm3-benchmarks .title { font-size: 14px; font-weight: 600; line-height: 1.35; }\n .d3-smollm3-benchmarks .subtitle { font-size: 12px; color: var(--muted-color); margin-top: 3px; line-height: 1.45; max-width: 66ch; }\n .d3-smollm3-benchmarks .legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 10px 0 4px; font-size: 11.5px; color: var(--muted-color); }\n .d3-smollm3-benchmarks .legend .item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }\n .d3-smollm3-benchmarks .legend .bar { width: 16px; height: 10px; border-radius: 2px; }\n .d3-smollm3-benchmarks .legend svg { width: 12px; height: 12px; overflow: visible; }\n .d3-smollm3-benchmarks .chart { display: block; width: 100%; overflow: visible; touch-action: pan-y; }\n .d3-smollm3-benchmarks text { font-family: inherit; }\n .d3-smollm3-benchmarks .axis path, .d3-smollm3-benchmarks .axis line { stroke: var(--axis-color); }\n .d3-smollm3-benchmarks .axis text { fill: var(--tick-color); font-size: 11px; }\n .d3-smollm3-benchmarks .grid line { stroke: var(--grid-color); }\n .d3-smollm3-benchmarks .axis-title { fill: var(--muted-color); font-size: 11.5px; }\n .d3-smollm3-benchmarks .head { fill: var(--muted-color); font-size: 11px; }\n .d3-smollm3-benchmarks .head-strong { font-size: 11.5px; font-weight: 600; }\n .d3-smollm3-benchmarks .zero { stroke-width: 1.5; }\n .d3-smollm3-benchmarks .row .hit { fill: var(--grid-color); fill-opacity: 0; }\n .d3-smollm3-benchmarks .row.on .hit { fill-opacity: .6; }\n .d3-smollm3-benchmarks .metric { fill: var(--text-color); font-weight: 600; }\n .d3-smollm3-benchmarks .category { fill: var(--muted-color); font-size: 11px; }\n .d3-smollm3-benchmarks .score { font-weight: 600; font-variant-numeric: tabular-nums; }\n .d3-smollm3-benchmarks .lead-label { fill: var(--text-color); }\n .d3-smollm3-benchmarks .lead { font-weight: 700; font-variant-numeric: tabular-nums; }\n .d3-smollm3-benchmarks .rival { fill: var(--muted-color); font-size: 11px; }\n .d3-smollm3-benchmarks .peer { fill: var(--muted-color); stroke: var(--page-bg); stroke-width: 1; }\n .d3-smollm3-benchmarks .larger { fill: none; stroke: var(--muted-color); stroke-width: 1.5; }\n .d3-smollm3-benchmarks .note { fill: var(--muted-color); font-size: 11px; paint-order: stroke; stroke: var(--page-bg); stroke-width: 3px; stroke-linejoin: round; }\n .d3-smollm3-benchmarks .note.missing { font-style: italic; }\n .d3-smollm3-benchmarks .divider { stroke: var(--border-color); }\n .d3-smollm3-benchmarks .footnote { margin-top: 8px; font-size: 11px; color: var(--muted-color); line-height: 1.5; }\n .d3-smollm3-benchmarks .tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--surface-bg); border: 1px solid var(--border-color); border-radius: 6px; padding: 7px 10px; font-size: 11.5px; line-height: 1.45; box-shadow: 0 2px 10px rgba(0,0,0,.15); opacity: 0; transition: opacity .12s; z-index: 2; }\n .d3-smollm3-benchmarks .tip .t-head { font-weight: 600; }\n .d3-smollm3-benchmarks .tip .muted { color: var(--muted-color); }\n .d3-smollm3-benchmarks .tip table { border-collapse: collapse; margin-top: 4px; }\n .d3-smollm3-benchmarks .tip td { padding: 0; white-space: nowrap; }\n .d3-smollm3-benchmarks .tip td.num { text-align: right; padding-left: 12px; font-variant-numeric: tabular-nums; }\n .d3-smollm3-benchmarks .tip tr.subject td { font-weight: 600; }\n @media (prefers-reduced-motion: reduce) { .d3-smollm3-benchmarks .tip { transition: none; } }\n</style>\n<script>\nEmbed.mount('d3-smollm3-benchmarks', (ctx) => {\n // SmolLM3-3B model card, \"No Extended Thinking\" table (instruct models).\n // The card spells the subject 'SmoLLM3-3B'; it is displayed as SmolLM3-3B.\n const MODELS = [\n { name: 'SmolLM3-3B', subject: true },\n { name: 'Qwen2.5-3B', symbol: d3.symbolSquare, size: 56 },\n { name: 'Llama3.1-3B', symbol: d3.symbolTriangle, size: 60 },\n { name: 'Qwen3-1.7B', symbol: d3.symbolDiamond, size: 64 },\n { name: 'Qwen3-4B', larger: true }\n ];\n // [category, benchmark, scores in MODELS order (null = not reported), note]\n const RAW = [\n ['High school math competition', 'AIME 2025', [9.3, 2.9, 0.3, 8.0, 17.1], ''],\n ['Math problem-solving', 'GSM-Plus', [72.8, 74.1, 59.2, 68.3, 82.1], ''],\n ['Competitive programming', 'LiveCodeBench v4', [15.2, 10.5, 3.4, 15.0, 24.9], ''],\n ['Graduate-level reasoning', 'GPQA Diamond', [35.7, 32.2, 29.4, 31.8, 44.4], ''],\n ['Instruction following', 'IFEval', [76.7, 65.6, 71.6, 74.0, 68.9], ''],\n ['Alignment', 'MixEval Hard', [26.9, 27.6, 24.9, 24.3, 31.6], ''],\n ['Tool calling', 'BFCL', [92.3, null, 92.3, 89.5, 95.0], 'Llama3.1-3B score is from a tool-calling finetune'],\n ['Multilingual Q&A', 'Global MMLU', [53.5, 50.54, 46.8, 49.5, 65.1], '']\n ];\n if (!RAW.length) throw new Error('No benchmark rows to plot.');\n\n const SUBJECT = MODELS[0];\n const LARGER = MODELS.find((m) => m.larger);\n const PEERS = MODELS.filter((m) => !m.subject && !m.larger);\n\n const rows = RAW.map((r) => {\n const s = r[2][0];\n if (!Number.isFinite(s)) throw new Error('Missing SmolLM3-3B score for ' + r[1] + '.');\n const marks = MODELS.slice(1).map((m, i) => ({ model: m, score: r[2][i + 1] }))\n .filter((d) => d.score != null)\n .map((d) => ({ model: d.model, score: d.score, lead: Math.round((s - d.score) * 100) / 100 }));\n const peers = marks.filter((d) => !d.model.larger);\n const closest = d3.least(peers, (d) => d.lead);\n const margin = closest.lead;\n const flagged = r[3] ? MODELS.find((m) => r[3].indexOf(m.name) === 0) : null;\n return {\n category: r[0], metric: r[1], score: s, scores: r[2], note: r[3], flagged,\n marks, closest, margin,\n status: Math.abs(margin) < 0.05 ? 'tie' : margin > 0 ? 'win' : 'loss',\n larger: marks.find((d) => d.model.larger),\n missing: MODELS.filter((m, i) => r[2][i] == null)\n };\n }).sort((a, b) => b.margin - a.margin);\n\n const fmtScore = (v) => (Math.abs(v * 10 - Math.round(v * 10)) < 1e-9 ? v.toFixed(1) : v.toFixed(2));\n const fmtLead = (v) => (v > 0.04 ? '+' : v < -0.04 ? '−' : '') + Math.abs(v).toFixed(1);\n const listing = (xs) => xs.length < 2 ? xs.join('') : xs.slice(0, -1).join(', ') + ' and ' + xs[xs.length - 1];\n const dagger = (r, m) => (r.flagged === m ? '†' : '');\n const esc = (s) => String(s).replace(/[&<>\"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' }[c]));\n\n const wins = rows.filter((r) => r.status === 'win');\n const ties = rows.filter((r) => r.status === 'tie');\n const losses = rows.filter((r) => r.status === 'loss');\n const largerAhead = rows.filter((r) => r.larger && r.larger.lead < 0);\n const largerBehind = rows.filter((r) => r.larger && r.larger.lead > 0);\n ctx.describe(\n 'Dot plot of how many points SmolLM3-3B scores above or below four other instruct models on ' + rows.length + ' benchmarks. ' +\n 'It beats every model its size or smaller (' + listing(PEERS.map((m) => m.name)) + ') on ' + wins.length + ' of ' + rows.length + ': ' +\n wins.map((r) => r.metric + ' (' + fmtLead(r.margin) + ')').join(', ') + '. ' +\n (ties.length ? 'It ties ' + ties.map((r) => r.closest.model.name + ' on ' + r.metric).join(', ') + '. ' : '') +\n (losses.length ? 'It trails on ' + listing(losses.map((r) => r.metric + ' (' + fmtLead(r.margin) + ' behind ' + r.closest.model.name + ')')) + '. ' : '') +\n 'The larger ' + LARGER.name + ' scores higher on ' + largerAhead.length + ' of ' + rows.length +\n (largerBehind.length ? ', all but ' + listing(largerBehind.map((r) => r.metric)) : '') + '.'\n );\n\n const root = d3.select(ctx.root);\n root.append('div').attr('class', 'title')\n .text(SUBJECT.name + ' beats every model its size or smaller on ' + wins.length + ' of ' + rows.length + ' benchmarks');\n root.append('div').attr('class', 'subtitle').text(\n 'Each mark is a rival, placed by how many points ' + SUBJECT.name + ' scores above it. ' +\n 'The bar is the lead over the closest of ' + listing(PEERS.map((m) => m.name)) +\n '; the hollow circle is the larger ' + LARGER.name + ', shown for reference.'\n );\n\n const legend = root.append('div').attr('class', 'legend');\n const winSw = legend.append('span').attr('class', 'item');\n const winBar = winSw.append('span').attr('class', 'bar');\n winSw.append('span').text('ahead of closest rival');\n const lossSw = legend.append('span').attr('class', 'item');\n const lossBar = lossSw.append('span').attr('class', 'bar');\n lossSw.append('span').text('behind it');\n MODELS.slice(1).forEach((m) => {\n const item = legend.append('span').attr('class', 'item');\n const g = item.append('svg').attr('viewBox', '-6 -6 12 12').attr('aria-hidden', 'true').append('g');\n if (m.larger) g.append('circle').attr('class', 'larger').attr('r', 4.5);\n else g.append('path').attr('class', 'peer').attr('d', d3.symbol(m.symbol, m.size)());\n item.append('span').text(m.larger ? m.name + ', larger model' : m.name);\n });\n\n const svg = root.append('svg').attr('class', 'chart');\n const gGrid = svg.append('g').attr('class', 'grid');\n const gHead = svg.append('g');\n const gRows = svg.append('g');\n const gZero = svg.append('g');\n const gNotes = svg.append('g');\n const gAxis = svg.append('g').attr('class', 'axis');\n const axisTitle = svg.append('text').attr('class', 'axis-title').attr('text-anchor', 'middle')\n .text('Points ' + SUBJECT.name + ' scores above each model');\n\n const notes = rows.filter((r) => r.note || r.missing.length).map((r) => {\n const parts = [];\n if (r.note) parts.push('† ' + r.metric + ': ' + r.note + '.');\n if (r.missing.length) parts.push(listing(r.missing.map((m) => m.name)) + ' reports no ' + r.metric + ' score, so it has no mark on that row (not a zero).');\n return parts.join(' ');\n });\n root.append('div').attr('class', 'footnote').text(\n notes.join(' ') + ' Source: SmolLM3-3B model card, instruct models without extended thinking.'\n );\n\n const tip = root.append('div').attr('class', 'tip').attr('aria-hidden', 'true');\n const tipHtml = (r) => {\n const items = MODELS.map((m, i) => ({ m, v: r.scores[i] }))\n .sort((a, b) => (b.v == null ? -1 : b.v) - (a.v == null ? -1 : a.v));\n return '<div class=\"t-head\">' + esc(r.metric) + '</div><div class=\"muted\">' + esc(r.category) + '</div><table>' +\n items.map((d) => '<tr class=\"' + (d.m.subject ? 'subject' : '') + '\"><td>' + esc(d.m.name + dagger(r, d.m)) + '</td>' +\n '<td class=\"num\">' + (d.v == null ? '<span class=\"muted\">not reported</span>' : esc(fmtScore(d.v))) + '</td>' +\n '<td class=\"num muted\">' + (d.m.subject || d.v == null ? '' : esc(fmtLead(r.score - d.v))) + '</td></tr>').join('') +\n '</table>' + (r.note ? '<div class=\"muted\">† ' + esc(r.note) + '</div>' : '');\n };\n\n return ({ width }) => {\n tip.style('opacity', 0);\n const div = ctx.colors('diverging', 2);\n const cWin = div[0], cLoss = div[1];\n const color = { win: cWin, loss: cLoss, tie: cWin };\n const subjectText = ctx.labelColor(cWin);\n winBar.style('background', cWin);\n lossBar.style('background', cLoss);\n\n const small = width < 600;\n const labelW = 168, scoreW = 44, rightW = 128, gap = 14;\n const headH = 36;\n const rowH = small ? 54 : 42;\n const cy = small ? 36 : rowH / 2;\n const x0 = small ? 6 : labelW + scoreW + gap;\n const x1 = small ? width - 6 : width - rightW - gap;\n const plotH = rows.length * rowH;\n const H = headH + plotH + 44;\n svg.attr('viewBox', '0 0 ' + width + ' ' + H).attr('height', H);\n\n const ext = d3.max(rows, (r) => d3.max(r.marks, (d) => Math.abs(d.lead)));\n const lim = Math.ceil(ext / 5) * 5;\n const x = d3.scaleLinear().domain([-lim, lim]).range([x0, x1]);\n const ticks = d3.range(-lim + 5, lim, 5).filter((t) => (x1 - x0) / (2 * lim / 5) > 34 || t % 10 === 0);\n const zx = x(0);\n\n gGrid.selectAll('line').data(ticks.filter((t) => t !== 0)).join('line')\n .attr('x1', x).attr('x2', x).attr('y1', headH).attr('y2', headH + plotH);\n gAxis.attr('transform', 'translate(0,' + (headH + plotH) + ')')\n .call(d3.axisBottom(x).tickValues(ticks).tickSize(4).tickSizeOuter(0).tickFormat((t) => (t > 0 ? '+' : t < 0 ? '−' : '') + Math.abs(t)));\n axisTitle.attr('x', zx).attr('y', headH + plotH + 36);\n\n gZero.selectAll('line').data([0]).join('line').attr('class', 'zero')\n .attr('x1', zx).attr('x2', zx).attr('y1', headH - 4).attr('y2', headH + plotH)\n .style('stroke', cWin);\n\n const heads = [\n { t: SUBJECT.name, x: zx, y: 12, a: 'middle', strong: true },\n { t: '← it trails', x: zx - 6, y: 28, a: 'end' },\n { t: 'it leads →', x: zx + 6, y: 28, a: 'start' }\n ];\n if (!small) {\n heads.push({ t: 'Score', x: labelW + scoreW, y: 28, a: 'end', accent: true });\n heads.push({ t: 'Margin, closest rival', x: width - rightW, y: 28, a: 'start' });\n }\n gHead.selectAll('text').data(heads).join('text')\n .attr('class', (d) => 'head' + (d.strong ? ' head-strong' : ''))\n .attr('x', (d) => d.x).attr('y', (d) => d.y).attr('text-anchor', (d) => d.a)\n .style('fill', (d) => (d.strong || d.accent ? subjectText : null))\n .text((d) => d.t);\n\n const row = gRows.selectAll('g.row').data(rows, (r) => r.metric).join((enter) => {\n const g = enter.append('g').attr('class', 'row');\n g.append('rect').attr('class', 'hit');\n g.append('line').attr('class', 'divider');\n g.append('text').attr('class', 'metric');\n g.append('text').attr('class', 'category');\n g.append('text').attr('class', 'score');\n g.append('rect').attr('class', 'margin-bar');\n g.append('g').attr('class', 'marks');\n g.append('text').attr('class', 'lead-label');\n g.append('text').attr('class', 'rival-label');\n return g;\n }).attr('transform', (r, i) => 'translate(0,' + (headH + i * rowH) + ')');\n\n row.select('rect.hit').attr('x', 0).attr('y', 1).attr('width', width).attr('height', rowH - 2).attr('rx', 4);\n\n // Thin rule where the rows stop being outright wins.\n row.select('line.divider')\n .attr('x1', 0).attr('x2', width).attr('y1', 0).attr('y2', 0)\n .style('display', (r, i) => (i > 0 && r.status !== 'win' && rows[i - 1].status === 'win' ? null : 'none'));\n\n row.select('text.metric')\n .attr('x', 0).attr('y', small ? 15 : cy - 3)\n .selectAll('tspan').data((r) => small\n ? [{ t: r.metric, c: null }, { t: fmtScore(r.score), c: 'score' }]\n : [{ t: r.metric, c: null }])\n .join('tspan')\n .attr('class', (d) => d.c)\n .attr('dx', (d, i) => (i ? 6 : 0))\n .style('fill', (d) => (d.c ? subjectText : null))\n .text((d) => d.t);\n row.select('text.category')\n .attr('x', 0).attr('y', cy + 11)\n .text((r) => (small ? '' : r.category));\n row.select('text.score')\n .attr('x', labelW + scoreW).attr('y', cy + 4).attr('text-anchor', 'end')\n .style('fill', subjectText)\n .text((r) => (small ? '' : fmtScore(r.score)));\n\n row.select('rect.margin-bar')\n .attr('x', (r) => Math.min(zx, x(r.margin))).attr('y', cy - 5)\n .attr('width', (r) => Math.abs(x(r.margin) - zx)).attr('height', 10).attr('rx', 2)\n .style('fill', (r) => color[r.status]);\n\n row.select('g.marks').selectAll('.mark')\n .data((r) => r.marks.slice().sort((a, b) => (a.model.larger ? -1 : 0) - (b.model.larger ? -1 : 0)), (d) => d.model.name)\n .join((enter) => enter.append('path'))\n .attr('class', (d) => 'mark ' + (d.model.larger ? 'larger' : 'peer'))\n .attr('d', (d) => (d.model.larger ? d3.symbol(d3.symbolCircle, 72)() : d3.symbol(d.model.symbol, d.model.size)()))\n .attr('transform', (d) => 'translate(' + x(d.lead) + ',' + cy + ')');\n\n const leadText = (r) => (r.status === 'tie' ? 'tie' : fmtLead(r.margin));\n const rivalText = (r) => (r.status === 'win' ? 'vs ' : r.status === 'tie' ? 'with ' : 'behind ') + r.closest.model.name + dagger(r, r.closest.model);\n row.select('text.lead-label')\n .attr('x', small ? width : width - rightW).attr('y', small ? 15 : cy - 3)\n .attr('text-anchor', small ? 'end' : 'start')\n .selectAll('tspan').data((r) => small\n ? [{ t: leadText(r), c: 'lead', s: r.status }, { t: rivalText(r), c: 'rival' }]\n : [{ t: leadText(r), c: 'lead', s: r.status }])\n .join('tspan')\n .attr('class', (d) => d.c)\n .attr('dx', (d, i) => (i ? 5 : 0))\n .style('fill', (d) => (d.c === 'lead' ? (d.s === 'tie' ? null : ctx.labelColor(color[d.s])) : null))\n .text((d) => d.t);\n row.select('text.rival-label').attr('class', 'rival-label rival')\n .attr('x', width - rightW).attr('y', cy + 11)\n .text((r) => (small ? '' : rivalText(r)));\n\n // Name the larger model once, on the row where it sits farthest left with\n // no same-size model ahead, so the label has free space up to zero.\n gNotes.selectAll('*').remove();\n const idx = (r) => rows.indexOf(r);\n const free = rows.filter((r) => r.larger && r.margin >= 0);\n const named = d3.least(free, (r) => r.larger.lead);\n if (named) {\n gNotes.append('text').attr('class', 'note')\n .attr('x', x(named.larger.lead) + 9).attr('y', headH + idx(named) * rowH + cy + 4)\n .text(LARGER.name + ', larger');\n }\n // And call out the benchmark where SmolLM3-3B beats it anyway.\n const upset = d3.greatest(largerBehind, (r) => r.larger.lead);\n if (upset) {\n gNotes.append('text').attr('class', 'note').attr('text-anchor', 'middle')\n .attr('x', x(upset.larger.lead)).attr('y', headH + idx(upset) * rowH + cy + (small ? 15 : -10))\n .text('beats ' + LARGER.name + ' too');\n }\n // A missing score gets a label, never a mark at zero.\n rows.filter((r) => r.missing.length).forEach((r) => {\n const right = d3.max(r.marks, (d) => x(d.lead));\n gNotes.append('text').attr('class', 'note missing')\n .attr('x', Math.max(zx, right) + 12).attr('y', headH + idx(r) * rowH + cy + 4)\n .text('no ' + listing(r.missing.map((m) => m.name)) + ' score');\n });\n\n const hide = () => { row.classed('on', false); tip.style('opacity', 0); };\n row.on('pointerenter pointermove', (event, r) => {\n row.classed('on', (d) => d === r);\n tip.html(tipHtml(r)).style('opacity', 1);\n const [px, py] = d3.pointer(event, ctx.root);\n const node = tip.node(), tw = node.offsetWidth, th = node.offsetHeight;\n let left = px + 14;\n if (left + tw > ctx.root.clientWidth) left = px - 14 - tw;\n let top = py - th - 12;\n if (top < 0) top = py + 16;\n tip.style('left', Math.max(0, Math.min(ctx.root.clientWidth - tw, left)) + 'px').style('top', top + 'px');\n }).on('pointerleave', hide);\n };\n});\n</script>"
},
{
"slug": "arena-win-rate-matrix",
"title": "Arena win-rate matrix",
"summary": "Head-to-head win rates between 12 LMArena models, one cell per pair, with rows and columns ordered by Bradley-Terry strength so the ranking reads as a color gradient from the top-right corner to the bottom-left one.",
"kind": "chart",
"html": "<div class=\"d3-arena-win-rate-matrix\"></div>\n<style>\n .d3-arena-win-rate-matrix { position: relative; color: var(--text-color); font-size: 12px; }\n .d3-arena-win-rate-matrix .title { font-size: 14px; font-weight: 600; line-height: 1.35; }\n .d3-arena-win-rate-matrix .subtitle { font-size: 12px; color: var(--muted-color); margin-top: 3px; line-height: 1.45; max-width: 66ch; }\n .d3-arena-win-rate-matrix .legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 10px 0 8px; font-size: 11.5px; color: var(--muted-color); }\n .d3-arena-win-rate-matrix .legend .item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }\n .d3-arena-win-rate-matrix .legend .scale { flex-basis: 100%; }\n .d3-arena-win-rate-matrix .ramp { width: 96px; height: 8px; border-radius: 4px; }\n .d3-arena-win-rate-matrix .key-bold { color: var(--text-color); font-weight: 700; }\n .d3-arena-win-rate-matrix .key-dash { width: 14px; height: 10px; box-sizing: border-box; border: 1.5px dashed var(--text-color); border-radius: 2px; }\n .d3-arena-win-rate-matrix svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }\n .d3-arena-win-rate-matrix text { font-family: inherit; }\n .d3-arena-win-rate-matrix .name { fill: var(--text-color); font-size: 12px; }\n .d3-arena-win-rate-matrix .rank { fill: var(--muted-color); font-size: 11px; font-variant-numeric: tabular-nums; }\n .d3-arena-win-rate-matrix .col-head { fill: var(--text-color); font-size: 11.5px; }\n .d3-arena-win-rate-matrix .col-head.num { fill: var(--muted-color); font-size: 11px; font-variant-numeric: tabular-nums; }\n .d3-arena-win-rate-matrix .col-head.overall { fill: var(--muted-color); }\n .d3-arena-win-rate-matrix .on { font-weight: 700; }\n .d3-arena-win-rate-matrix .col-head.on, .d3-arena-win-rate-matrix .rank.on { fill: var(--text-color); }\n .d3-arena-win-rate-matrix .diag { fill: var(--grid-color); opacity: .45; }\n .d3-arena-win-rate-matrix .cell rect { stroke: var(--border-color); stroke-opacity: .7; stroke-width: .5; }\n .d3-arena-win-rate-matrix .val { font-variant-numeric: tabular-nums; pointer-events: none; }\n .d3-arena-win-rate-matrix .cnt { font-size: 11px; font-variant-numeric: tabular-nums; pointer-events: none; opacity: .8; }\n .d3-arena-win-rate-matrix .exception { fill: none; stroke: var(--text-color); stroke-width: 1.5; stroke-dasharray: 3 2; pointer-events: none; }\n .d3-arena-win-rate-matrix .hover { fill: none; stroke: var(--text-color); stroke-width: 2; pointer-events: none; }\n .d3-arena-win-rate-matrix .note { font-size: 11px; color: var(--muted-color); line-height: 1.5; margin-top: 10px; max-width: 76ch; }\n .d3-arena-win-rate-matrix .tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--surface-bg); border: 1px solid var(--border-color); border-radius: 6px; padding: 7px 10px; font-size: 11.5px; line-height: 1.5; max-width: 270px; box-shadow: 0 2px 10px rgba(0,0,0,.15); opacity: 0; transition: opacity .12s; z-index: 2; }\n .d3-arena-win-rate-matrix .tip .muted { color: var(--muted-color); }\n</style>\n<script>\nEmbed.mount('d3-arena-win-rate-matrix', (ctx) => {\n // [model_1, model_2, model_1_wins, model_2_wins, ties, both_bad, battles]:\n // LMArena human-preference votes, April to July 2025 (arena-human-preference-140k).\n const RAW = [\n ['claude-opus-4-20250514', 'gemini-2.5-pro', 65, 212, 52, 36, 365],\n ['claude-opus-4-20250514', 'o3-2025-04-16', 84, 150, 47, 27, 308],\n ['claude-opus-4-20250514', 'chatgpt-4o-latest-20250326', 72, 131, 37, 30, 270],\n ['claude-opus-4-20250514', 'deepseek-r1-0528', 71, 133, 38, 29, 271],\n ['claude-opus-4-20250514', 'gemini-2.5-flash', 133, 192, 65, 39, 429],\n ['claude-opus-4-20250514', 'claude-sonnet-4-20250514', 142, 85, 76, 48, 351],\n ['claude-opus-4-20250514', 'qwen3-235b-a22b-no-thinking', 110, 165, 63, 31, 369],\n ['claude-opus-4-20250514', 'gpt-4.1-2025-04-14', 84, 109, 49, 26, 268],\n ['claude-opus-4-20250514', 'mistral-medium-2505', 122, 135, 59, 39, 355],\n ['claude-opus-4-20250514', 'gemma-3-27b-it', 111, 118, 34, 36, 299],\n ['claude-opus-4-20250514', 'llama-4-maverick-17b-128e-instruct', 72, 49, 25, 21, 167],\n ['gemini-2.5-pro', 'o3-2025-04-16', 109, 74, 50, 25, 258],\n ['gemini-2.5-pro', 'chatgpt-4o-latest-20250326', 81, 62, 45, 23, 211],\n ['gemini-2.5-pro', 'deepseek-r1-0528', 90, 66, 43, 16, 215],\n ['gemini-2.5-pro', 'gemini-2.5-flash', 141, 67, 68, 32, 308],\n ['gemini-2.5-pro', 'claude-sonnet-4-20250514', 169, 66, 52, 25, 312],\n ['gemini-2.5-pro', 'qwen3-235b-a22b-no-thinking', 147, 69, 54, 23, 293],\n ['gemini-2.5-pro', 'gpt-4.1-2025-04-14', 116, 47, 35, 16, 214],\n ['gemini-2.5-pro', 'mistral-medium-2505', 197, 77, 49, 29, 352],\n ['gemini-2.5-pro', 'gemma-3-27b-it', 147, 56, 43, 22, 268],\n ['gemini-2.5-pro', 'llama-4-maverick-17b-128e-instruct', 107, 26, 26, 23, 182],\n ['o3-2025-04-16', 'chatgpt-4o-latest-20250326', 81, 88, 53, 24, 246],\n ['o3-2025-04-16', 'deepseek-r1-0528', 85, 74, 34, 15, 208],\n ['o3-2025-04-16', 'gemini-2.5-flash', 112, 93, 54, 30, 289],\n ['o3-2025-04-16', 'claude-sonnet-4-20250514', 141, 63, 18, 25, 247],\n ['o3-2025-04-16', 'qwen3-235b-a22b-no-thinking', 115, 86, 38, 27, 266],\n ['o3-2025-04-16', 'gpt-4.1-2025-04-14', 87, 68, 36, 23, 214],\n ['o3-2025-04-16', 'mistral-medium-2505', 138, 85, 49, 22, 294],\n ['o3-2025-04-16', 'gemma-3-27b-it', 105, 64, 35, 14, 218],\n ['o3-2025-04-16', 'llama-4-maverick-17b-128e-instruct', 118, 46, 20, 17, 201],\n ['chatgpt-4o-latest-20250326', 'deepseek-r1-0528', 49, 49, 31, 14, 143],\n ['chatgpt-4o-latest-20250326', 'gemini-2.5-flash', 107, 78, 42, 17, 244],\n ['chatgpt-4o-latest-20250326', 'claude-sonnet-4-20250514', 100, 62, 33, 27, 222],\n ['chatgpt-4o-latest-20250326', 'qwen3-235b-a22b-no-thinking', 92, 51, 49, 26, 218],\n ['chatgpt-4o-latest-20250326', 'gpt-4.1-2025-04-14', 88, 52, 48, 26, 214],\n ['chatgpt-4o-latest-20250326', 'mistral-medium-2505', 120, 68, 40, 26, 254],\n ['chatgpt-4o-latest-20250326', 'gemma-3-27b-it', 111, 60, 30, 17, 218],\n ['chatgpt-4o-latest-20250326', 'llama-4-maverick-17b-128e-instruct', 109, 44, 27, 26, 206],\n ['deepseek-r1-0528', 'gemini-2.5-flash', 96, 92, 62, 34, 284],\n ['deepseek-r1-0528', 'claude-sonnet-4-20250514', 108, 54, 18, 28, 208],\n ['deepseek-r1-0528', 'qwen3-235b-a22b-no-thinking', 112, 73, 56, 31, 272],\n ['deepseek-r1-0528', 'gpt-4.1-2025-04-14', 67, 60, 24, 9, 160],\n ['deepseek-r1-0528', 'mistral-medium-2505', 96, 69, 58, 19, 242],\n ['deepseek-r1-0528', 'gemma-3-27b-it', 86, 49, 46, 21, 202],\n ['deepseek-r1-0528', 'llama-4-maverick-17b-128e-instruct', 57, 23, 10, 9, 99],\n ['gemini-2.5-flash', 'claude-sonnet-4-20250514', 189, 79, 54, 41, 363],\n ['gemini-2.5-flash', 'qwen3-235b-a22b-no-thinking', 120, 113, 59, 37, 329],\n ['gemini-2.5-flash', 'gpt-4.1-2025-04-14', 101, 70, 57, 24, 252],\n ['gemini-2.5-flash', 'mistral-medium-2505', 150, 119, 62, 43, 374],\n ['gemini-2.5-flash', 'gemma-3-27b-it', 122, 73, 51, 35, 281],\n ['gemini-2.5-flash', 'llama-4-maverick-17b-128e-instruct', 93, 30, 28, 21, 172],\n ['claude-sonnet-4-20250514', 'qwen3-235b-a22b-no-thinking', 88, 151, 47, 36, 322],\n ['claude-sonnet-4-20250514', 'gpt-4.1-2025-04-14', 61, 98, 32, 29, 220],\n ['claude-sonnet-4-20250514', 'mistral-medium-2505', 92, 148, 44, 36, 320],\n ['claude-sonnet-4-20250514', 'gemma-3-27b-it', 72, 100, 23, 22, 217],\n ['claude-sonnet-4-20250514', 'llama-4-maverick-17b-128e-instruct', 61, 46, 14, 19, 140],\n ['qwen3-235b-a22b-no-thinking', 'gpt-4.1-2025-04-14', 85, 67, 41, 23, 216],\n ['qwen3-235b-a22b-no-thinking', 'mistral-medium-2505', 115, 106, 54, 37, 312],\n ['qwen3-235b-a22b-no-thinking', 'gemma-3-27b-it', 78, 71, 44, 26, 219],\n ['qwen3-235b-a22b-no-thinking', 'llama-4-maverick-17b-128e-instruct', 68, 26, 29, 19, 142],\n ['gpt-4.1-2025-04-14', 'mistral-medium-2505', 75, 67, 42, 28, 212],\n ['gpt-4.1-2025-04-14', 'gemma-3-27b-it', 85, 57, 29, 23, 194],\n ['gpt-4.1-2025-04-14', 'llama-4-maverick-17b-128e-instruct', 60, 35, 19, 13, 127],\n ['mistral-medium-2505', 'gemma-3-27b-it', 91, 83, 45, 33, 252],\n ['mistral-medium-2505', 'llama-4-maverick-17b-128e-instruct', 76, 44, 25, 18, 163],\n ['gemma-3-27b-it', 'llama-4-maverick-17b-128e-instruct', 66, 39, 22, 22, 149]\n ];\n if (!RAW.length) throw new Error('No battles to plot.');\n\n // [label at 760px, label at 360px, full name for the tooltip]\n const NAMES = {\n 'gemini-2.5-pro': ['Gemini 2.5 Pro', 'Gemini Pro', 'Gemini 2.5 Pro'],\n 'chatgpt-4o-latest-20250326': ['ChatGPT-4o', 'ChatGPT-4o', 'ChatGPT-4o (latest, 2025-03-26)'],\n 'o3-2025-04-16': ['o3', 'o3', 'OpenAI o3 (2025-04-16)'],\n 'deepseek-r1-0528': ['DeepSeek R1', 'DeepSeek R1', 'DeepSeek R1 (0528)'],\n 'gemini-2.5-flash': ['Gemini 2.5 Flash', 'Gemini Flash', 'Gemini 2.5 Flash'],\n 'qwen3-235b-a22b-no-thinking': ['Qwen3 235B', 'Qwen3 235B', 'Qwen3 235B A22B (no thinking)'],\n 'gpt-4.1-2025-04-14': ['GPT-4.1', 'GPT-4.1', 'GPT-4.1 (2025-04-14)'],\n 'mistral-medium-2505': ['Mistral Medium', 'Mistral Med.', 'Mistral Medium (2505)'],\n 'gemma-3-27b-it': ['Gemma 3 27B', 'Gemma 3', 'Gemma 3 27B IT'],\n 'claude-opus-4-20250514': ['Claude Opus 4', 'Opus 4', 'Claude Opus 4 (2025-05-14)'],\n 'claude-sonnet-4-20250514': ['Claude Sonnet 4', 'Sonnet 4', 'Claude Sonnet 4 (2025-05-14)'],\n 'llama-4-maverick-17b-128e-instruct': ['Llama 4 Maverick', 'Llama 4 Mav.', 'Llama 4 Maverick 17B 128E Instruct']\n };\n const label = (id, k) => (NAMES[id] ? NAMES[id][k] : id);\n\n const ids = Array.from(new Set(RAW.flatMap((r) => [r[0], r[1]])));\n const N = ids.length;\n if (RAW.length !== N * (N - 1) / 2) throw new Error('Expected every pair of models exactly once.');\n const rec = new Map(ids.map((id) => [id, new Map()]));\n RAW.forEach((r) => {\n rec.get(r[0]).set(r[1], { w: r[2], l: r[3], t: r[4], bb: r[5], n: r[6] });\n rec.get(r[1]).set(r[0], { w: r[3], l: r[2], t: r[4], bb: r[5], n: r[6] });\n });\n\n // Bradley-Terry strengths on decisive votes (minorization-maximization),\n // the model behind arena leaderboards. Ties and both-bad votes carry no\n // preference, so they are left out of every rate below.\n let s = new Map(ids.map((id) => [id, 1]));\n for (let it = 0; it < 400; it++) {\n const next = new Map();\n ids.forEach((i) => {\n let wins = 0, denom = 0;\n rec.get(i).forEach((r, j) => { wins += r.w; denom += (r.w + r.l) / (s.get(i) + s.get(j)); });\n next.set(i, wins / denom);\n });\n const g = Math.exp(d3.mean(ids, (id) => Math.log(next.get(id))));\n ids.forEach((id) => next.set(id, next.get(id) / g));\n s = next;\n }\n const elo = (id) => 400 * Math.log10(s.get(id));\n const order = ids.slice().sort((a, b) => s.get(b) - s.get(a));\n const rank = new Map(order.map((id, i) => [id, i + 1]));\n\n // 95% Wilson interval on the decisive win share.\n const wilson = (w, n) => {\n const z = 1.96, p = w / n, d = 1 + z * z / n;\n const c = (p + z * z / (2 * n)) / d;\n const h = z * Math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / d;\n return [c - h, c + h];\n };\n const withRate = (o) => {\n const dec = o.w + o.l, ci = wilson(o.w, dec);\n return Object.assign({}, o, { dec: dec, rate: o.w / dec, ci: ci, sig: ci[0] > 0.5 || ci[1] < 0.5 });\n };\n\n const cells = [];\n order.forEach((row, i) => order.forEach((col, j) => {\n if (i === j) return;\n cells.push(Object.assign({ key: row + '|' + col, i: i, j: j, row: row, col: col }, withRate(rec.get(row).get(col))));\n }));\n const overall = order.map((row, i) => {\n const o = { w: 0, l: 0, t: 0, bb: 0, n: 0 };\n rec.get(row).forEach((r) => { o.w += r.w; o.l += r.l; o.t += r.t; o.bb += r.bb; o.n += r.n; });\n return Object.assign({ key: 'all|' + row, i: i, row: row, overall: true }, withRate(o));\n });\n\n // Upper triangle: the row is the higher-ranked model of the pair.\n const upper = cells.filter((d) => d.i < d.j);\n const holds = upper.filter((d) => d.w > d.l);\n const exceptions = upper.filter((d) => d.w <= d.l);\n const exceptionKeys = new Set(exceptions.flatMap((d) => [d.row + '|' + d.col, d.col + '|' + d.row]));\n const sigPairs = upper.filter((d) => d.sig).length;\n // How far apart two models must be before every pair is clear of 50%.\n const neighbors = upper.filter((d) => d.j - d.i === 1);\n const sigNeighbors = neighbors.filter((d) => d.sig).length;\n let safeGap = N;\n while (safeGap > 1 && upper.every((d) => d.j - d.i < safeGap - 1 || d.sig)) safeGap--;\n const totals = RAW.reduce((a, r) => { a.n += r[6]; a.t += r[4]; a.bb += r[5]; return a; }, { n: 0, t: 0, bb: 0 });\n const decExt = d3.extent(upper, (d) => d.dec);\n const top = order[0], last = order[N - 1];\n const topBeats = upper.filter((d) => d.row === top && d.w > d.l).length;\n const fmtInt = d3.format(',');\n const pct0 = d3.format('.0%');\n const pct1 = d3.format('.1%');\n const ext = Math.ceil(d3.max(cells, (d) => Math.abs(d.rate - 0.5)) * 20) / 20;\n\n const exceptionText = (k) => exceptions.map((d) => {\n const a = label(d.row, k), b = label(d.col, k);\n return d.w === d.l ? a + ' and ' + b + ' split ' + d.w + ' to ' + d.l : b + ' beats ' + a + ' ' + d.l + ' to ' + d.w;\n }).join('; ');\n\n ctx.describe(\n 'Heatmap of head-to-head win rates between ' + N + ' LMArena models, from ' + fmtInt(totals.n) + ' battles, rows and columns ranked by Bradley-Terry strength. ' +\n 'The higher-ranked model wins ' + holds.length + ' of ' + upper.length + ' pairs' + (exceptions.length ? ' (exception: ' + exceptionText(0) + ')' : '') + '. ' +\n label(top, 0) + ' ranks first and beats ' + topBeats + ' of ' + (N - 1) + ' rivals, with ' + pct0(overall[0].rate) + ' of its decisive votes; ' +\n label(last, 0) + ' ranks last with ' + pct0(overall[N - 1].rate) + '. Ties and both-bad votes are excluded.'\n );\n\n const root = d3.select(ctx.root);\n root.append('div').attr('class', 'title').text(\n 'Arena votes form a clean ladder: the higher-ranked model wins ' + holds.length + ' of ' + upper.length + ' head-to-heads'\n );\n root.append('div').attr('class', 'subtitle').text(\n 'Share of decisive votes the row model won against the column model, in ' + fmtInt(totals.n) +\n ' LMArena battles (April to July 2025). Models are ranked by Bradley-Terry strength, so above the diagonal the row is always the stronger model.'\n );\n const legend = root.append('div').attr('class', 'legend');\n const rampItem = legend.append('span').attr('class', 'item scale');\n rampItem.append('span').text('Row loses ' + pct0(0.5 - ext));\n const ramp = rampItem.append('span').attr('class', 'ramp');\n rampItem.append('span').text(pct0(0.5 + ext) + ' row wins');\n legend.append('span').attr('class', 'item').html(\n '<span class=\"key-bold\">Bold</span> clear of 50% at 95% confidence (' + sigPairs + ' of ' + upper.length + ' pairs)'\n );\n const countKey = legend.append('span').attr('class', 'item').html('<span class=\"key-bold\">n</span> decisive votes');\n if (exceptions.length) legend.append('span').attr('class', 'item').html('<span class=\"key-dash\"></span>Does not follow the ranking');\n\n const svg = root.append('svg');\n const gHead = svg.append('g');\n const gRows = svg.append('g');\n const gCells = svg.append('g');\n const gOverall = svg.append('g');\n const gMarks = svg.append('g');\n const hoverBox = svg.append('rect').attr('class', 'hover').style('opacity', 0);\n const note = root.append('div').attr('class', 'note');\n const tip = root.append('div').attr('class', 'tip');\n const measure = document.createElement('canvas').getContext('2d');\n\n const esc = (v) => String(v).replace(/[&<>\"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' }[c]));\n const tipHtml = (d) => {\n const head = d.overall\n ? '<b>' + esc(label(d.row, 2)) + '</b> vs all ' + (N - 1) + ' rivals'\n : '<b>' + esc(label(d.row, 2)) + '</b> vs <b>' + esc(label(d.col, 2)) + '</b>';\n const extra = d.overall\n ? '<span class=\"muted\">Rank ' + rank.get(d.row) + ', Bradley-Terry ' + d3.format('+.0f')(elo(d.row)) + ' Elo points vs the average model</span>'\n : '<span class=\"muted\">' + (d.sig ? 'Clear of 50% at 95% confidence' : 'Within noise of 50% at 95% confidence') + '</span>';\n return head + '<br>' +\n 'Wins <b>' + pct1(d.rate) + '</b> of ' + fmtInt(d.dec) + ' decisive votes (' + fmtInt(d.w) + ' to ' + fmtInt(d.l) + ')<br>' +\n '<span class=\"muted\">95% interval ' + pct0(d.ci[0]) + ' to ' + pct0(d.ci[1]) + '. Excluded: ' + fmtInt(d.t) + ' ties, ' + fmtInt(d.bb) + ' both bad, of ' + fmtInt(d.n) + ' battles</span><br>' +\n extra;\n };\n\n const hide = () => {\n tip.style('opacity', 0);\n hoverBox.style('opacity', 0);\n svg.selectAll('.on').classed('on', false);\n };\n svg.on('pointerleave', hide);\n\n return ({ width }) => {\n hide();\n const small = width < 560;\n const k = small ? 1 : 0;\n const font = getComputedStyle(ctx.root).fontFamily || 'sans-serif';\n const textW = (t, px, bold) => { measure.font = (bold ? '700 ' : '') + px + 'px ' + font; return measure.measureText(t).width; };\n\n const rankW = textW('12', 11);\n const nameW = d3.max(order, (id) => textW(label(id, k), 12, true));\n const left = Math.ceil(rankW + 6 + nameW + 8);\n const gap = small ? 6 : 10;\n const overallHead = small ? 'All' : 'Overall';\n\n // Wide: column names slanted at 45 degrees; narrow: rank numbers, matched\n // to the rank printed before each row name.\n const SIN = Math.SQRT1_2;\n const heads = order.map((id, j) => ({ id: id, j: j, text: small ? String(j + 1) : label(id, 0) }));\n heads.push({ id: null, j: N, text: overallHead, overall: true });\n let cell = Math.floor((width - left - gap - 2) / (N + 1));\n if (!small) {\n heads.forEach((h) => {\n const room = width - 4 - left - (h.overall ? gap : 0) - textW(h.text, 11.5, true) * SIN;\n cell = Math.min(cell, Math.floor(room / (h.j + 0.5)));\n });\n }\n cell = Math.max(16, Math.min(48, cell));\n // Narrow cells get taller than wide, so rows stay separable and tappable.\n const rowH = Math.max(cell, 24);\n const headH = small ? 20 : Math.ceil(d3.max(heads, (h) => textW(h.text, 11.5, true)) * SIN + 14);\n const xOf = (j) => left + j * cell;\n const yOf = (i) => headH + i * rowH;\n const xAll = left + N * cell + gap;\n const y0 = headH;\n const H = y0 + N * rowH + 2;\n const showCount = cell >= 40;\n const valSize = cell >= 40 ? 13 : cell >= 26 ? 12 : 11;\n svg.attr('viewBox', '0 0 ' + width + ' ' + H).attr('height', H);\n countKey.style('display', showCount ? null : 'none');\n\n // ctx.colors('diverging') runs from the primary color through a neutral\n // midpoint to its complement; winning is drawn in the primary color.\n const stops = ctx.colors('diverging', 11).slice().reverse();\n const interp = d3.interpolateRgbBasis(stops);\n const color = (v) => interp(Math.max(0, Math.min(1, (v - (0.5 - ext)) / (2 * ext))));\n ramp.style('background', 'linear-gradient(90deg, ' + stops.join(', ') + ')');\n\n gHead.selectAll('text').data(heads).join('text')\n .attr('class', (h) => 'col-head' + (small ? ' num' : '') + (h.overall ? ' overall' : ''))\n .attr('text-anchor', small ? 'middle' : 'start')\n .attr('transform', (h) => {\n const cx = (h.overall ? xAll : xOf(h.j)) + cell / 2;\n return small ? 'translate(' + cx + ',' + (y0 - 7) + ')' : 'translate(' + (cx - 3) + ',' + (y0 - 7) + ') rotate(-45)';\n })\n .text((h) => h.text);\n\n const rows = gRows.selectAll('g').data(order).join((enter) => {\n const g = enter.append('g');\n g.append('text').attr('class', 'rank').attr('text-anchor', 'end').attr('dy', '0.35em');\n g.append('text').attr('class', 'name').attr('text-anchor', 'end').attr('dy', '0.35em');\n return g;\n }).attr('transform', (id, i) => 'translate(0,' + (yOf(i) + rowH / 2) + ')');\n rows.select('.rank').attr('x', Math.ceil(rankW)).text((id) => rank.get(id));\n rows.select('.name').attr('x', left - 8).text((id) => label(id, k));\n\n gCells.selectAll('rect.diag').data(order).join('rect').attr('class', 'diag')\n .attr('x', (id, i) => xOf(i) + 1).attr('y', (id, i) => yOf(i) + 1)\n .attr('width', cell - 2).attr('height', rowH - 2).attr('rx', 2);\n\n const draw = (sel, x) => sel.join((enter) => {\n const g = enter.append('g').attr('class', 'cell');\n g.append('rect').attr('rx', 2);\n g.append('text').attr('class', 'val').attr('text-anchor', 'middle');\n g.append('text').attr('class', 'cnt').attr('text-anchor', 'middle');\n return g;\n })\n .attr('transform', (d) => 'translate(' + x(d) + ',' + yOf(d.i) + ')')\n .call((g) => g.select('rect').attr('x', 1).attr('y', 1).attr('width', cell - 2).attr('height', rowH - 2)\n .style('fill', (d) => color(d.rate)))\n .call((g) => g.select('.val').attr('x', cell / 2).attr('y', showCount ? rowH / 2 - 5 : rowH / 2).attr('dy', '0.35em')\n .style('font-size', valSize + 'px').style('font-weight', (d) => (d.sig ? 700 : 400))\n .style('fill', (d) => ctx.textOn(color(d.rate)))\n .text((d) => Math.round(d.rate * 100)))\n .call((g) => g.select('.cnt').attr('x', cell / 2).attr('y', rowH / 2 + 10).attr('dy', '0.35em')\n .style('fill', (d) => ctx.textOn(color(d.rate)))\n .text((d) => (showCount ? 'n ' + d.dec : '')));\n\n const pairSel = draw(gCells.selectAll('g.cell').data(cells, (d) => d.key), (d) => xOf(d.j));\n const allSel = draw(gOverall.selectAll('g.cell').data(overall, (d) => d.key), () => xAll);\n\n gMarks.selectAll('rect.exception').data(cells.filter((d) => exceptionKeys.has(d.key))).join('rect')\n .attr('class', 'exception')\n .attr('x', (d) => xOf(d.j) + 1.5).attr('y', (d) => yOf(d.i) + 1.5)\n .attr('width', cell - 3).attr('height', rowH - 3).attr('rx', 2);\n\n note.text(\n (small ? 'Columns are numbered by rank. ' : '') +\n 'Win rate = wins / (wins + losses): ties (' + fmtInt(totals.t) + ') and both-bad votes (' + fmtInt(totals.bb) + '), ' +\n pct0((totals.t + totals.bb) / totals.n) + ' of all battles, count for neither side. ' +\n 'Pairs have ' + decExt[0] + ' to ' + decExt[1] + ' decisive votes' + (showCount ? ' (n in each cell)' : '') + ', too few to separate neighbors: ' +\n 'only ' + sigNeighbors + ' of ' + neighbors.length + ' adjacent pairs ' + (sigNeighbors === 1 ? 'is' : 'are') + ' clear of 50%' +\n (safeGap > 1 && safeGap < N ? ', against every pair ' + safeGap + ' or more ranks apart. ' : '. ') +\n (exceptions.length ? 'Dashed: ' + exceptionText(k) + ', the one pair that does not follow the ranking. ' : '') +\n 'Raw votes, without the style control used by the public leaderboard.'\n );\n\n const onMove = (event, d) => {\n const x = d.overall ? xAll : xOf(d.j);\n hoverBox.attr('x', x + 1).attr('y', yOf(d.i) + 1).attr('width', cell - 2).attr('height', rowH - 2).attr('rx', 2).style('opacity', 1);\n rows.selectAll('text').classed('on', (id) => id === d.row);\n gHead.selectAll('text').classed('on', (h) => (d.overall ? !!h.overall : h.id === d.col));\n tip.html(tipHtml(d)).style('opacity', 1);\n const node = tip.node();\n const [px, py] = d3.pointer(event, ctx.root);\n const rw = ctx.root.clientWidth, tw = node.offsetWidth, th = node.offsetHeight;\n let tx = px + 14, ty = py - th - 12;\n if (tx + tw > rw) tx = px - tw - 14;\n if (ty < 0) ty = py + 16;\n tip.style('left', Math.max(0, Math.min(rw - tw, tx)) + 'px').style('top', ty + 'px');\n };\n pairSel.on('pointermove', onMove);\n allSel.on('pointermove', onMove);\n };\n});\n</script>"
},
{
"slug": "moe-banner",
"title": "Mixture-of-experts banner",
"summary": "A 5:2 hero banner for an article on mixture of experts. A stream of tokens crosses seven MoE layers, one per real model, drawn to scale from Mixtral 8x7B (8 experts) to Kimi K2 (384). At each layer a token splits into exactly as many strands as the model routes it to, lights only those experts, and merges again before the next router.",
"kind": "banner",
"html": "<div class=\"d3-moe-banner\"></div>\n<style>\n .d3-moe-banner { width: 100%; aspect-ratio: 5 / 2; overflow: hidden; position: relative; }\n .d3-moe-banner canvas { display: block; width: 100%; height: 100%; }\n</style>\n<script>\nEmbed.mount('d3-moe-banner', (ctx) => {\n // moe-architectures.csv: routed and shared experts per MoE layer, experts per\n // token (top-k), total and active parameters in billions.\n const models = [\n { model: 'Mixtral 8x7B', total: 46.7, active: 12.9, routed: 8, shared: 0, k: 2 },\n { model: 'OLMoE 1B-7B', total: 6.9, active: 1.3, routed: 64, shared: 0, k: 8 },\n { model: 'Qwen3 30B-A3B', total: 30.5, active: 3.3, routed: 128, shared: 0, k: 8 },\n { model: 'gpt-oss-120b', total: 117, active: 5.1, routed: 128, shared: 0, k: 4 },\n { model: 'Qwen3 235B-A22B', total: 235, active: 22, routed: 128, shared: 0, k: 8 },\n { model: 'DeepSeek-V3', total: 671, active: 37, routed: 256, shared: 1, k: 8 },\n { model: 'Kimi K2', total: 1000, active: 32, routed: 384, shared: 1, k: 8 },\n ];\n if (!models.length) throw new Error('No models to draw.');\n models.forEach((m) => {\n if (!(m.routed > 0 && m.k > 0 && m.k <= m.routed)) throw new Error('Invalid expert counts for ' + m.model + '.');\n });\n\n const canvas = document.createElement('canvas');\n ctx.root.appendChild(canvas);\n const g = canvas.getContext('2d');\n\n const pct = (m) => d3.format('.1~f')((100 * m.k) / m.routed) + '%';\n const first = models[0];\n const last = models[models.length - 1];\n const totalExperts = d3.sum(models, (m) => m.routed + m.shared);\n ctx.describe(\n 'Banner: a stream of tokens crosses ' + models.length + ' mixture-of-experts layers drawn to scale, ' +\n totalExperts + ' experts in all, from ' + first.model + ' (' + first.routed + ' experts) to ' + last.model +\n ' (' + last.routed + ' routed plus ' + last.shared + ' shared). At each layer a token splits into exactly as many ' +\n 'strands as the model routes it to, lights only those experts and merges again: ' + first.k + ' of ' + first.routed +\n ' (' + pct(first) + ') in ' + first.model + ', ' + last.k + ' of ' + last.routed + ' (' + pct(last) + ') in ' +\n last.model + ', which runs ' + last.active + 'B of its ' + d3.format(',')(last.total) + 'B parameters per token.'\n );\n\n const GAP = 3; // cells between two blocks: merge point, router, shared expert\n const TRAVEL = 11; // seconds for a token to cross the banner\n const PERIOD = TRAVEL / 3.1;\n const TAU = 1.3; // decay of an expert's glow, seconds\n const T_STILL = 40 * PERIOD + 0.62 * PERIOD;\n\n const ease = (u) => (u <= 0 ? 0 : u >= 1 ? 1 : u * u * (3 - 2 * u));\n\n let L = null;\n let C = null;\n let now = T_STILL;\n\n function buildLayout(width, height) {\n const availH = height * 0.84;\n const availW = width * 0.975;\n let best = null;\n for (let R = 8; R <= 48; R += 2) {\n const cols = models.map((m) => Math.ceil(m.routed / R));\n const units = d3.sum(cols) + models.length * GAP + 1;\n const s = Math.min(availW / units, availH / R);\n if (!best || s > best.s) best = { R, cols, units, s };\n }\n const { R, cols, units, s } = best;\n const cy = Math.round(height / 2) + 0.5;\n let x = (width - units * s) / 2;\n const blocks = models.map((m, i) => {\n const gapStart = x;\n const left = gapStart + GAP * s;\n const c = cols[i];\n const full = Math.floor(m.routed / R);\n const rest = m.routed - full * R;\n const pos = [];\n for (let col = 0; col < c; col++) {\n const count = col < full ? R : rest;\n for (let r = 0; r < count; r++) {\n pos.push([left + (col + 0.5) * s, cy + (r - (count - 1) / 2) * s]);\n }\n }\n x = left + c * s;\n return {\n ...m, i, pos, left, right: x,\n merge: gapStart + 0.7 * s,\n router: gapStart + 1.45 * s,\n sharedX: gapStart + 2.3 * s,\n };\n });\n blocks.forEach((b, i) => {\n b.exit = i < blocks.length - 1 ? blocks[i + 1].merge : b.right + 0.9 * s;\n });\n // Straight stretches of the token path: the gaps, and the blocks whose\n // shared expert sees every token.\n const spine = [[0, blocks[0].router]];\n blocks.forEach((b, i) => {\n if (b.shared) spine.push([b.router, b.exit]);\n spine.push([b.exit, i < blocks.length - 1 ? blocks[i + 1].router : width]);\n });\n const reach = (R / 2) * s;\n const idleBands = d3.range(6).map(() => []);\n blocks.forEach((b) => b.pos.forEach((p) => {\n idleBands[Math.min(5, Math.floor((Math.abs(p[1] - cy) / reach) * 6))].push(p);\n }));\n return { width, height, s, cy, blocks, spine, idleBands, v: width / TRAVEL, trail: (width / TRAVEL) * PERIOD * 1.05 };\n }\n\n // Which experts the router picks for token j in block i, with synthetic gate\n // weights. Seeded, so every load and the PDF show the same routing.\n const pickCache = new Map();\n function picks(j, b) {\n const key = j * 16 + b.i;\n let p = pickCache.get(key);\n if (p) return p;\n const rand = d3.randomLcg(((j + 1000) * 7919 + b.i * 104729 + 42) % 2147483647);\n const chosen = new Set();\n while (chosen.size < b.k) chosen.add(Math.floor(rand() * b.routed));\n const ws = Array.from(chosen, () => 0.25 + rand() * 0.75);\n const wMax = d3.max(ws);\n p = Array.from(chosen, (e, n) => ({ e, w: ws[n] / wMax }));\n pickCache.set(key, p);\n if (pickCache.size > 400) {\n const keys = Array.from(pickCache.keys()).sort((a, c) => a - c);\n keys.slice(0, 200).forEach((k) => pickCache.delete(k));\n }\n return p;\n }\n\n // Height of a strand at x: router -> expert -> merge point, eased so it\n // leaves and rejoins the token path horizontally.\n function strandY(b, ex, ey, x) {\n if (x <= ex) return L.cy + (ey - L.cy) * ease((x - b.router) / (ex - b.router));\n return ey + (L.cy - ey) * ease((x - ex) / (b.exit - ex));\n }\n\n function strokeStrand(b, ex, ey, x0, x1) {\n const step = Math.max(1.5, L.s * 0.25);\n g.beginPath();\n g.moveTo(x0, strandY(b, ex, ey, x0));\n for (let x = x0 + step; x < x1; x += step) g.lineTo(x, strandY(b, ex, ey, x));\n g.lineTo(x1, strandY(b, ex, ey, x1));\n g.stroke();\n }\n\n function draw(t) {\n if (!L || !C) return;\n const { width, height, s, cy, blocks, v, trail } = L;\n g.clearRect(0, 0, width, height);\n g.lineCap = 'round';\n g.lineJoin = 'round';\n\n const jHi = Math.floor(t / PERIOD);\n const jLo = Math.floor((t - (width + trail) / v) / PERIOD);\n const tokens = [];\n for (let j = jLo; j <= jHi; j++) {\n tokens.push({ j, X: (t - j * PERIOD) * v, color: C.shades[((j % C.shades.length) + C.shades.length) % C.shades.length] });\n }\n\n // Expert glow: each pick lights up when its token reaches it, then fades.\n const act = blocks.map((b) => new Float32Array(b.routed));\n const actColor = blocks.map((b) => new Array(b.routed));\n tokens.forEach((tk) => {\n blocks.forEach((b) => {\n if (tk.X < b.router) return;\n picks(tk.j, b).forEach((p) => {\n const age = t - (tk.j * PERIOD + b.pos[p.e][0] / v);\n if (age < 0) return;\n const a = Math.exp(-age / TAU) * (0.55 + 0.45 * p.w);\n if (a > act[b.i][p.e]) { act[b.i][p.e] = a; actColor[b.i][p.e] = tk.color; }\n });\n });\n });\n\n g.strokeStyle = C.path;\n g.lineWidth = 1;\n g.beginPath();\n L.spine.forEach((sg) => { g.moveTo(sg[0], cy); g.lineTo(sg[1], cy); });\n g.stroke();\n\n // Idle experts, fading toward the top and bottom edges so the blocks read\n // as fields rather than boxes.\n const rIdle = Math.max(1, s * 0.2);\n L.idleBands.forEach((band, n) => {\n g.fillStyle = C.idle.alpha(1 - 0.6 * (n / (L.idleBands.length - 1)) ** 1.6);\n g.beginPath();\n band.forEach((p) => {\n g.moveTo(p[0] + rIdle, p[1]);\n g.arc(p[0], p[1], rIdle, 0, Math.PI * 2);\n });\n g.fill();\n });\n\n // Token strands with a trail that fades behind the wavefront.\n const baseW = Math.max(0.9, s * 0.1);\n tokens.forEach((tk) => {\n const x0 = Math.max(0, tk.X - trail);\n const x1 = Math.min(width, tk.X);\n if (x1 <= x0) return;\n const grad = g.createLinearGradient(tk.X - trail, 0, tk.X, 0);\n grad.addColorStop(0, tk.color.alpha(0));\n grad.addColorStop(0.55, tk.color.alpha(0.28));\n grad.addColorStop(1, tk.color.alpha(0.9));\n g.strokeStyle = grad;\n\n g.lineWidth = baseW * 1.6;\n g.beginPath();\n L.spine.forEach((sg) => {\n const a0 = Math.max(x0, sg[0]), a1 = Math.min(x1, sg[1]);\n if (a1 > a0) { g.moveTo(a0, cy); g.lineTo(a1, cy); }\n });\n g.stroke();\n\n blocks.forEach((b) => {\n const a0 = Math.max(x0, b.router), a1 = Math.min(x1, b.exit);\n if (a1 <= a0) return;\n picks(tk.j, b).forEach((p) => {\n const pt = b.pos[p.e];\n g.lineWidth = baseW * (0.55 + 0.75 * p.w);\n strokeStrand(b, pt[0], pt[1], a0, a1);\n });\n });\n });\n\n // Lit experts: soft halo, then a core that grows with the gate weight.\n blocks.forEach((b) => {\n const a = act[b.i];\n for (let e = 0; e < b.routed; e++) {\n if (a[e] < 0.03) continue;\n const p = b.pos[e];\n const col = actColor[b.i][e];\n g.fillStyle = col.alpha(a[e] * C.halo);\n g.beginPath();\n g.arc(p[0], p[1], s * (0.55 + 0.25 * a[e]), 0, Math.PI * 2);\n g.fill();\n g.fillStyle = col.alpha(0.45 + 0.55 * a[e]);\n g.beginPath();\n g.arc(p[0], p[1], Math.max(rIdle, s * (0.22 + 0.16 * a[e])), 0, Math.PI * 2);\n g.fill();\n }\n });\n\n // Routers, and the shared expert as an always-lit ring.\n blocks.forEach((b) => {\n let flash = 0;\n tokens.forEach((tk) => {\n const age = t - (tk.j * PERIOD + b.router / v);\n if (age >= 0) flash = Math.max(flash, Math.exp(-age / 0.35));\n });\n const rr = Math.max(1.6, s * 0.2);\n g.fillStyle = C.router;\n g.beginPath();\n g.moveTo(b.router, cy - rr * 1.5);\n g.lineTo(b.router + rr * 1.5, cy);\n g.lineTo(b.router, cy + rr * 1.5);\n g.lineTo(b.router - rr * 1.5, cy);\n g.closePath();\n g.fill();\n if (flash > 0.03) {\n g.fillStyle = C.primary.alpha(flash);\n g.fill();\n }\n for (let n = 0; n < b.shared; n++) {\n g.lineWidth = Math.max(1, s * 0.1);\n g.strokeStyle = C.primary.alpha(1);\n g.fillStyle = C.page;\n g.beginPath();\n g.arc(b.sharedX, cy, Math.max(2.4, s * 0.42), 0, Math.PI * 2);\n g.fill();\n g.stroke();\n g.fillStyle = C.primary.alpha(1);\n g.beginPath();\n g.arc(b.sharedX, cy, Math.max(1.1, s * 0.2), 0, Math.PI * 2);\n g.fill();\n }\n });\n\n // Token heads: one dot on the path, k dots while it is split.\n const rHead = Math.max(1.5, s * 0.24);\n tokens.forEach((tk) => {\n const X = tk.X;\n if (X < 0 || X > width) return;\n const b = blocks.find((bb) => X > bb.router && X < bb.exit);\n const heads = b ? picks(tk.j, b).map((p) => [X, strandY(b, b.pos[p.e][0], b.pos[p.e][1], X), rHead * (0.75 + 0.35 * p.w)]) : [];\n if (!b || b.shared) heads.push([X, cy, rHead * 1.35]);\n heads.forEach((hd) => {\n g.fillStyle = C.page;\n g.beginPath();\n g.arc(hd[0], hd[1], hd[2] + Math.max(1, s * 0.08), 0, Math.PI * 2);\n g.fill();\n g.fillStyle = tk.color.alpha(1);\n g.beginPath();\n g.arc(hd[0], hd[1], hd[2], 0, Math.PI * 2);\n g.fill();\n });\n });\n }\n\n if (!ctx.reducedMotion) {\n let start = null;\n ctx.animate((time) => {\n if (start === null) start = time;\n now = T_STILL + (time - start) / 1000;\n draw(now);\n });\n }\n\n // --primary-color is often oklch(), which d3.color cannot parse: let a\n // canvas pixel resolve any CSS color to RGB.\n const probe = document.createElement('canvas').getContext('2d', { willReadFrequently: true });\n const resolve = (css) => {\n probe.clearRect(0, 0, 1, 1);\n probe.fillStyle = '#000';\n probe.fillStyle = css;\n probe.fillRect(0, 0, 1, 1);\n const p = probe.getImageData(0, 0, 1, 1).data;\n return d3.rgb(p[0], p[1], p[2], p[3] / 255);\n };\n const rgba = (css) => {\n const c = resolve(css);\n return { alpha: (a) => { const k = c.copy(); k.opacity = c.opacity * a; return k.formatRgb(); } };\n };\n\n return ({ width, height, isDark }) => {\n if (!width || !height) return;\n const dpr = Math.min(2, window.devicePixelRatio || 1);\n canvas.width = Math.round(width * dpr);\n canvas.height = Math.round(height * dpr);\n g.setTransform(dpr, 0, 0, dpr, 0, 0);\n L = buildLayout(width, height);\n\n const css = getComputedStyle(ctx.root);\n const prop = (name, fallback) => css.getPropertyValue(name).trim() || fallback;\n const seq = ctx.colors('sequential', 7);\n const primary = resolve(prop('--primary-color', seq[3])).formatRgb();\n // Structure is the text color with a hint of the accent, so idle experts\n // and the token path belong to the same palette as the lit ones.\n const text = d3.color(d3.interpolateRgb(resolve(prop('--text-color', isDark ? '#eeeeee' : '#222222')), primary)(0.22));\n const tone = (a) => { const k = text.copy(); k.opacity = a; return k.formatRgb(); };\n // Shades of the accent, taken from the half of the ramp that stands out\n // against the page in the current theme.\n const strong = isDark ? seq.slice().reverse() : seq;\n C = {\n primary: rgba(primary),\n shades: [rgba(primary), rgba(strong[isDark ? 0 : 1]), rgba(strong[isDark ? 2 : 4])],\n page: prop('--page-bg', isDark ? '#0f1115' : '#ffffff'),\n idle: rgba(tone(isDark ? 0.24 : 0.2)),\n path: tone(isDark ? 0.22 : 0.2),\n router: tone(isDark ? 0.55 : 0.5),\n halo: isDark ? 0.26 : 0.22,\n };\n draw(now);\n };\n}, { resize: 'size' });\n</script>"
}
];