joelniklaus HF Staff commited on
Commit
fe33625
·
1 Parent(s): 6af5a04

added speedup annotation for main plot

Browse files
app/src/content/chapters/1-introduction.mdx CHANGED
@@ -27,6 +27,10 @@ Reading time: One weekend
27
  nemotron_hq_synth: { display: "Nemotron-HQ-Synth", color: "#76b900" },
28
  rewire: { display: "REWIRE", color: "#1877F2" },
29
  synth_query_reasoning_answer: { display: "SYNTH", color: "#b07aa1" }
 
 
 
 
30
  }
31
  }}
32
  />
 
27
  nemotron_hq_synth: { display: "Nemotron-HQ-Synth", color: "#76b900" },
28
  rewire: { display: "REWIRE", color: "#1877F2" },
29
  synth_query_reasoning_answer: { display: "SYNTH", color: "#b07aa1" }
30
+ },
31
+ speedupAnnotation: {
32
+ baselineRun: "nemotron_hq_synth",
33
+ targetRun: "mix-fw_edu_hq-table_smollm2_1.7b_hq"
34
  }
35
  }}
36
  />
app/src/content/embeds/d3-benchmark-comparison.html CHANGED
@@ -121,6 +121,15 @@
121
  .d3-benchmark-comparison .line-path.ghost { opacity: .15; }
122
  .d3-benchmark-comparison .line-dot.ghost { opacity: .15; }
123
  .d3-benchmark-comparison .baseline.ghost { opacity: .1; }
 
 
 
 
 
 
 
 
 
124
  .d3-benchmark-comparison .axes path { display: none; }
125
  .d3-benchmark-comparison .axes line { stroke: var(--axis-color); }
126
  .d3-benchmark-comparison .axes text { fill: var(--tick-color); }
@@ -698,6 +707,121 @@
698
  exit => exit.remove()
699
  );
700
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  // Hover overlay
702
  gRoot.selectAll('.hover-line').data([0]).join('line').attr('class', 'hover-line')
703
  .attr('y1', 0).attr('y2', innerHeight).style('display', 'none');
 
121
  .d3-benchmark-comparison .line-path.ghost { opacity: .15; }
122
  .d3-benchmark-comparison .line-dot.ghost { opacity: .15; }
123
  .d3-benchmark-comparison .baseline.ghost { opacity: .1; }
124
+ .d3-benchmark-comparison .speedup-annotation line {
125
+ stroke-dasharray: 4,3;
126
+ stroke-width: 1.5;
127
+ }
128
+ .d3-benchmark-comparison .speedup-label {
129
+ font-weight: 700;
130
+ paint-order: stroke;
131
+ stroke-linejoin: round;
132
+ }
133
  .d3-benchmark-comparison .axes path { display: none; }
134
  .d3-benchmark-comparison .axes line { stroke: var(--axis-color); }
135
  .d3-benchmark-comparison .axes text { fill: var(--tick-color); }
 
707
  exit => exit.remove()
708
  );
709
 
