Spaces:
Running
Running
Refactor init_leaderboard function to handle multiple subsets, improve column selection and hiding, and include Dataset Version in filter_columns
Browse files- app.py +22 -28
- src/display/utils.py +1 -3
app.py
CHANGED
@@ -3,6 +3,7 @@ from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
from huggingface_hub import snapshot_download
|
|
|
6 |
# from fastchat.serve.monitor.monitor import build_leaderboard_tab, build_basic_stats_tab, basic_component_values, leader_component_values
|
7 |
|
8 |
from src.about import (
|
@@ -70,15 +71,18 @@ LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
|
|
70 |
|
71 |
def init_leaderboard(dataframes):
|
72 |
subsets = list(dataframes.keys())
|
73 |
-
|
74 |
with gr.Row():
|
75 |
selected_subset = gr.Dropdown(choices=subsets, label="Select Dataset Subset", value=subsets[-1])
|
76 |
research_textbox = gr.Textbox(placeholder="π Search Models... [press enter]", label="Filter Models by Name")
|
77 |
-
selected_columns = gr.CheckboxGroup(
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
data = dataframes[subsets[-1]]
|
81 |
-
|
82 |
with gr.Row():
|
83 |
datatype = [c.type for c in fields(AutoEvalColumn)]
|
84 |
df = gr.Dataframe(data, datatype=datatype, type="pandas")
|
@@ -90,34 +94,23 @@ def init_leaderboard(dataframes):
|
|
90 |
selected_subset.choices = subsets
|
91 |
update_data(subset, research_textbox, selected_columns)
|
92 |
|
93 |
-
|
94 |
-
|
95 |
def update_data(subset, search_term, selected_columns):
|
96 |
return dataframes[subset][dataframes[subset].model.str.contains(search_term, case=False)][selected_columns]
|
97 |
|
98 |
with gr.Row():
|
99 |
refresh_button = gr.Button("Refresh")
|
100 |
-
refresh_button.click(
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
outputs=data
|
113 |
-
)
|
114 |
-
selected_columns.change(
|
115 |
-
update_data,
|
116 |
-
inputs=[selected_subset, research_textbox, selected_columns],
|
117 |
-
outputs=data
|
118 |
-
)
|
119 |
-
|
120 |
-
|
121 |
|
122 |
# return Leaderboard(
|
123 |
# value=dataframes,
|
@@ -139,7 +132,8 @@ def init_leaderboard(dataframes):
|
|
139 |
# ],
|
140 |
# interactive=False,
|
141 |
# )
|
142 |
-
|
|
|
143 |
demo = gr.Blocks(css=custom_css)
|
144 |
with demo:
|
145 |
gr.HTML(TITLE)
|
|
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
from huggingface_hub import snapshot_download
|
6 |
+
|
7 |
# from fastchat.serve.monitor.monitor import build_leaderboard_tab, build_basic_stats_tab, basic_component_values, leader_component_values
|
8 |
|
9 |
from src.about import (
|
|
|
71 |
|
72 |
def init_leaderboard(dataframes):
|
73 |
subsets = list(dataframes.keys())
|
74 |
+
|
75 |
with gr.Row():
|
76 |
selected_subset = gr.Dropdown(choices=subsets, label="Select Dataset Subset", value=subsets[-1])
|
77 |
research_textbox = gr.Textbox(placeholder="π Search Models... [press enter]", label="Filter Models by Name")
|
78 |
+
selected_columns = gr.CheckboxGroup(
|
79 |
+
choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden],
|
80 |
+
label="Select Columns to Display",
|
81 |
+
value=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
|
82 |
+
)
|
83 |
|
|
|
84 |
data = dataframes[subsets[-1]]
|
85 |
+
|
86 |
with gr.Row():
|
87 |
datatype = [c.type for c in fields(AutoEvalColumn)]
|
88 |
df = gr.Dataframe(data, datatype=datatype, type="pandas")
|
|
|
94 |
selected_subset.choices = subsets
|
95 |
update_data(subset, research_textbox, selected_columns)
|
96 |
|
|
|
|
|
97 |
def update_data(subset, search_term, selected_columns):
|
98 |
return dataframes[subset][dataframes[subset].model.str.contains(search_term, case=False)][selected_columns]
|
99 |
|
100 |
with gr.Row():
|
101 |
refresh_button = gr.Button("Refresh")
|
102 |
+
refresh_button.click(
|
103 |
+
refresh,
|
104 |
+
inputs=[
|
105 |
+
selected_subset,
|
106 |
+
],
|
107 |
+
outputs=data,
|
108 |
+
concurrency_limit=20,
|
109 |
+
)
|
110 |
+
|
111 |
+
selected_subset.change(update_data, inputs=[selected_subset, research_textbox, selected_columns], outputs=data)
|
112 |
+
research_textbox.submit(update_data, inputs=[selected_subset, research_textbox, selected_columns], outputs=data)
|
113 |
+
selected_columns.change(update_data, inputs=[selected_subset, research_textbox, selected_columns], outputs=data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
# return Leaderboard(
|
116 |
# value=dataframes,
|
|
|
132 |
# ],
|
133 |
# interactive=False,
|
134 |
# )
|
135 |
+
|
136 |
+
|
137 |
demo = gr.Blocks(css=custom_css)
|
138 |
with demo:
|
139 |
gr.HTML(TITLE)
|
src/display/utils.py
CHANGED
@@ -26,9 +26,7 @@ class ColumnContent:
|
|
26 |
auto_eval_column_dict = []
|
27 |
# Init
|
28 |
# auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
29 |
-
auto_eval_column_dict.append(
|
30 |
-
["model", ColumnContent, ColumnContent("Model Name", "str", True, never_hidden=True)]
|
31 |
-
)
|
32 |
# Scores
|
33 |
auto_eval_column_dict.append(["Overall", ColumnContent, ColumnContent("Total", "number", True)])
|
34 |
for task in Tasks:
|
|
|
26 |
auto_eval_column_dict = []
|
27 |
# Init
|
28 |
# auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
29 |
+
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model Name", "str", True, never_hidden=True)])
|
|
|
|
|
30 |
# Scores
|
31 |
auto_eval_column_dict.append(["Overall", ColumnContent, ColumnContent("Total", "number", True)])
|
32 |
for task in Tasks:
|