Jerrycool commited on
Commit
14cd4fc
·
verified ·
1 Parent(s): f065bf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -3,10 +3,12 @@ import pandas as pd
3
  from apscheduler.schedulers.background import BackgroundScheduler
4
 
5
  """
6
- MLE‑Dojo Benchmark Leaderboard — Dark Elegance v3
7
- ================================================
8
- * Fix: removed unsupported `height` param for `gr.Dataframe`.
9
- * Font tweak: leaderboard cells slightly smaller.
 
 
10
  """
11
 
12
  # ---------------------------------------------------------------------------
@@ -38,9 +40,8 @@ except ImportError:
38
  return "Submission placeholder."
39
 
40
  # ---------------------------------------------------------------------------
41
- # Data
42
  # ---------------------------------------------------------------------------
43
- # (unchanged)-------------------------------------------
44
 
45
  data = [
46
  {"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,25 +67,34 @@ CATEGORY_MAP = {
66
  "NLP": "NLP_Elo",
67
  "CV": "CV_Elo",
68
  }
69
- MEDALS = {1: "🥇", 2: "🥈", 3: "🥉"}
70
 
71
- def update_leaderboard(category: str, ascending: bool):
72
  col = CATEGORY_MAP.get(category, CATEGORY_MAP[DEFAULT_CATEGORY])
73
  df = (
74
  master_df[["model_name", "url", "organizer", "license", col]]
75
- .sort_values(by=col, ascending=ascending)
76
  .reset_index(drop=True)
77
  )
78
  df.insert(0, "Rank", df.index + 1)
79
- df["Rank"] = df["Rank"].apply(lambda r: MEDALS.get(r, str(r)))
80
  df["Model"] = df.apply(lambda r: f"<a href='{r.url}' target='_blank'>{r.model_name}</a>", axis=1)
81
  df.rename(columns={"organizer": "Organizer", "license": "License", col: "Elo Score"}, inplace=True)
82
  return df[["Rank", "Model", "Organizer", "License", "Elo Score"]]
83
 
84
  # ---------------------------------------------------------------------------
85
- # CSS (dark + slightly smaller table font)
86
  # ---------------------------------------------------------------------------
87
  custom_css += """
 
 
 
 
 
 
 
 
 
 
 
88
  #leaderboard-table td{padding:.7em;font-size:1.05rem;border-top:1px solid #334155;}
89
  """
90
 
@@ -99,20 +109,17 @@ with app:
99
  with gr.Tabs():
100
  with gr.TabItem("🏅 Leaderboard"):
101
  gr.HTML("<h3 class='section-title'><span class='icon'>📊</span>Model Elo Rankings by Category</h3>")
102
- with gr.Row():
103
- category_radio = gr.Radio(CATEGORIES, value=DEFAULT_CATEGORY, label="Category")
104
- asc_check = gr.Checkbox(label="⬆️ Asc. order", value=False)
105
  board = gr.Dataframe(
106
- value=update_leaderboard(DEFAULT_CATEGORY, False),
107
  headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
108
- datatype=["html", "html", "str", "str", "number"],
109
  row_count=(len(master_df), "fixed"),
110
  col_count=(5, "fixed"),
111
  interactive=False,
112
  elem_id="leaderboard-table",
113
  )
114
- category_radio.change(update_leaderboard, [category_radio, asc_check], board)
115
- asc_check.change(update_leaderboard, [category_radio, asc_check], board)
116
  with gr.TabItem("ℹ️ About"):
117
  gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
118
  with gr.Accordion("📖 Citation", open=False):
 
3
  from apscheduler.schedulers.background import BackgroundScheduler
4
 
5
  """
6
+ MLE‑Dojo Benchmark Leaderboard — Dark Elegance v4
7
+ =================================================
8
+ * Removed "Asc. order" toggle (always sorted high→low).
9
+ * Rank column back to plain numbers.
10
+ * Category selector restyled via CSS.
11
+ * Horizontal scrollbar hidden; vertical scrollbar retained.
12
  """
13
 
14
  # ---------------------------------------------------------------------------
 
40
  return "Submission placeholder."
41
 
42
  # ---------------------------------------------------------------------------
43
+ # Data (unchanged)
44
  # ---------------------------------------------------------------------------
 
45
 
46
  data = [
47
  {"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
  "NLP": "NLP_Elo",
68
  "CV": "CV_Elo",
69
  }
 
70
 
71
+ def update_leaderboard(category: str):
72
  col = CATEGORY_MAP.get(category, CATEGORY_MAP[DEFAULT_CATEGORY])
73
  df = (
74
  master_df[["model_name", "url", "organizer", "license", col]]
75
+ .sort_values(by=col, ascending=False)
76
  .reset_index(drop=True)
77
  )
78
  df.insert(0, "Rank", df.index + 1)
 
79
  df["Model"] = df.apply(lambda r: f"<a href='{r.url}' target='_blank'>{r.model_name}</a>", axis=1)
80
  df.rename(columns={"organizer": "Organizer", "license": "License", col: "Elo Score"}, inplace=True)
81
  return df[["Rank", "Model", "Organizer", "License", "Elo Score"]]
82
 
83
  # ---------------------------------------------------------------------------
84
+ # CSS tweaks category radio beautify & horizontal scroll hidden
85
  # ---------------------------------------------------------------------------
86
  custom_css += """
87
+ /* Category radio stylish pill */
88
+ .gr-radio input+label{
89
+ background:#1e293b; color:#e2e8f0; padding:6px 14px; border-radius:9999px; margin-right:8px; cursor:pointer;
90
+ transition:background .2s, color .2s;
91
+ }
92
+ .gr-radio input:checked+label{background:#38bdf8;color:#0f172a;font-weight:600;}
93
+
94
+ /* Remove horizontal scrollbar; keep vertical */
95
+ #leaderboard-table tbody{overflow-y:auto;overflow-x:hidden;max-height:520px;display:block;}
96
+ #leaderboard-table thead, #leaderboard-table tbody tr{display:table;width:100%;table-layout:fixed;}
97
+
98
  #leaderboard-table td{padding:.7em;font-size:1.05rem;border-top:1px solid #334155;}
99
  """
100
 
 
109
  with gr.Tabs():
110
  with gr.TabItem("🏅 Leaderboard"):
111
  gr.HTML("<h3 class='section-title'><span class='icon'>📊</span>Model Elo Rankings by Category</h3>")
112
+ category_radio = gr.Radio(CATEGORIES, value=DEFAULT_CATEGORY, label="Category")
 
 
113
  board = gr.Dataframe(
114
+ value=update_leaderboard(DEFAULT_CATEGORY),
115
  headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
116
+ datatype=["number", "html", "str", "str", "number"],
117
  row_count=(len(master_df), "fixed"),
118
  col_count=(5, "fixed"),
119
  interactive=False,
120
  elem_id="leaderboard-table",
121
  )
122
+ category_radio.change(update_leaderboard, category_radio, board)
 
123
  with gr.TabItem("ℹ️ About"):
124
  gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
125
  with gr.Accordion("📖 Citation", open=False):