hysts HF staff commited on
Commit
1d28680
1 Parent(s): 7e013b3

Add size vs. score graph

Browse files
Files changed (5) hide show
  1. app.py +24 -0
  2. pyproject.toml +1 -0
  3. requirements.txt +5 -0
  4. style.css +5 -0
  5. uv.lock +24 -0
app.py CHANGED
@@ -2,6 +2,8 @@ import os
2
 
3
  import gradio as gr
4
  import pandas as pd
 
 
5
  from apscheduler.schedulers.background import BackgroundScheduler
6
  from huggingface_hub import snapshot_download
7
 
@@ -314,6 +316,18 @@ def toggle_all_categories(action: str) -> list[gr.CheckboxGroup]:
314
  return results
315
 
316
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  SELECT_ALL_BUTTON_LABEL = "Select All"
318
  SELECT_ALL_BUTTON_LABEL_JA = "全選択"
319
  SELECT_NONE_BUTTON_LABEL = "Select None"
@@ -443,6 +457,8 @@ with gr.Blocks() as demo_leaderboard:
443
  visible=True,
444
  )
445
 
 
 
446
  # Dummy leaderboard for handling the case when the user uses backspace key
447
  hidden_leaderboard_table_for_search = gr.Dataframe(
448
  value=original_df[COLS],
@@ -502,6 +518,14 @@ with gr.Blocks() as demo_leaderboard:
502
  outputs=leaderboard_table,
503
  )
504
 
 
 
 
 
 
 
 
 
505
  # Check query parameter once at startup and update search bar + hidden component
506
  demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
507
 
 
2
 
3
  import gradio as gr
4
  import pandas as pd
5
+ import plotly.express as px
6
+ import plotly.graph_objects as go
7
  from apscheduler.schedulers.background import BackgroundScheduler
8
  from huggingface_hub import snapshot_download
9
 
 
316
  return results
317
 
318
 
319
+ def plot_size_vs_score(df: pd.DataFrame, hidden_df: pd.DataFrame) -> go.Figure:
320
+ df2 = hidden_df.iloc[df.index]
321
+ df2 = df2[df2["#Params (B)"] > 0]
322
+ df2 = df2[["model_name_for_query", "#Params (B)", "AVG"]]
323
+ df2["AVG"] = df2["AVG"].astype(float)
324
+ df2 = df2.rename(columns={"model_name_for_query": "Model"})
325
+ fig = px.scatter(df2, x="#Params (B)", y="AVG", hover_data=["Model"])
326
+ fig.update_traces(hovertemplate="<b>%{customdata[0]}</b><br>#Params: %{x:.2f}B<br>AVG: %{y:.4f}<extra></extra>")
327
+ fig.update_layout(yaxis_range=[0, 1])
328
+ return fig
329
+
330
+
331
  SELECT_ALL_BUTTON_LABEL = "Select All"
332
  SELECT_ALL_BUTTON_LABEL_JA = "全選択"
333
  SELECT_NONE_BUTTON_LABEL = "Select None"
 
457
  visible=True,
458
  )
459
 
460
+ graph_size_vs_score = gr.Plot(label="Model size vs. Average score")
461
+
462
  # Dummy leaderboard for handling the case when the user uses backspace key
463
  hidden_leaderboard_table_for_search = gr.Dataframe(
464
  value=original_df[COLS],
 
518
  outputs=leaderboard_table,
519
  )
520
 
521
+ leaderboard_table.change(
522
+ fn=plot_size_vs_score,
523
+ inputs=[leaderboard_table, hidden_leaderboard_table_for_search],
524
+ outputs=graph_size_vs_score,
525
+ api_name=False,
526
+ queue=False,
527
+ )
528
+
529
  # Check query parameter once at startup and update search bar + hidden component
530
  demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
531
 
pyproject.toml CHANGED
@@ -9,6 +9,7 @@ dependencies = [
9
  "datasets>=3.0.1",
10
  "gradio>=5.3.0",
11
  "hf-transfer>=0.1.8",
 
12
  "transformers>=4.45.2",
13
  ]
14
 
 
9
  "datasets>=3.0.1",
10
  "gradio>=5.3.0",
11
  "hf-transfer>=0.1.8",
12
+ "plotly>=5.24.1",
13
  "transformers>=4.45.2",
14
  ]
15
 
requirements.txt CHANGED
@@ -120,6 +120,7 @@ packaging==24.1
120
  # gradio
121
  # gradio-client
122
  # huggingface-hub
 
123
  # transformers
124
  pandas==2.2.3
125
  # via
@@ -127,6 +128,8 @@ pandas==2.2.3
127
  # gradio
128
  pillow==10.4.0
129
  # via gradio
 
 
130
  propcache==0.2.0
131
  # via yarl
132
  pyarrow==17.0.0
@@ -184,6 +187,8 @@ starlette==0.40.0
184
  # via
185
  # fastapi
186
  # gradio
 
 
187
  tokenizers==0.20.1
188
  # via transformers
189
  tomlkit==0.12.0
 
120
  # gradio
121
  # gradio-client
122
  # huggingface-hub
123
+ # plotly
124
  # transformers
125
  pandas==2.2.3
126
  # via
 
128
  # gradio
129
  pillow==10.4.0
130
  # via gradio
131
+ plotly==5.24.1
132
+ # via open-japanese-llm-leaderboard (pyproject.toml)
133
  propcache==0.2.0
134
  # via yarl
135
  pyarrow==17.0.0
 
187
  # via
188
  # fastapi
189
  # gradio
190
+ tenacity==9.0.0
191
+ # via plotly
192
  tokenizers==0.20.1
193
  # via transformers
