thinkwee commited on
Commit
8735f85
·
1 Parent(s): daa6be0
Files changed (1) hide show
  1. charts.js +45 -11
charts.js CHANGED
@@ -110,15 +110,24 @@ function initScalingCharts() {
110
  });
111
  });
112
 
 
 
 
 
 
113
  const layout = {
114
  ...darkLayout,
115
  xaxis: {
116
  ...darkLayout.xaxis,
117
- title: { text: 'Interaction Turns', font: { size: 11, color: '#e2e8f0' } }
 
 
118
  },
119
  yaxis: {
120
  ...darkLayout.yaxis,
121
- title: { text: 'Accuracy (%)', font: { size: 11, color: '#e2e8f0' } }
 
 
122
  },
123
  showlegend: true
124
  };
@@ -127,11 +136,12 @@ function initScalingCharts() {
127
  });
128
  }
129
 
 
130
  function updateScalingCharts(dimension) {
131
  const scenarios = ['mimic', '10k', 'globem'];
132
  const xLabels = {
133
- 'turn': 'Interaction Turns',
134
- 'token': 'Token Usage',
135
  'cost': 'Inference Cost ($)'
136
  };
137
 
@@ -163,6 +173,25 @@ function updateScalingCharts(dimension) {
163
  newY.push(modelData.accuracy);
164
  });
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  // Animate the transition
167
  Plotly.animate(`scaling-${scenario}`, {
168
  data: newX.map((x, i) => ({ x, y: newY[i] })),
@@ -170,21 +199,26 @@ function updateScalingCharts(dimension) {
170
  layout: {
171
  xaxis: {
172
  title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
173
- type: dimension === 'cost' ? 'log' : 'linear'
 
 
 
 
174
  }
175
  }
176
  }, animationSettings);
177
 
178
  // Update hover templates
179
  const hoverLabels = {
180
- 'turn': 'Turn',
181
- 'token': 'Tokens',
182
- 'cost': 'Cost: $'
183
  };
184
 
185
  models.forEach((model, i) => {
 
186
  Plotly.restyle(`scaling-${scenario}`, {
187
- hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: %{x}<br>Accuracy: %{y:.1f}%<extra></extra>`
188
  }, [i]);
189
  });
190
  });
@@ -352,7 +386,7 @@ function initTurnCharts() {
352
  barmode: 'group',
353
  xaxis: {
354
  ...darkLayout.xaxis,
355
- title: { text: 'Median Turns', font: { size: 11, color: '#e2e8f0' } },
356
  range: [0, Math.max(...sortedData.map(d => d.median)) * 1.15]
357
  },
358
  yaxis: {
@@ -428,7 +462,7 @@ function renderProbingCharts(mode) {
428
  ...darkLayout,
429
  xaxis: {
430
  ...darkLayout.xaxis,
431
- title: { text: mode === 'byTurn' ? 'Turn' : 'Progress (%)', font: { size: 11, color: '#e2e8f0' } }
432
  },
433
  yaxis: {
434
  ...darkLayout.yaxis,
 
110
  });
111
  });
112
 
113
+ // Calculate Y-axis range (similar to Python: round to nearest 5)
114
+ const allAccuracies = models.flatMap(m => data[m].accuracy);
115
+ const yMin = Math.max(0, Math.floor(Math.min(...allAccuracies) / 5) * 5);
116
+ const yMax = (Math.floor(Math.max(...allAccuracies) / 5) + 1) * 5 + 5;
117
+
118
  const layout = {
119
  ...darkLayout,
120
  xaxis: {
121
  ...darkLayout.xaxis,
122
+ title: { text: 'Number of Interaction Turns', font: { size: 11, color: '#e2e8f0' } },
123
+ dtick: 5, // 5 turn intervals
124
+ range: [0, Math.max(...models.flatMap(m => data[m].turns)) + 2]
125
  },
126
  yaxis: {
127
  ...darkLayout.yaxis,
128
+ title: { text: 'Accuracy (%)', font: { size: 11, color: '#e2e8f0' } },
129
+ dtick: 5, // 5% intervals
130
+ range: [yMin, yMax]
131
  },
132
  showlegend: true
133
  };
 
136
  });
137
  }
138
 
139
+
140
  function updateScalingCharts(dimension) {
141
  const scenarios = ['mimic', '10k', 'globem'];
142
  const xLabels = {
143
+ 'turn': 'Number of Interaction Turns',
144
+ 'token': 'Total Costed Tokens',
145
  'cost': 'Inference Cost ($)'
146
  };
147
 
 
173
  newY.push(modelData.accuracy);
174
  });
175
 
176
+ // Calculate proper axis settings for each dimension
177
+ const xAxisSettings = {
178
+ 'turn': {
179
+ dtick: 5,
180
+ tickformat: null,
181
+ range: [0, Math.max(...newX.flat()) + 2]
182
+ },
183
+ 'token': {
184
+ dtick: 5000,
185
+ tickformat: ',.0f',
186
+ range: [0, Math.max(...newX.flat()) * 1.05]
187
+ },
188
+ 'cost': {
189
+ dtick: null, // auto for log scale
190
+ tickformat: '$.2f',
191
+ range: null // auto for log scale
192
+ }
193
+ };
194
+
195
  // Animate the transition
196
  Plotly.animate(`scaling-${scenario}`, {
197
  data: newX.map((x, i) => ({ x, y: newY[i] })),
 
199
  layout: {
200
  xaxis: {
201
  title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
202
+ type: dimension === 'cost' ? 'log' : 'linear',
203
+ dtick: xAxisSettings[dimension].dtick,
204
+ tickformat: xAxisSettings[dimension].tickformat,
205
+ range: xAxisSettings[dimension].range,
206
+ exponentformat: 'none'
207
  }
208
  }
209
  }, animationSettings);
210
 
211
  // Update hover templates
212
  const hoverLabels = {
213
+ 'turn': 'Turns',
214
+ 'token': 'Total Tokens',
215
+ 'cost': 'Cost'
216
  };
217
 
218
  models.forEach((model, i) => {
219
+ const hoverFormat = dimension === 'token' ? '%{x:,.0f}' : (dimension === 'cost' ? '$%{x:.4f}' : '%{x}');
220
  Plotly.restyle(`scaling-${scenario}`, {
221
+ hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: ${hoverFormat}<br>Accuracy: %{y:.1f}%<extra></extra>`
222
  }, [i]);
223
  });
224
  });
 
386
  barmode: 'group',
387
  xaxis: {
388
  ...darkLayout.xaxis,
389
+ title: { text: 'Number of Turns', font: { size: 11, color: '#e2e8f0' } },
390
  range: [0, Math.max(...sortedData.map(d => d.median)) * 1.15]
391
  },
392
  yaxis: {
 
462
  ...darkLayout,
463
  xaxis: {
464
  ...darkLayout.xaxis,
465
+ title: { text: mode === 'byTurn' ? 'Turn' : 'Interaction Progress (%)', font: { size: 11, color: '#e2e8f0' } }
466
  },
467
  yaxis: {
468
  ...darkLayout.yaxis,