Spaces:
Runtime error
Runtime error
Tianyi (Alex) Qiu
commited on
Commit
·
24a3e20
1
Parent(s):
487d79e
customize tasks
Browse files- .gitignore +5 -0
- app.py +5 -19
- src/about.py +5 -2
- src/display/utils.py +4 -1
- src/envs.py +2 -0
- src/leaderboard/read_evals.py +9 -2
- src/legacy/app.py +0 -331
- src/legacy/submit.py +0 -119
- src/populate.py +3 -0
- src/submission/submit.py +3 -2
.gitignore
CHANGED
@@ -11,3 +11,8 @@ eval-results/
|
|
11 |
eval-queue-bk/
|
12 |
eval-results-bk/
|
13 |
logs/
|
|
|
|
|
|
|
|
|
|
|
|
11 |
eval-queue-bk/
|
12 |
eval-results-bk/
|
13 |
logs/
|
14 |
+
|
15 |
+
demo-leaderboard/
|
16 |
+
results/
|
17 |
+
upload_history/
|
18 |
+
master_table.json
|
app.py
CHANGED
@@ -26,7 +26,7 @@ from src.display.utils import (
|
|
26 |
WeightType,
|
27 |
Precision
|
28 |
)
|
29 |
-
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, DATA_REPO, REPO_ID, TOKEN
|
30 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
31 |
from src.submission.submit import add_new_eval
|
32 |
|
@@ -35,31 +35,17 @@ def restart_space():
|
|
35 |
API.restart_space(repo_id=REPO_ID)
|
36 |
|
37 |
try:
|
38 |
-
print(
|
39 |
snapshot_download(
|
40 |
-
repo_id=DATA_REPO, local_dir=
|
41 |
)
|
42 |
except Exception:
|
|
|
43 |
restart_space()
|
44 |
-
try:
|
45 |
-
print(EVAL_RESULTS_PATH)
|
46 |
-
snapshot_download(
|
47 |
-
repo_id=DATA_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
48 |
-
)
|
49 |
-
except Exception:
|
50 |
-
restart_space()
|
51 |
-
|
52 |
|
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,
|
@@ -75,7 +61,7 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
|
75 |
|
76 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
77 |
always_here_cols = [
|
78 |
-
AutoEvalColumn.model_type_symbol.name,
|
79 |
AutoEvalColumn.model.name,
|
80 |
]
|
81 |
# We use COLS to maintain sorting
|
|
|
26 |
WeightType,
|
27 |
Precision
|
28 |
)
|
29 |
+
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, DATA_REPO, REPO_ID, TOKEN, REQUESTS_REPO_PATH, RESULTS_REPO_PATH, CACHE_PATH
|
30 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
31 |
from src.submission.submit import add_new_eval
|
32 |
|
|
|
35 |
API.restart_space(repo_id=REPO_ID)
|
36 |
|
37 |
try:
|
38 |
+
print(CACHE_PATH)
|
39 |
snapshot_download(
|
40 |
+
repo_id=DATA_REPO, local_dir=CACHE_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
41 |
)
|
42 |
except Exception:
|
43 |
+
print("Could not download the dataset. Please check your token and network connection.")
|
44 |
restart_space()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
47 |
leaderboard_df = original_df.copy()
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
# Searching and filtering
|
50 |
def update_table(
|
51 |
hidden_df: pd.DataFrame,
|
|
|
61 |
|
62 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
63 |
always_here_cols = [
|
64 |
+
# AutoEvalColumn.model_type_symbol.name,
|
65 |
AutoEvalColumn.model.name,
|
66 |
]
|
67 |
# We use COLS to maintain sorting
|
src/about.py
CHANGED
@@ -12,8 +12,11 @@ class Task:
|
|
12 |
# ---------------------------------------------------
|
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("anli_r1", "acc", "ANLI")
|
16 |
-
task1 = Task("logiqa", "acc_norm", "LogiQA")
|
|
|
|
|
|
|
17 |
|
18 |
NUM_FEWSHOT = 0 # Change with your few shot
|
19 |
# ---------------------------------------------------
|
|
|
12 |
# ---------------------------------------------------
|
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("anli_r1", "acc", "ANLI")
|
16 |
+
# task1 = Task("logiqa", "acc_norm", "LogiQA")
|
17 |
+
task0 = Task("Follow", "accuracy", "Follow")
|
18 |
+
task1 = Task("Predict", "accuracy", "Predict")
|
19 |
+
task2 = Task("Coevolve", "accuracy", "Coevolve")
|
20 |
|
21 |
NUM_FEWSHOT = 0 # Change with your few shot
|
22 |
# ---------------------------------------------------
|
src/display/utils.py
CHANGED
@@ -22,13 +22,16 @@ class ColumnContent:
|
|
22 |
|
23 |
## Leaderboard columns
|
24 |
auto_eval_column_dict = []
|
|
|
25 |
# Init
|
26 |
-
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
27 |
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
|
|
28 |
#Scores
|
29 |
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
30 |
for task in Tasks:
|
31 |
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
|
|
32 |
# Model information
|
33 |
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
34 |
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
|
|
22 |
|
23 |
## Leaderboard columns
|
24 |
auto_eval_column_dict = []
|
25 |
+
|
26 |
# Init
|
27 |
+
# auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
28 |
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
29 |
+
|
30 |
#Scores
|
31 |
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
32 |
for task in Tasks:
|
33 |
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
34 |
+
|
35 |
# Model information
|
36 |
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
37 |
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
src/envs.py
CHANGED
@@ -11,6 +11,8 @@ OWNER = "PKU-Alignment" # Change to your org - don't forget to create a results
|
|
11 |
|
12 |
REPO_ID = f"{OWNER}/ProgressGym-LeaderBoard"
|
13 |
DATA_REPO = f"{OWNER}/ProgressGym-LeaderBoardData"
|
|
|
|
|
14 |
|
15 |
# If you setup a cache later, just change HF_HOME
|
16 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
|
|
11 |
|
12 |
REPO_ID = f"{OWNER}/ProgressGym-LeaderBoard"
|
13 |
DATA_REPO = f"{OWNER}/ProgressGym-LeaderBoardData"
|
14 |
+
RESULTS_REPO_PATH = 'eval-results/'
|
15 |
+
REQUESTS_REPO_PATH = 'eval-queue/'
|
16 |
|
17 |
# If you setup a cache later, just change HF_HOME
|
18 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
src/leaderboard/read_evals.py
CHANGED
@@ -114,7 +114,7 @@ class EvalResult:
|
|
114 |
"eval_name": self.eval_name, # not a column, just a save name,
|
115 |
AutoEvalColumn.precision.name: self.precision.value.name,
|
116 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
117 |
-
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
118 |
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
119 |
AutoEvalColumn.architecture.name: self.architecture,
|
120 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
@@ -127,7 +127,10 @@ class EvalResult:
|
|
127 |
}
|
128 |
|
129 |
for task in Tasks:
|
130 |
-
|
|
|
|
|
|
|
131 |
|
132 |
return data_dict
|
133 |
|
@@ -158,6 +161,7 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
158 |
"""From the path of the results folder root, extract all needed info for results"""
|
159 |
model_result_filepaths = []
|
160 |
|
|
|
161 |
for root, _, files in os.walk(results_path):
|
162 |
# We should only have json files in model results
|
163 |
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
@@ -172,11 +176,13 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
172 |
for file in files:
|
173 |
model_result_filepaths.append(os.path.join(root, file))
|
174 |
|
|
|
175 |
eval_results = {}
|
176 |
for model_result_filepath in model_result_filepaths:
|
177 |
# Creation of result
|
178 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
179 |
eval_result.update_with_request_file(requests_path)
|
|
|
180 |
|
181 |
# Store results of same eval together
|
182 |
eval_name = eval_result.eval_name
|
@@ -191,6 +197,7 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
191 |
v.to_dict() # we test if the dict version is complete
|
192 |
results.append(v)
|
193 |
except KeyError: # not all eval values present
|
|
|
194 |
continue
|
195 |
|
196 |
return results
|
|
|
114 |
"eval_name": self.eval_name, # not a column, just a save name,
|
115 |
AutoEvalColumn.precision.name: self.precision.value.name,
|
116 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
117 |
+
# AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
118 |
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
119 |
AutoEvalColumn.architecture.name: self.architecture,
|
120 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
|
|
127 |
}
|
128 |
|
129 |
for task in Tasks:
|
130 |
+
try:
|
131 |
+
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
132 |
+
except:
|
133 |
+
data_dict[task.value.col_name] = 0
|
134 |
|
135 |
return data_dict
|
136 |
|
|
|
161 |
"""From the path of the results folder root, extract all needed info for results"""
|
162 |
model_result_filepaths = []
|
163 |
|
164 |
+
print(f"Reading results from {results_path}")
|
165 |
for root, _, files in os.walk(results_path):
|
166 |
# We should only have json files in model results
|
167 |
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
|
|
176 |
for file in files:
|
177 |
model_result_filepaths.append(os.path.join(root, file))
|
178 |
|
179 |
+
print(f"Found these files: {model_result_filepaths}")
|
180 |
eval_results = {}
|
181 |
for model_result_filepath in model_result_filepaths:
|
182 |
# Creation of result
|
183 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
184 |
eval_result.update_with_request_file(requests_path)
|
185 |
+
print(f"Found result for {eval_result.full_model} with precision {eval_result.precision.value.name}")
|
186 |
|
187 |
# Store results of same eval together
|
188 |
eval_name = eval_result.eval_name
|
|
|
197 |
v.to_dict() # we test if the dict version is complete
|
198 |
results.append(v)
|
199 |
except KeyError: # not all eval values present
|
200 |
+
print(f"Skipping {v.full_model} as not all values are present ({v.to_dict()})")
|
201 |
continue
|
202 |
|
203 |
return results
|
src/legacy/app.py
DELETED
@@ -1,331 +0,0 @@
|
|
1 |
-
import subprocess
|
2 |
-
import gradio as gr
|
3 |
-
import pandas as pd
|
4 |
-
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
-
from huggingface_hub import snapshot_download
|
6 |
-
|
7 |
-
from src.about import (
|
8 |
-
CITATION_BUTTON_LABEL,
|
9 |
-
CITATION_BUTTON_TEXT,
|
10 |
-
EVALUATION_QUEUE_TEXT,
|
11 |
-
INTRODUCTION_TEXT,
|
12 |
-
LLM_BENCHMARKS_TEXT,
|
13 |
-
TITLE,
|
14 |
-
)
|
15 |
-
from src.display.css_html_js import custom_css
|
16 |
-
from src.display.utils import (
|
17 |
-
BENCHMARK_COLS,
|
18 |
-
COLS,
|
19 |
-
EVAL_COLS,
|
20 |
-
EVAL_TYPES,
|
21 |
-
NUMERIC_INTERVALS,
|
22 |
-
TYPES,
|
23 |
-
AutoEvalColumn,
|
24 |
-
ModelType,
|
25 |
-
fields,
|
26 |
-
WeightType,
|
27 |
-
Precision
|
28 |
-
)
|
29 |
-
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
30 |
-
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
31 |
-
from src.submission.submit import add_new_eval
|
32 |
-
|
33 |
-
|
34 |
-
def restart_space():
|
35 |
-
API.restart_space(repo_id=REPO_ID)
|
36 |
-
|
37 |
-
try:
|
38 |
-
print(EVAL_REQUESTS_PATH)
|
39 |
-
snapshot_download(
|
40 |
-
repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
41 |
-
)
|
42 |
-
except Exception:
|
43 |
-
restart_space()
|
44 |
-
try:
|
45 |
-
print(EVAL_RESULTS_PATH)
|
46 |
-
snapshot_download(
|
47 |
-
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
48 |
-
)
|
49 |
-
except Exception:
|
50 |
-
restart_space()
|
51 |
-
|
52 |
-
|
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, filtered_df)
|
75 |
-
df = select_columns(filtered_df, columns)
|
76 |
-
return df
|
77 |
-
|
78 |
-
|
79 |
-
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
80 |
-
return df[(df[AutoEvalColumn.model.name].str.contains(query, case=False))]
|
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.model.name,
|
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()
|
101 |
-
# if _q != "":
|
102 |
-
# temp_filtered_df = search_table(filtered_df, _q)
|
103 |
-
# if len(temp_filtered_df) > 0:
|
104 |
-
# final_df.append(temp_filtered_df)
|
105 |
-
# if len(final_df) > 0:
|
106 |
-
# filtered_df = pd.concat(final_df)
|
107 |
-
# filtered_df = filtered_df.drop_duplicates(
|
108 |
-
# subset=[AutoEvalColumn.model.name, AutoEvalColumn.precision.name, AutoEvalColumn.revision.name]
|
109 |
-
# )
|
110 |
-
|
111 |
-
return filtered_df
|
112 |
-
|
113 |
-
|
114 |
-
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 |
-
return df
|
119 |
-
|
120 |
-
|
121 |
-
demo = gr.Blocks(css=custom_css)
|
122 |
-
with demo:
|
123 |
-
gr.HTML(TITLE)
|
124 |
-
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
125 |
-
|
126 |
-
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
127 |
-
with gr.TabItem("Leaderboard", elem_id="llm-benchmark-tab-table", id=0):
|
128 |
-
with gr.Row():
|
129 |
-
with gr.Column():
|
130 |
-
# with gr.Row():
|
131 |
-
# search_bar = gr.Textbox(
|
132 |
-
# placeholder=" 🔍 Search for your model (separate multiple queries with `;`) and press ENTER...",
|
133 |
-
# show_label=False,
|
134 |
-
# elem_id="search-bar",
|
135 |
-
# )
|
136 |
-
with gr.Row():
|
137 |
-
shown_columns = gr.CheckboxGroup(
|
138 |
-
choices=[
|
139 |
-
c.name
|
140 |
-
for c in fields(AutoEvalColumn)
|
141 |
-
if not c.hidden and not c.never_hidden
|
142 |
-
],
|
143 |
-
value=[
|
144 |
-
c.name
|
145 |
-
for c in fields(AutoEvalColumn)
|
146 |
-
if c.displayed_by_default and not c.hidden and not c.never_hidden
|
147 |
-
],
|
148 |
-
label="Select columns to show",
|
149 |
-
elem_id="column-select",
|
150 |
-
interactive=True,
|
151 |
-
)
|
152 |
-
# with gr.Row():
|
153 |
-
# deleted_models_visibility = gr.Checkbox(
|
154 |
-
# value=False, label="Show gated/private/deleted models", interactive=True
|
155 |
-
# )
|
156 |
-
# with gr.Column(min_width=320):
|
157 |
-
# #with gr.Box(elem_id="box-filter"):
|
158 |
-
# filter_columns_type = gr.CheckboxGroup(
|
159 |
-
# label="Model types",
|
160 |
-
# choices=[t.to_str() for t in ModelType],
|
161 |
-
# value=[t.to_str() for t in ModelType],
|
162 |
-
# interactive=True,
|
163 |
-
# elem_id="filter-columns-type",
|
164 |
-
# )
|
165 |
-
# filter_columns_precision = gr.CheckboxGroup(
|
166 |
-
# label="Precision",
|
167 |
-
# choices=[i.value.name for i in Precision],
|
168 |
-
# value=[i.value.name for i in Precision],
|
169 |
-
# interactive=True,
|
170 |
-
# elem_id="filter-columns-precision",
|
171 |
-
# )
|
172 |
-
# filter_columns_size = gr.CheckboxGroup(
|
173 |
-
# label="Model sizes (in billions of parameters)",
|
174 |
-
# choices=list(NUMERIC_INTERVALS.keys()),
|
175 |
-
# value=list(NUMERIC_INTERVALS.keys()),
|
176 |
-
# interactive=True,
|
177 |
-
# elem_id="filter-columns-size",
|
178 |
-
# )
|
179 |
-
|
180 |
-
leaderboard_table = gr.components.Dataframe(
|
181 |
-
value=leaderboard_df[
|
182 |
-
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
183 |
-
+ shown_columns.value
|
184 |
-
],
|
185 |
-
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
186 |
-
datatype=TYPES,
|
187 |
-
elem_id="leaderboard-table",
|
188 |
-
interactive=False,
|
189 |
-
visible=True,
|
190 |
-
)
|
191 |
-
|
192 |
-
# Dummy leaderboard for handling the case when the user uses backspace key
|
193 |
-
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
194 |
-
value=original_df[COLS],
|
195 |
-
headers=COLS,
|
196 |
-
datatype=TYPES,
|
197 |
-
visible=False,
|
198 |
-
)
|
199 |
-
# search_bar.submit(
|
200 |
-
# update_table,
|
201 |
-
# [
|
202 |
-
# hidden_leaderboard_table_for_search,
|
203 |
-
# shown_columns,
|
204 |
-
# filter_columns_type,
|
205 |
-
# filter_columns_precision,
|
206 |
-
# filter_columns_size,
|
207 |
-
# deleted_models_visibility,
|
208 |
-
# search_bar,
|
209 |
-
# ],
|
210 |
-
# leaderboard_table,
|
211 |
-
# )
|
212 |
-
for selector in [shown_columns]: # removed: filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility
|
213 |
-
selector.change(
|
214 |
-
update_table,
|
215 |
-
[
|
216 |
-
hidden_leaderboard_table_for_search,
|
217 |
-
shown_columns,
|
218 |
-
# filter_columns_type,
|
219 |
-
# filter_columns_precision,
|
220 |
-
# filter_columns_size,
|
221 |
-
# deleted_models_visibility,
|
222 |
-
# search_bar,
|
223 |
-
],
|
224 |
-
leaderboard_table,
|
225 |
-
queue=True,
|
226 |
-
)
|
227 |
-
|
228 |
-
with gr.TabItem("About", elem_id="llm-benchmark-tab-table", id=2):
|
229 |
-
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
230 |
-
|
231 |
-
with gr.TabItem("Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
232 |
-
with gr.Column():
|
233 |
-
with gr.Row():
|
234 |
-
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
235 |
-
|
236 |
-
with gr.Column():
|
237 |
-
with gr.Accordion(
|
238 |
-
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
239 |
-
open=False,
|
240 |
-
):
|
241 |
-
with gr.Row():
|
242 |
-
finished_eval_table = gr.components.Dataframe(
|
243 |
-
value=finished_eval_queue_df,
|
244 |
-
headers=EVAL_COLS,
|
245 |
-
datatype=EVAL_TYPES,
|
246 |
-
row_count=5,
|
247 |
-
)
|
248 |
-
with gr.Accordion(
|
249 |
-
f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
|
250 |
-
open=False,
|
251 |
-
):
|
252 |
-
with gr.Row():
|
253 |
-
running_eval_table = gr.components.Dataframe(
|
254 |
-
value=running_eval_queue_df,
|
255 |
-
headers=EVAL_COLS,
|
256 |
-
datatype=EVAL_TYPES,
|
257 |
-
row_count=5,
|
258 |
-
)
|
259 |
-
|
260 |
-
with gr.Accordion(
|
261 |
-
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
262 |
-
open=False,
|
263 |
-
):
|
264 |
-
with gr.Row():
|
265 |
-
pending_eval_table = gr.components.Dataframe(
|
266 |
-
value=pending_eval_queue_df,
|
267 |
-
headers=EVAL_COLS,
|
268 |
-
datatype=EVAL_TYPES,
|
269 |
-
row_count=5,
|
270 |
-
)
|
271 |
-
with gr.Row():
|
272 |
-
gr.Markdown("# Submit your model here!", elem_classes="markdown-text")
|
273 |
-
|
274 |
-
with gr.Row():
|
275 |
-
with gr.Column():
|
276 |
-
model_name_textbox = gr.Textbox(label="Model name")
|
277 |
-
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
278 |
-
model_type = gr.Dropdown(
|
279 |
-
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
280 |
-
label="Model type",
|
281 |
-
multiselect=False,
|
282 |
-
value=None,
|
283 |
-
interactive=True,
|
284 |
-
)
|
285 |
-
|
286 |
-
with gr.Column():
|
287 |
-
precision = gr.Dropdown(
|
288 |
-
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
289 |
-
label="Precision",
|
290 |
-
multiselect=False,
|
291 |
-
value="float16",
|
292 |
-
interactive=True,
|
293 |
-
)
|
294 |
-
weight_type = gr.Dropdown(
|
295 |
-
choices=[i.value.name for i in WeightType],
|
296 |
-
label="Weights type",
|
297 |
-
multiselect=False,
|
298 |
-
value="Original",
|
299 |
-
interactive=True,
|
300 |
-
)
|
301 |
-
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
302 |
-
|
303 |
-
submit_button = gr.Button("Submit Eval")
|
304 |
-
submission_result = gr.Markdown()
|
305 |
-
submit_button.click(
|
306 |
-
add_new_eval,
|
307 |
-
[
|
308 |
-
model_name_textbox,
|
309 |
-
base_model_name_textbox,
|
310 |
-
revision_name_textbox,
|
311 |
-
precision,
|
312 |
-
weight_type,
|
313 |
-
model_type,
|
314 |
-
],
|
315 |
-
submission_result,
|
316 |
-
)
|
317 |
-
|
318 |
-
with gr.Row():
|
319 |
-
with gr.Accordion("Citation", open=False):
|
320 |
-
citation_button = gr.Textbox(
|
321 |
-
value=CITATION_BUTTON_TEXT,
|
322 |
-
label=CITATION_BUTTON_LABEL,
|
323 |
-
lines=20,
|
324 |
-
elem_id="citation-button",
|
325 |
-
show_copy_button=True,
|
326 |
-
)
|
327 |
-
|
328 |
-
scheduler = BackgroundScheduler()
|
329 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
330 |
-
scheduler.start()
|
331 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/legacy/submit.py
DELETED
@@ -1,119 +0,0 @@
|
|
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,
|
10 |
-
get_model_size,
|
11 |
-
is_model_on_hub,
|
12 |
-
)
|
13 |
-
|
14 |
-
REQUESTED_MODELS = None
|
15 |
-
USERS_TO_SUBMISSION_DATES = None
|
16 |
-
|
17 |
-
def add_new_eval(
|
18 |
-
model: str,
|
19 |
-
base_model: str,
|
20 |
-
revision: str,
|
21 |
-
precision: str,
|
22 |
-
weight_type: str,
|
23 |
-
model_type: str,
|
24 |
-
):
|
25 |
-
global REQUESTED_MODELS
|
26 |
-
global USERS_TO_SUBMISSION_DATES
|
27 |
-
if not REQUESTED_MODELS:
|
28 |
-
REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
|
29 |
-
|
30 |
-
user_name = ""
|
31 |
-
model_path = model
|
32 |
-
if "/" in model:
|
33 |
-
user_name = model.split("/")[0]
|
34 |
-
model_path = model.split("/")[1]
|
35 |
-
|
36 |
-
precision = precision.split(" ")[0]
|
37 |
-
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
38 |
-
|
39 |
-
if model_type is None or model_type == "":
|
40 |
-
return styled_error("Please select a model type.")
|
41 |
-
|
42 |
-
# Does the model actually exist?
|
43 |
-
if revision == "":
|
44 |
-
revision = "main"
|
45 |
-
|
46 |
-
# Is the model on the hub?
|
47 |
-
if weight_type in ["Delta", "Adapter"]:
|
48 |
-
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=True)
|
49 |
-
if not base_model_on_hub:
|
50 |
-
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
-
|
52 |
-
if not weight_type == "Adapter":
|
53 |
-
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=True)
|
54 |
-
if not model_on_hub:
|
55 |
-
return styled_error(f'Model "{model}" {error}')
|
56 |
-
|
57 |
-
# Is the model info correctly filled?
|
58 |
-
try:
|
59 |
-
model_info = API.model_info(repo_id=model, revision=revision)
|
60 |
-
except Exception:
|
61 |
-
return styled_error("Could not get your model information. Please fill it up properly.")
|
62 |
-
|
63 |
-
model_size = get_model_size(model_info=model_info, precision=precision)
|
64 |
-
|
65 |
-
# Were the model card and license filled?
|
66 |
-
try:
|
67 |
-
license = model_info.cardData["license"]
|
68 |
-
except Exception:
|
69 |
-
return styled_error("Please select a license for your model")
|
70 |
-
|
71 |
-
modelcard_OK, error_msg = check_model_card(model)
|
72 |
-
if not modelcard_OK:
|
73 |
-
return styled_error(error_msg)
|
74 |
-
|
75 |
-
# Seems good, creating the eval
|
76 |
-
print("Adding new eval")
|
77 |
-
|
78 |
-
eval_entry = {
|
79 |
-
"model": model,
|
80 |
-
"base_model": base_model,
|
81 |
-
"revision": revision,
|
82 |
-
"precision": precision,
|
83 |
-
"weight_type": weight_type,
|
84 |
-
"status": "PENDING",
|
85 |
-
"submitted_time": current_time,
|
86 |
-
"model_type": model_type,
|
87 |
-
"likes": model_info.likes,
|
88 |
-
"params": model_size,
|
89 |
-
"license": license,
|
90 |
-
"private": False,
|
91 |
-
}
|
92 |
-
|
93 |
-
# Check for duplicate submission
|
94 |
-
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
95 |
-
return styled_warning("This model has been already submitted.")
|
96 |
-
|
97 |
-
print("Creating eval file")
|
98 |
-
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
99 |
-
os.makedirs(OUT_DIR, exist_ok=True)
|
100 |
-
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
101 |
-
|
102 |
-
with open(out_path, "w") as f:
|
103 |
-
f.write(json.dumps(eval_entry))
|
104 |
-
|
105 |
-
print("Uploading eval file")
|
106 |
-
API.upload_file(
|
107 |
-
path_or_fileobj=out_path,
|
108 |
-
path_in_repo=out_path.split("eval-queue/")[1],
|
109 |
-
repo_id=QUEUE_REPO,
|
110 |
-
repo_type="dataset",
|
111 |
-
commit_message=f"Add {model} to eval queue",
|
112 |
-
)
|
113 |
-
|
114 |
-
# Remove the local file
|
115 |
-
os.remove(out_path)
|
116 |
-
|
117 |
-
return styled_message(
|
118 |
-
"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."
|
119 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/populate.py
CHANGED
@@ -11,9 +11,11 @@ from src.leaderboard.read_evals import get_raw_eval_results
|
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
"""Creates a dataframe from all the individual experiment results"""
|
13 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
|
|
14 |
all_data_json = [v.to_dict() for v in raw_data]
|
15 |
|
16 |
df = pd.DataFrame.from_records(all_data_json)
|
|
|
17 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
18 |
df = df[cols].round(decimals=2)
|
19 |
|
@@ -40,6 +42,7 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
40 |
elif ".md" not in entry:
|
41 |
# this is a folder
|
42 |
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
|
|
43 |
for sub_entry in sub_entries:
|
44 |
file_path = os.path.join(save_path, entry, sub_entry)
|
45 |
with open(file_path) as fp:
|
|
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
"""Creates a dataframe from all the individual experiment results"""
|
13 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
14 |
+
print(raw_data)
|
15 |
all_data_json = [v.to_dict() for v in raw_data]
|
16 |
|
17 |
df = pd.DataFrame.from_records(all_data_json)
|
18 |
+
print(df, AutoEvalColumn.average.name)
|
19 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
20 |
df = df[cols].round(decimals=2)
|
21 |
|
|
|
42 |
elif ".md" not in entry:
|
43 |
# this is a folder
|
44 |
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
45 |
+
print(sub_entries)
|
46 |
for sub_entry in sub_entries:
|
47 |
file_path = os.path.join(save_path, entry, sub_entry)
|
48 |
with open(file_path) as fp:
|
src/submission/submit.py
CHANGED
@@ -51,7 +51,8 @@ def add_new_eval(
|
|
51 |
|
52 |
# parse the submission file
|
53 |
try:
|
54 |
-
|
|
|
55 |
except JSONDecodeError:
|
56 |
return styled_error("Invalid submission file: JSON parsing failed.")
|
57 |
|
@@ -90,7 +91,7 @@ def add_new_eval(
|
|
90 |
"update_timestamp": timestamp_filename,
|
91 |
}
|
92 |
|
93 |
-
for challenge, result in results_per_challenge:
|
94 |
try:
|
95 |
parsed_result: float = parse_challenge_result_dict(challenge, result)
|
96 |
assert isinstance(parsed_result, float)
|
|
|
51 |
|
52 |
# parse the submission file
|
53 |
try:
|
54 |
+
with open(file_path, "r") as f:
|
55 |
+
submission_data = json.load(f)
|
56 |
except JSONDecodeError:
|
57 |
return styled_error("Invalid submission file: JSON parsing failed.")
|
58 |
|
|
|
91 |
"update_timestamp": timestamp_filename,
|
92 |
}
|
93 |
|
94 |
+
for challenge, result in results_per_challenge.items():
|
95 |
try:
|
96 |
parsed_result: float = parse_challenge_result_dict(challenge, result)
|
97 |
assert isinstance(parsed_result, float)
|