Spaces:
Running
Running
Paul Hager commited on
Commit 路
43e1ef3
1
Parent(s): 6b24873
Label all historical SOTA models
Browse files
app.js
CHANGED
|
@@ -56,7 +56,6 @@ function historicalSotaRuns(points) {
|
|
| 56 |
});
|
| 57 |
|
| 58 |
const highlighted = new Set();
|
| 59 |
-
let currentLabel = null;
|
| 60 |
let bestScore = -Infinity;
|
| 61 |
|
| 62 |
[...releases.keys()]
|
|
@@ -70,17 +69,98 @@ function historicalSotaRuns(points) {
|
|
| 70 |
(point) => point.plotScore === releaseBest,
|
| 71 |
);
|
| 72 |
releaseLeaders.forEach((point) => highlighted.add(plotRunKey(point)));
|
| 73 |
-
|
| 74 |
-
const labelLeader = [...releaseLeaders].sort(
|
| 75 |
-
(a, b) =>
|
| 76 |
-
(b.quantization_bits || 0) - (a.quantization_bits || 0) ||
|
| 77 |
-
a.model.localeCompare(b.model),
|
| 78 |
-
)[0];
|
| 79 |
-
currentLabel = plotRunKey(labelLeader);
|
| 80 |
bestScore = Math.max(bestScore, releaseBest);
|
| 81 |
});
|
| 82 |
|
| 83 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
function plotDate(value) {
|
|
@@ -152,20 +232,24 @@ function renderReleasePlot(rows) {
|
|
| 152 |
}).join("");
|
| 153 |
|
| 154 |
const sotaRuns = historicalSotaRuns(points);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
const marks = points
|
| 157 |
.map((point) => {
|
| 158 |
const runKey = plotRunKey(point);
|
| 159 |
-
const
|
| 160 |
-
const
|
| 161 |
-
const showLabel = labelIndex !== -1;
|
| 162 |
const pointX = x(point.releasedTime) + quantizationJitter(point.quantization_bits);
|
| 163 |
const pointY = y(point.plotScore);
|
| 164 |
-
const
|
| 165 |
-
|
| 166 |
-
const labelY = pointY + (labelIndex % 2 === 1 ? 22 : -10);
|
| 167 |
-
const label = showLabel
|
| 168 |
-
? `<text class="point-label" x="${labelX}" y="${labelY}" text-anchor="${labelOnLeft ? "end" : "start"}">${escapeHtml(shortModelName(point.model))}</text>`
|
| 169 |
: "";
|
| 170 |
const sotaDescription = isSota
|
| 171 |
? ", historical state of the art at release"
|
|
@@ -173,16 +257,13 @@ function renderReleasePlot(rows) {
|
|
| 173 |
const accessibleLabel = `${point.model}, ${point.plotScore.toFixed(2)} ${metricDescription}, released ${point.releasedAt}${sotaDescription}`;
|
| 174 |
const tooltipMeta = `${metricLabel}: ${point.plotScore.toFixed(2)} 路 ${point.releasedAt} 路 ${runLabel(point)}${isSota ? " 路 SOTA at release" : ""}`;
|
| 175 |
return `<a class="plot-point" href="https://huggingface.co/${encodeURI(point.hub_model)}" target="_blank" rel="noreferrer" tabindex="0" aria-label="${escapeHtml(accessibleLabel)}" aria-describedby="plot-tooltip" data-tooltip-title="${escapeHtml(point.model)}" data-tooltip-meta="${escapeHtml(tooltipMeta)}">
|
| 176 |
-
<circle class="${isSota ? "sota-point" : ""}" cx="${pointX}" cy="${pointY}" r="${isSota ? 8 : 6}">
|
| 177 |
-
<title>${escapeHtml(accessibleLabel)}</title>
|
| 178 |
-
</circle>
|
| 179 |
${label}
|
| 180 |
</a>`;
|
| 181 |
})
|
| 182 |
.join("");
|
| 183 |
|
| 184 |
-
plot.innerHTML = `<svg viewBox="0 0 ${width} ${height}" role="img" aria-
|
| 185 |
-
<title id="plot-svg-title">Model release date versus ${escapeHtml(metricDescription)}</title>
|
| 186 |
<desc id="plot-svg-desc">Each point is an evaluated model run. The horizontal axis is release date and the vertical axis is ${escapeHtml(metricDescription)} from zero to one hundred. Coral points matched or established the best score available at their release date.</desc>
|
| 187 |
<g class="plot-grid">${yTicks}${xTicks}</g>
|
| 188 |
<text class="axis-label y-axis-label" transform="translate(17 ${height / 2}) rotate(-90)" text-anchor="middle">${escapeHtml(metricLabel)} score</text>
|
|
|
|
| 56 |
});
|
| 57 |
|
| 58 |
const highlighted = new Set();
|
|
|
|
| 59 |
let bestScore = -Infinity;
|
| 60 |
|
| 61 |
[...releases.keys()]
|
|
|
|
| 69 |
(point) => point.plotScore === releaseBest,
|
| 70 |
);
|
| 71 |
releaseLeaders.forEach((point) => highlighted.add(plotRunKey(point)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
bestScore = Math.max(bestScore, releaseBest);
|
| 73 |
});
|
| 74 |
|
| 75 |
+
return highlighted;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function layoutSotaLabels(points, highlighted, dimensions) {
|
| 79 |
+
const { x, y, quantizationJitter, width, height, margin } = dimensions;
|
| 80 |
+
const labels = new Map();
|
| 81 |
+
const occupied = [];
|
| 82 |
+
const verticalOffsets = [-11, 22, -30, 41, -49, 60, -68, 79, -87, 98];
|
| 83 |
+
const sotaPoints = points
|
| 84 |
+
.filter((point) => highlighted.has(plotRunKey(point)))
|
| 85 |
+
.sort(
|
| 86 |
+
(a, b) =>
|
| 87 |
+
a.releasedTime - b.releasedTime ||
|
| 88 |
+
a.plotScore - b.plotScore ||
|
| 89 |
+
a.model.localeCompare(b.model),
|
| 90 |
+
);
|
| 91 |
+
|
| 92 |
+
sotaPoints.forEach((point, index) => {
|
| 93 |
+
const pointX = x(point.releasedTime) + quantizationJitter(point.quantization_bits);
|
| 94 |
+
const pointY = y(point.plotScore);
|
| 95 |
+
const name = shortModelName(point.model);
|
| 96 |
+
const labelWidth = Math.max(54, name.length * 6.2);
|
| 97 |
+
const preferredDirections =
|
| 98 |
+
pointX + labelWidth + 14 > width - margin.right
|
| 99 |
+
? [-1, 1]
|
| 100 |
+
: index % 2 === 0
|
| 101 |
+
? [1, -1]
|
| 102 |
+
: [-1, 1];
|
| 103 |
+
let selected = null;
|
| 104 |
+
|
| 105 |
+
for (const offset of verticalOffsets) {
|
| 106 |
+
for (const direction of preferredDirections) {
|
| 107 |
+
const labelX = pointX + direction * 10;
|
| 108 |
+
const labelY = Math.max(
|
| 109 |
+
margin.top + 12,
|
| 110 |
+
Math.min(height - margin.bottom - 4, pointY + offset),
|
| 111 |
+
);
|
| 112 |
+
const box = {
|
| 113 |
+
left: direction === 1 ? labelX : labelX - labelWidth,
|
| 114 |
+
right: direction === 1 ? labelX + labelWidth : labelX,
|
| 115 |
+
top: labelY - 11,
|
| 116 |
+
bottom: labelY + 3,
|
| 117 |
+
};
|
| 118 |
+
const withinPlot =
|
| 119 |
+
box.left >= margin.left &&
|
| 120 |
+
box.right <= width - margin.right &&
|
| 121 |
+
box.top >= margin.top &&
|
| 122 |
+
box.bottom <= height - margin.bottom;
|
| 123 |
+
const collides = occupied.some(
|
| 124 |
+
(other) =>
|
| 125 |
+
box.left < other.right + 5 &&
|
| 126 |
+
box.right > other.left - 5 &&
|
| 127 |
+
box.top < other.bottom + 4 &&
|
| 128 |
+
box.bottom > other.top - 4,
|
| 129 |
+
);
|
| 130 |
+
if (withinPlot && !collides) {
|
| 131 |
+
selected = {
|
| 132 |
+
x: labelX,
|
| 133 |
+
y: labelY,
|
| 134 |
+
anchor: direction === 1 ? "start" : "end",
|
| 135 |
+
box,
|
| 136 |
+
};
|
| 137 |
+
break;
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
if (selected) break;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
if (!selected) {
|
| 144 |
+
const labelX = Math.min(width - margin.right, pointX + 10);
|
| 145 |
+
const labelY = Math.max(margin.top + 12, pointY - 11);
|
| 146 |
+
selected = {
|
| 147 |
+
x: labelX,
|
| 148 |
+
y: labelY,
|
| 149 |
+
anchor: "start",
|
| 150 |
+
box: {
|
| 151 |
+
left: labelX,
|
| 152 |
+
right: labelX + labelWidth,
|
| 153 |
+
top: labelY - 11,
|
| 154 |
+
bottom: labelY + 3,
|
| 155 |
+
},
|
| 156 |
+
};
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
occupied.push(selected.box);
|
| 160 |
+
labels.set(plotRunKey(point), selected);
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
return labels;
|
| 164 |
}
|
| 165 |
|
| 166 |
function plotDate(value) {
|
|
|
|
| 232 |
}).join("");
|
| 233 |
|
| 234 |
const sotaRuns = historicalSotaRuns(points);
|
| 235 |
+
const sotaLabels = layoutSotaLabels(points, sotaRuns, {
|
| 236 |
+
x,
|
| 237 |
+
y,
|
| 238 |
+
quantizationJitter,
|
| 239 |
+
width,
|
| 240 |
+
height,
|
| 241 |
+
margin,
|
| 242 |
+
});
|
| 243 |
|
| 244 |
const marks = points
|
| 245 |
.map((point) => {
|
| 246 |
const runKey = plotRunKey(point);
|
| 247 |
+
const isSota = sotaRuns.has(runKey);
|
| 248 |
+
const labelPosition = sotaLabels.get(runKey);
|
|
|
|
| 249 |
const pointX = x(point.releasedTime) + quantizationJitter(point.quantization_bits);
|
| 250 |
const pointY = y(point.plotScore);
|
| 251 |
+
const label = labelPosition
|
| 252 |
+
? `<text class="point-label" x="${labelPosition.x}" y="${labelPosition.y}" text-anchor="${labelPosition.anchor}">${escapeHtml(shortModelName(point.model))}</text>`
|
|
|
|
|
|
|
|
|
|
| 253 |
: "";
|
| 254 |
const sotaDescription = isSota
|
| 255 |
? ", historical state of the art at release"
|
|
|
|
| 257 |
const accessibleLabel = `${point.model}, ${point.plotScore.toFixed(2)} ${metricDescription}, released ${point.releasedAt}${sotaDescription}`;
|
| 258 |
const tooltipMeta = `${metricLabel}: ${point.plotScore.toFixed(2)} 路 ${point.releasedAt} 路 ${runLabel(point)}${isSota ? " 路 SOTA at release" : ""}`;
|
| 259 |
return `<a class="plot-point" href="https://huggingface.co/${encodeURI(point.hub_model)}" target="_blank" rel="noreferrer" tabindex="0" aria-label="${escapeHtml(accessibleLabel)}" aria-describedby="plot-tooltip" data-tooltip-title="${escapeHtml(point.model)}" data-tooltip-meta="${escapeHtml(tooltipMeta)}">
|
| 260 |
+
<circle class="${isSota ? "sota-point" : ""}" cx="${pointX}" cy="${pointY}" r="${isSota ? 8 : 6}"></circle>
|
|
|
|
|
|
|
| 261 |
${label}
|
| 262 |
</a>`;
|
| 263 |
})
|
| 264 |
.join("");
|
| 265 |
|
| 266 |
+
plot.innerHTML = `<svg viewBox="0 0 ${width} ${height}" role="img" aria-label="Model release date versus ${escapeHtml(metricDescription)}" aria-describedby="plot-svg-desc">
|
|
|
|
| 267 |
<desc id="plot-svg-desc">Each point is an evaluated model run. The horizontal axis is release date and the vertical axis is ${escapeHtml(metricDescription)} from zero to one hundred. Coral points matched or established the best score available at their release date.</desc>
|
| 268 |
<g class="plot-grid">${yTicks}${xTicks}</g>
|
| 269 |
<text class="axis-label y-axis-label" transform="translate(17 ${height / 2}) rotate(-90)" text-anchor="middle">${escapeHtml(metricLabel)} score</text>
|