Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit Β·
d6bc164
1
Parent(s): 5df08f8
made various improvements to the verbosity plot
Browse files123493 unmodified lines98991001011021032 unmodified lines10610710810911011111211311411511611727 unmodified lines14514614714814915015115215314 unmodified lines16816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420554 unmodified lines2602612622632642652662672682692702712722732742752762772782792802812824 unmodified lines2872882892902912922932942952962972982993003013023033043054 unmodified lines31031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636733 unmodified lines40140240340440540640740840941015 unmodified lines4264274284294304314329 unmodified lines4424434444454464474484494502 unmodified lines453454455456457458459460461<div class="d3-verbosity" style="width:100%;margin:10px 0;aspect-ratio:3/1;min-height:260px;"></div><script>(() => {const ensureD3 = (cb) => {93 unmodified linesoutEdu: d.output_edu_score,inEdu: d.input_edu_score,compPerDoc: d.output_token_count_mean,phase: Math.random() * Math.PI * 2};});2 unmodified lines// MODEL FAMILIES// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββconst familyColors = {'Gemma': '#4EA5B7','Qwen': '#8B7BE8','SmolLM2': '#E8C44A','Falcon': '#E889AB','Granite': '#5BC0A4','Llama': '#D09090',};const familyOrder = ['Gemma','Qwen','SmolLM2','Falcon','Granite','Llama'];27 unmodified lines`<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${familyColors[d.family]};margin-right:4px;vertical-align:middle;"></span>` +`${d.model} \u00b7 ${d.source}</div>` +`<div style="padding-top:5px;border-top:1px solid var(--border-color);display:grid;grid-template-columns:auto 1fr;gap:2px 8px;font-size:11.5px;">` +`<span style="color:var(--muted-color);">Total output</span><span>${fmtB(d.compTokens)}</span>` +`<span style="color:var(--muted-color);">Output/doc</span><span>${Math.round(d.compPerDoc)} tokens</span>` +`<span style="color:var(--muted-color);">Docs</span><span>${d.numDocs.toFixed(1)}M</span>` +`</div>` +`<div style="margin-top:5px;padding-top:5px;border-top:1px solid var(--border-color);display:grid;grid-template-columns:auto 1fr;gap:2px 8px;font-size:11.5px;">` +`<span style="color:var(--muted-color);">DCLM</span>` +14 unmodified linesconst render = () => {const width = container.clientWidth || 800;const height = Math.max(260, Math.round(width / 3));svg.attr('width', width).attr('height', height);const isDark = document.documentElement.getAttribute('data-theme') === 'dark';const textColor = isDark ? 'rgba(255,255,255,0.72)' : 'rgba(0,0,0,0.62)';const mutedText = isDark ? 'rgba(255,255,255,0.22)' : 'rgba(0,0,0,0.18)';const subtleText = isDark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.08)';const refLine = isDark ? 'rgba(255,255,255,0.10)' : 'rgba(0,0,0,0.07)';const bandEven = isDark ? 'rgba(255,255,255,0.022)' : 'rgba(0,0,0,0.018)';const glowColor = isDark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.25)';const smolHighlight = isDark ? 'rgba(232,196,74,0.18)' : 'rgba(232,196,74,0.12)';const fontSize = Math.max(8, Math.min(12, width / 80));// βββ LAYOUT βββconst labelW = Math.max(68, width * 0.085);const pl = labelW + 12;const pr = width * 0.965;const pt = height * 0.20;const pb = height * 0.86;const plotH = pb - pt;const rowH = plotH / sortedPrompts.length;const rowCenter = {};sortedPrompts.forEach((p, i) => { rowCenter[p] = pt + (i + 0.5) * rowH; });// βββ X SCALE: completion tokens per document (log) βββconst xScale = d3.scaleLog().base(10).domain([15, 1000]).range([pl, pr]);const rBase = Math.max(3.5, Math.min(8, width * 0.007));// βββ FORCE SIMULATION βββfiltered.forEach(d => {54 unmodified lines.attr('stroke', refLine).attr('stroke-width', 0.5);}// SmolLM2 highlight zoneconst smolExp = filtered.filter(d => d.prompt === p && d.family === 'SmolLM2');if (smolExp.length) {const smolX = smolExp[0].x;gRows.append('rect').attr('x', smolX - rBase * 2.5).attr('y', y - rowH * 0.42).attr('width', rBase * 5).attr('height', rowH * 0.84).attr('fill', smolHighlight).attr('rx', rBase * 2);}// LabelgRows.append('text').attr('x', pl - 10).attr('y', y).attr('text-anchor', 'end').attr('dominant-baseline', 'central').attr('fill', textColor).attr('font-size', fontSize + 'px').attr('font-weight', '700').attr('font-family', 'system-ui, -apple-system, sans-serif').attr('letter-spacing', '-0.2px')4 unmodified linesconst gRef = svg.selectAll('g.ref').data([0]).join('g').attr('class', 'ref');gRef.selectAll('*').remove();[20, 50, 100, 200, 500].forEach(v => {const x = xScale(v);if (x > pl && x < pr) {gRef.append('line').attr('x1', x).attr('x2', x).attr('y1', pb).attr('y2', pb + 3).attr('stroke', mutedText).attr('stroke-width', 0.7);gRef.append('text').attr('x', x).attr('y', pb + 5).attr('text-anchor', 'middle').attr('dominant-baseline', 'hanging').attr('fill', mutedText).attr('font-size', (fontSize * 0.65) + 'px').attr('font-family', 'system-ui, -apple-system, sans-serif').text(v);gRef.append('line')4 unmodified lines}});// Axis labelgRef.append('text').attr('x', pr).attr('y', pb + 16).attr('text-anchor', 'end').attr('fill', mutedText).attr('font-size', (fontSize * 0.72) + 'px').attr('font-weight', '600').attr('font-family', 'system-ui, -apple-system, sans-serif').text('Output tokens / document \u2192');// "concise" / "verbose" labelsgRef.append('text').attr('x', pl + 6).attr('y', pt - 5).attr('text-anchor', 'start').attr('fill', subtleText).attr('font-size', (fontSize * 0.62) + 'px').attr('font-style', 'italic').attr('font-family', 'system-ui, -apple-system, sans-serif').text('\u2190 concise');gRef.append('text').attr('x', pr - 6).attr('y', pt - 5).attr('text-anchor', 'end').attr('fill', subtleText).attr('font-size', (fontSize * 0.62) + 'px').attr('font-style', 'italic').attr('font-family', 'system-ui, -apple-system, sans-serif').text('verbose \u2192');// βββ MODEL FAMILY LEGEND βββconst gLeg = svg.selectAll('g.legend').data([0]).join('g').attr('class', 'legend');gLeg.selectAll('*').remove();const legDotR = Math.max(3, fontSize * 0.35);const legGap = Math.max(68, width * 0.082);const totalLegW = familyOrder.length * legGap;const legStartX = Math.max(pl, (width - totalLegW) / 2);const legY = height * 0.055;familyOrder.forEach((fam, i) => {const lx = legStartX + i * legGap;gLeg.append('circle').attr('cx', lx).attr('cy', legY).attr('r', legDotR).attr('fill', familyColors[fam]).attr('fill-opacity', 0.85);gLeg.append('text').attr('x', lx + legDotR + 4).attr('y', legY).attr('dominant-baseline', 'central').attr('fill', isDark ? 'rgba(255,255,255,0.48)' : 'rgba(0,0,0,0.42)').attr('font-size', (fontSize * 0.72) + 'px').attr('font-weight', fam === 'SmolLM2' ? '700' : '500').attr('font-family', 'system-ui, -apple-system, sans-serif').text(fam);});// βββ TOOLTIP βββ33 unmodified linesconst gDots = svg.selectAll('g.dots').data([0]).join('g').attr('class', 'dots');const handleEnter = function (ev, d) {gDots.selectAll('circle').attr('fill-opacity', 0.12).attr('stroke-opacity', 0.05);gDots.selectAll('circle').filter(c => c.family === d.family).attr('fill-opacity', 0.60).attr('stroke-opacity', 0.4);d3.select(this).raise().attr('fill-opacity', 1)15 unmodified linesconst handleLeave = function () {gDots.selectAll('circle').attr('fill-opacity', 0.82).attr('stroke-opacity', 0.30);d3.select(this).style('filter', null).transition().duration(90).ease(d3.easeCubicOut)9 unmodified lines.attr('r', rBase).attr('fill', d => familyColors[d.family] || '#aaa').attr('fill-opacity', 0.82).attr('stroke', d => d.family === 'SmolLM2' ? '#fff' : (familyColors[d.family] || '#aaa')).attr('stroke-width', d => d.family === 'SmolLM2' ? 1.5 : 0.9).attr('stroke-opacity', d => d.family === 'SmolLM2' ? 0.5 : 0.30).on('mouseenter', handleEnter).on('mousemove', handleMove).on('mouseleave', handleLeave),2 unmodified lines.attr('r', rBase).attr('fill', d => familyColors[d.family] || '#aaa').attr('fill-opacity', 0.82).attr('stroke', d => d.family === 'SmolLM2' ? '#fff' : (familyColors[d.family] || '#aaa')).attr('stroke-width', d => d.family === 'SmolLM2' ? 1.5 : 0.9).attr('stroke-opacity', d => d.family === 'SmolLM2' ? 0.5 : 0.30).on('mouseenter', handleEnter).on('mousemove', handleMove).on('mouseleave', handleLeave)123493 unmodified lines98991001011021031041051062 unmodified lines10911011111211311411511611711811912027 unmodified lines14814915015115215315415515615715814 unmodified lines17317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121254 unmodified lines2672682692702712722732742752762772782794 unmodified lines2842852862872882892902912922932942952962972982993003013024 unmodified lines30730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539633 unmodified lines43043143243343443543643743843915 unmodified lines4554564574584594604619 unmodified lines4714724734744754764774784792 unmodified lines482483484485486487488489490<div class="d3-verbosity" style="width:100%;margin:10px 0;aspect-ratio:2.2/1;min-height:320px;"></div><script>(() => {const ensureD3 = (cb) => {93 unmodified linesoutEdu: d.output_edu_score,inEdu: d.input_edu_score,compPerDoc: d.output_token_count_mean,inputPerDoc: d.input_token_count_mean,tokenReduction: d.token_reduction_mean,compressionRatio: d.compression_ratio,phase: Math.random() * Math.PI * 2};});2 unmodified lines// MODEL FAMILIES// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββconst familyColors = {'Gemma': '#5b9bd5','Qwen': '#e07b54','SmolLM2': '#e06b9e','Falcon': '#c9a046','Granite': '#9a8ec2','Llama': '#8bc474',};const familyOrder = ['Gemma','Qwen','SmolLM2','Falcon','Granite','Llama'];27 unmodified lines`<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${familyColors[d.family]};margin-right:4px;vertical-align:middle;"></span>` +`${d.model} \u00b7 ${d.source}</div>` +`<div style="padding-top:5px;border-top:1px solid var(--border-color);display:grid;grid-template-columns:auto 1fr;gap:2px 8px;font-size:11.5px;">` +`<span style="color:var(--muted-color);">Input/doc</span><span>${Math.round(d.inputPerDoc)} tokens</span>` +`<span style="color:var(--muted-color);">Output/doc</span><span>${Math.round(d.compPerDoc)} tokens</span>` +`<span style="color:var(--muted-color);">Reduction</span><span>${Math.round(d.tokenReduction)} tokens (${(d.compressionRatio * 100).toFixed(0)}% ratio)</span>` +`<span style="color:var(--muted-color);">Docs</span><span>${d.numDocs.toFixed(1)}M</span>` +`<span style="color:var(--muted-color);">Total output</span><span>${fmtB(d.compTokens)}</span>` +`</div>` +`<div style="margin-top:5px;padding-top:5px;border-top:1px solid var(--border-color);display:grid;grid-template-columns:auto 1fr;gap:2px 8px;font-size:11.5px;">` +`<span style="color:var(--muted-color);">DCLM</span>` +14 unmodified linesconst render = () => {const width = container.clientWidth || 800;const height = Math.max(320, Math.round(width / 2.2));svg.attr('width', width).attr('height', height);const isDark = document.documentElement.getAttribute('data-theme') === 'dark';const textColor = isDark ? 'rgba(255,255,255,0.82)' : 'rgba(0,0,0,0.72)';const mutedText = isDark ? 'rgba(255,255,255,0.40)' : 'rgba(0,0,0,0.35)';const subtleText = isDark ? 'rgba(255,255,255,0.20)' : 'rgba(0,0,0,0.15)';const refLine = isDark ? 'rgba(255,255,255,0.10)' : 'rgba(0,0,0,0.07)';const bandEven = isDark ? 'rgba(255,255,255,0.022)' : 'rgba(0,0,0,0.018)';const glowColor = isDark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.25)';const fontSize = Math.max(12, Math.min(15, width / 45));// βββ LAYOUT βββconst labelW = Math.max(70, width * 0.08);const pl = labelW + 10;const pr = width - 4;const pt = fontSize * 2.8;const pb = height - fontSize * 5;const plotH = pb - pt;const rowH = plotH / sortedPrompts.length;const rowCenter = {};sortedPrompts.forEach((p, i) => { rowCenter[p] = pt + (i + 0.5) * rowH; });// βββ X SCALE: linear βββconst allVals = filtered.map(d => d.compPerDoc);const xMin = Math.min(150, d3.min(allVals) - 50);const xMax = Math.max(1150, d3.max(allVals) + 50);const xScale = d3.scaleLinear().domain([xMin, xMax]).range([pl, pr]);const rBase = Math.max(4.5, Math.min(10, width * 0.009));// βββ FORCE SIMULATION βββfiltered.forEach(d => {54 unmodified lines.attr('stroke', refLine).attr('stroke-width', 0.5);}// LabelgRows.append('text').attr('x', pl - 10).attr('y', y).attr('text-anchor', 'end').attr('dominant-baseline', 'central').attr('fill', textColor).attr('font-size', (fontSize * 1.05) + 'px').attr('font-weight', '700').attr('font-family', 'system-ui, -apple-system, sans-serif').attr('letter-spacing', '-0.2px')4 unmodified linesconst gRef = svg.selectAll('g.ref').data([0]).join('g').attr('class', 'ref');gRef.selectAll('*').remove();[200, 500, 800, 1100].forEach(v => {const x = xScale(v);if (x > pl + 10 && x < pr - 10) {gRef.append('line').attr('x1', x).attr('x2', x).attr('y1', pb).attr('y2', pb + 4).attr('stroke', mutedText).attr('stroke-width', 0.7);gRef.append('text').attr('x', x).attr('y', pb + 8).attr('text-anchor', 'middle').attr('dominant-baseline', 'hanging').attr('fill', mutedText).attr('font-size', (fontSize * 0.9) + 'px').attr('font-family', 'system-ui, -apple-system, sans-serif').text(v);gRef.append('line')4 unmodified lines}});// Axis label (centered below tick numbers)const axisLabelY = pb + 8 + fontSize * 1.6;gRef.append('text').attr('x', (pl + pr) / 2).attr('y', axisLabelY).attr('text-anchor', 'middle').attr('fill', mutedText).attr('font-size', (fontSize * 0.9) + 'px').attr('font-weight', '600').attr('font-family', 'system-ui, -apple-system, sans-serif').text('Output tokens / document');// "concise" / "verbose" arrows (aligned below first/last tick)gRef.append('text').attr('x', xScale(200)).attr('y', axisLabelY).attr('text-anchor', 'middle').attr('fill', subtleText).attr('font-size', (fontSize * 0.82) + 'px').attr('font-style', 'italic').attr('font-family', 'system-ui, -apple-system, sans-serif').text('\u2190 concise');gRef.append('text').attr('x', xScale(1100)).attr('y', axisLabelY).attr('text-anchor', 'middle').attr('fill', subtleText).attr('font-size', (fontSize * 0.82) + 'px').attr('font-style', 'italic').attr('font-family', 'system-ui, -apple-system, sans-serif').text('verbose \u2192');// βββ MODEL FAMILY LEGEND βββconst gLeg = svg.selectAll('g.legend').data([0]).join('g').attr('class', 'legend');gLeg.selectAll('*').remove();const legDotR = Math.max(4, fontSize * 0.38);const legFontSize = fontSize * 0.9;const legY = fontSize * 1.1;const legItemSpacing = legDotR * 2 + 6;// Measure text widths to compute equal center-to-center gapsconst tempTexts = familyOrder.map(fam => {const t = gLeg.append('text').attr('font-size', legFontSize + 'px').attr('font-weight', '500').attr('font-family', 'system-ui, -apple-system, sans-serif').text(fam);const w = t.node().getComputedTextLength();t.remove();return w;});const itemWidths = tempTexts.map(tw => legItemSpacing + tw);const totalLegW = itemWidths.reduce((a, b) => a + b, 0);const legPadding = Math.max(12, (width - totalLegW) / (familyOrder.length + 1));const totalWithPad = totalLegW + legPadding * (familyOrder.length - 1);const legStartX = (width - totalWithPad) / 2;let lx = legStartX;familyOrder.forEach((fam, i) => {const ig = gLeg.append('g').style('cursor', 'pointer');ig.append('circle').attr('cx', lx).attr('cy', legY).attr('r', legDotR).attr('fill', familyColors[fam]).attr('fill-opacity', 0.85);ig.append('text').attr('x', lx + legDotR + 5).attr('y', legY).attr('dominant-baseline', 'central').attr('fill', isDark ? 'rgba(255,255,255,0.65)' : 'rgba(0,0,0,0.60)').attr('font-size', legFontSize + 'px').attr('font-weight', '500').attr('font-family', 'system-ui, -apple-system, sans-serif').text(fam);// Hit area for easier hoveringig.append('rect').attr('x', lx - legDotR - 4).attr('y', legY - legFontSize * 0.7).attr('width', itemWidths[i] + 8).attr('height', legFontSize * 1.4).attr('fill', 'transparent');ig.on('mouseenter', () => {gDots.selectAll('circle').transition().duration(80).attr('fill-opacity', d => d.family === fam ? 0.55 : 0.06).attr('stroke-opacity', d => d.family === fam ? 0.5 : 0.03);}).on('mouseleave', () => {gDots.selectAll('circle').transition().duration(160).attr('fill-opacity', 0.82).attr('stroke-opacity', 0.12);});lx += itemWidths[i] + legPadding;});// βββ TOOLTIP βββ33 unmodified linesconst gDots = svg.selectAll('g.dots').data([0]).join('g').attr('class', 'dots');const handleEnter = function (ev, d) {gDots.selectAll('circle').attr('fill-opacity', 0.1).attr('stroke-opacity', 0.08);gDots.selectAll('circle').filter(c => c.family === d.family).attr('fill-opacity', 0.55).attr('stroke-opacity', 0.5);d3.select(this).raise().attr('fill-opacity', 1)15 unmodified linesconst handleLeave = function () {gDots.selectAll('circle').attr('fill-opacity', 0.82).attr('stroke-opacity', 0.12);d3.select(this).style('filter', null).transition().duration(90).ease(d3.easeCubicOut)9 unmodified lines.attr('r', rBase).attr('fill', d => familyColors[d.family] || '#aaa').attr('fill-opacity', 0.82).attr('stroke', d => familyColors[d.family] || '#aaa').attr('stroke-width', 0.7).attr('stroke-opacity', 0.12).on('mouseenter', handleEnter).on('mousemove', handleMove).on('mouseleave', handleLeave),2 unmodified lines.attr('r', rBase).attr('fill', d => familyColors[d.family] || '#aaa').attr('fill-opacity', 0.82).attr('stroke', d => familyColors[d.family] || '#aaa').attr('stroke-width', 0.7).attr('stroke-opacity', 0.12).on('mouseenter', handleEnter).on('mousemove', handleMove).on('mouseleave', handleLeave)
app/src/content/embeds/verbosity.html+101-72