Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
@@ -60,12 +61,10 @@ Models are ranked based on their Elo score within each category. Higher scores i
|
|
60 |
|
61 |
# --- Elo Leaderboard Configuration ---
|
62 |
# Enhanced data with Rank (placeholder), Organizer, License, and URL
|
63 |
-
# !!! IMPORTANT: Replace placeholder URLs with actual model/project pages. !!!
|
64 |
-
# Verify organizer and license information for accuracy.
|
65 |
data = [
|
66 |
{'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},
|
67 |
{'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},
|
68 |
-
{'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},
|
69 |
{'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},
|
70 |
{'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},
|
71 |
{'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},
|
@@ -169,19 +168,19 @@ enhanced_css = """
|
|
169 |
body, .gradio-container {
|
170 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; /* Modern Font Stack */
|
171 |
font-size: 16px !important; /* Base font size */
|
172 |
-
color: #
|
173 |
-
background-color: #f8f9fa; /* Light background */
|
174 |
line-height: 1.6;
|
175 |
}
|
176 |
|
177 |
/* --- Headings --- */
|
178 |
-
h1, .markdown-text h1 {
|
179 |
-
font-size: 2.6em !important;
|
180 |
font-weight: 700 !important;
|
181 |
color: #212529;
|
182 |
margin-bottom: 0.7em !important;
|
183 |
line-height: 1.3 !important;
|
184 |
-
text-align: center;
|
185 |
}
|
186 |
h2, .markdown-text h2 {
|
187 |
font-size: 1.8em !important;
|
@@ -204,7 +203,7 @@ h3, .markdown-text h3 {
|
|
204 |
.markdown-text p {
|
205 |
margin-bottom: 1.2em !important;
|
206 |
font-size: 1.05em !important;
|
207 |
-
color: #
|
208 |
}
|
209 |
.markdown-text ul, .markdown-text ol {
|
210 |
padding-left: 1.8em !important;
|
@@ -216,7 +215,7 @@ h3, .markdown-text h3 {
|
|
216 |
}
|
217 |
.markdown-text strong {
|
218 |
font-weight: 600;
|
219 |
-
color: #0056b3;
|
220 |
}
|
221 |
.markdown-text a {
|
222 |
color: #0056b3;
|
@@ -228,69 +227,70 @@ h3, .markdown-text h3 {
|
|
228 |
|
229 |
/* --- Gradio Components Styling --- */
|
230 |
.gradio-container {
|
231 |
-
max-width:
|
232 |
-
margin:
|
233 |
-
padding:
|
234 |
-
box-shadow: 0 4px
|
235 |
-
border-radius: 12px; /* Rounded corners */
|
236 |
-
background-color: #
|
|
|
237 |
}
|
238 |
|
239 |
/* --- Tabs --- */
|
240 |
-
.tab-buttons button {
|
241 |
-
font-size: 1.1em !important;
|
242 |
padding: 12px 20px !important;
|
243 |
-
border-radius: 8px 8px 0 0 !important;
|
244 |
border: 1px solid #dee2e6 !important;
|
245 |
border-bottom: none !important;
|
246 |
-
background-color: #
|
247 |
color: #495057 !important;
|
248 |
margin-right: 4px !important;
|
249 |
transition: background-color 0.3s ease, color 0.3s ease;
|
250 |
}
|
251 |
-
.tab-buttons button.selected {
|
252 |
-
background-color: #
|
253 |
-
color: #0056b3 !important;
|
254 |
font-weight: 600 !important;
|
255 |
-
border-color: #dee2e6 #dee2e6 #
|
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: #
|
269 |
-
margin-bottom:
|
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;
|
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;
|
@@ -300,7 +300,7 @@ h3, .markdown-text h3 {
|
|
300 |
border-color: #adb5bd;
|
301 |
}
|
302 |
#category-selector-radio .gr-form input[type="radio"]:checked + label:hover {
|
303 |
-
background-color: #004a9e;
|
304 |
}
|
305 |
|
306 |
|
@@ -308,49 +308,52 @@ h3, .markdown-text h3 {
|
|
308 |
#leaderboard-table {
|
309 |
margin-top: 20px;
|
310 |
border: 1px solid #dee2e6;
|
311 |
-
border-radius: 8px;
|
312 |
-
overflow: hidden;
|
313 |
-
box-shadow: 0 2px
|
314 |
}
|
315 |
-
#leaderboard-table .gr-dataframe {
|
316 |
-
border: none !important;
|
317 |
-
border-radius: 0 !important;
|
318 |
}
|
319 |
|
320 |
#leaderboard-table table {
|
321 |
width: 100%;
|
322 |
-
border-collapse: collapse;
|
|
|
323 |
}
|
324 |
#leaderboard-table th, #leaderboard-table td {
|
325 |
-
padding:
|
326 |
-
border: none !important;
|
327 |
-
border-bottom: 1px solid #e9ecef !important;
|
328 |
text-align: left;
|
329 |
-
vertical-align: middle;
|
330 |
-
font-size: 1em !important; /*
|
331 |
-
white-space: normal;
|
|
|
332 |
}
|
333 |
#leaderboard-table th {
|
334 |
-
background-color: #
|
335 |
font-weight: 600 !important;
|
336 |
-
color: #
|
337 |
-
font-size: 1.
|
338 |
-
border-bottom-width: 2px !important;
|
339 |
border-color: #dee2e6 !important;
|
|
|
340 |
}
|
341 |
#leaderboard-table tr:last-child td {
|
342 |
-
border-bottom: none !important;
|
343 |
}
|
344 |
#leaderboard-table tr:nth-child(even) {
|
345 |
-
background-color: #
|
346 |
}
|
347 |
#leaderboard-table tr:hover {
|
348 |
-
background-color: #e9f5ff !important;
|
349 |
}
|
350 |
#leaderboard-table td a {
|
351 |
color: #0056b3;
|
352 |
text-decoration: none;
|
353 |
-
font-weight: 500;
|
354 |
}
|
355 |
#leaderboard-table td a:hover {
|
356 |
text-decoration: underline;
|
@@ -360,25 +363,27 @@ h3, .markdown-text h3 {
|
|
360 |
#leaderboard-table th:first-child {
|
361 |
text-align: center;
|
362 |
font-weight: 600;
|
363 |
-
width:
|
364 |
}
|
365 |
#leaderboard-table td:last-child, /* Elo Score column */
|
366 |
#leaderboard-table th:last-child {
|
367 |
text-align: right;
|
368 |
font-weight: 600;
|
369 |
-
|
|
|
370 |
}
|
371 |
|
372 |
/* --- Accordion --- */
|
373 |
-
.gradio-accordion {
|
374 |
border: 1px solid #dee2e6 !important;
|
375 |
border-radius: 8px !important;
|
376 |
margin-bottom: 15px !important;
|
377 |
overflow: hidden;
|
|
|
378 |
}
|
379 |
-
.gradio-accordion > button,
|
380 |
-
.gradio-accordion > .gr-panel > button {
|
381 |
-
background-color: #
|
382 |
border: none !important;
|
383 |
border-bottom: 1px solid #dee2e6 !important;
|
384 |
padding: 12px 18px !important;
|
@@ -389,20 +394,24 @@ h3, .markdown-text h3 {
|
|
389 |
text-align: left;
|
390 |
cursor: pointer;
|
391 |
}
|
|
|
|
|
|
|
392 |
.gradio-accordion > button:hover,
|
393 |
.gradio-accordion > .gr-panel > button:hover {
|
394 |
background-color: #e9ecef !important;
|
395 |
}
|
396 |
.gradio-accordion > div { /* Accordion content */
|
397 |
padding: 15px 18px !important;
|
398 |
-
background-color: #ffffff;
|
399 |
}
|
400 |
-
#citation-button textarea {
|
401 |
font-family: 'Courier New', Courier, monospace;
|
402 |
font-size: 0.95em !important;
|
403 |
-
background-color: #
|
404 |
border-radius: 6px;
|
405 |
padding: 12px;
|
|
|
406 |
}
|
407 |
#citation-button label {
|
408 |
font-weight: 600;
|
@@ -433,6 +442,7 @@ h3, .markdown-text h3 {
|
|
433 |
border-radius: 6px !important;
|
434 |
border: 1px solid #ced4da !important;
|
435 |
padding: 10px 12px !important;
|
|
|
436 |
}
|
437 |
.gr-input:focus, .gr-dropdown:focus, .gr-textbox textarea:focus {
|
438 |
border-color: #80bdff !important;
|
@@ -446,7 +456,6 @@ h3, .markdown-text h3 {
|
|
446 |
margin-bottom: 5px !important;
|
447 |
}
|
448 |
|
449 |
-
|
450 |
"""
|
451 |
# Combine original CSS (if any) with new enhancements
|
452 |
final_css = custom_css + enhanced_css
|
@@ -456,41 +465,36 @@ demo = gr.Blocks(css=final_css, theme=gr.themes.Soft(
|
|
456 |
primary_hue=gr.themes.colors.blue,
|
457 |
secondary_hue=gr.themes.colors.sky,
|
458 |
neutral_hue=gr.themes.colors.gray,
|
459 |
-
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
460 |
radius_size=gr.themes.sizes.radius_md,
|
461 |
))
|
462 |
|
463 |
with demo:
|
464 |
-
# Use the enhanced TITLE HTML
|
465 |
gr.HTML(TITLE)
|
466 |
-
|
467 |
-
# Use the INTRODUCTION_TEXT variable
|
468 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
469 |
|
470 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
471 |
-
# Added Emojis to Tab Titles
|
472 |
with gr.TabItem("🏅 Leaderboard", elem_id="llm-benchmark-tab-table", id=0):
|
473 |
with gr.Column():
|
474 |
-
gr.Markdown("## Select Category to View Rankings", elem_classes="markdown-text")
|
475 |
category_selector = gr.Radio(
|
476 |
choices=CATEGORIES,
|
477 |
-
label=None,
|
478 |
value=DEFAULT_CATEGORY,
|
479 |
interactive=True,
|
480 |
-
elem_id="category-selector-radio"
|
481 |
)
|
482 |
leaderboard_df_component = gr.Dataframe(
|
483 |
value=update_leaderboard(DEFAULT_CATEGORY),
|
484 |
headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
|
485 |
-
# Ensure datatypes match the formatted output
|
486 |
datatype=["number", "html", "str", "str", "number"],
|
487 |
interactive=False,
|
488 |
-
row_count=(len(master_df), "fixed"),
|
489 |
col_count=(5, "fixed"),
|
490 |
-
wrap=True,
|
491 |
-
elem_id="leaderboard-table"
|
|
|
492 |
)
|
493 |
-
# Link the radio button change to the update function
|
494 |
category_selector.change(
|
495 |
fn=update_leaderboard,
|
496 |
inputs=category_selector,
|
@@ -498,72 +502,32 @@ with demo:
|
|
498 |
)
|
499 |
|
500 |
with gr.TabItem("ℹ️ About", elem_id="llm-benchmark-tab-about", id=1):
|
501 |
-
with gr.Column(scale=2, min_width=600):
|
502 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
503 |
|
504 |
-
# --- Submit Tab (Commented out
|
505 |
-
# Make sure EVALUATION_QUEUE_TEXT and add_new_eval are imported/defined if uncommented
|
506 |
# with gr.TabItem("🚀 Submit Model", elem_id="llm-benchmark-tab-submit", id=2):
|
507 |
-
#
|
508 |
-
|
509 |
-
# gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text") # Requires import/definition
|
510 |
-
# with gr.Column():
|
511 |
-
# with gr.Accordion(f"✅ Finished Evaluations ({len(finished_eval_queue_df)})", open=False, elem_classes="gradio-accordion"):
|
512 |
-
# finished_eval_table = gr.components.Dataframe(
|
513 |
-
# value=finished_eval_queue_df, headers=EVAL_COLS, datatype=EVAL_TYPES, row_count=5,
|
514 |
-
# )
|
515 |
-
# with gr.Accordion(f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})", open=True, elem_classes="gradio-accordion"): # Open running by default
|
516 |
-
# running_eval_table = gr.components.Dataframe(
|
517 |
-
# value=running_eval_queue_df, headers=EVAL_COLS, datatype=EVAL_TYPES, row_count=5,
|
518 |
-
# )
|
519 |
-
# with gr.Accordion(f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})", open=True, elem_classes="gradio-accordion"): # Open pending by default
|
520 |
-
# pending_eval_table = gr.components.Dataframe(
|
521 |
-
# value=pending_eval_queue_df, headers=EVAL_COLS, datatype=EVAL_TYPES, row_count=5,
|
522 |
-
# )
|
523 |
-
# gr.Markdown("--- \n # ✨ Submit Your Model for Evaluation!", elem_classes="markdown-text") # Enhanced submit section title
|
524 |
-
# with gr.Row():
|
525 |
-
# with gr.Column(scale=1):
|
526 |
-
# model_name_textbox = gr.Textbox(label="Model Name (Hugging Face Hub ID)", placeholder="e.g., openai-community/gpt2")
|
527 |
-
# revision_name_textbox = gr.Textbox(label="Revision / Commit Hash", placeholder="main")
|
528 |
-
# model_type = gr.Dropdown(choices=["Encoder-Decoder", "Decoder Only", "Encoder Only", "Other"], label="Model Architecture Type", multiselect=False, value=None, interactive=True)
|
529 |
-
# with gr.Column(scale=1):
|
530 |
-
# precision = gr.Dropdown(choices=["float16", "bfloat16", "float32", "int8", "auto"], label="Precision", multiselect=False, value="auto", interactive=True)
|
531 |
-
# weight_type = gr.Dropdown(choices=["Original", "Adapter", "Delta"], label="Weights Type", multiselect=False, value="Original", interactive=True)
|
532 |
-
# base_model_name_textbox = gr.Textbox(label="Base Model HF ID (if using Adapter/Delta weights)", placeholder="e.g., meta-llama/Llama-2-7b-hf")
|
533 |
-
# with gr.Row():
|
534 |
-
# submit_button = gr.Button("🚀 Submit for Evaluation", variant="primary", elem_id="submit_button") # Added variant and ID
|
535 |
-
# with gr.Row():
|
536 |
-
# submission_result = gr.Markdown()
|
537 |
-
# # Ensure add_new_eval is correctly imported/defined and handles these inputs
|
538 |
-
# submit_button.click(
|
539 |
-
# add_new_eval, # Requires import/definition
|
540 |
-
# [ model_name_textbox, base_model_name_textbox, revision_name_textbox, precision, weight_type, model_type, ],
|
541 |
-
# submission_result,
|
542 |
-
# )
|
543 |
-
|
544 |
-
# --- Citation Accordion (at the bottom, outside Tabs) ---
|
545 |
with gr.Accordion("📙 Citation", open=False, elem_classes="gradio-accordion"):
|
546 |
-
# Use the CITATION_BUTTON_TEXT and CITATION_BUTTON_LABEL variables
|
547 |
citation_button = gr.Textbox(
|
548 |
value=CITATION_BUTTON_TEXT,
|
549 |
label=CITATION_BUTTON_LABEL,
|
550 |
-
lines=8,
|
551 |
elem_id="citation-button",
|
552 |
show_copy_button=True,
|
553 |
-
# interactive=False # Make it non-editable if it's just for display/copy
|
554 |
)
|
555 |
|
556 |
-
# ---
|
557 |
-
# Only start scheduler if the script is run directly
|
558 |
if __name__ == "__main__":
|
559 |
try:
|
560 |
-
scheduler = BackgroundScheduler(daemon=True)
|
561 |
-
# Add job only if restart_space is callable and REPO_ID is valid
|
562 |
if callable(restart_space) and REPO_ID and REPO_ID != "your/space-id":
|
563 |
print(f"Scheduling space restart for {REPO_ID} every 30 minutes.")
|
564 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
565 |
scheduler.start()
|
566 |
else:
|
|
|
567 |
if not callable(restart_space):
|
568 |
print("Warning: restart_space function not available; space restart job not scheduled.")
|
569 |
if not REPO_ID or REPO_ID == "your/space-id":
|
@@ -573,9 +537,7 @@ if __name__ == "__main__":
|
|
573 |
|
574 |
|
575 |
# --- Launch the app ---
|
576 |
-
# Ensures the app launches only when the script is run directly
|
577 |
if __name__ == "__main__":
|
578 |
-
# Ensure you have installed necessary libraries: pip install gradio pandas apscheduler
|
579 |
-
# Make sure your src module files (about.py etc.) are accessible OR use the placeholder definitions.
|
580 |
print("Launching Gradio App...")
|
|
|
581 |
demo.launch()
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
61 |
|
62 |
# --- Elo Leaderboard Configuration ---
|
63 |
# Enhanced data with Rank (placeholder), Organizer, License, and URL
|
|
|
|
|
64 |
data = [
|
65 |
{'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},
|
66 |
{'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},
|
67 |
+
{'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},
|
68 |
{'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},
|
69 |
{'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},
|
70 |
{'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},
|
|
|
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 |
h2, .markdown-text h2 {
|
186 |
font-size: 1.8em !important;
|
|
|
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;
|
|
|
215 |
}
|
216 |
.markdown-text strong {
|
217 |
font-weight: 600;
|
218 |
+
color: #0056b3;
|
219 |
}
|
220 |
.markdown-text a {
|
221 |
color: #0056b3;
|
|
|
227 |
|
228 |
/* --- Gradio Components Styling --- */
|
229 |
.gradio-container {
|
230 |
+
max-width: 1300px !important; /* Increased max width */
|
231 |
+
margin: 25px auto !important; /* Center container with margin */
|
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 |
/* --- Tabs --- */
|
240 |
+
.tab-buttons button {
|
241 |
+
font-size: 1.1em !important;
|
242 |
padding: 12px 20px !important;
|
243 |
+
border-radius: 8px 8px 0 0 !important;
|
244 |
border: 1px solid #dee2e6 !important;
|
245 |
border-bottom: none !important;
|
246 |
+
background-color: #f1f3f5 !important; /* Default tab background slightly darker */
|
247 |
color: #495057 !important;
|
248 |
margin-right: 4px !important;
|
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;
|
|
|
300 |
border-color: #adb5bd;
|
301 |
}
|
302 |
#category-selector-radio .gr-form input[type="radio"]:checked + label:hover {
|
303 |
+
background-color: #004a9e;
|
304 |
}
|
305 |
|
306 |
|
|
|
308 |
#leaderboard-table {
|
309 |
margin-top: 20px;
|
310 |
border: 1px solid #dee2e6;
|
311 |
+
border-radius: 8px;
|
312 |
+
overflow: hidden;
|
313 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); /* Refined shadow */
|
314 |
}
|
315 |
+
#leaderboard-table .gr-dataframe {
|
316 |
+
border: none !important;
|
317 |
+
border-radius: 0 !important;
|
318 |
}
|
319 |
|
320 |
#leaderboard-table table {
|
321 |
width: 100%;
|
322 |
+
border-collapse: collapse;
|
323 |
+
table-layout: auto; /* Let browser handle column widths based on content */
|
324 |
}
|
325 |
#leaderboard-table th, #leaderboard-table td {
|
326 |
+
padding: 16px 18px !important; /* Increased vertical padding */
|
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 |
#leaderboard-table tr:nth-child(even) {
|
348 |
+
background-color: #f8f9fa !important; /* Subtle striping slightly darker */
|
349 |
}
|
350 |
#leaderboard-table tr:hover {
|
351 |
+
background-color: #e9f5ff !important;
|
352 |
}
|
353 |
#leaderboard-table td a {
|
354 |
color: #0056b3;
|
355 |
text-decoration: none;
|
356 |
+
font-weight: 500;
|
357 |
}
|
358 |
#leaderboard-table td a:hover {
|
359 |
text-decoration: underline;
|
|
|
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;
|
|
|
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;
|
|
|
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;
|
|
|
456 |
margin-bottom: 5px !important;
|
457 |
}
|
458 |
|
|
|
459 |
"""
|
460 |
# Combine original CSS (if any) with new enhancements
|
461 |
final_css = custom_css + enhanced_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("🏅 Leaderboard", elem_id="llm-benchmark-tab-table", id=0):
|
478 |
with gr.Column():
|
479 |
+
gr.Markdown("## Select Category to View Rankings", elem_classes="markdown-text")
|
480 |
category_selector = gr.Radio(
|
481 |
choices=CATEGORIES,
|
482 |
+
label=None,
|
483 |
value=DEFAULT_CATEGORY,
|
484 |
interactive=True,
|
485 |
+
elem_id="category-selector-radio"
|
486 |
)
|
487 |
leaderboard_df_component = gr.Dataframe(
|
488 |
value=update_leaderboard(DEFAULT_CATEGORY),
|
489 |
headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
|
|
|
490 |
datatype=["number", "html", "str", "str", "number"],
|
491 |
interactive=False,
|
492 |
+
row_count=(len(master_df), "fixed"),
|
493 |
col_count=(5, "fixed"),
|
494 |
+
wrap=True,
|
495 |
+
elem_id="leaderboard-table",
|
496 |
+
allow_sort=False # <<< Disable sorting arrows
|
497 |
)
|
|
|
498 |
category_selector.change(
|
499 |
fn=update_leaderboard,
|
500 |
inputs=category_selector,
|
|
|
502 |
)
|
503 |
|
504 |
with gr.TabItem("ℹ️ About", elem_id="llm-benchmark-tab-about", id=1):
|
505 |
+
with gr.Column(scale=2, min_width=600):
|
506 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
507 |
|
508 |
+
# --- Submit Tab (Commented out) ---
|
|
|
509 |
# with gr.TabItem("🚀 Submit Model", elem_id="llm-benchmark-tab-submit", id=2):
|
510 |
+
# ... (Submit tab code remains the same) ...
|
511 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
with gr.Accordion("📙 Citation", open=False, elem_classes="gradio-accordion"):
|
|
|
513 |
citation_button = gr.Textbox(
|
514 |
value=CITATION_BUTTON_TEXT,
|
515 |
label=CITATION_BUTTON_LABEL,
|
516 |
+
lines=8,
|
517 |
elem_id="citation-button",
|
518 |
show_copy_button=True,
|
|
|
519 |
)
|
520 |
|
521 |
+
# --- Scheduler ---
|
|
|
522 |
if __name__ == "__main__":
|
523 |
try:
|
524 |
+
scheduler = BackgroundScheduler(daemon=True)
|
|
|
525 |
if callable(restart_space) and REPO_ID and REPO_ID != "your/space-id":
|
526 |
print(f"Scheduling space restart for {REPO_ID} every 30 minutes.")
|
527 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
528 |
scheduler.start()
|
529 |
else:
|
530 |
+
# Print appropriate warnings
|
531 |
if not callable(restart_space):
|
532 |
print("Warning: restart_space function not available; space restart job not scheduled.")
|
533 |
if not REPO_ID or REPO_ID == "your/space-id":
|
|
|
537 |
|
538 |
|
539 |
# --- Launch the app ---
|
|
|
540 |
if __name__ == "__main__":
|
|
|
|
|
541 |
print("Launching Gradio App...")
|
542 |
+
# Use share=True if you need a public link for testing on different devices/networks
|
543 |
demo.launch()
|