Reja1 commited on
Commit
87a3703
·
1 Parent(s): 8a86e58

feat: add dark-theme HTML leaderboard template

Browse files

Also fix render_html to serialize YAML-parsed date objects (default=str),
with a regression test.

scripts/generate_leaderboard.py CHANGED
@@ -124,7 +124,8 @@ def render_html(entries: list[dict], template_path: str, generated: str) -> str:
124
  if "__DATA__" not in template:
125
  raise ValueError(f"Template {template_path} missing __DATA__ placeholder")
126
  payload = {"entries": entries, "generated": generated}
127
- json_str = json.dumps(payload, ensure_ascii=False)
 
128
  json_str = json_str.replace("</", "<\\/") # don't break out of <script>
129
  return template.replace("__DATA__", json_str)
130
 
 
124
  if "__DATA__" not in template:
125
  raise ValueError(f"Template {template_path} missing __DATA__ placeholder")
126
  payload = {"entries": entries, "generated": generated}
127
+ # default=str so YAML-parsed dates (datetime.date) and similar serialize cleanly.
128
+ json_str = json.dumps(payload, ensure_ascii=False, default=str)
129
  json_str = json_str.replace("</", "<\\/") # don't break out of <script>
130
  return template.replace("__DATA__", json_str)
131
 
