Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,542 +1,229 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
-
# Removed Hugging Face Hub imports as they are not needed for the simplified leaderboard
|
6 |
|
7 |
-
# ---
|
8 |
-
# Option 1: If src is a directory in the same folder as your script:
|
9 |
try:
|
10 |
from src.about import (
|
11 |
CITATION_BUTTON_LABEL,
|
12 |
CITATION_BUTTON_TEXT,
|
13 |
-
EVALUATION_QUEUE_TEXT,
|
14 |
INTRODUCTION_TEXT,
|
15 |
LLM_BENCHMARKS_TEXT,
|
16 |
-
TITLE
|
17 |
)
|
18 |
-
from src.display.css_html_js import custom_css
|
19 |
-
from src.envs import REPO_ID
|
20 |
-
from src.submission.submit import add_new_eval
|
21 |
print("Successfully imported from src module.")
|
22 |
-
# Start with original CSS if available
|
23 |
-
custom_css = original_css if isinstance(original_css, str) else ""
|
24 |
-
# Use original title if available, otherwise create a default
|
25 |
-
TITLE = ORIGINAL_TITLE if isinstance(ORIGINAL_TITLE, str) else "<h1>π MLE-Dojo Benchmark Leaderboard</h1>"
|
26 |
-
|
27 |
-
# Option 2: If you don't have these files, define placeholders (REMOVE THIS if using Option 1)
|
28 |
except ImportError:
|
29 |
print("Warning: Using placeholder values because src module imports failed.")
|
30 |
-
CITATION_BUTTON_LABEL="Citation"
|
31 |
-
CITATION_BUTTON_TEXT="Please cite us if you use this benchmark..."
|
32 |
-
EVALUATION_QUEUE_TEXT="Current evaluation queue:"
|
33 |
-
INTRODUCTION_TEXT="Welcome to the
|
34 |
-
LLM_BENCHMARKS_TEXT=""
|
35 |
-
|
36 |
-
|
37 |
-
This leaderboard tracks model performance using Elo ratings across several key areas:
|
38 |
-
|
39 |
-
* **Overall:** A combined score reflecting performance across all categories.
|
40 |
-
* **MLE-Lite:** Benchmarks focusing on lightweight machine learning engineering tasks.
|
41 |
-
* **Tabular:** Performance on tasks involving structured, tabular data.
|
42 |
-
* **NLP:** Natural Language Processing capabilities.
|
43 |
-
* **CV:** Computer Vision tasks.
|
44 |
-
|
45 |
-
Models are ranked based on their Elo score within each category. Higher scores indicate better relative performance. Click on a model name to visit its associated page (if available).
|
46 |
-
"""
|
47 |
-
# Define an enhanced TITLE with an icon
|
48 |
-
TITLE = """
|
49 |
-
<div style="display: flex; align-items: center; justify-content: center; margin-bottom: 20px;">
|
50 |
-
<span style="font-size: 2.5em; margin-right: 15px;">π</span>
|
51 |
-
<h1 style="font-size: 2.8em; font-weight: 600; color: #333; margin: 0; line-height: 1.2;">
|
52 |
-
MLE-Dojo Benchmark Leaderboard
|
53 |
-
</h1>
|
54 |
-
</div>
|
55 |
-
"""
|
56 |
-
custom_css="" # Start with empty CSS if not imported
|
57 |
-
REPO_ID="your/space-id" # Replace with actual ID if needed
|
58 |
def add_new_eval(*args): return "Submission placeholder."
|
59 |
-
# --- End Placeholder Definitions ---
|
60 |
-
|
61 |
|
62 |
-
# --- Elo
|
63 |
-
# Enhanced data with Rank (placeholder), Organizer, License, and URL
|
64 |
data = [
|
65 |
-
{'model_name': 'gpt-4o-mini',
|
66 |
-
{'model_name': 'gpt-4o',
|
67 |
-
{'model_name': 'o3-mini',
|
68 |
-
{'model_name': 'deepseek-v3',
|
69 |
-
{'model_name': 'deepseek-r1',
|
70 |
-
{'model_name': 'gemini-2.0-flash',
|
71 |
-
{'model_name': 'gemini-2.0-pro', 'url': 'https://blog.google/technology/google-deepmind/gemini-model-updates-february-2025/', 'organizer': 'Google', 'license': 'Proprietary', 'MLE-Lite_Elo': 1064, 'Tabular_Elo': 1139, 'NLP_Elo': 1028, 'CV_Elo': 973,
|
72 |
-
{'model_name': 'gemini-2.5-pro', 'url': 'https://deepmind.google/technologies/gemini/pro/',
|
73 |
]
|
74 |
-
|
75 |
-
# Create a master DataFrame
|
76 |
master_df = pd.DataFrame(data)
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
DEFAULT_CATEGORY = "π Overall" # Set a default category
|
81 |
-
|
82 |
-
# Map user-facing categories (WITHOUT emojis) to DataFrame column names
|
83 |
category_to_column = {
|
84 |
-
"Overall": "Overall",
|
85 |
-
"MLE-Lite": "MLE-Lite_Elo",
|
86 |
-
"Tabular": "Tabular_Elo",
|
87 |
-
"NLP": "NLP_Elo",
|
88 |
-
"CV": "CV_Elo",
|
89 |
}
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
adds Rank, formats model name as a link, and returns the DataFrame.
|
96 |
-
Handles category names with emojis.
|
97 |
-
"""
|
98 |
-
# Extract the base category name by removing the emoji and leading space
|
99 |
-
base_category = category_with_emoji.split(" ", 1)[-1]
|
100 |
-
score_column = category_to_column.get(base_category)
|
101 |
-
|
102 |
-
if score_column is None or score_column not in master_df.columns:
|
103 |
-
print(f"Warning: Invalid category '{base_category}' or column '{score_column}'. Falling back to default.")
|
104 |
-
default_base_category = DEFAULT_CATEGORY.split(" ", 1)[-1]
|
105 |
-
score_column = category_to_column[default_base_category]
|
106 |
-
# Check fallback column too
|
107 |
-
if score_column not in master_df.columns:
|
108 |
-
print(f"Error: Default column '{score_column}' also not found.")
|
109 |
-
# Return empty df with correct columns
|
110 |
-
return pd.DataFrame({
|
111 |
-
"Rank": [],
|
112 |
-
"Model": [],
|
113 |
-
"Elo Score": [],
|
114 |
-
"Organizer": [],
|
115 |
-
"License": []
|
116 |
-
})
|
117 |
-
|
118 |
-
# Select base columns + the score column for sorting
|
119 |
-
cols_to_select = ['model_name', 'url', 'organizer', 'license', score_column]
|
120 |
-
df = master_df[cols_to_select].copy()
|
121 |
-
|
122 |
-
# Sort by the selected 'Elo Score' descending
|
123 |
-
df.sort_values(by=score_column, ascending=False, inplace=True)
|
124 |
-
|
125 |
-
# Add Rank based on the sorted order
|
126 |
df.reset_index(drop=True, inplace=True)
|
127 |
-
df.insert(0, 'Rank', df.index
|
128 |
-
|
129 |
-
# Format Model Name as HTML Hyperlink with improved styling
|
130 |
df['Model'] = df.apply(
|
131 |
-
lambda
|
132 |
-
f"style='color: #0056b3; text-decoration: none; font-weight: 500;'>"
|
133 |
-
f"{row['model_name']}</a>",
|
134 |
axis=1
|
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 |
-
# Replace with your actual space restart mechanism if needed (e.g., HfApi().restart_space(REPO_ID))
|
163 |
-
|
164 |
-
|
165 |
-
# --- Enhanced CSS ---
|
166 |
-
enhanced_css = """
|
167 |
-
/* --- Overall Body and Font --- */
|
168 |
-
body, .gradio-container {
|
169 |
-
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; /* Modern Font Stack */
|
170 |
-
font-size: 16px !important; /* Base font size */
|
171 |
-
color: #212529; /* Slightly darker base text for better contrast on lighter bg */
|
172 |
-
background-color: #f8f9fa; /* Light gray page background */
|
173 |
-
line-height: 1.6;
|
174 |
-
}
|
175 |
-
|
176 |
-
/* --- Headings --- */
|
177 |
-
h1, .markdown-text h1 {
|
178 |
-
font-size: 2.6em !important;
|
179 |
-
font-weight: 700 !important;
|
180 |
-
color: #212529;
|
181 |
-
margin-bottom: 0.7em !important;
|
182 |
-
line-height: 1.3 !important;
|
183 |
text-align: center;
|
|
|
184 |
}
|
185 |
-
|
186 |
-
|
187 |
-
font-
|
188 |
-
|
189 |
-
margin-top: 1.5em !important;
|
190 |
-
margin-bottom: 0.8em !important;
|
191 |
-
border-bottom: 2px solid #dee2e6;
|
192 |
-
padding-bottom: 0.3em;
|
193 |
-
}
|
194 |
-
h3, .markdown-text h3 {
|
195 |
-
font-size: 1.4em !important;
|
196 |
-
font-weight: 600 !important;
|
197 |
-
color: #495057;
|
198 |
-
margin-top: 1.2em !important;
|
199 |
-
margin-bottom: 0.6em !important;
|
200 |
-
}
|
201 |
-
|
202 |
-
/* --- Markdown & Text --- */
|
203 |
-
.markdown-text p {
|
204 |
-
margin-bottom: 1.2em !important;
|
205 |
-
font-size: 1.05em !important;
|
206 |
-
color: #343a40; /* Darker paragraph text */
|
207 |
-
}
|
208 |
-
.markdown-text ul, .markdown-text ol {
|
209 |
-
padding-left: 1.8em !important;
|
210 |
-
margin-bottom: 1.2em !important;
|
211 |
-
font-size: 1.05em !important;
|
212 |
-
}
|
213 |
-
.markdown-text li {
|
214 |
-
margin-bottom: 0.6em !important;
|
215 |
-
}
|
216 |
-
.markdown-text strong {
|
217 |
-
font-weight: 600;
|
218 |
-
color: #0056b3;
|
219 |
-
}
|
220 |
-
.markdown-text a {
|
221 |
-
color: #0056b3;
|
222 |
-
text-decoration: none;
|
223 |
-
}
|
224 |
-
.markdown-text a:hover {
|
225 |
-
text-decoration: underline;
|
226 |
}
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
padding: 30px !important; /* Increased padding */
|
233 |
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07); /* Slightly adjusted shadow */
|
234 |
-
border-radius: 12px !important; /* Rounded corners */
|
235 |
-
background-color: #fafafa !important; /* Slightly off-white background */
|
236 |
-
border: 1px solid #e9ecef; /* Subtle border */
|
237 |
}
|
238 |
|
239 |
-
/*
|
240 |
.tab-buttons button {
|
241 |
-
|
242 |
-
padding:
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
transition: background-color 0.3s ease, color 0.3s ease;
|
250 |
-
}
|
251 |
-
.tab-buttons button.selected {
|
252 |
-
background-color: #fafafa !important; /* Match container background */
|
253 |
-
color: #0056b3 !important;
|
254 |
-
font-weight: 600 !important;
|
255 |
-
border-color: #dee2e6 #dee2e6 #fafafa !important; /* Hide bottom border */
|
256 |
-
position: relative;
|
257 |
-
top: 1px;
|
258 |
-
}
|
259 |
-
|
260 |
-
/* --- Radio Buttons (Category Selector) --- */
|
261 |
-
#category-selector-radio .gr-form {
|
262 |
-
display: flex;
|
263 |
-
flex-wrap: wrap;
|
264 |
-
gap: 12px;
|
265 |
-
border: 1px solid #ced4da;
|
266 |
-
padding: 15px;
|
267 |
-
border-radius: 8px;
|
268 |
-
background-color: #f1f3f5; /* Match default tab background */
|
269 |
-
margin-bottom: 25px; /* Increased margin */
|
270 |
-
}
|
271 |
-
#category-selector-radio .gr-form .gr-input-label {
|
272 |
-
display: none;
|
273 |
-
}
|
274 |
-
#category-selector-radio .gr-form > div {
|
275 |
-
flex-grow: 1;
|
276 |
-
min-width: 150px;
|
277 |
-
}
|
278 |
-
#category-selector-radio .gr-form label {
|
279 |
-
display: block;
|
280 |
-
padding: 10px 15px;
|
281 |
-
border: 1px solid #ced4da;
|
282 |
-
border-radius: 6px;
|
283 |
-
background-color: #ffffff; /* White buttons */
|
284 |
-
cursor: pointer;
|
285 |
-
text-align: center;
|
286 |
-
transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
|
287 |
-
font-size: 1.05em;
|
288 |
-
}
|
289 |
-
#category-selector-radio .gr-form input[type="radio"] {
|
290 |
-
display: none;
|
291 |
-
}
|
292 |
-
#category-selector-radio .gr-form input[type="radio"]:checked + label {
|
293 |
-
background-color: #0056b3;
|
294 |
-
color: #ffffff;
|
295 |
-
border-color: #004494;
|
296 |
-
font-weight: 600;
|
297 |
}
|
298 |
-
|
299 |
-
background
|
300 |
-
border-color: #adb5bd;
|
301 |
}
|
302 |
-
|
303 |
-
background
|
|
|
304 |
}
|
305 |
|
306 |
-
|
307 |
-
|
308 |
-
#
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
|
|
|
|
|
|
314 |
}
|
315 |
-
#
|
316 |
-
|
317 |
-
|
318 |
}
|
319 |
|
320 |
-
|
|
|
321 |
width: 100%;
|
322 |
-
border
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
border: none !important;
|
328 |
-
border-bottom: 1px solid #e9ecef !important;
|
329 |
-
text-align: left;
|
330 |
-
vertical-align: middle;
|
331 |
-
font-size: 1.1em !important; /* <<< Increased leaderboard font size */
|
332 |
-
white-space: normal;
|
333 |
-
/* Removed fixed widths */
|
334 |
-
}
|
335 |
-
#leaderboard-table th {
|
336 |
-
background-color: #f1f3f5 !important; /* Match other subtle backgrounds */
|
337 |
-
font-weight: 600 !important;
|
338 |
-
color: #343a40; /* Darker header text */
|
339 |
-
font-size: 1.15em !important; /* Slightly larger header font */
|
340 |
-
border-bottom-width: 2px !important;
|
341 |
-
border-color: #dee2e6 !important;
|
342 |
-
white-space: nowrap; /* Prevent header text wrapping */
|
343 |
-
}
|
344 |
-
#leaderboard-table tr:last-child td {
|
345 |
-
border-bottom: none !important;
|
346 |
}
|
347 |
-
|
348 |
-
background
|
|
|
349 |
}
|
350 |
-
|
351 |
-
|
352 |
}
|
353 |
-
|
354 |
-
|
|
|
|
|
355 |
text-decoration: none;
|
356 |
-
font-weight: 500;
|
357 |
}
|
358 |
-
|
|
|
359 |
text-decoration: underline;
|
360 |
-
color: #003d80;
|
361 |
-
}
|
362 |
-
#leaderboard-table td:first-child, /* Rank column */
|
363 |
-
#leaderboard-table th:first-child {
|
364 |
-
text-align: center;
|
365 |
-
font-weight: 600;
|
366 |
-
/* width: auto; Let browser decide width */
|
367 |
-
}
|
368 |
-
#leaderboard-table td:last-child, /* Elo Score column */
|
369 |
-
#leaderboard-table th:last-child {
|
370 |
-
text-align: right;
|
371 |
-
font-weight: 600;
|
372 |
-
white-space: nowrap; /* Prevent Elo score wrapping */
|
373 |
-
/* width: auto; Let browser decide width */
|
374 |
-
}
|
375 |
-
|
376 |
-
/* --- Accordion --- */
|
377 |
-
.gradio-accordion {
|
378 |
-
border: 1px solid #dee2e6 !important;
|
379 |
-
border-radius: 8px !important;
|
380 |
-
margin-bottom: 15px !important;
|
381 |
-
overflow: hidden;
|
382 |
-
background-color: #ffffff; /* White background for accordion content area */
|
383 |
-
}
|
384 |
-
.gradio-accordion > button,
|
385 |
-
.gradio-accordion > .gr-panel > button {
|
386 |
-
background-color: #f1f3f5 !important;
|
387 |
-
border: none !important;
|
388 |
-
border-bottom: 1px solid #dee2e6 !important;
|
389 |
-
padding: 12px 18px !important;
|
390 |
-
font-size: 1.1em !important;
|
391 |
-
font-weight: 600 !important;
|
392 |
-
color: #343a40 !important;
|
393 |
-
width: 100%;
|
394 |
-
text-align: left;
|
395 |
-
cursor: pointer;
|
396 |
-
}
|
397 |
-
.gradio-accordion > button[open] { /* Style when accordion is open */
|
398 |
-
border-bottom: 1px solid #dee2e6 !important;
|
399 |
-
}
|
400 |
-
.gradio-accordion > button:hover,
|
401 |
-
.gradio-accordion > .gr-panel > button:hover {
|
402 |
-
background-color: #e9ecef !important;
|
403 |
-
}
|
404 |
-
.gradio-accordion > div { /* Accordion content */
|
405 |
-
padding: 15px 18px !important;
|
406 |
-
background-color: #ffffff; /* Ensure content background is white */
|
407 |
}
|
408 |
-
#citation-button textarea {
|
409 |
-
font-family: 'Courier New', Courier, monospace;
|
410 |
-
font-size: 0.95em !important;
|
411 |
-
background-color: #f1f3f5; /* Match other subtle backgrounds */
|
412 |
-
border-radius: 6px;
|
413 |
-
padding: 12px;
|
414 |
-
border: 1px solid #dee2e6; /* Add border */
|
415 |
-
}
|
416 |
-
#citation-button label {
|
417 |
-
font-weight: 600;
|
418 |
-
color: #343a40;
|
419 |
-
}
|
420 |
-
|
421 |
-
/* --- Buttons (General / Submit) --- */
|
422 |
-
.gr-button {
|
423 |
-
font-size: 1.05em !important;
|
424 |
-
padding: 10px 20px !important;
|
425 |
-
border-radius: 6px !important;
|
426 |
-
font-weight: 500 !important;
|
427 |
-
transition: background-color 0.2s ease, border-color 0.2s ease;
|
428 |
-
}
|
429 |
-
/* Style specific buttons if needed */
|
430 |
-
#submit_button { /* Example if you add an ID to the submit button */
|
431 |
-
background-color: #0069d9 !important;
|
432 |
-
color: white !important;
|
433 |
-
border: none !important;
|
434 |
-
}
|
435 |
-
#submit_button:hover {
|
436 |
-
background-color: #0056b3 !important;
|
437 |
-
}
|
438 |
-
|
439 |
-
/* --- Textbox / Dropdown --- */
|
440 |
-
.gr-input, .gr-dropdown, .gr-textbox textarea {
|
441 |
-
font-size: 1em !important;
|
442 |
-
border-radius: 6px !important;
|
443 |
-
border: 1px solid #ced4da !important;
|
444 |
-
padding: 10px 12px !important;
|
445 |
-
background-color: #ffffff; /* Ensure inputs have white background */
|
446 |
-
}
|
447 |
-
.gr-input:focus, .gr-dropdown:focus, .gr-textbox textarea:focus {
|
448 |
-
border-color: #80bdff !important;
|
449 |
-
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
|
450 |
-
}
|
451 |
-
.gr-input-label > span, /* Label text */
|
452 |
-
.gr-checkbox-label > span {
|
453 |
-
font-size: 1em !important;
|
454 |
-
font-weight: 500 !important;
|
455 |
-
color: #495057 !important;
|
456 |
-
margin-bottom: 5px !important;
|
457 |
-
}
|
458 |
-
|
459 |
"""
|
460 |
-
|
461 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
|
463 |
-
#
|
464 |
-
demo = gr.Blocks(css=
|
465 |
-
primary_hue=gr.themes.colors.blue,
|
466 |
-
secondary_hue=gr.themes.colors.sky,
|
467 |
-
neutral_hue=gr.themes.colors.gray,
|
468 |
-
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
469 |
-
radius_size=gr.themes.sizes.radius_md,
|
470 |
-
))
|
471 |
|
472 |
with demo:
|
473 |
gr.HTML(TITLE)
|
474 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
475 |
|
476 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
477 |
-
with gr.TabItem("
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
# --- Submit Tab (Commented out) ---
|
508 |
-
# with gr.TabItem("π Submit Model", elem_id="llm-benchmark-tab-submit", id=2):
|
509 |
-
# ... (Submit tab code remains the same) ...
|
510 |
-
|
511 |
-
with gr.Accordion("π Citation", open=False, elem_classes="gradio-accordion"):
|
512 |
-
citation_button = gr.Textbox(
|
513 |
value=CITATION_BUTTON_TEXT,
|
514 |
label=CITATION_BUTTON_LABEL,
|
515 |
-
lines=
|
516 |
elem_id="citation-button",
|
517 |
-
show_copy_button=True
|
518 |
)
|
519 |
|
520 |
-
# --- Scheduler ---
|
521 |
if __name__ == "__main__":
|
|
|
522 |
try:
|
523 |
-
|
524 |
-
if callable(restart_space) and REPO_ID and REPO_ID != "your/space-id":
|
525 |
-
print(f"Scheduling space restart for {REPO_ID} every 30 minutes.")
|
526 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
527 |
-
scheduler.start()
|
528 |
-
else:
|
529 |
-
# Print appropriate warnings
|
530 |
-
if not callable(restart_space):
|
531 |
-
print("Warning: restart_space function not available; space restart job not scheduled.")
|
532 |
-
if not REPO_ID or REPO_ID == "your/space-id":
|
533 |
-
print("Warning: REPO_ID not set or is placeholder; space restart job not scheduled.")
|
534 |
except Exception as e:
|
535 |
-
print(f"
|
536 |
-
|
537 |
-
|
538 |
-
# --- Launch the app ---
|
539 |
-
if __name__ == "__main__":
|
540 |
-
print("Launching Gradio App...")
|
541 |
-
# Use share=True if you need a public link for testing on different devices/networks
|
542 |
-
demo.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
4 |
|
5 |
+
# --- Placeholder Imports / Definitions ---
|
|
|
6 |
try:
|
7 |
from src.about import (
|
8 |
CITATION_BUTTON_LABEL,
|
9 |
CITATION_BUTTON_TEXT,
|
10 |
+
EVALUATION_QUEUE_TEXT,
|
11 |
INTRODUCTION_TEXT,
|
12 |
LLM_BENCHMARKS_TEXT,
|
13 |
+
TITLE, # We will override TITLE below for styling
|
14 |
)
|
15 |
+
from src.display.css_html_js import custom_css
|
16 |
+
from src.envs import REPO_ID
|
17 |
+
from src.submission.submit import add_new_eval
|
18 |
print("Successfully imported from src module.")
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
except ImportError:
|
20 |
print("Warning: Using placeholder values because src module imports failed.")
|
21 |
+
CITATION_BUTTON_LABEL = "Citation"
|
22 |
+
CITATION_BUTTON_TEXT = "Please cite us if you use this benchmark..."
|
23 |
+
EVALUATION_QUEUE_TEXT = "Current evaluation queue:"
|
24 |
+
INTRODUCTION_TEXT = "Welcome to the MLE-Dojo Benchmark Leaderboard."
|
25 |
+
LLM_BENCHMARKS_TEXT = "Information about the benchmarks..."
|
26 |
+
custom_css = ""
|
27 |
+
REPO_ID = "your/space-id"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def add_new_eval(*args): return "Submission placeholder."
|
|
|
|
|
29 |
|
30 |
+
# --- Elo Data ---
|
|
|
31 |
data = [
|
32 |
+
{'model_name': 'gpt-4o-mini', 'url': 'https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 753, 'Tabular_Elo': 839, 'NLP_Elo': 758, 'CV_Elo': 754, 'Overall': 778},
|
33 |
+
{'model_name': 'gpt-4o', 'url': 'https://openai.com/index/hello-gpt-4o/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 830, 'Tabular_Elo': 861, 'NLP_Elo': 903, 'CV_Elo': 761, 'Overall': 841},
|
34 |
+
{'model_name': 'o3-mini', 'url': 'https://openai.com/index/openai-o3-mini/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 1108, 'Tabular_Elo': 1019, 'NLP_Elo': 1056, 'CV_Elo': 1207, 'Overall': 1096},
|
35 |
+
{'model_name': 'deepseek-v3', 'url': 'https://api-docs.deepseek.com/news/news1226', 'organizer': 'DeepSeek','license': 'DeepSeek', 'MLE-Lite_Elo': 1004, 'Tabular_Elo': 1015, 'NLP_Elo': 1028, 'CV_Elo': 1067, 'Overall': 1023},
|
36 |
+
{'model_name': 'deepseek-r1', 'url': 'https://api-docs.deepseek.com/news/news250120', 'organizer': 'DeepSeek','license': 'DeepSeek', 'MLE-Lite_Elo': 1137, 'Tabular_Elo': 1053, 'NLP_Elo': 1103, 'CV_Elo': 1083, 'Overall': 1100},
|
37 |
+
{'model_name': 'gemini-2.0-flash','url': 'https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash', 'organizer': 'Google', 'license': 'Proprietary', 'MLE-Lite_Elo': 847, 'Tabular_Elo': 923, 'NLP_Elo': 860, 'CV_Elo': 978, 'Overall': 895},
|
38 |
+
{'model_name': 'gemini-2.0-pro', 'url': 'https://blog.google/technology/google-deepmind/gemini-model-updates-february-2025/', 'organizer': 'Google', 'license': 'Proprietary', 'MLE-Lite_Elo': 1064, 'Tabular_Elo': 1139, 'NLP_Elo': 1028, 'CV_Elo': 973, 'Overall': 1054},
|
39 |
+
{'model_name': 'gemini-2.5-pro', 'url': 'https://deepmind.google/technologies/gemini/pro/', 'organizer': 'Google', 'license': 'Proprietary', 'MLE-Lite_Elo': 1257, 'Tabular_Elo': 1150, 'NLP_Elo': 1266, 'CV_Elo': 1177, 'Overall': 1214},
|
40 |
]
|
|
|
|
|
41 |
master_df = pd.DataFrame(data)
|
42 |
|
43 |
+
CATEGORIES = ["Overall", "MLE-Lite", "Tabular", "NLP", "CV"]
|
44 |
+
DEFAULT_CATEGORY = "Overall"
|
|
|
|
|
|
|
45 |
category_to_column = {
|
46 |
+
"Overall": "Overall",
|
47 |
+
"MLE-Lite": "MLE-Lite_Elo",
|
48 |
+
"Tabular": "Tabular_Elo",
|
49 |
+
"NLP": "NLP_Elo",
|
50 |
+
"CV": "CV_Elo",
|
51 |
}
|
52 |
|
53 |
+
def update_leaderboard(category):
|
54 |
+
col = category_to_column.get(category, category_to_column[DEFAULT_CATEGORY])
|
55 |
+
df = master_df[['model_name','url','organizer','license',col]].copy()
|
56 |
+
df.sort_values(by=col, ascending=False, inplace=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
df.reset_index(drop=True, inplace=True)
|
58 |
+
df.insert(0, 'Rank', df.index+1)
|
|
|
|
|
59 |
df['Model'] = df.apply(
|
60 |
+
lambda r: f"<a href='{r['url']}' target='_blank'>{r['model_name']}</a>",
|
|
|
|
|
61 |
axis=1
|
62 |
)
|
63 |
+
df.rename(columns={col:'Elo Score','organizer':'Organizer','license':'License'}, inplace=True)
|
64 |
+
return df[['Rank','Model','Organizer','License','Elo Score']]
|
65 |
|
66 |
+
# --- Advanced Styling ---
|
67 |
+
# Base font-size bump (if any)
|
68 |
+
font_size_css = """
|
69 |
+
body { font-size: 1em !important; }
|
70 |
+
"""
|
71 |
+
custom_css += font_size_css
|
72 |
+
|
73 |
+
# Import fonts & icons + component styling
|
74 |
+
advanced_css = """
|
75 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
76 |
+
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
|
77 |
+
|
78 |
+
body {
|
79 |
+
font-family: 'Inter', sans-serif;
|
80 |
+
background-color: #f8f9fa;
|
81 |
+
color: #333;
|
82 |
+
}
|
83 |
+
|
84 |
+
/* Hero Section */
|
85 |
+
.hero-section {
|
86 |
+
background: linear-gradient(135deg, #6c63ff, #8f94fb);
|
87 |
+
color: #fff;
|
88 |
+
padding: 2rem 1rem;
|
89 |
+
border-radius: .75rem;
|
90 |
+
margin-bottom: 1.5rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
text-align: center;
|
92 |
+
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
93 |
}
|
94 |
+
.hero-section h1 {
|
95 |
+
margin: 0;
|
96 |
+
font-size: 2.5rem !important;
|
97 |
+
font-weight: 700 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
+
.hero-section h2 {
|
100 |
+
margin: .5rem 0 0 !important;
|
101 |
+
font-size: 1.25rem !important;
|
102 |
+
font-weight: 400 !important;
|
103 |
+
opacity: 0.9;
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
+
/* Tab Buttons */
|
107 |
.tab-buttons button {
|
108 |
+
border-radius: 20px !important;
|
109 |
+
padding: 0.5rem 1rem !important;
|
110 |
+
margin-right: 0.5rem !important;
|
111 |
+
background: #e0e0e0 !important;
|
112 |
+
color: #333 !important;
|
113 |
+
border: none !important;
|
114 |
+
transition: background 0.3s !important;
|
115 |
+
font-weight: 500 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
+
.tab-buttons button:hover {
|
118 |
+
background: #d0d0d0 !important;
|
|
|
119 |
}
|
120 |
+
.tab-buttons button[aria-selected="true"] {
|
121 |
+
background: #6c63ff !important;
|
122 |
+
color: #fff !important;
|
123 |
}
|
124 |
|
125 |
+
/* Category Selector Pills */
|
126 |
+
#category-selector input[type="radio"] { display: none; }
|
127 |
+
#category-selector label {
|
128 |
+
display: inline-block;
|
129 |
+
padding: 0.5rem 1rem;
|
130 |
+
margin-right: 0.5rem;
|
131 |
+
border-radius: 999px;
|
132 |
+
background: #e0e0e0;
|
133 |
+
cursor: pointer;
|
134 |
+
transition: background 0.3s, color 0.3s;
|
135 |
+
font-weight: 500;
|
136 |
}
|
137 |
+
#category-selector input[type="radio"]:checked + label {
|
138 |
+
background: #6c63ff;
|
139 |
+
color: #fff;
|
140 |
}
|
141 |
|
142 |
+
/* Table Styling */
|
143 |
+
table {
|
144 |
width: 100%;
|
145 |
+
border: none;
|
146 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
147 |
+
border-radius: 0.5rem;
|
148 |
+
overflow: hidden;
|
149 |
+
margin: 1rem 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
+
th {
|
152 |
+
background: #6c63ff;
|
153 |
+
color: #fff;
|
154 |
}
|
155 |
+
td, th {
|
156 |
+
padding: 0.75rem 1rem;
|
157 |
}
|
158 |
+
tr:nth-child(even) { background: #f7f5ff; }
|
159 |
+
tr:hover { background: #edeaff; }
|
160 |
+
td a {
|
161 |
+
color: #6c63ff;
|
162 |
text-decoration: none;
|
|
|
163 |
}
|
164 |
+
td a:hover {
|
165 |
+
color: #534bbe;
|
166 |
text-decoration: underline;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
"""
|
169 |
+
custom_css += advanced_css
|
170 |
+
|
171 |
+
# --- Override Title ---
|
172 |
+
TITLE = """
|
173 |
+
<div class="hero-section">
|
174 |
+
<h1><i class="fas fa-trophy"></i> MLE-Dojo Benchmark Leaderboard</h1>
|
175 |
+
<h2>Improving LLM Agents for Machine Learning Engineering</h2>
|
176 |
+
</div>
|
177 |
+
"""
|
178 |
|
179 |
+
# --- Build App ---
|
180 |
+
demo = gr.Blocks(css=custom_css, theme=gr.themes.Soft())
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
with demo:
|
183 |
gr.HTML(TITLE)
|
184 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
185 |
|
186 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
187 |
+
with gr.TabItem("<i class='fas fa-list'></i> Leaderboard"):
|
188 |
+
gr.Markdown("## Model Elo Rankings by Category")
|
189 |
+
category_selector = gr.Radio(
|
190 |
+
choices=CATEGORIES,
|
191 |
+
label="Select Category:",
|
192 |
+
value=DEFAULT_CATEGORY,
|
193 |
+
interactive=True,
|
194 |
+
elem_id="category-selector"
|
195 |
+
)
|
196 |
+
leaderboard_df = gr.Dataframe(
|
197 |
+
value=update_leaderboard(DEFAULT_CATEGORY),
|
198 |
+
headers=["Rank","Model","Organizer","License","Elo Score"],
|
199 |
+
datatype=["number","html","str","str","number"],
|
200 |
+
interactive=False,
|
201 |
+
row_count=(len(master_df),"fixed"),
|
202 |
+
col_count=(5,"fixed"),
|
203 |
+
wrap=True,
|
204 |
+
elem_id="leaderboard-table"
|
205 |
+
)
|
206 |
+
category_selector.change(
|
207 |
+
fn=update_leaderboard,
|
208 |
+
inputs=category_selector,
|
209 |
+
outputs=leaderboard_df
|
210 |
+
)
|
211 |
+
|
212 |
+
with gr.TabItem("<i class='fas fa-info-circle'></i> About"):
|
213 |
+
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
214 |
+
|
215 |
+
with gr.Accordion("π Citation", open=False):
|
216 |
+
gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
value=CITATION_BUTTON_TEXT,
|
218 |
label=CITATION_BUTTON_LABEL,
|
219 |
+
lines=10,
|
220 |
elem_id="citation-button",
|
221 |
+
show_copy_button=True
|
222 |
)
|
223 |
|
|
|
224 |
if __name__ == "__main__":
|
225 |
+
print("Launching Gradio App...")
|
226 |
try:
|
227 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
except Exception as e:
|
229 |
+
print(f"Error launching app: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|