Skip to content

Commit 992a113

Browse files
committed
make interactive plots usable
1 parent 85443f2 commit 992a113

1 file changed

Lines changed: 57 additions & 37 deletions

File tree

static/js/index.js

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ const AVERAGE_METRIC_PLOTS = [
77
{
88
plotId: 'plot-avg-r50',
99
metricKey: 'recall_50',
10-
yTitle: 'Recall@50 (avg.)',
11-
hoverMetric: 'Recall@50'
10+
yTitle: 'R@50 (Avg. 5)',
11+
hoverMetric: 'Recall@50',
12+
yMax: 0.755
1213
},
1314
{
1415
plotId: 'plot-avg-alpha10',
1516
metricKey: 'alpha_ndcg_10',
16-
yTitle: 'α@10 (avg., alpha-nDCG@10)',
17-
hoverMetric: 'α@10'
17+
yTitle: 'α@10 (Avg. 5)',
18+
hoverMetric: 'α@10',
19+
yMax: 0.541
1820
},
1921
{
2022
plotId: 'plot-avg-c20',
2123
metricKey: 'coverage_20',
22-
yTitle: 'C@20 (avg., Coverage@20)',
23-
hoverMetric: 'C@20'
24+
yTitle: 'C@20 (Avg. 5)',
25+
hoverMetric: 'C@20',
26+
yMax: 0.868
2427
}
2528
];
2629

@@ -125,10 +128,8 @@ function formatParameterSize(sizeInBillions) {
125128
return `${sizeInBillions.toFixed(3)}B`;
126129
}
127130

128-
function getModelAverageMetric(data, modelName, metricKey) {
129-
const row = (data || []).find(
130-
item => String(item?.info?.name || '').toLowerCase() === modelName.toLowerCase()
131-
);
131+
function getModelAverageMetric(data, matcher, metricKey) {
132+
const row = (data || []).find(item => matcher(String(item?.info?.name || '').toLowerCase()));
132133
const val = row?.datasets?.average?.[metricKey];
133134
if (val === undefined || val === null || Number.isNaN(Number(val))) return null;
134135
return Number(val);
@@ -169,7 +170,7 @@ function renderRecallPlots(dataToRender) {
169170
const plotConfig = { responsive: true, displayModeBar: true, displaylogo: false };
170171
const familyColors = buildFamilyColorMap(dataToRender);
171172

172-
AVERAGE_METRIC_PLOTS.forEach(({ plotId, metricKey, yTitle, hoverMetric }) => {
173+
AVERAGE_METRIC_PLOTS.forEach(({ plotId, metricKey, yTitle, hoverMetric, yMax }) => {
173174
const el = document.getElementById(plotId);
174175
if (!el) return;
175176

@@ -197,34 +198,52 @@ function renderRecallPlots(dataToRender) {
197198

198199
const traces = Object.keys(grouped)
199200
.sort((a, b) => a.localeCompare(b))
200-
.map(family => ({
201-
type: 'scatter',
202-
mode: 'markers',
203-
name: family,
204-
x: grouped[family].x,
205-
y: grouped[family].y,
206-
hovertext: grouped[family].hovertext,
207-
marker: {
208-
color: familyColors[family] || '#666',
209-
symbol: grouped[family].symbols,
210-
size: 12,
211-
opacity: 0.95,
212-
line: { width: 1, color: '#fff' }
213-
},
214-
hovertemplate:
215-
'%{hovertext}<br>' +
216-
hoverMetric +
217-
': %{y:.3f}<extra></extra>'
218-
}));
201+
.map(family => {
202+
const points = grouped[family].x.map((x, i) => ({
203+
x,
204+
y: grouped[family].y[i],
205+
hovertext: grouped[family].hovertext[i],
206+
symbol: grouped[family].symbols[i]
207+
})).sort((a, b) => a.x - b.x);
208+
209+
return {
210+
type: 'scatter',
211+
mode: 'lines+markers',
212+
name: family,
213+
x: points.map(p => p.x),
214+
y: points.map(p => p.y),
215+
hovertext: points.map(p => p.hovertext),
216+
marker: {
217+
color: familyColors[family] || '#666',
218+
symbol: points.map(p => p.symbol),
219+
size: 12,
220+
opacity: 0.95,
221+
line: { width: 1, color: '#fff' }
222+
},
223+
line: {
224+
color: familyColors[family] || '#666',
225+
width: 1.5,
226+
dash: 'dash'
227+
},
228+
hovertemplate:
229+
'%{hovertext}<br>' +
230+
hoverMetric +
231+
': %{y:.3f}<extra></extra>'
232+
};
233+
});
219234

220235
const xValues = traces.flatMap(t => t.x || []);
221236
const xMin = xValues.length ? Math.min(...xValues) : null;
222237
const xMax = xValues.length ? Math.max(...xValues) : null;
223238
const baselineData = fullLeaderboardData || dataToRender;
224-
const bm25Score = getModelAverageMetric(baselineData, 'BM25', metricKey);
239+
const bm25Score = getModelAverageMetric(
240+
baselineData,
241+
name => name === 'bm25' || name.startsWith('oracle: bm25'),
242+
metricKey
243+
);
225244
const fusionScore = getModelAverageMetric(
226245
baselineData,
227-
'Fusion (BM25, BGE, E5, Voyage)',
246+
name => name.startsWith('fusion (bm25, bge, e5, voyage)') || name.startsWith('oracle: fusion (bm25'),
228247
metricKey
229248
);
230249

@@ -283,23 +302,24 @@ function renderRecallPlots(dataToRender) {
283302
}
284303

285304
const layout = {
286-
margin: { t: 28, r: 12, b: 52, l: 56 },
305+
margin: { t: 28, r: 12, b: 88, l: 56 },
287306
xaxis: {
288-
title: { text: 'Parameters (billions)' },
307+
title: { text: 'Model Parameters (Billions)', standoff: 18 },
289308
type: 'log',
290309
showgrid: true,
291-
zeroline: false
310+
zeroline: false,
311+
tickfont: { size: 11 }
292312
},
293313
yaxis: {
294314
title: { text: yTitle },
295-
range: [0, 1],
315+
range: [0, yMax],
296316
tickformat: '.2f',
297317
showgrid: true
298318
},
299319
legend: {
300320
orientation: 'h',
301321
yanchor: 'top',
302-
y: -0.22,
322+
y: -0.34,
303323
xanchor: 'center',
304324
x: 0.5,
305325
title: { text: 'Model family' }

0 commit comments

Comments
 (0)