710
+ // Speedup annotation
711
+ if (cfg.speedupAnnotation && currentMetric === defaultMetric) {
712
+ const ann = cfg.speedupAnnotation;
713
+ const baselineRows = parsedData.filter(r => r[RUN_COL] === ann.baselineRun);
714
+ const baselineStepResolved = ann.baselineStep || d3.max(baselineRows, r => +r[STEP_COL]);
715
+ const baselineRow = baselineRows.find(r => +r[STEP_COL] === baselineStepResolved);
716
+ const targetSeries = series.find(s => s.rawName === ann.targetRun);
717
+
718
+ if (baselineRow && targetSeries) {
719
+ const baselineVal = +baselineRow[currentMetric];
720
+ const baselineStepNum = baselineStepResolved;
721
+
722
+ // Find the exact step where the target *data points* first meet or exceed baseline
723
+ const pts = targetSeries.values;
724
+ let crossStep = null;
725
+ for (let i = 0; i < pts.length; i++) {
726
+ if (pts[i].value >= baselineVal) {
727
+ if (i === 0) { crossStep = pts[0].step; break; }
728
+ const t = (baselineVal - pts[i - 1].value) / (pts[i].value - pts[i - 1].value);
729
+ crossStep = pts[i - 1].step + t * (pts[i].step - pts[i - 1].step);
730
+ break;
731
+ }
732
+ }
733
+
734
+ // Snap crossStep to the nearest actual data point for visual alignment
735
+ let snapStep = crossStep;
736
+ if (crossStep !== null) {
737
+ let bestDist = Infinity;
738
+ for (const p of pts) {
739
+ const d = Math.abs(p.step - crossStep);
740
+ if (d < bestDist) { bestDist = d; snapStep = p.step; }
741
+ }
742
+ }
743
+
744
+ if (crossStep !== null) {
745
+ const speedup = baselineStepNum / crossStep;
746
+ const targetColor = colorMap[ann.targetRun] || 'var(--primary-color)';
747
+ const annG = gRoot.append('g').attr('class', 'speedup-annotation');
748
+
749
+ const yPos = y(baselineVal);
750
+ const snapPt = pts.find(p => p.step === snapStep);
751
+ const x1Pos = x(snapStep);
752
+ const y1Pos = snapPt ? y(snapPt.value) : yPos;
753
+ const x2Pos = x(baselineStepNum);
754
+
755
+ // Vertical drop from FinePhrase curve to baseline level at snap point
756
+ annG.append('line')
757
+ .attr('x1', x1Pos).attr('x2', x1Pos)
758
+ .attr('y1', y1Pos).attr('y2', yPos)
759
+ .attr('stroke', targetColor).attr('stroke-width', 1.5).attr('stroke-dasharray', '4,3');
760
+
761
+ // Horizontal bracket at baseline level
762
+ annG.append('line')
763
+ .attr('x1', x1Pos).attr('x2', x2Pos)
764
+ .attr('y1', yPos).attr('y2', yPos)
765
+ .attr('stroke', targetColor).attr('stroke-width', 1.5).attr('stroke-dasharray', '4,3');
766
+
767
+ // Vertical tick at baseline step end
768
+ annG.append('line')
769
+ .attr('x1', x2Pos).attr('x2', x2Pos)
770
+ .attr('y1', yPos - 8).attr('y2', yPos + 8)
771
+ .attr('stroke', targetColor).attr('stroke-width', 2).attr('stroke-dasharray', 'none');
772
+
773
+ // Speedup label
774
+ const labelX = (x1Pos + x2Pos) / 2;
775
+ annG.append('text').attr('class', 'speedup-label')
776
+ .attr('x', labelX).attr('y', yPos - 10)
777
+ .attr('text-anchor', 'middle')
778
+ .attr('fill', targetColor)
779
+ .attr('stroke', 'var(--surface-bg)').attr('stroke-width', 3)
780
+ .attr('font-size', isMobile ? 12 : 14)
781
+ .text(`${speedup.toFixed(1)}× faster`);
782
+
783
+ // Vertical "how much better" annotation at baselineStep
784
+ const targetAtBaseline = targetSeries.values.find(v => v.step === baselineStepNum);
785
+ if (targetAtBaseline) {
786
+ const targetVal = targetAtBaseline.value;
787
+ const pctBetter = ((targetVal - baselineVal) / baselineVal * 100).toFixed(0);
788
+ const yTop = y(targetVal);
789
+ const yBot = y(baselineVal);
790
+ const vx = x2Pos;
791
+
792
+ // Vertical line from baseline to FinePhrase at that step
793
+ annG.append('line')
794
+ .attr('x1', vx).attr('x2', vx)
795
+ .attr('y1', yBot).attr('y2', yTop)
796
+ .attr('stroke', targetColor).attr('stroke-width', 2).attr('stroke-dasharray', 'none');
797
+
798
+ // Tick caps
799
+ const capW = 5;
800
+ annG.append('line')
801
+ .attr('x1', vx - capW).attr('x2', vx + capW)
802
+ .attr('y1', yBot).attr('y2', yBot)
803
+ .attr('stroke', targetColor).attr('stroke-width', 2);
804
+ annG.append('line')
805
+ .attr('x1', vx - capW).attr('x2', vx + capW)
806
+ .attr('y1', yTop).attr('y2', yTop)
807
+ .attr('stroke', targetColor).attr('stroke-width', 2);
808
+
809
+ // "+X% better" label (place left of line if near right edge)
810
+ const nearRightEdge = vx > innerWidth * 0.75;
811
+ annG.append('text').attr('class', 'speedup-label')
812
+ .attr('x', nearRightEdge ? vx - 8 : vx + 8)
813
+ .attr('y', (yTop + yBot) / 2)
814
+ .attr('text-anchor', nearRightEdge ? 'end' : 'start')
815
+ .attr('dominant-baseline', 'central')
816
+ .attr('fill', targetColor)
817
+ .attr('stroke', 'var(--surface-bg)').attr('stroke-width', 3)
818
+ .attr('font-size', isMobile ? 11 : 13)
819
+ .text(`${pctBetter}% better`);
820
+ }
821
+ }
822
+ }
823
+ }
824
+
825
  // Hover overlay
826
  gRoot.selectAll('.hover-line').data([0]).join('line').attr('class', 'hover-line')
827
  .attr('y1', 0).attr('y2', innerHeight).style('display', 'none');