194
  tomlkit==0.12.0
style.css CHANGED
@@ -108,3 +108,8 @@ table th:first-child {
108
  .accordion {
109
  min-width: 200px!important;
110
  }
 
 
 
 
 
 
108
  .accordion {
109
  min-width: 200px!important;
110
  }
111
+
112
+ /* Hide the modebar of Plotly */
113
+ .modebar-group {
114
+ display: none;
115
+ }
uv.lock CHANGED
@@ -797,6 +797,7 @@ dependencies = [
797
  { name = "datasets" },
798
  { name = "gradio" },
799
  { name = "hf-transfer" },
 
800
  { name = "transformers" },
801
  ]
802
 
@@ -806,6 +807,7 @@ requires-dist = [
806
  { name = "datasets", specifier = ">=3.0.1" },
807
  { name = "gradio", specifier = ">=5.3.0" },
808
  { name = "hf-transfer", specifier = ">=0.1.8" },
 
809
  { name = "transformers", specifier = ">=4.45.2" },
810
  ]
811
 
@@ -969,6 +971,19 @@ wheels = [
969
  { url = "https://files.pythonhosted.org/packages/52/3b/ce7a01026a7cf46e5452afa86f97a5e88ca97f562cafa76570178ab56d8d/pillow-10.4.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:0755ffd4a0c6f267cccbae2e9903d95477ca2f77c4fcf3a3a09570001856c8a5", size = 2554661 },
970
  ]
971
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
  [[package]]
973
  name = "propcache"
974
  version = "0.2.0"
@@ -1479,6 +1494,15 @@ wheels = [
1479
  { url = "https://files.pythonhosted.org/packages/0a/0f/64baf7a06492e8c12f5c4b49db286787a7255195df496fc21f5fd9eecffa/starlette-0.40.0-py3-none-any.whl", hash = "sha256:c494a22fae73805376ea6bf88439783ecfba9aac88a43911b48c653437e784c4", size = 73303 },
1480
  ]
1481
 
 
 
 
 
 
 
 
 
 
1482
  [[package]]
1483
  name = "tokenizers"
1484
  version = "0.20.1"
 
797
  { name = "datasets" },
798
  { name = "gradio" },
799
  { name = "hf-transfer" },
800
+ { name = "plotly" },
801
  { name = "transformers" },
802
  ]
803
 
 
807
  { name = "datasets", specifier = ">=3.0.1" },
808
  { name = "gradio", specifier = ">=5.3.0" },
809
  { name = "hf-transfer", specifier = ">=0.1.8" },
810
+ { name = "plotly", specifier = ">=5.24.1" },
811
  { name = "transformers", specifier = ">=4.45.2" },
812
  ]
813
 
 
971
  { url = "https://files.pythonhosted.org/packages/52/3b/ce7a01026a7cf46e5452afa86f97a5e88ca97f562cafa76570178ab56d8d/pillow-10.4.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:0755ffd4a0c6f267cccbae2e9903d95477ca2f77c4fcf3a3a09570001856c8a5", size = 2554661 },
972
  ]
973
 
974
+ [[package]]
975
+ name = "plotly"
976
+ version = "5.24.1"
977
+ source = { registry = "https://pypi.org/simple" }
978
+ dependencies = [
979
+ { name = "packaging" },
980
+ { name = "tenacity" },
981
+ ]
982
+ sdist = { url = "https://files.pythonhosted.org/packages/79/4f/428f6d959818d7425a94c190a6b26fbc58035cbef40bf249be0b62a9aedd/plotly-5.24.1.tar.gz", hash = "sha256:dbc8ac8339d248a4bcc36e08a5659bacfe1b079390b8953533f4eb22169b4bae", size = 9479398 }
983
+ wheels = [
984
+ { url = "https://files.pythonhosted.org/packages/e5/ae/580600f441f6fc05218bd6c9d5794f4aef072a7d9093b291f1c50a9db8bc/plotly-5.24.1-py3-none-any.whl", hash = "sha256:f67073a1e637eb0dc3e46324d9d51e2fe76e9727c892dde64ddf1e1b51f29089", size = 19054220 },
985
+ ]
986
+
987
  [[package]]
988
  name = "propcache"
989
  version = "0.2.0"
 
1494
  { url = "https://files.pythonhosted.org/packages/0a/0f/64baf7a06492e8c12f5c4b49db286787a7255195df496fc21f5fd9eecffa/starlette-0.40.0-py3-none-any.whl", hash = "sha256:c494a22fae73805376ea6bf88439783ecfba9aac88a43911b48c653437e784c4", size = 73303 },
1495
  ]
1496
 
1497
+ [[package]]
1498
+ name = "tenacity"
1499
+ version = "9.0.0"
1500
+ source = { registry = "https://pypi.org/simple" }
1501
+ sdist = { url = "https://files.pythonhosted.org/packages/cd/94/91fccdb4b8110642462e653d5dcb27e7b674742ad68efd146367da7bdb10/tenacity-9.0.0.tar.gz", hash = "sha256:807f37ca97d62aa361264d497b0e31e92b8027044942bfa756160d908320d73b", size = 47421 }
1502
+ wheels = [
1503
+ { url = "https://files.pythonhosted.org/packages/b6/cb/b86984bed139586d01532a587464b5805f12e397594f19f931c4c2fbfa61/tenacity-9.0.0-py3-none-any.whl", hash = "sha256:93de0c98785b27fcf659856aa9f54bfbd399e29969b0621bc7f762bd441b4539", size = 28169 },
1504
+ ]
1505
+
1506
  [[package]]
1507
  name = "tokenizers"
1508
  version = "0.20.1"