davidadamczyk
commited on
Commit
·
657d04f
1
Parent(s):
eb088fd
first version of czechbench leaderboard
Browse files- app.py +55 -54
- src/display/about.py +20 -3
- src/display/utils.py +24 -0
- src/envs.py +4 -4
- src/leaderboard/read_evals.py +5 -20
- src/populate.py +4 -4
- src/submission/submit.py +52 -9
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
@@ -53,48 +54,46 @@ except Exception:
|
|
53 |
raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
54 |
leaderboard_df = original_df.copy()
|
55 |
|
|
|
56 |
(
|
57 |
finished_eval_queue_df,
|
58 |
running_eval_queue_df,
|
59 |
pending_eval_queue_df,
|
60 |
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
61 |
-
|
62 |
|
63 |
# Searching and filtering
|
64 |
def update_table(
|
65 |
hidden_df: pd.DataFrame,
|
66 |
columns: list,
|
67 |
-
type_query: list,
|
68 |
-
precision_query: str,
|
69 |
-
size_query: list,
|
70 |
-
show_deleted: bool,
|
71 |
query: str,
|
72 |
-
):
|
73 |
-
filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
74 |
-
filtered_df = filter_queries(query,
|
75 |
df = select_columns(filtered_df, columns)
|
76 |
return df
|
77 |
|
78 |
|
79 |
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
80 |
-
|
|
|
81 |
|
82 |
|
83 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
84 |
always_here_cols = [
|
85 |
-
AutoEvalColumn.model_type_symbol.name,
|
86 |
-
AutoEvalColumn.
|
87 |
]
|
88 |
# We use COLS to maintain sorting
|
89 |
filtered_df = df[
|
90 |
-
always_here_cols + [c for c in COLS if c in df.columns and c in columns]
|
91 |
]
|
92 |
return filtered_df
|
93 |
|
94 |
|
95 |
def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
96 |
final_df = []
|
97 |
-
if query != "":
|
98 |
queries = [q.strip() for q in query.split(";")]
|
99 |
for _q in queries:
|
100 |
_q = _q.strip()
|
@@ -105,7 +104,7 @@ def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
|
105 |
if len(final_df) > 0:
|
106 |
filtered_df = pd.concat(final_df)
|
107 |
filtered_df = filtered_df.drop_duplicates(
|
108 |
-
subset=[AutoEvalColumn.
|
109 |
)
|
110 |
|
111 |
return filtered_df
|
@@ -115,23 +114,35 @@ def filter_models(
|
|
115 |
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
|
116 |
) -> pd.DataFrame:
|
117 |
# Show all models
|
118 |
-
if show_deleted:
|
119 |
-
|
120 |
-
else: # Show only still on the hub models
|
121 |
-
|
|
|
|
|
122 |
|
123 |
-
type_emoji = [t[0] for t in type_query]
|
124 |
-
filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
125 |
-
filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
126 |
|
127 |
-
numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
128 |
-
params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
129 |
-
mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
130 |
-
filtered_df = filtered_df.loc[mask]
|
131 |
|
132 |
return filtered_df
|
133 |
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
demo = gr.Blocks(css=custom_css)
|
136 |
with demo:
|
137 |
gr.HTML(TITLE)
|
@@ -163,10 +174,7 @@ with demo:
|
|
163 |
elem_id="column-select",
|
164 |
interactive=True,
|
165 |
)
|
166 |
-
|
167 |
-
deleted_models_visibility = gr.Checkbox(
|
168 |
-
value=False, label="Show gated/private/deleted models", interactive=True
|
169 |
-
)
|
170 |
with gr.Column(min_width=320):
|
171 |
# with gr.Box(elem_id="box-filter"):
|
172 |
filter_columns_type = gr.CheckboxGroup(
|
@@ -190,19 +198,20 @@ with demo:
|
|
190 |
interactive=True,
|
191 |
elem_id="filter-columns-size",
|
192 |
)
|
193 |
-
|
194 |
leaderboard_table = gr.components.Dataframe(
|
195 |
value=leaderboard_df[
|
196 |
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
197 |
+ shown_columns.value
|
198 |
-
|
199 |
],
|
200 |
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
201 |
datatype=TYPES,
|
202 |
elem_id="leaderboard-table",
|
203 |
interactive=False,
|
204 |
visible=True,
|
205 |
-
|
|
|
206 |
)
|
207 |
|
208 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
@@ -217,30 +226,18 @@ with demo:
|
|
217 |
[
|
218 |
hidden_leaderboard_table_for_search,
|
219 |
shown_columns,
|
220 |
-
filter_columns_type,
|
221 |
-
filter_columns_precision,
|
222 |
-
filter_columns_size,
|
223 |
-
deleted_models_visibility,
|
224 |
search_bar,
|
225 |
],
|
226 |
leaderboard_table,
|
227 |
)
|
228 |
for selector in [
|
229 |
shown_columns,
|
230 |
-
filter_columns_type,
|
231 |
-
filter_columns_precision,
|
232 |
-
filter_columns_size,
|
233 |
-
deleted_models_visibility,
|
234 |
]:
|
235 |
selector.change(
|
236 |
update_table,
|
237 |
[
|
238 |
hidden_leaderboard_table_for_search,
|
239 |
shown_columns,
|
240 |
-
filter_columns_type,
|
241 |
-
filter_columns_precision,
|
242 |
-
filter_columns_size,
|
243 |
-
deleted_models_visibility,
|
244 |
search_bar,
|
245 |
],
|
246 |
leaderboard_table,
|
@@ -254,8 +251,9 @@ with demo:
|
|
254 |
with gr.Column():
|
255 |
with gr.Row():
|
256 |
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
257 |
-
|
258 |
with gr.Column():
|
|
|
259 |
with gr.Accordion(
|
260 |
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
261 |
open=False,
|
@@ -290,12 +288,18 @@ with demo:
|
|
290 |
datatype=EVAL_TYPES,
|
291 |
row_count=5,
|
292 |
)
|
|
|
293 |
with gr.Row():
|
294 |
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
295 |
|
296 |
with gr.Row():
|
297 |
with gr.Column():
|
298 |
model_name_textbox = gr.Textbox(label="Model name")
|
|
|
|
|
|
|
|
|
|
|
299 |
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
300 |
model_type = gr.Dropdown(
|
301 |
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
@@ -304,7 +308,8 @@ with demo:
|
|
304 |
value=None,
|
305 |
interactive=True,
|
306 |
)
|
307 |
-
|
|
|
308 |
with gr.Column():
|
309 |
precision = gr.Dropdown(
|
310 |
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
@@ -321,18 +326,14 @@ with demo:
|
|
321 |
interactive=True,
|
322 |
)
|
323 |
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
324 |
-
|
325 |
-
submit_button = gr.Button("Submit Eval")
|
326 |
submission_result = gr.Markdown()
|
327 |
submit_button.click(
|
328 |
add_new_eval,
|
329 |
[
|
330 |
model_name_textbox,
|
331 |
-
|
332 |
-
revision_name_textbox,
|
333 |
-
precision,
|
334 |
-
weight_type,
|
335 |
-
model_type,
|
336 |
],
|
337 |
submission_result,
|
338 |
)
|
@@ -350,4 +351,4 @@ with demo:
|
|
350 |
scheduler = BackgroundScheduler()
|
351 |
scheduler.add_job(restart_space, "interval", seconds=1800)
|
352 |
scheduler.start()
|
353 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
+
import json
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
54 |
raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
55 |
leaderboard_df = original_df.copy()
|
56 |
|
57 |
+
"""
|
58 |
(
|
59 |
finished_eval_queue_df,
|
60 |
running_eval_queue_df,
|
61 |
pending_eval_queue_df,
|
62 |
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
63 |
+
"""
|
64 |
|
65 |
# Searching and filtering
|
66 |
def update_table(
|
67 |
hidden_df: pd.DataFrame,
|
68 |
columns: list,
|
|
|
|
|
|
|
|
|
69 |
query: str,
|
70 |
+
):
|
71 |
+
#filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
72 |
+
filtered_df = filter_queries(query, hidden_df)
|
73 |
df = select_columns(filtered_df, columns)
|
74 |
return df
|
75 |
|
76 |
|
77 |
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
78 |
+
print(query)
|
79 |
+
return df[(df[AutoEvalColumn.eval_name.name].str.contains(query, case=False))]
|
80 |
|
81 |
|
82 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
83 |
always_here_cols = [
|
84 |
+
#AutoEvalColumn.model_type_symbol.name,
|
85 |
+
AutoEvalColumn.eval_name.name,
|
86 |
]
|
87 |
# We use COLS to maintain sorting
|
88 |
filtered_df = df[
|
89 |
+
always_here_cols + [c for c in COLS if c in df.columns and c in columns] #+ [AutoEvalColumn.dummy.name]
|
90 |
]
|
91 |
return filtered_df
|
92 |
|
93 |
|
94 |
def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
95 |
final_df = []
|
96 |
+
if query != "" and query is not None:
|
97 |
queries = [q.strip() for q in query.split(";")]
|
98 |
for _q in queries:
|
99 |
_q = _q.strip()
|
|
|
104 |
if len(final_df) > 0:
|
105 |
filtered_df = pd.concat(final_df)
|
106 |
filtered_df = filtered_df.drop_duplicates(
|
107 |
+
subset=[AutoEvalColumn.eval_name.name]
|
108 |
)
|
109 |
|
110 |
return filtered_df
|
|
|
114 |
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
|
115 |
) -> pd.DataFrame:
|
116 |
# Show all models
|
117 |
+
#if show_deleted:
|
118 |
+
# filtered_df = df
|
119 |
+
#else: # Show only still on the hub models
|
120 |
+
# filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
|
121 |
+
|
122 |
+
filtered_df = df
|
123 |
|
124 |
+
#type_emoji = [t[0] for t in type_query]
|
125 |
+
#filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
126 |
+
#filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
127 |
|
128 |
+
#numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
129 |
+
#params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
130 |
+
#mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
131 |
+
#filtered_df = filtered_df.loc[mask]
|
132 |
|
133 |
return filtered_df
|
134 |
|
135 |
|
136 |
+
def validate_upload(input):
|
137 |
+
try:
|
138 |
+
with open(input, mode="r") as f:
|
139 |
+
data = json.load(f)
|
140 |
+
#raise gr.Error("Cannot divide by zero!")
|
141 |
+
except:
|
142 |
+
raise gr.Error("Cannot parse file")
|
143 |
+
|
144 |
+
|
145 |
+
|
146 |
demo = gr.Blocks(css=custom_css)
|
147 |
with demo:
|
148 |
gr.HTML(TITLE)
|
|
|
174 |
elem_id="column-select",
|
175 |
interactive=True,
|
176 |
)
|
177 |
+
"""
|
|
|
|
|
|
|
178 |
with gr.Column(min_width=320):
|
179 |
# with gr.Box(elem_id="box-filter"):
|
180 |
filter_columns_type = gr.CheckboxGroup(
|
|
|
198 |
interactive=True,
|
199 |
elem_id="filter-columns-size",
|
200 |
)
|
201 |
+
"""
|
202 |
leaderboard_table = gr.components.Dataframe(
|
203 |
value=leaderboard_df[
|
204 |
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
205 |
+ shown_columns.value
|
206 |
+
|
207 |
],
|
208 |
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
209 |
datatype=TYPES,
|
210 |
elem_id="leaderboard-table",
|
211 |
interactive=False,
|
212 |
visible=True,
|
213 |
+
wrap=False,
|
214 |
+
#column_widths=["2%", "2%"],
|
215 |
)
|
216 |
|
217 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
|
|
226 |
[
|
227 |
hidden_leaderboard_table_for_search,
|
228 |
shown_columns,
|
|
|
|
|
|
|
|
|
229 |
search_bar,
|
230 |
],
|
231 |
leaderboard_table,
|
232 |
)
|
233 |
for selector in [
|
234 |
shown_columns,
|
|
|
|
|
|
|
|
|
235 |
]:
|
236 |
selector.change(
|
237 |
update_table,
|
238 |
[
|
239 |
hidden_leaderboard_table_for_search,
|
240 |
shown_columns,
|
|
|
|
|
|
|
|
|
241 |
search_bar,
|
242 |
],
|
243 |
leaderboard_table,
|
|
|
251 |
with gr.Column():
|
252 |
with gr.Row():
|
253 |
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
254 |
+
"""
|
255 |
with gr.Column():
|
256 |
+
|
257 |
with gr.Accordion(
|
258 |
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
259 |
open=False,
|
|
|
288 |
datatype=EVAL_TYPES,
|
289 |
row_count=5,
|
290 |
)
|
291 |
+
"""
|
292 |
with gr.Row():
|
293 |
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
294 |
|
295 |
with gr.Row():
|
296 |
with gr.Column():
|
297 |
model_name_textbox = gr.Textbox(label="Model name")
|
298 |
+
|
299 |
+
file_output = gr.File()
|
300 |
+
upload_button = gr.UploadButton("Upload json", file_types=['.json'])
|
301 |
+
upload_button.upload(validate_upload, upload_button, file_output)
|
302 |
+
"""
|
303 |
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
304 |
model_type = gr.Dropdown(
|
305 |
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
|
|
308 |
value=None,
|
309 |
interactive=True,
|
310 |
)
|
311 |
+
"""
|
312 |
+
"""
|
313 |
with gr.Column():
|
314 |
precision = gr.Dropdown(
|
315 |
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
|
|
326 |
interactive=True,
|
327 |
)
|
328 |
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
329 |
+
"""
|
330 |
+
submit_button = gr.Button("Submit Eval", interactive=True)
|
331 |
submission_result = gr.Markdown()
|
332 |
submit_button.click(
|
333 |
add_new_eval,
|
334 |
[
|
335 |
model_name_textbox,
|
336 |
+
upload_button
|
|
|
|
|
|
|
|
|
337 |
],
|
338 |
submission_result,
|
339 |
)
|
|
|
351 |
scheduler = BackgroundScheduler()
|
352 |
scheduler.add_job(restart_space, "interval", seconds=1800)
|
353 |
scheduler.start()
|
354 |
+
demo.queue(default_concurrency_limit=40).launch(server_name="0.0.0.0")
|
src/display/about.py
CHANGED
@@ -12,9 +12,26 @@ class Task:
|
|
12 |
# Init: to update with your specific keys
|
13 |
class Tasks(Enum):
|
14 |
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
15 |
-
task0 = Task("task_agree", "accuracy", "
|
16 |
-
task1 = Task("task_anli", "accuracy", "
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Your leaderboard name
|
20 |
TITLE = """<h1 align="center" id="space-title">CzechBench example leaderboard</h1>"""
|
|
|
12 |
# Init: to update with your specific keys
|
13 |
class Tasks(Enum):
|
14 |
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
15 |
+
task0 = Task("task_agree", "accuracy", "agree")
|
16 |
+
task1 = Task("task_anli", "accuracy", "anli")
|
17 |
+
task2 = Task("task_agree_en", "accuracy", "anli_en")
|
18 |
+
task3 = Task("arc_challenge", "accuracy", "arc_challenge")
|
19 |
+
task4 = Task("arc_easy", "accuracy", "arc_easy")
|
20 |
+
task5 = Task("belebele", "accuracy", "belebele")
|
21 |
+
task6 = Task("ctkfacts", "accuracy", "ctkfacts")
|
22 |
+
task7 = Task("ctkfacts_en", "accuracy", "ctkfacts_en")
|
23 |
+
task8 = Task("czechnews", "accuracy", "czechnews")
|
24 |
+
task9 = Task("facebook_comments", "accuracy", "facebook_comments")
|
25 |
+
task10 = Task("klokánek", "accuracy", "klokánek")
|
26 |
+
task11 = Task("mall_reviews", "accuracy", "mall_reviews")
|
27 |
+
task12 = Task("mmlu", "accuracy", "mmlu")
|
28 |
+
task13 = Task("snli", "accuracy", "snli")
|
29 |
+
task14 = Task("snli_en", "accuracy", "snli_en")
|
30 |
+
task15 = Task("subjectivity", "accuracy", "subjectivity")
|
31 |
+
task16 = Task("subjectivity_en", "accuracy", "subjectivity_en")
|
32 |
+
task17 = Task("truthfulqa", "accuracy", "truthfulqa")
|
33 |
+
task18 = Task("gsm8k", "accuracy", "gsm8k")
|
34 |
+
task19 = Task("squad", "accuracy", "squad")
|
35 |
|
36 |
# Your leaderboard name
|
37 |
TITLE = """<h1 align="center" id="space-title">CzechBench example leaderboard</h1>"""
|
src/display/utils.py
CHANGED
@@ -25,6 +25,7 @@ class ColumnContent:
|
|
25 |
|
26 |
## Leaderboard columns
|
27 |
auto_eval_column_dict = []
|
|
|
28 |
# Init
|
29 |
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
30 |
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
@@ -44,6 +45,29 @@ auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Avai
|
|
44 |
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
45 |
# Dummy column for the search bar (hidden by the custom CSS)
|
46 |
auto_eval_column_dict.append(["dummy", ColumnContent, ColumnContent("model_name_for_query", "str", False, dummy=True)])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# We use make dataclass to dynamically fill the scores from Tasks
|
49 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
|
|
25 |
|
26 |
## Leaderboard columns
|
27 |
auto_eval_column_dict = []
|
28 |
+
"""
|
29 |
# Init
|
30 |
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
31 |
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
|
|
45 |
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
46 |
# Dummy column for the search bar (hidden by the custom CSS)
|
47 |
auto_eval_column_dict.append(["dummy", ColumnContent, ColumnContent("model_name_for_query", "str", False, dummy=True)])
|
48 |
+
"""
|
49 |
+
|
50 |
+
auto_eval_column_dict.append(["eval_name", ColumnContent, ColumnContent("eval_name", "str", True, never_hidden=True)])
|
51 |
+
auto_eval_column_dict.append(["agree", ColumnContent, ColumnContent("agree", "number", True)])
|
52 |
+
auto_eval_column_dict.append(["anli", ColumnContent, ColumnContent("anli", "number", True)])
|
53 |
+
auto_eval_column_dict.append(["anli_en", ColumnContent, ColumnContent("anli_en", "number", True)])
|
54 |
+
auto_eval_column_dict.append(["arc_challenge", ColumnContent, ColumnContent("arc_challenge", "number", True)])
|
55 |
+
auto_eval_column_dict.append(["arc_easy", ColumnContent, ColumnContent("arc_easy", "number", True)])
|
56 |
+
auto_eval_column_dict.append(["belebele", ColumnContent, ColumnContent("belebele", "number", True)])
|
57 |
+
auto_eval_column_dict.append(["ctkfacts", ColumnContent, ColumnContent("ctkfacts", "number", True)])
|
58 |
+
auto_eval_column_dict.append(["ctkfacts_en", ColumnContent, ColumnContent("ctkfacts_en", "number", True)])
|
59 |
+
auto_eval_column_dict.append(["czechnews", ColumnContent, ColumnContent("czechnews", "number", True)])
|
60 |
+
auto_eval_column_dict.append(["facebook_comments", ColumnContent, ColumnContent("facebook_comments", "number", True)])
|
61 |
+
auto_eval_column_dict.append(["klokánek", ColumnContent, ColumnContent("klokánek", "number", True)])
|
62 |
+
auto_eval_column_dict.append(["mall_reviews", ColumnContent, ColumnContent("mall_reviews", "number", True)])
|
63 |
+
auto_eval_column_dict.append(["mmlu", ColumnContent, ColumnContent("mmlu", "number", True)])
|
64 |
+
auto_eval_column_dict.append(["snli", ColumnContent, ColumnContent("snli", "number", True)])
|
65 |
+
auto_eval_column_dict.append(["snli_en", ColumnContent, ColumnContent("snli_en", "number", True)])
|
66 |
+
auto_eval_column_dict.append(["subjectivity", ColumnContent, ColumnContent("subjectivity", "number", True)])
|
67 |
+
auto_eval_column_dict.append(["subjectivity_en", ColumnContent, ColumnContent("subjectivity_en", "number", True)])
|
68 |
+
auto_eval_column_dict.append(["truthfulqa", ColumnContent, ColumnContent("truthfulqa", "number", True)])
|
69 |
+
auto_eval_column_dict.append(["gsm8k", ColumnContent, ColumnContent("gsm8k", "number", True)])
|
70 |
+
auto_eval_column_dict.append(["squad", ColumnContent, ColumnContent("squad", "number", True)])
|
71 |
|
72 |
# We use make dataclass to dynamically fill the scores from Tasks
|
73 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
src/envs.py
CHANGED
@@ -4,13 +4,13 @@ from huggingface_hub import HfApi
|
|
4 |
|
5 |
# clone / pull the lmeh eval data
|
6 |
TOKEN = os.environ.get("TOKEN", None)
|
7 |
-
|
8 |
OWNER = "davidadamczyk"
|
9 |
REPO_ID = f"{OWNER}/leaderboard"
|
10 |
-
QUEUE_REPO = f"{OWNER}/
|
11 |
-
RESULTS_REPO = f"{OWNER}/
|
12 |
|
13 |
-
CACHE_PATH = os.getenv("HF_HOME", ".")
|
14 |
|
15 |
# Local caches
|
16 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
|
|
4 |
|
5 |
# clone / pull the lmeh eval data
|
6 |
TOKEN = os.environ.get("TOKEN", None)
|
7 |
+
print(TOKEN)
|
8 |
OWNER = "davidadamczyk"
|
9 |
REPO_ID = f"{OWNER}/leaderboard"
|
10 |
+
QUEUE_REPO = f"{OWNER}/leaderboard"
|
11 |
+
RESULTS_REPO = f"{OWNER}/leaderboard"
|
12 |
|
13 |
+
CACHE_PATH = "." #os.getenv("HF_HOME", ".")
|
14 |
|
15 |
# Local caches
|
16 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
src/leaderboard/read_evals.py
CHANGED
@@ -35,7 +35,7 @@ class EvalResult:
|
|
35 |
"""Inits the result from the specific model result file"""
|
36 |
with open(json_filepath) as fp:
|
37 |
data = json.load(fp)
|
38 |
-
|
39 |
config = data.get("config")
|
40 |
|
41 |
# Precision
|
@@ -168,25 +168,10 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
168 |
for file in files:
|
169 |
model_result_filepaths.append(os.path.join(root, file))
|
170 |
|
171 |
-
eval_results =
|
172 |
for model_result_filepath in model_result_filepaths:
|
173 |
# Creation of result
|
174 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
eval_name = eval_result.eval_name
|
179 |
-
if eval_name in eval_results.keys():
|
180 |
-
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
181 |
-
else:
|
182 |
-
eval_results[eval_name] = eval_result
|
183 |
-
|
184 |
-
results = []
|
185 |
-
for v in eval_results.values():
|
186 |
-
try:
|
187 |
-
v.to_dict() # we test if the dict version is complete
|
188 |
-
results.append(v)
|
189 |
-
except KeyError: # not all eval values present
|
190 |
-
continue
|
191 |
-
|
192 |
-
return results
|
|
|
35 |
"""Inits the result from the specific model result file"""
|
36 |
with open(json_filepath) as fp:
|
37 |
data = json.load(fp)
|
38 |
+
return data
|
39 |
config = data.get("config")
|
40 |
|
41 |
# Precision
|
|
|
168 |
for file in files:
|
169 |
model_result_filepaths.append(os.path.join(root, file))
|
170 |
|
171 |
+
eval_results = []
|
172 |
for model_result_filepath in model_result_filepaths:
|
173 |
# Creation of result
|
174 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
175 |
+
eval_results.append(eval_result)
|
176 |
+
|
177 |
+
return eval_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/populate.py
CHANGED
@@ -10,10 +10,10 @@ from src.leaderboard.read_evals import get_raw_eval_results
|
|
10 |
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
13 |
-
all_data_json = [v.to_dict() for v in raw_data]
|
14 |
-
|
15 |
-
df =
|
16 |
-
|
17 |
df = df[cols].round(decimals=2)
|
18 |
|
19 |
# filter out if any of the benchmarks have not been produced
|
|
|
10 |
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
13 |
+
#all_data_json = [v.to_dict() for v in raw_data]
|
14 |
+
df = pd.DataFrame.from_records(raw_data)
|
15 |
+
#df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
16 |
+
|
17 |
df = df[cols].round(decimals=2)
|
18 |
|
19 |
# filter out if any of the benchmarks have not been produced
|
src/submission/submit.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import json
|
2 |
import os
|
3 |
from datetime import datetime, timezone
|
4 |
-
|
5 |
from src.display.formatting import styled_error, styled_message, styled_warning
|
6 |
-
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
|
7 |
from src.submission.check_validity import (
|
8 |
already_submitted_models,
|
9 |
check_model_card,
|
@@ -11,18 +11,61 @@ from src.submission.check_validity import (
|
|
11 |
is_model_on_hub,
|
12 |
)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
14 |
REQUESTED_MODELS = None
|
15 |
USERS_TO_SUBMISSION_DATES = None
|
16 |
|
17 |
|
18 |
def add_new_eval(
|
19 |
-
|
20 |
-
|
21 |
-
revision: str,
|
22 |
-
precision: str,
|
23 |
-
weight_type: str,
|
24 |
-
model_type: str,
|
25 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
global REQUESTED_MODELS
|
27 |
global USERS_TO_SUBMISSION_DATES
|
28 |
if not REQUESTED_MODELS:
|
@@ -115,7 +158,7 @@ def add_new_eval(
|
|
115 |
|
116 |
# Remove the local file
|
117 |
os.remove(out_path)
|
118 |
-
|
119 |
return styled_message(
|
120 |
"Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
121 |
)
|
|
|
1 |
import json
|
2 |
import os
|
3 |
from datetime import datetime, timezone
|
4 |
+
import numpy as np
|
5 |
from src.display.formatting import styled_error, styled_message, styled_warning
|
6 |
+
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO, RESULTS_REPO
|
7 |
from src.submission.check_validity import (
|
8 |
already_submitted_models,
|
9 |
check_model_card,
|
|
|
11 |
is_model_on_hub,
|
12 |
)
|
13 |
|
14 |
+
from src.display.utils import (
|
15 |
+
BENCHMARK_COLS,
|
16 |
+
COLS
|
17 |
+
)
|
18 |
+
|
19 |
REQUESTED_MODELS = None
|
20 |
USERS_TO_SUBMISSION_DATES = None
|
21 |
|
22 |
|
23 |
def add_new_eval(
|
24 |
+
eval_name: str,
|
25 |
+
upload: object
|
|
|
|
|
|
|
|
|
26 |
):
|
27 |
+
with open(upload, mode="r") as f:
|
28 |
+
data = json.load(f)
|
29 |
+
|
30 |
+
results = data['results']
|
31 |
+
|
32 |
+
ret = {"eval_name": eval_name}
|
33 |
+
# TODO add complex validation
|
34 |
+
print(results.keys())
|
35 |
+
print(BENCHMARK_COLS)
|
36 |
+
for input_col in results.keys():
|
37 |
+
if input_col not in BENCHMARK_COLS:
|
38 |
+
print(input_col)
|
39 |
+
return styled_error(f'Missing: {input_col}')
|
40 |
+
#ret.update({i:j['acc,none'] for i,j in results.items()})
|
41 |
+
ret.update({i:round(np.random.normal(1, 0.5, 1)[0], 2) for i,j in results.items()})
|
42 |
+
|
43 |
+
|
44 |
+
user_name = "davidadamczyk"
|
45 |
+
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
46 |
+
|
47 |
+
out_path = f"{OUT_DIR}/{eval_name}_eval_request.json"
|
48 |
+
|
49 |
+
with open(out_path, "w") as f:
|
50 |
+
f.write(json.dumps(ret))
|
51 |
+
|
52 |
+
|
53 |
+
print("Uploading eval file")
|
54 |
+
|
55 |
+
print("path_or_fileobj: ", out_path)
|
56 |
+
print("path_in_repo: ",out_path.split("eval-queue/")[1])
|
57 |
+
print("repo_id: ", RESULTS_REPO)
|
58 |
+
print("repo_type: ", "dataset")
|
59 |
+
|
60 |
+
API.upload_file(
|
61 |
+
path_or_fileobj=out_path,
|
62 |
+
path_in_repo=out_path.split("eval-queue/")[1],
|
63 |
+
repo_id=RESULTS_REPO,
|
64 |
+
repo_type="dataset",
|
65 |
+
commit_message=f"Add {eval_name} to eval queue",
|
66 |
+
)
|
67 |
+
|
68 |
+
"""
|
69 |
global REQUESTED_MODELS
|
70 |
global USERS_TO_SUBMISSION_DATES
|
71 |
if not REQUESTED_MODELS:
|
|
|
158 |
|
159 |
# Remove the local file
|
160 |
os.remove(out_path)
|
161 |
+
"""
|
162 |
return styled_message(
|
163 |
"Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
164 |
)
|