scripts/leaderboard_template.html ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>JEE / NEET LLM Benchmark Leaderboard</title>
7
+ <style>
8
+ :root{--bg:#0d1117;--panel:#161b22;--border:#30363d;--text:#e6edf3;--muted:#8b949e;--accent:#58a6ff;--open:#3fb950;--closed:#f85149;}
9
+ *{box-sizing:border-box;}
10
+ body{margin:0;background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;}
11
+ .wrap{max-width:1000px;margin:0 auto;padding:32px 20px;}
12
+ header h1{margin:0 0 4px;font-size:26px;}
13
+ header p{margin:0;color:var(--muted);}
14
+ .controls{display:flex;gap:12px;margin:24px 0 8px;flex-wrap:wrap;align-items:center;}
15
+ label{font-size:13px;color:var(--muted);}
16
+ select{background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:6px 10px;font-size:14px;margin-left:4px;}
17
+ table{width:100%;border-collapse:collapse;background:var(--panel);border:1px solid var(--border);border-radius:8px;overflow:hidden;}
18
+ th,td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border);}
19
+ th{cursor:pointer;user-select:none;font-size:13px;color:var(--muted);white-space:nowrap;}
20
+ th.num,td.num{text-align:right;}
21
+ tr:last-child td{border-bottom:none;}
22
+ tbody tr:hover{background:#1c2128;}
23
+ .badge{font-size:11px;padding:1px 6px;border-radius:10px;margin-left:6px;vertical-align:middle;}
24
+ .badge.open{background:rgba(63,185,80,.15);color:var(--open);}
25
+ .badge.closed{background:rgba(248,81,73,.15);color:var(--closed);}
26
+ .lab{color:var(--muted);font-size:12px;margin-left:6px;}
27
+ .sup{color:var(--accent);font-size:11px;vertical-align:super;margin-left:2px;}
28
+ .footnotes{margin-top:14px;color:var(--muted);font-size:13px;}
29
+ .footnotes div{margin:2px 0;}
30
+ .caveat{margin-top:12px;padding:10px 12px;background:rgba(210,153,34,.12);border:1px solid rgba(210,153,34,.4);border-radius:6px;color:#d29922;font-size:13px;}
31
+ footer{margin-top:24px;color:var(--muted);font-size:12px;}
32
+ a{color:var(--accent);}
33
+ </style>
34
+ </head>
35
+ <body>
36
+ <div class="wrap">
37
+ <header>
38
+ <h1>JEE / NEET LLM Benchmark</h1>
39
+ <p>Vision LLMs on India's hardest competitive exams</p>
40
+ </header>
41
+ <div class="controls">
42
+ <label>Exam<select id="exam"></select></label>
43
+ <label>Year<select id="year"></select></label>
44
+ <span id="updated" style="color:var(--muted);font-size:13px;margin-left:auto;"></span>
45
+ </div>
46
+ <table>
47
+ <thead><tr>
48
+ <th data-k="rank" class="num">#</th>
49
+ <th data-k="model">Model</th>
50
+ <th data-k="score" class="num">Score</th>
51
+ <th data-k="pct" class="num">%</th>
52
+ <th data-k="correct" class="num">Correct</th>
53
+ <th data-k="partial" class="num">Partial</th>
54
+ <th data-k="incorrect" class="num">Incorrect</th>
55
+ <th data-k="skipped" class="num">Skipped</th>
56
+ <th data-k="failures" class="num">Fail</th>
57
+ </tr></thead>
58
+ <tbody id="rows"></tbody>
59
+ </table>
60
+ <div id="caveat"></div>
61
+ <div class="footnotes" id="footnotes"></div>
62
+ <footer>Data: <a href="https://huggingface.co/datasets/Reja1/jee-neet-benchmark">Reja1/jee-neet-benchmark</a> · <a href="https://x.com/RejaullahmdMd">@RejaullahmdMd</a></footer>
63
+ </div>
64
+ <script id="data" type="application/json">__DATA__</script>
65
+ <script>
66
+ const DATA = JSON.parse(document.getElementById('data').textContent);
67
+ const entries = DATA.entries;
68
+ document.getElementById('updated').textContent = 'updated ' + DATA.generated;
69
+
70
+ function pct(e){ return (e.max_score && e.max_score > 0) ? (e.score / e.max_score * 100) : null; }
71
+ function examLabel(x){ return x.replace('JEE_ADVANCED','JEE Advanced').replace('JEE_MAIN','JEE Main').replace('_',' '); }
72
+
73
+ const exams = [...new Set(entries.map(e => e.exam))].sort();
74
+ let state = {exam:'JEE_ADVANCED', year:'2026', sort:'score', dir:-1};
75
+ if(!exams.includes(state.exam)) state.exam = exams[0];
76
+
77
+ const examSel = document.getElementById('exam');
78
+ const yearSel = document.getElementById('year');
79
+
80
+ function fillExams(){
81
+ examSel.innerHTML = '';
82
+ exams.forEach(x => { const o = document.createElement('option'); o.value = x; o.textContent = examLabel(x); if(x === state.exam) o.selected = true; examSel.appendChild(o); });
83
+ }
84
+ function fillYears(){
85
+ const years = [...new Set(entries.filter(e => e.exam === state.exam).map(e => String(e.year)))].sort().reverse();
86
+ if(!years.includes(state.year)) state.year = years[0];
87
+ yearSel.innerHTML = '';
88
+ years.forEach(y => { const o = document.createElement('option'); o.value = y; o.textContent = y; if(y === state.year) o.selected = true; yearSel.appendChild(o); });
89
+ }
90
+
91
+ function render(){
92
+ let rows = entries.filter(e => e.exam === state.exam && String(e.year) === String(state.year));
93
+ rows.sort((a,b) => {
94
+ if(state.sort === 'model') return state.dir * a.model.localeCompare(b.model);
95
+ let va = state.sort === 'pct' ? (pct(a) ?? -1) : (a[state.sort] ?? 0);
96
+ let vb = state.sort === 'pct' ? (pct(b) ?? -1) : (b[state.sort] ?? 0);
97
+ return state.dir * (va - vb);
98
+ });
99
+
100
+ const fn = []; const fnIndex = {};
101
+ function notesFor(e){
102
+ const m = e.meta || {}; const notes = [];
103
+ if(m.contamination === 'suspect') notes.push('released after exam — contamination not ruled out');
104
+ if(m.quant) notes.push('served at ' + m.quant + ' precision');
105
+ return notes;
106
+ }
107
+
108
+ const tbody = document.getElementById('rows'); tbody.innerHTML = '';
109
+ let rank = 0, shown = 0, prevScore = null;
110
+ rows.forEach(e => {
111
+ shown++;
112
+ if(e.score !== prevScore){ rank = shown; prevScore = e.score; }
113
+ const m = e.meta || {};
114
+ const p = pct(e);
115
+ const sups = notesFor(e).map(n => { if(!(n in fnIndex)){ fn.push(n); fnIndex[n] = fn.length; } return fnIndex[n]; });
116
+ const badge = (m.open_weight === true) ? '<span class="badge open">open</span>'
117
+ : (m.open_weight === false) ? '<span class="badge closed">closed</span>' : '';
118
+ const lab = m.lab ? '<span class="lab">' + m.lab + '</span>' : '';
119
+ const title = [m.license && ('License: ' + m.license), m.release_date && ('Released: ' + m.release_date), m.provider_pinned && ('Provider: ' + m.provider_pinned)].filter(Boolean).join(' · ');
120
+ const sup = sups.length ? '<span class="sup">' + sups.join(',') + '</span>' : '';
121
+ const tr = document.createElement('tr');
122
+ tr.innerHTML =
123
+ '<td class="num">' + rank + '</td>' +
124
+ '<td title="' + title.replace(/"/g,'&quot;') + '">' + e.model + badge + lab + sup + '</td>' +
125
+ '<td class="num">' + e.score + (e.max_score ? (' / ' + e.max_score) : '') + '</td>' +
126
+ '<td class="num">' + (p !== null ? p.toFixed(1) : '?') + '</td>' +
127
+ '<td class="num">' + e.correct + '</td>' +
128
+ '<td class="num">' + e.partial + '</td>' +
129
+ '<td class="num">' + e.incorrect + '</td>' +
130
+ '<td class="num">' + e.skipped + '</td>' +
131
+ '<td class="num">' + e.failures + '</td>';
132
+ tbody.appendChild(tr);
133
+ });
134
+
135
+ let html = '<div>🟢 <span style="color:var(--open)">open</span> = open weights · 🔒 <span style="color:var(--closed)">closed</span></div>';
136
+ fn.forEach((n,i) => { html += '<div><span class="sup">' + (i+1) + '</span> ' + n + '</div>'; });
137
+ document.getElementById('footnotes').innerHTML = html;
138
+
139
+ const cav = document.getElementById('caveat');
140
+ cav.innerHTML = (state.exam === 'JEE_ADVANCED' && String(state.year) === '2025')
141
+ ? '<div class="caveat">Note: JEE Advanced 2025 was scored under an earlier marking scheme and was not rescored — scores here mix schemes.</div>'
142
+ : '';
143
+ }
144
+
145
+ examSel.addEventListener('change', () => { state.exam = examSel.value; fillYears(); render(); });
146
+ yearSel.addEventListener('change', () => { state.year = yearSel.value; render(); });
147
+ document.querySelectorAll('th').forEach(th => {
148
+ th.addEventListener('click', () => {
149
+ const k = th.dataset.k; if(k === 'rank') return;
150
+ if(state.sort === k){ state.dir *= -1; } else { state.sort = k; state.dir = (k === 'model') ? 1 : -1; }
151
+ render();
152
+ });
153
+ });
154
+
155
+ fillExams(); fillYears(); render();
156
+ </script>
157
+ </body>
158
+ </html>
tests/test_leaderboard_html.py CHANGED
@@ -46,3 +46,17 @@ def test_render_html_missing_placeholder_raises(tmp_path):
46
  template.write_text("<html>no placeholder</html>")
47
  with pytest.raises(ValueError):
48
  gl.render_html([], str(template), "2026-06-20")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  template.write_text("<html>no placeholder</html>")
47
  with pytest.raises(ValueError):
48
  gl.render_html([], str(template), "2026-06-20")
49
+
50
+
51
+ def test_render_html_serializes_yaml_date_objects(tmp_path):
52
+ # PyYAML parses unquoted ISO dates into datetime.date, which json can't
53
+ # serialize natively. render_html must handle it.
54
+ import datetime
55
+
56
+ template = tmp_path / "t.html"
57
+ template.write_text('<script id="data">__DATA__</script>')
58
+ entries = [{"model": "a/b", "meta": {"release_date": datetime.date(2025, 9, 22)}}]
59
+ out = gl.render_html(entries, str(template), "2026-06-20")
60
+ start = out.index(">") + 1
61
+ payload = json.loads(out[start:out.index("</script>")])
62
+ assert payload["entries"][0]["meta"]["release_date"] == "2025-09-22"