-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
166 lines (155 loc) · 7.87 KB
/
Copy pathindex.html
File metadata and controls
166 lines (155 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Word2Vec Leaderboard</title>
<style>
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #fff; color: #111827; }
main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 56px; }
.hero { padding: 24px 0 18px; border-bottom: 1px solid #e5e7eb; }
h1 { margin: 0 0 10px; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -0.05em; }
h1 a { color: inherit; text-decoration: none; }
h1 a:hover { text-decoration: underline; }
p { color: #4b5563; }
code { background: #f3f4f6; padding: 0.15rem 0.35rem; border-radius: 0.35rem; }
.status { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 7px 11px; border-radius: 999px; background: #f9fafb; border: 1px solid #e5e7eb; font-weight: 700; color: #374151; }
.dot { width: 9px; height: 9px; border-radius: 999px; background: #f59e0b; }
.online .dot { background: #22c55e; }
.offline .dot { background: #f97316; }
.error .dot { background: #ef4444; }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 26px; }
.panel { min-width: 0; }
.board { display: grid; gap: 8px; }
.entry { border-bottom: 1px solid #f1f5f9; }
.row { display: grid; grid-template-columns: 44px minmax(90px, 1fr) minmax(120px, 1.3fr) 80px 72px; gap: 10px; align-items: center; padding: 12px 0; }
.run-list { display: none; margin: 0 0 8px 44px; padding-left: 14px; border-left: 2px solid #e5e7eb; }
.entry.open .run-list { display: block; }
.run-row { padding: 8px 0; color: #4b5563; font-size: 0.94rem; }
.rank { font-weight: 900; font-size: 1.05rem; color: #6b7280; }
.name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-line { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-count { color: #6b7280; font-weight: 600; }
.toggle { width: 22px; height: 22px; border: 1px solid #d1d5db; border-radius: 999px; background: #fff; color: #374151; cursor: pointer; line-height: 18px; padding: 0; font-weight: 900; }
.toggle:hover { background: #f9fafb; }
.toggle-spacer { display: inline-block; width: 22px; }
.bar-wrap { height: 14px; border-radius: 999px; overflow: hidden; background: #eef2f7; }
.bar { height: 100%; border-radius: inherit; width: 0; min-width: 3px; transition: width 0.7s ease; }
.score, .loss { text-align: right; font-variant-numeric: tabular-nums; font-weight: 900; }
.loss { color: #4b5563; font-weight: 700; }
.muted { color: #6b7280; }
@media (max-width: 900px) {
.boards { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
.row { grid-template-columns: 38px 1fr 70px; }
.bar-wrap, .loss { grid-column: 2 / 4; }
.run-list { margin-left: 38px; }
}
</style>
</head>
<body>
<main>
<section class="hero">
<h1><a href="https://github.com/TUES-AI/word2vec">Word2Vec Leaderboard</a></h1>
<p>Two boards: CBOW predicts the center word from context; Skip-gram predicts context from the center word.</p>
<div id="status" class="status"><span class="dot"></span><span>Loading leaderboard...</span></div>
</section>
<section class="boards">
<div class="panel">
<h2>CBOW</h2>
<div id="cbow-board" class="board"><p class="muted">Loading...</p></div>
</div>
<div class="panel">
<h2>Skip-gram</h2>
<div id="skipgram-board" class="board"><p class="muted">Loading...</p></div>
</div>
</section>
</main>
<script>
const statusEl = document.getElementById("status");
const boards = {
cbow: document.getElementById("cbow-board"),
skipgram: document.getElementById("skipgram-board"),
};
function setStatus(kind, text) {
statusEl.className = "status " + kind;
statusEl.querySelector("span:last-child").textContent = text;
}
function fallbackGradient(name) {
let hash = 0;
for (let i = 0; i < name.length; i++) hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
const hue = Math.abs(hash) % 360;
return `linear-gradient(90deg, hsl(${hue}, 75%, 52%), hsl(${(hue + 42) % 360}, 75%, 62%))`;
}
function escapeHtml(value) {
return String(value).replace(/[&<>'"]/g, char => ({"&":"&","<":"<",">":">","'":"'","\"":"""}[char]));
}
function rowHtml(row, index, isRun=false) {
const rank = isRun ? (row.run_rank || index + 1) : (row.rank || index + 1);
const rankText = isRun ? `${rank}.` : `#${rank}`;
const percent = Math.max(0, Math.min(100, row.accuracy * 100));
const barPercent = Math.max(3, percent);
const safeName = escapeHtml(row.name);
const loss = Number.isFinite(row.loss) ? row.loss.toFixed(3) : "—";
const hasRuns = !isRun && row.runs && row.runs.length;
const toggle = hasRuns ? `<button class="toggle" type="button" aria-label="show runs">▸</button>` : `<span class="toggle-spacer"></span>`;
const runCount = hasRuns ? `<span class="run-count">(${row.runs.length} runs)</span>` : "";
return `
<div class="row ${isRun ? "run-row" : ""}">
<div class="rank">${rankText}</div>
<div class="name" title="${safeName}">
<span class="name-line">${toggle}<span class="name-text">${safeName}</span>${runCount}</span>
</div>
<div class="bar-wrap"><div class="bar" style="width:${barPercent.toFixed(2)}%; background:${row.gradient || fallbackGradient(row.name)}"></div></div>
<div class="score">${percent.toFixed(2)}%</div>
<div class="loss">${loss}</div>
</div>`;
}
function renderBoard(model, rows) {
if (!rows || !rows.length) {
boards[model].innerHTML = `<p class="muted">No submissions yet.</p>`;
return;
}
boards[model].innerHTML = rows.map((row, index) => {
const runList = row.runs && row.runs.length
? `<div class="run-list">${row.runs.map((run, runIndex) => rowHtml(run, runIndex, true)).join("")}</div>`
: "";
return `<div class="entry">${rowHtml(row, index)}${runList}</div>`;
}).join("");
boards[model].querySelectorAll(".toggle").forEach(button => {
button.addEventListener("click", () => {
const entry = button.closest(".entry");
const opened = entry.classList.toggle("open");
button.textContent = opened ? "▾" : "▸";
button.setAttribute("aria-label", opened ? "hide runs" : "show runs");
});
});
}
function render(data) {
const grouped = data.leaderboards || data;
renderBoard("cbow", grouped.cbow || []);
renderBoard("skipgram", grouped.skipgram || []);
}
async function main() {
const current = await fetch("server-url/current.txt?ts=" + Date.now(), {cache: "no-store"}).then(r => r.text());
const serverUrl = current.trim();
if (!serverUrl) {
setStatus("offline", "Backend is sleeping");
boards.cbow.innerHTML = `<p class="muted">Run the backend tunnel to show live results here.</p>`;
boards.skipgram.innerHTML = `<p class="muted">Run the backend tunnel to show live results here.</p>`;
return;
}
setStatus("online", "Backend online");
const data = await fetch(serverUrl + "/api/leaderboard?ts=" + Date.now(), {cache: "no-store"}).then(r => r.json());
render(data);
}
main().catch(error => {
setStatus("error", "Could not load leaderboard");
boards.cbow.innerHTML = `<p class="muted">${escapeHtml(error.message)}</p>`;
boards.skipgram.innerHTML = `<p class="muted">${escapeHtml(error.message)}</p>`;
});
</script>
</body>
</html>